Skip to content

Instantly share code, notes, and snippets.

@searchwpgists
Created March 29, 2022 13:52
Show Gist options
  • Select an option

  • Save searchwpgists/2edb7b91013c0d428ad920b3d27055b1 to your computer and use it in GitHub Desktop.

Select an option

Save searchwpgists/2edb7b91013c0d428ad920b3d27055b1 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