add_filter('the_content', function($content){ $tag = defined('GHQ_AMAZON_TAG') ? GHQ_AMAZON_TAG : 'Gamesherehq00-20';return preg_replace_callback('#https?://(www\.)?amazon\.com/[^"\s<]+#i', function($m) use ($tag){ $url = $m[0];// replace any existing tag with yours if (stripos($url,'tag=') !== false) { $url = preg_replace('/([?&])tag=[^&]+/i', '$1tag=' . rawurlencode($tag), $url); return $url; }// otherwise append your tag $sep = (strpos($url,'?') !== false) ? '&' : '?'; return $url . $sep . 'tag=' . rawurlencode($tag); }, $content); }, 60);
As an Amazon Associate, GamesHereHQ earns from qualifying purchases.
function ghq_price_box_shortcode($atts) { $atts = shortcode_atts(array( 'asin' => '', 'btn_text' => 'Check Price on Amazon' ), $atts);$asin = esc_attr($atts['asin']); $btn_text = esc_html($atts['btn_text']); $affiliate_id = 'Gamesherehq-20'; $link = "https://www.amazon.com/dp/$asin?tag=$affiliate_id"; return ''; add_shortcode('ghq_price_box', 'ghq_price_box_shortcode');