Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- function reorder_admin_menu( $menu_items ) {
- // Our top level items
- $top_level = array();
- // Post Types
- $post_types = array();
- // Our bottom level items
- $bottom_level = array();
- // And our penalty box...known that we want last
- $penalty_box = array();
- // Loop over each item
- foreach( $menu_items as $menu_item ) {
- /**
- * Known offenders that we want to stick as low as possible
- */
- if( in_array( $menu_item, array( 'jetpack', 'genesis', 'woocommerce', 'edit.php?post_type=fl-builder-template' ) ) ) {
- $penalty_box[] = $menu_item;
- }
- /**
- * Our top level items
- * Dashboard, and the first seperator
- */
- if( in_array( $menu_item, array( 'index.php', 'separator1' ) ) ) {
- $top_level[] = $menu_item;
- }
- /**
- * Content related items
- * anything that starts with edit.php and not already in the penalty box
- * Nested pages plugin is whitelisted for this section
- */
- else if( strripos( $menu_item , 'edit.php' ) !== false || $menu_item === 'nestedpages' ) {
- $post_types[] = $menu_item;
- }
- /**
- * Everything else
- * Contains settings, users, appearence, etc.
- */
- else {
- $bottom_level[] = $menu_item;
- }
- }
- // Mush it all together in a new order, and send it back
- return array_merge( $top_level, $post_types, $bottom_level, $penalty_box );
- }
- add_filter( 'menu_order', 'reorder_admin_menu', 99 );
- /**
- * Add flag to allow custom menu order
- */
- add_filter( 'custom_menu_order', '__return_true' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement