Skip to main content

benecaster_referral_link_output

Filter Free

Filters the complete output of the benecaster_referral_link shortcode: an <a class="benecaster-referral-link" rel="sponsored"> tag, or the bare URL when style="url".

It runs only when there is a link to show. When the shortcode renders nothing (no referral link has arrived from the license server, or the license is no longer Active or Expiring) the filter does not fire, so a callback never has to handle an empty link.

Use it to wrap the link in a footer credit line, add an icon, or restyle it. Do not use it to add the referral balance. A cached balance can be out of date, and a stale balance is never shown to anyone.

Parameters

Name Type Default Description
$html string The rendered link (an anchor tag), or the bare URL for style="url"
$referral_link string The site owner's referral URL, as cached from the last daily license check
$atts array Resolved shortcode attributes, style and label

Returns: string

Examples

Wrap the link in a credit line, leaving the bare URL alone

add_filter( 'benecaster_referral_link_output', static function ( string $html, string $link, array $atts ): string {
    if ( 'url' === $atts['style'] ) {
        return $html;
    }
    return '<span class="my-credit">' . $html . '</span>';
}, 10, 3 );

Notes

The $html is already escaped by the shortcode; escape anything you add yourself.

[benecaster_recipe name="referral-link-in-site-footer"]

Affects

Need this built rather than just documented? See our services →