Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I installed a plugin for my users in WPMU and I want to make it appear at the end of the admin menu ....

I tried this but the menu never appears at the end:

function custom_menu_order($menu_ord) {  
if (!$menu_ord) return true;  

return array(  
    'index.php', // Dashboard  
    'edit.php', // Posts 
    'upload.php', // Media
    'options-general.php', // Settings  
 => 'admin.php?page=support', // my plugin

);
}  
add_filter('custom_menu_order', 'custom_menu_order'); // Activate custom_menu_order  
add_filter('menu_order', 'custom_menu_order');

my plugin menu is "admin.php?page=support"

share|improve this question
    
You are not revealing how your plugin menu item is being inserted, and that's what Johannes is talking about. Yes, it is possible to manipulate the menu order, but those hooks you are using doesn't seem adequate and are not being used correctly. –  brasofilo Apr 7 '13 at 0:32
add comment

2 Answers

The global variable $menu can be manipulated. Here, we are moving the Pages menu item to the end:

moved pages to the end of the menu

Maybe there's a simpler method to do the recursive array search, I've grabbed an example from PHP Manual. The value to be searched has to be inspected inside the $menu var, enable the debug lines to brute force inspect it.

add_action( 'admin_menu', 'move_menu_item_wpse_94808', 999 );

function move_menu_item_wpse_94808() 
{
    global $menu;

    // Inspect the $menu variable:
    // echo '<pre>' . print_r( $menu, true ) . '</pre>';
    // die();

    // Pinpoint menu item
    $move = recursive_array_search_php_91365( 'edit.php?post_type=page', $menu );

    // Validate
    if( !$move )
        return;

    // Store menu item
    $new = $menu[ $move ];

    // Remove menu item, and add previously stored at the end
    unset( $menu[ $move ] );
    $menu[] = $new;
}

// http://www.php.net/manual/en/function.array-search.php#91365
function recursive_array_search_php_91365( $needle, $haystack ) 
{
    foreach( $haystack as $key => $value ) 
    {
        $current_key = $key;
        if( 
            $needle === $value 
            OR ( 
                is_array( $value )
                && recursive_array_search_php_91365( $needle, $value ) !== false 
            )
        ) 
        {
            return $current_key;
        }
    }
    return false;
}
share|improve this answer
    
What plugin is this? Try to change the priority to a greater number: add_action( 'admin_menu', 'callback', 9999 ); –  brasofilo Apr 8 '13 at 11:30
    
is a plugin to provide user support ....I contacted the seller several times but does not respond. –  Ghinnersmee Apr 8 '13 at 13:34
add comment

Are you using add_menu_page?
If so: Its last parameter is the menu position, setting this to a huge number should ensure it's always at the end.

share|improve this answer
    
thanks for the reply ,my plugin is already in the admin menu ... ...but not at the end... –  Ghinnersmee Apr 6 '13 at 21:24
    
Please clarify: which function are you using to create your plugin's admin menu page? –  Simon Blackbourn Apr 7 '13 at 12:20
    
Aha! I thought you were talking about a plugin you had written, hence my question. In that case, you could try the Admin Menu Editor plugin, I've never used it but looks like it might do what you need. –  Simon Blackbourn Apr 7 '13 at 16:37
    
I used that plugin for years...and this time it didn't solve my problem . Thanks anyway for the help –  Ghinnersmee Apr 7 '13 at 17:22
    
@Ghinnersmee, the snapshot and "I didn't create this plugin" should be part of the Question. –  brasofilo Apr 7 '13 at 22:38
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.