Skip to content

Instantly share code, notes, and snippets.

@jchristopher
Created June 17, 2015 16:07
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/c92d3dd5927a6828adb9 to your computer and use it in GitHub Desktop.
Save jchristopher/c92d3dd5927a6828adb9 to your computer and use it in GitHub Desktop.
Add your own tabs to the SearchWP settings
<?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