Writing a Plugin with a Sub Menu and Tabs within the Plugin Page
-
I’m writing a plugin for WordPress that uses a menu and submenu. Inside one of the Submenu pages I want to include tabs so that the menu isn’t so clustered with submenus. This isn’t that big of a deal but would definitely make it look nicer. I’ve seen a lot of html javascript and jquery options but they are typically clunky. Finally I came across a nice PHP option from onedesigns
I edited this code so that it wasn’t going to be used for a themes menu but for my plugin menu.
// mt_sublevel_page3() displays the page content for the third submenu // of the custom Pedigree Builder Admin menu // the code below creates the tabs function mt_sublevel_page3($current = 'about') { $tabs = array( 'about' => 'About Us', 'social' => 'Social Media', 'web' => 'Web Design', 'page9' => 'Videos' ); $links = array(); foreach( $tabs as $tab => $name ) : if ( $tab == $current ) : $links[] = "<a class='nav-tab nav-tab-active' href='?page=sub-$tab&tab=$tab'>$name</a>"; else : $links[] = "<a class='nav-tab' href='?page=sub-$tab&tab=$tab'>$name</a>"; endif; endforeach; echo '<h2>'; foreach ( $links as $link ) echo $link; echo '</h2><hr>'; // use the "PEDIGREE ADMIN CSS" style echo '<link rel="stylesheet" href="/wp-content/plugins/PEDIGREE/admin/css/pedigree_admin.css" type="text/css" />'; if ( $pagenow == 'pedigree_about.php' && $_GET['page'] == 'mt_sublevel_page3' ) : if ( isset ( $_GET['tab'] ) ) : $tab = $_GET['tab']; else: $tab = 'about'; endif; switch ( $tab ) : case 'about' : mt_sublevel_page3(); break; case 'social' : mt_sublevel_page3(); break; case 'web' : mt_sublevel_page3(); break; case 'video' : mt_sublevel_page9(); break; endswitch; endif;
The only problem is that the content for these pages don’t show up right. I’ve edited the case values, the page now and even tried adding includes, but often just broke the page.
Thoughts? Help?
- The topic ‘Writing a Plugin with a Sub Menu and Tabs within the Plugin Page’ is closed to new replies.