Perform cap checks for favorite actions

git-svn-id: http://svn.automattic.com/wordpress/trunk@9130 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-10-13 17:30:45 +00:00
parent 14954d7fca
commit 209d229ed1
1 changed files with 20 additions and 4 deletions

View File

@ -3003,15 +3003,31 @@ function the_post_password() {
*/
function favorite_actions() {
$actions = array(
'page-new.php' => __('Add New Page'),
'edit-comments.php' => __('Manage Comments')
'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')
);
$actions = apply_filters('favorite_actions', $actions);
$allowed_actions = array();
foreach ( $actions as $action => $data ) {
if ( current_user_can($data[1]) )
$allowed_actions[$action] = $data[0];
}
if ( empty($allowed_actions) )
return;
$first = array_keys($allowed_actions);
$first = $first[0];
echo '<div id="favorite-actions">';
echo '<div id="favorite-first"><a href="post-new.php">' . __('Add New Post') . '</a></div>';
echo '<div id="favorite-first"><a href="$first">' . $allowed_actions[$first] . '</a></div>';
echo '<div id="favorite-action">';
foreach ( $actions as $action => $label) {
array_shift($allowed_actions);
foreach ( $allowed_actions as $action => $label) {
echo "<div class='favorite-action'><a href='$action'>";
echo $label;
echo "</a></div>\n";