searchwp\extensions
Since: 4.0.0
Table of Contents
Register an Extension to be used in SearchWP, specifically in the Extensions menu of the SearchWP settings UI.
Parameters
| Type | Parameter | Default | Since |
|---|---|---|---|
| Array | $extensions |
[] |
4.0.0 |
Examples
All hooks should be added to your custom SearchWP Customizations Plugin.
Add custom Extension to settings UI
Starter class to implement a custom Extension that has a link in the Extensions dropdown of the SearchWP settings screen and an associated view when that link is clicked.
| <?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(); |

