Posted By

alp on 04/03/11


Tagged

wordpress theming


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

stonetatara


How To Display Ads Only To Search Visitors | Wordpress


 / Published in: PHP
 

URL: http://www.scratch99.com/2008/09/avoid-smart-pricing-show-adsense-only-to-search-engine-visitors/

Place snippet in functions.php. Works with the Shylock Adsense plugin (http://planetozh.com/blog/my-projects/wordpress-plugin-who-sees-ads-control-adsense-display/)

  1. function scratch99_fromasearchengine(){
  2. $ref = $_SERVER['HTTP_REFERER'];
  3. $SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
  4. foreach ($SE as $source) {
  5. if (strpos($ref,$source)!==false) return true;
  6. }
  7. return false;
  8. }
  9.  
  10. Call:
  11.  
  12. if (function_exists('scratch99_fromasearchengine')) {
  13. if (scratch99_fromasearchengine()) {
  14. INSERT YOUR CODE HERE
  15. }
  16. }

Report this snippet  

You need to login to post a comment.