Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2012
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.50 KB | None | 0 0
  1. /**
  2.  * Move options menu item to top level and set it's position below Dashboard
  3.  */
  4.  
  5. add_action( 'admin_init', 'options_menu_item' );
  6. function options_menu_item() {
  7.     if ( current_user_can( 'edit_theme_options' ) ) {
  8.         global $menu;
  9.        
  10.         $icon_file = '/-files/gfx/options.png';
  11.        
  12.         $child_theme_icon = get_stylesheet_directory().$icon_file;
  13.         $parent_theme_icon = get_template_directory().$icon_file;
  14.         $default_icon = '';
  15.        
  16.         $child_theme_icon = file_exists( $child_theme_icon );
  17.         $parent_theme_icon = file_exists( $parent_theme_icon );
  18.        
  19.         if( $child_theme_icon == TRUE ) {
  20.             $icon = get_stylesheet_directory_uri().$icon_file;
  21.         } elseif( $parent_theme_icon == TRUE ) {
  22.             $icon = get_template_directory_uri().$icon_file;
  23.         } else {
  24.             $icon = $default_icon;
  25.         }
  26.        
  27.         remove_submenu_page( 'themes.php', 'options-framework' );
  28.         $options_page = add_menu_page( 'Options', 'Options', 'edit_theme_options', 'options-framework', 'optionsframework_page', $icon, 85 );
  29.         add_action( 'admin_print_styles-' . $options_page, 'optionsframework_load_styles' );
  30.        
  31.         if( $_GET['page'] == 'options-framework' ) {
  32.             // Enqueued scripts
  33.             wp_enqueue_script('jquery-ui-core');
  34.             wp_enqueue_script('color-picker', OPTIONS_FRAMEWORK_URL .'js/colorpicker.js', array('jquery'));
  35.             wp_enqueue_script('options-custom', OPTIONS_FRAMEWORK_URL .'js/options-custom.js', array('jquery'));
  36.         }
  37.        
  38.         $options_menu_item = $menu[85];
  39.         unset( $menu[85] );
  40.         $menu[3] = $options_menu_item;
  41.         ksort( $menu );
  42.     }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement