From f9066ea3272ba4e7a0ec777003639e80f9bef11a Mon Sep 17 00:00:00 2001 From: "Mitchell D. Miller" Date: Mon, 30 May 2022 21:53:14 -0400 Subject: [PATCH 1/2] Check for unset server variables Check for unset Web server variables, because all servers might not use them. --- BlockWpSearch.php | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/BlockWpSearch.php b/BlockWpSearch.php index 8bea00b..08db93a 100755 --- a/BlockWpSearch.php +++ b/BlockWpSearch.php @@ -2,10 +2,10 @@ /** * Plugin Name: Block WP Search * Description: Block all WordPress Searches. - * Version: 1.00 + * Version: 1.02 * Author: Mitchell D. Miller * Author URI: https://mitchelldmiller.com/ - * Plugin URI: https://mitchelldmiller.github.io/block-wp-search/ + * Plugin URI: https://github.com/mitchelldmiller/block-wp-search * GitHub Plugin URI: https://github.com/mitchelldmiller/block-wp-search * License: MIT * License URI: https://github.com/mitchelldmiller/block-wp-search/blob/main/LICENSE @@ -37,7 +37,7 @@ class BlockWpSearch { /** - * Add init hook to block search requests. + * Add init hook to intercept search requests. * @see https://developer.wordpress.org/reference/hooks/init/ * @return BlockWpSearch */ @@ -55,11 +55,14 @@ public function block_searches() { if (defined( 'WP_CLI' ) && WP_CLI) { return; } - if (empty($_SERVER['REQUEST_URI']) || strstr($_SERVER['REQUEST_URI'], '/wp-admin/') || $_SERVER['REQUEST_METHOD'] == 'HEAD') { + if (empty($_SERVER['REQUEST_URI']) || empty($_SERVER['REQUEST_METHOD'])) { + return; + } + if (strstr($_SERVER['REQUEST_URI'], '/wp-admin/') || $_SERVER['REQUEST_METHOD'] != 'GET') { return; } // end if - if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'GET' && isset($_GET['s'])) { + if (isset($_GET['s'])) { wp_safe_redirect('/not_found/', 307); exit; } From b6a1123a7ab6cb2560af48c87506963fa1a57261 Mon Sep 17 00:00:00 2001 From: "Mitchell D. Miller" Date: Mon, 30 May 2022 21:55:28 -0400 Subject: [PATCH 2/2] Bumped version Updated READMES. Edited text. --- README.md | 5 ++--- readme.txt | 12 ++++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 7b2834e..daafc26 100755 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ block-wp-search ==================== * Requires: [WordPress 2.3](https://wordpress.org/support/wordpress-version/version-2-3/) * Tested with: [WordPress 6.0](https://wordpress.org/support/wordpress-version/version-6-0/) -* Stable version: [1.00](https://github.com/mitchelldmiller/block-wp-search/releases/latest) +* Stable version: [1.02](https://github.com/mitchelldmiller/block-wp-search/releases/latest) Description ----------- @@ -11,7 +11,6 @@ Description WordPress search is not always helpful: especially for small sites. Use Block WordPress Search plugin to redirect search requests. - Features ----------- * Redirects search requests to `/not_found/` @@ -38,7 +37,7 @@ Configuration Updates ----------- -* Install [GitHub Updater](https://github.com/afragen/github-updater/releases/latest) plugin to update Quick Mail from Github. +* Install [GitHub Updater](https://github.com/afragen/github-updater/releases/latest) plugin to update Block WP Search from Github. Translators / Translations ----------- diff --git a/readme.txt b/readme.txt index 1dd3441..dff19db 100755 --- a/readme.txt +++ b/readme.txt @@ -5,7 +5,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i Requires at least: 2.3 Tested up to: 6.0.0 Requires PHP: 5.3 -Stable tag: 1.00 +Stable tag: 1.02 License: MIT License URI: https://github.com/mitchelldmiller/block-wp-search/blob/main/LICENSE @@ -18,11 +18,9 @@ WordPress search is not always helpful: especially for small sites. Use Block WordPress Search plugin to redirect search requests. == Features == - * Redirects search requests to `/not_found/` = Learn More = - * [Follow development on Github](https://github.com/mitchelldmiller/block-wp-search/). == Installation == @@ -35,7 +33,7 @@ Use Block WordPress Search plugin to redirect search requests. 2. Activate the plugin through the WordPress _Plugins_ menu. = WP-CLI -* How to install and activate the latest version of Quick Mail with [WP-CLI](https://wp-cli.org/) : +* How to install and activate the latest version of Block WP Search with [WP-CLI](https://wp-cli.org/) : `wp plugin install https://github.com/mitchelldmiller/block-wp-search/archive/main.zip --activate` @@ -57,11 +55,17 @@ Use Block WordPress Search plugin to redirect search requests. * First public release. * Tested with WordPress 6.0.0 += 1.02 +* Check for empty server variables. == Upgrade Notice == = 1.00 = * First public release. += 1.02 = +* Upgrade recommeneded. + + == License == Block Wp Search is free for personal or commercial use. Please support future development with a [donation](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4AAGBFXRAPFJY).