Advertisement
MrPauloeN

Switching between tabs in WordPress Theme Options in PHP

Jun 25th, 2015
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.02 KB | None | 0 0
  1. // Fist you need to specify tabs
  2.  
  3. function pn_get_settings_page_tabs() {
  4.      $tabs = array(
  5.           'general' => 'General',
  6.           'user_manual' => 'User Manual'
  7.      );
  8.      return $tabs;
  9. }
  10.  
  11.  
  12. // Then, you can generate tabs
  13. function pn_admin_options_page_tabs( $current = 'general' ) {
  14.      if ( isset ( $_GET['tab'] ) ) :
  15.           $current = $_GET['tab'];
  16.      else:
  17.           $current = 'general';
  18.      endif;
  19.      $tabs = pn_get_settings_page_tabs();
  20.      $links = array();
  21.      foreach( $tabs as $tab => $name ) :
  22.           if ( $tab == $current ) :
  23.                $links[] = '<a class="nav-tab nav-tab-active" href="?page=settings_page&tab='.$tab.'">'.$name.'</a>';
  24.           else :
  25.                $links[] = '<a class="nav-tab" href="?page=setting_page&tab='.$tab.'">'.$name.'</a>';
  26.           endif;
  27.      endforeach;
  28.      echo '<div id="icon-themes" class="icon32"><br /></div>';
  29.      echo '<h2 class="nav-tab-wrapper">';
  30.      foreach ( $links as $link )
  31.           echo $link;
  32.      echo '</h2>';
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement