Hi there,
Let me answer your questions cronologically:
Put a if( aicp_can_see_ads() ) { /* return your ad code here */ } block before returning your ad code to the front end
Wrap your ad code within a simple div tag like this <div class=”aicp”>…your ad code goes here…</div>
– An example code is already given in the description section of the plugin and also shown in the video demonstration. So, I’m copy pasing the example shortcode creation code given in the descripsion below:
add_shortcode( 'your_shortcode_name', 'your_shortcode_function_name' );
function your_shortcode_function_name() {
if( aicp_can_see_ads() ) { // This part will show ads to your non-banned visitors
$adCode = '<div class="aicp"><!-- Don\'t forget to add this div with aicp class -->
<!-- Your AdSense Code Starts Here -->
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- AdSense Responsive Ad Code -->
<ins class="adsbygoogle"
style="display:block"
data-ad-client="ca-pub-1234567890"
data-ad-slot="0987654321"
data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
<!-- Your AdSense Code Ends here -->
</div><!-- end of the aicp div -->';
return $adCode;
} else { // Anything within this part will be shown to your banned visitors or to the blocked country visitors
return '<div class="error">You have been blocked from seeing ads.</div>';
}
}
Also modifying adsense code is against their TOS, or we are not modifying it ?
– We are not modifying the adsense code anyway, as youcan see above you just need to copy paste your adsense code above. No need to modify your adsense code.
What about caching plugins ? How do we need to setup them in order for the plugin to work.
– I have tested the plugin with various cache plugin like cache enabler, wp rocket, super cache etc. and there is no problem whatsoever. You just have to make sure that after you setup the plugin and it’s code, you clear your full cache so that the updated codes can reflect in your site. That’s it.
Hope this helps. 🙂