WordPress.org

Make WordPress Core

Changeset 19050


Ignore:
Timestamp:
10/24/2011 06:10:36 AM (9 years ago)
Author:
nacin
Message:

Deprecate favorite_actions(). see #18785.

Location:
trunk/wp-admin/includes
Files:
2 edited

Legend:

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

    r19046 r19050  
    806806}
    807807
     808/**
     809 * Favorite actions were deprecated in version 3.2. Use the admin bar instead.
     810 *
     811 * @since 2.7.0
     812 * @deprecated 3.2.0
     813 */
     814function favorite_actions() {
     815    _deprecated_function( __FUNCTION__, '3.2', 'WP_Admin_Bar' );
     816}
     817
    808818function media_upload_image() {
    809819    __deprecated_function( __FUNCTION__, '3.3', 'wp_media_upload_handler()' );
  • trunk/wp-admin/includes/screen.php

    r19049 r19050  
    106106
    107107    return apply_filters( 'hidden_meta_boxes', $hidden, $screen, $use_defaults );
    108 }
    109 
    110 /**
    111  * {@internal Missing Short Description}}
    112  *
    113  * @since 2.7.0
    114  */
    115 function favorite_actions( $screen = null ) {
    116     $default_action = false;
    117 
    118     if ( is_string($screen) )
    119         $screen = convert_to_screen($screen);
    120 
    121     if ( $screen->is_user )
    122         return;
    123 
    124     if ( isset($screen->post_type) ) {
    125         $post_type_object = get_post_type_object($screen->post_type);
    126         if ( 'add' != $screen->action )
    127             $default_action = array('post-new.php?post_type=' . $post_type_object->name => array($post_type_object->labels->new_item, $post_type_object->cap->edit_posts));
    128         else
    129             $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
    130     }
    131 
    132     if ( !$default_action ) {
    133         if ( $screen->is_network ) {
    134             $default_action = array('sites.php' => array( __('Sites'), 'manage_sites'));
    135         } else {
    136             switch ( $screen->id ) {
    137                 case 'upload':
    138                     $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
    139                     break;
    140                 case 'media':
    141                     $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
    142                     break;
    143                 case 'link-manager':
    144                 case 'link':
    145                     if ( 'add' != $screen->action )
    146                         $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
    147                     else
    148                         $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
    149                     break;
    150                 case 'users':
    151                     $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
    152                     break;
    153                 case 'user':
    154                     $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
    155                     break;
    156                 case 'plugins':
    157                     $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
    158                     break;
    159                 case 'plugin-install':
    160                     $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
    161                     break;
    162                 case 'themes':
    163                     $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
    164                     break;
    165                 case 'theme-install':
    166                     $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
    167                     break;
    168                 default:
    169                     $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
    170                     break;
    171             }
    172         }
    173     }
    174 
    175     if ( !$screen->is_network ) {
    176         $actions = array(
    177             'post-new.php' => array(__('New Post'), 'edit_posts'),
    178             'edit.php?post_status=draft' => array(__('Drafts'), 'edit_posts'),
    179             'post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'),
    180             'media-new.php' => array(__('Upload'), 'upload_files'),
    181             'edit-comments.php' => array(__('Comments'), 'moderate_comments')
    182             );
    183     } else {
    184         $actions = array(
    185             'sites.php' => array( __('Sites'), 'manage_sites'),
    186             'users.php' => array( __('Users'), 'manage_network_users')
    187         );
    188     }
    189 
    190     $default_key = array_keys($default_action);
    191     $default_key = $default_key[0];
    192     if ( isset($actions[$default_key]) )
    193         unset($actions[$default_key]);
    194     $actions = array_merge($default_action, $actions);
    195     $actions = apply_filters( 'favorite_actions', $actions, $screen );
    196 
    197     $allowed_actions = array();
    198     foreach ( $actions as $action => $data ) {
    199         if ( current_user_can($data[1]) )
    200             $allowed_actions[$action] = $data[0];
    201     }
    202 
    203     if ( empty($allowed_actions) )
    204         return;
    205 
    206     $first = array_keys($allowed_actions);
    207     $first = $first[0];
    208     echo '<div id="favorite-actions">';
    209     echo '<div id="favorite-first"><a href="' . $first . '">' . $allowed_actions[$first] . '</a></div><div id="favorite-toggle"><br /></div>';
    210     echo '<div id="favorite-inside">';
    211 
    212     array_shift($allowed_actions);
    213 
    214     foreach ( $allowed_actions as $action => $label) {
    215         echo "<div class='favorite-action'><a href='$action'>";
    216         echo $label;
    217         echo "</a></div>\n";
    218     }
    219     echo "</div></div>\n";
    220108}
    221109
Note: See TracChangeset for help on using the changeset viewer.