Add your own tabs to the SearchWP settings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// exit if accessed directly | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; | |
} | |
/** | |
* Implement the shell of a SearchWP settings screen tab | |
*/ | |
class SearchWP_Settings_Implementation_My_Settings_Screen { | |
function init() { | |
// render the tab on the settings screen | |
add_action( 'searchwp_settings_nav_tab', array( $this, 'render_tab_my_settings' ) ); | |
// render the My Settings view when the my_settings tab is viewed | |
add_action( 'searchwp_settings_view\my_settings', array( $this, 'render_view_my_settings' ) ); | |
} | |
/** | |
* Callback to render the settings nav for the My Settings screen | |
*/ | |
function render_tab_my_settings() { | |
if ( current_user_can( apply_filters( 'searchwp_settings_cap', 'manage_options' ) ) ) { | |
searchwp_get_nav_tab( array( | |
'tab' => 'my_settings', | |
'label' => __( 'My Settings', 'searchwp' ), | |
) ); | |
} | |
} | |
/** | |
* Outputs the HTML for the My Settings tab | |
*/ | |
function render_view_my_settings() { | |
?> | |
<div class="my-settings"> | |
<h3><?php echo __( 'My Settings', 'searchwp' ); ?></h3> | |
</div> | |
<?php | |
} | |
} | |
$my_searchwp_settings = new SearchWP_Settings_Implementation_My_Settings_Screen(); | |
$my_searchwp_settings->init(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment