SHARE
TWEET

Untitled

a guest Apr 20th, 2019 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. function reorder_admin_menu( $menu_items ) {
  4.     // Our top level items
  5.     $top_level = array();
  6.     // Post Types
  7.     $post_types = array();
  8.     // Our bottom level items
  9.     $bottom_level = array();
  10.     // And our penalty box...known that we want last
  11.     $penalty_box = array();
  12.     // Loop over each item
  13.     foreach( $menu_items as $menu_item ) {
  14.         /**
  15.          * Known offenders that we want to stick as low as possible
  16.          */
  17.         if( in_array( $menu_item, array( 'jetpack', 'genesis', 'woocommerce', 'edit.php?post_type=fl-builder-template' ) ) ) {
  18.             $penalty_box[] = $menu_item;
  19.         }
  20.         /**
  21.          * Our top level items
  22.          * Dashboard, and the first seperator
  23.          */
  24.         if( in_array( $menu_item, array( 'index.php', 'separator1' ) ) ) {
  25.             $top_level[] = $menu_item;
  26.         }
  27.         /**
  28.          * Content related items
  29.          * anything that starts with edit.php and not already in the penalty box
  30.          * Nested pages plugin is whitelisted for this section
  31.          */
  32.         else if( strripos( $menu_item , 'edit.php' ) !== false || $menu_item === 'nestedpages' ) {
  33.             $post_types[] = $menu_item;
  34.         }
  35.         /**
  36.          * Everything else
  37.          * Contains settings, users, appearence, etc.
  38.          */
  39.         else {
  40.             $bottom_level[] = $menu_item;
  41.         }
  42.  
  43.     }
  44.     // Mush it all together in a new order, and send it back
  45.     return array_merge( $top_level, $post_types, $bottom_level, $penalty_box );
  46. }
  47. add_filter( 'menu_order', 'reorder_admin_menu', 99 );
  48. /**
  49.  * Add flag to allow custom menu order
  50.  */
  51. add_filter( 'custom_menu_order', '__return_true' );
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top