Return to Snippet

Revision: 43929
at April 3, 2011 17:36 by alp


Initial Code
function scratch99_fromasearchengine(){
  $ref = $_SERVER['HTTP_REFERER'];
  $SE = array('/search?', 'images.google.', 'web.info.com', 'search.', 'del.icio.us/search', 'soso.com', '/search/', '.yahoo.');
  foreach ($SE as $source) {
    if (strpos($ref,$source)!==false) return true;
  }
  return false;
}

Call:

if (function_exists('scratch99_fromasearchengine')) {
  if (scratch99_fromasearchengine()) {
    INSERT YOUR CODE HERE
  }
}

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

Initial Description
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/)

Initial Title
How To Display Ads Only To Search Visitors | Wordpress

Initial Tags
wordpress

Initial Language
PHP