Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Last active March 21, 2020 02:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jchristopher/2522d79359a5d07f25f3afee7c450e42 to your computer and use it in GitHub Desktop.
Save jchristopher/2522d79359a5d07f25f3afee7c450e42 to your computer and use it in GitHub Desktop.
Add custom SearchWP Extension to Extensions dropdown in settings UI
<?php
// Add custom SearchWP Extension to Extensions dropdown in settings UI.
// SearchWP Extensions must be a class that starts with "SearchWP"
// immediately followed by your unique class name.
class SearchWPMyExtension {
function __construct() {
add_filter( 'searchwp\extensions', function( $extensions ) {
// Following the class name rule, the array key is your unique
// class name _excluding_ the required "SearchWP" prefix.
$extensions['MyExtension'] = __FILE__;
return $extensions;
} );
}
// Render Extension view.
function view() {
?>
<h3>My Extension</h3>
<?php
}
}
new MySearchWPExtension();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment