How to modify WordPress favorite actions menu

Since WordPess 2.7 there is a drop-down menu in admin that displays links to common actions. I don’t know the official name for it so I will just call it favorite actions menu.

WordPress Favorite Action Menu

WordPress Favorite Action Menu

The problem with this menu is that there are no options in WordPress to change the content of this menu (sure, there are of course plugins that can change this for you).

However, in this tutorial I will show you how to change this menu by adding some code to your themes functions.php.

This first example will show you how to remove the favorite actions menu completely. This is really simple. Just return an empty array.

function my_favorite_actions_menu($actions) {
	$actions = array();
	 return $actions;
}
add_filter('favorite_actions', 'my_favorite_actions_menu');

In the next example I will show you how to remove a menu item. To remove a menu item just unset that item. To find out which file to use in the unset function, just hover the mouse over the menu item and see what file it links to.

function my_favorite_actions_menu($actions) {
	unset($actions['media-new.php']);
	return $actions;
}
add_filter('favorite_actions', 'my_favorite_actions_menu');

The last example will show you how to add a menu item to the plugins page. Worth mentioning is that the second parameter of the array is the capability. By using the capabilities we can choose which menu items each user role will see.

function my_favorite_actions_menu($actions) {
	$actions['plugins.php'] = array('Plugins', 'activate_plugins');
	return $actions;
}
add_filter('favorite_actions', 'my_favorite_actions_menu');

About Fredrik Malmgren

Fredrik Malmgren is an entrepreneur, project manager and developer specialized in WordPress. Read more about me or get in contact with me. You can also find me on Twitter. (@fredrikmalmgren).
This entry was posted in Tutorials, WordPress and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>