Make WordPress Core

Changeset 9130


Ignore:
Timestamp:
10/13/2008 05:30:45 PM (18 years ago)
Author:
ryan
Message:

Perform cap checks for favorite actions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/template.php

    r9120 r9130  
    30043004function favorite_actions() {
    30053005    $actions = array(
    3006         'page-new.php' => __('Add New Page'),
    3007         'edit-comments.php' => __('Manage Comments')
     3006        'post-new.php' => array(__('Add New Post'), 'edit_posts'),
     3007        'page-new.php' => array(__('Add New Page'), 'edit_pages'),
     3008        'edit-comments.php' => array(__('Manage Comments'), 'moderate_comments')
    30083009        );
    30093010
    30103011    $actions = apply_filters('favorite_actions', $actions);
     3012
     3013    $allowed_actions = array();
     3014    foreach ( $actions as $action => $data ) {
     3015        if ( current_user_can($data[1]) )
     3016            $allowed_actions[$action] = $data[0];
     3017    }
     3018
     3019    if ( empty($allowed_actions) )
     3020        return;
     3021
     3022    $first = array_keys($allowed_actions);
     3023    $first = $first[0];
    30113024    echo '<div id="favorite-actions">';
    3012     echo '<div id="favorite-first"><a href="post-new.php">' . __('Add New Post') . '</a></div>';
     3025    echo '<div id="favorite-first"><a href="$first">' . $allowed_actions[$first] . '</a></div>';
    30133026    echo '<div id="favorite-action">';
    3014     foreach ( $actions as $action => $label) {
     3027
     3028    array_shift($allowed_actions);
     3029
     3030    foreach ( $allowed_actions as $action => $label) {
    30153031        echo "<div class='favorite-action'><a href='$action'>";
    30163032        echo $label;
Note: See TracChangeset for help on using the changeset viewer.