Skip to content

Automate creating a tabbed navigation and maintaining tabbed states

License

Notifications You must be signed in to change notification settings

Objectivco/WP_Tabbed_Navigation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

WP_Tabbed_Navigation

Automate creating a tabbed navigation and maintaining tabbed states

Installing

Use composer:

composer require objectivco/wp_tabbed_navigation

Or include the file. (But really, just use composer)

Initiating the Tab System

$wp_tabbed_navigation = new WP_Tabbed_Navigation( 'My Plugin Settings', $selected_tab_query_arg = 'subpage' );

Setup Some Submenus

These will be linked to our tab'

add_options_page( __( 'My Plugin Settings', 'my-plugin' ), __( 'My Plugin Settings', 'my-plugin' ), 'manage_options', 'my-plugin-settings', array($this, 'admin_page') );

Setup Tabs Using The Same Menu Slugs

$wp_tabbed_navigation->add_tab( 'Settings', add_query_arg( array('subpage' => 'settings'), menu_page_url('my-plugin-settings', false) ) );
$wp_tabbed_navigation->add_tab( 'Add-ons', add_query_arg( array('subpage' => 'addons'), menu_page_url('my-plugin-settings', false) ) );
$wp_tabbed_navigation->add_tab( 'License', add_query_arg( array('subpage' => 'license'), menu_page_url('my-plugin-settings', false) ) );
$wp_tabbed_navigation->add_tab( 'Support', add_query_arg( array('subpage' => 'support'), menu_page_url('my-plugin-settings', false) ) );

Displaying the Tabs

Add this to the top of each admin page in a tab.

$wp_tabbed_navigation->display_tabs();

That's it! Have fun kids.

About

Automate creating a tabbed navigation and maintaining tabbed states

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages