Categories

Disable Search

Author: Scott Reilly
Version: 2.0.1
First released: 2009-06-11
Last update: 2023-09-03
Compatibility: WP 4.6 – 6.3.4
Download: [ zip ]
Description:

Disable the built-in front-end search capabilities of WordPress.

Extended Description

This plugin prevents WordPress from allowing and handling any search requests from the front-end of the site. Specifically, this plugin:

  • Prevents the search form from appearing if the theme uses the standard get_search_form() function to display the search form.
  • Prevents the search form from appearing if the theme uses a searchform.php template
  • Prevents the search item from appearing in the admin tool bar when shown on the front-end.
  • Disables the search widget.
    • Removes the Search widget from the list of available widgets
    • Deactivates any search widgets currently in use in any sidebars (they are hidden, not deleted; they’ll reappear in their original locations if this plugin gets deactivated)
  • Disables the search block.
    • Removes the Search block from the list of available blocks
    • Deactivates any search blocks currently in use, such as in posts or as a widget (they are disabled, not deleted; they’ll reappear if this plugin gets deactivated and the associated placeholder block doesn’t get deleted)
  • With or without a search form, the plugin prevents any direct or manual requests by visitors, via either GET or POST requests, from actually returning any search results.
  • Submitted attempts at a search will be given a 404 File Not Found response, rendered by your site’s 404.php template, if present.
  • Disables output of SearchAction in SEO schema by the Yoast SEO plugin.

The plugin only affects search on the front-end of the site. It does not disable searching in the admin section of the site.

Links: Plugin Homepage | Plugin Directory Page | GitHub | Author Homepage

Find out more at the plugin’s WordPress Plugin Repository page.

Installation

  1. Install via the built-in WordPress plugin installer. Or install the plugin code inside the plugins directory for your site (typically /wp-content/plugins/).
  2. Activate the plugin through the ‘Plugins’ admin menu in WordPress

Release Log

2.0.1 (2023-09-02)

  • Change: Safeguard JS from throwing error if WP JS isn’t loaded (should be rare to never)
  • Change: Note compatibility through WP 6.3+
  • Change: Update copyright date (2023)
  • Change: Tweak code alignment
  • New: Add .gitignore file
  • Unit tests:
    • Fix: Allow tests to run against current versions of WordPress
    • New: Add composer.json for PHPUnit Polyfill dependency
    • Change: Prevent PHP warnings due to missing core-related generated files

2.0 (2021-09-13)

  • This release finally addresses disabling the search block, notes compatibility through WP 5.8+, and restructures unit test directories.

Details:

  • New: Disable the search block
    • New: Add disable_core_search_block() to unregister block via PHP
    • New: Add enqueue_block_editor_assets() to register JS script to unregister search block via JS
    • New: Add JS script file to unregister search block
    • Change: Update documentation to reflect search block being disabled
  • Change: Remove get_search_form() and simply use __return_empty_string() as callback to 'get_search_form' filter
  • Change: Note compatibility through WP 5.8+
  • Change: Tweak installation instruction
  • Unit tests:
    • Change: Restructure unit test directories
      • Change: Move phpunit/ into tests/
      • Change: Move phpunit/bin into tests/
    • Change: Remove ‘test-‘ prefix from unit test file
    • Change: In bootstrap, store path to plugin file constant
    • Change: In bootstrap, add backcompat for PHPUnit pre-v6.0

1.8.3 (2021-05-01)

  • Fix: Change __wakeup() method visibility from private to public to avoid warnings under PHP8
  • Fix: Throw an error when attempting to unserialize an instance of the class to actually prevent it from happening

Copyright & Disclaimer

Copyright © 2009-2024 by Scott Reilly (aka coffee2code)

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Discussion / Support

Have any questions, comments, or suggestions? Please provide them via the plugin’s WordPress.org support forum. I’ll do my best to reply in a timely fashion and help as best I can.

Unfortunately, I cannot provide guaranteed support, nor do I provide support via any other means.

Was this plugin useful useful to you? Consider giving it a rating. If you’re inclined to give it a poor rating, please first post to the support forum to give me a chance to address or explain the situation.

3 replies on “Disable Search”