There's a very handy new function and feature in the upcoming WordPress 2.7: the favorite actions, showing a nice little drop down menu containing quick links to your, well, favorite tasks.
By default, this drop down contains a link to "Add New Post", "Add New Page" and "Manage Comments". Hopefully and as usual, it's very easy to customize this menu and to add (or to remove) elements.
Concept
The new function that draws this drop down box is the well named favorite_actions() which calls a similarly named filter. This filter wants you to play with an array with the following structure: array( url => array ( title, level ) ). For instance and by default, the links are drawn by the following array:
-
$actions = array(
-
'post-new.php' => array(__('Add New Post'), 'edit_posts'),
-
'page-new.php' => array(__('Add New Page'), 'edit_pages'),
-
'edit-comments.php' => array(__('Manage Comments'), 'moderate_comments')
-
);
The 'level' parameter (here, 'edit_pages' or 'moderate_comments') is described and explained on the Codex: Roles and Capabilities.
Play with the filter
Now, let's modify the array, using the appropriate filter. All you need is to create a custom function that returns an array with the same structure as above.
For instance, the following plugin would remove the link to "Add new page" from the favorite actions, and add a link to a fictional plugin:
-
<?php
-
/*
-
Plugin Name: Sample Favorite Actions
-
Plugin URI: http://planetozh.com/blog/
-
Description: Example plugin showing how to modify the favorite actions
-
Author: Ozh
-
Author URI: http://planetozh.com/
-
*/
-
-
add_filter('favorite_actions', 'ozh_sample_fav');
-
-
function ozh_sample_fav($actions) {
-
// remove the "Add new page" link
-
unset($actions['page-new.php']);
-
// add quick link to our favorite plugin
-
$actions['admin.php?page=blah/blah.php'] = array('Some plugin', 'manage_options');
-
return $actions;
-
}
-
-
?>
(Or, get this file: sample_favorite_actions.php and rename as .php before playing with it)
Pushing further : plugin idea
Since this menu is called "favorite actions", it would be really cool to populate it with your true favorite ones. A plugin could rather easily monitor what admin pages are called and their frequency, and modify the drop down menu accordingly.
Anyone fancy to code it?
Pages: [2] 1 » Show All
wrote, on 02/Jan/09 at 11:52 pm # :
You wanted a plugin? Here it is, fresh from the code forges: http://wordpress.org/extend/plugins/favorites-menu-manager/