Mahdi Mohebi

Limit the amount of text searched on the search page to prevent SEO spam

				
					add_action('init', 'limit_serach_str_x22');
function limit_serach_str_x22(){
  if ( is_admin() ) {
        return;
    }
  //if(is_search() ){
    if(isset($_GET['s'])) {
      $str = $_GET['s'];
      if(strlen($str)>100){
        header('HTTP/1.0 403 Forbidden');
                                echo "<p> Your search text is too long</p>";
        exit;
      }
    }
  //}
}
				
			
© 2019 All rights reserved.