Affiliate Links plugin provides with shortcode for embedding affiliate links into the post content.
[af_link href="http://affiliatelinkswp.com/go/download/" rel="nofollow" target="_blank" title="Link Title" class="btn-primary"]Click Here[/af_link]
Hooks in WordPress core, plugins and themes essentially allow you to manipulate code without editing core files.
So you can change third-party plugin behaviour from your own theme or plugin and keep future updates as well.
add_filter( 'af_link_target_url', 'my_target_url_filter' );
function my_target_url_filter( $target_url ){
$aff_id_value = 'your_value'; //some php here
$target_url = add_query_arg( array(
'aff_id' => $aff_id_value
), $target_url );
//var_dump($target_url); die();
return $target_url;
}
This example shows how you can add custom variable to the target link URL dynamically generated by PHP.
add_action( 'af_link_before_redirect', 'my_header_action', 10, 3 );
function my_header_action( $post_id, $target_url, $redirect_type ){
header( 'X-Custom-Header: cool!', true );
}
This example shows how you can add custom HTTP headers when the affiliate link is redirected to the target URL.