Created
June 23, 2015 20:59
-
-
Save fastmover/6d15299a8f6b8cc330bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /************************************************************************** | |
| Plugin Name: Disable Search Query | |
| Description: Disables Search Queries in URL | |
| Version: 0.0.1 | |
| Author: Fastmover | |
| **************************************************************************/ | |
| class SK_Disable_Search_Query { | |
| public function __construct() { | |
| add_action( 'parse_query', array( $this, 'filterQuery' ) ); | |
| add_filter( 'get_search_form', create_function( '$a', "return null;" ) ); | |
| } | |
| public function filterQuery( $query, $error = true ) | |
| { | |
| if ( is_search() ) { | |
| $query->is_search = false; | |
| $query->query_vars['s'] = false; | |
| $query->query['s'] = false; | |
| ///////////// Uncomment the next 2 lines to enable showing a 404 when someone tries to search | |
| // if ( $error == true ) | |
| // $query->is_404 = true; | |
| } | |
| } | |
| } | |
| $SKDisableSearchQuery = new SK_Disable_Search_Query(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment