Add An Item to WordPress 2.7’s Favorites Menu

WordPress 2.7 introduced a little menu in the upper right corner of the backend. By default it includes commonly-used links, such as the New Post and Comments Management pages.

It’s a neat idea, but the developers didn’t give the average user an easy way to add and remove links from the list. Hopefully a plugin will be developed to allow it to be customized easily. In the meantime, you can use your theme’s functions.php file to add an item to the list. Just use a code snippet similar to this:

function add_favorite_item($actions) {
$actions['options-general.php'] = array('Settings', 'manage_options');
return $actions;
add_filter('favorite_actions', '

The favorite_actions hook calls your function when it’s needed, which in turn adds an entry to the array that WordPress uses to construct the menu. You can duplicate the $actions[... line to add more than one item. Just substitute options-general.php with the URL of the page you want (everything after the “wp-admin/”). Then change the 'Settings' to whatever text you want for the menu label. The final argument is the minimum permission for the item to be displayed at.

This hook could also be used in a plugin, if you have a use for it there. Just use it with discretion, so people don’t end up with a long list of not-quite-favorite links added by numerous plugins. ;)

For further reading, see Ozh’s little write-up of the favorite_actions hook.

  • Pingback: Weekend Links - Dec 26, 2008 « OMNINOGGIN

  • Maligno

    But you can change the array by changing the permissions:

    function add_favorite_item($actions) {
    $actions[‘post-new.php’] = array(__(‘New Post’), ‘manage_options’);
    $actions[‘page-new.php’] = array(__(‘New Page’), ‘manage_options’);
    $actions[‘media-new.php’] = array(__(‘Upload’), ‘manage_options’);
    $actions[‘edit.php?post_status=draft’] = array(__(‘Drafts’), ‘manage_options’);
    $actions[‘profile.php’] = array(__(‘Profile’), ‘edit_posts’);
    $actions[‘edit-comments.php’] = array(__(‘Comments’), ‘manage_options’);
    return $actions;
    add_filter(‘favorite_actions’, ‘add_favorite_item’);