Make WordPress Core

Changeset 13536


Ignore:
Timestamp:
03/01/2010 04:03:27 PM (17 years ago)
Author:
ryan
Message:

Make favorite actions custom post type aware. Props ptahdunbar. fixes #12433

File:
1 edited

Legend:

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

    r13535 r13536  
    33543354 */
    33553355function favorite_actions( $screen = null ) {
     3356        global $post_type_object;
     3357       
     3358        $default_action = false;
     3359       
    33563360        if ( is_string($screen) )
    33573361                $screen = convert_to_screen($screen);
    3358 
    3359         switch ( $screen->id ) {
    3360                 case 'post':
    3361                         $default_action = array('edit.php' => array(__('Edit Posts'), 'edit_posts'));
    3362                         break;
    3363                 case 'edit-page':
    3364                         $default_action = array('post-new.php?post_type=page' => array(__('New Page'), 'edit_pages'));
    3365                         break;
    3366                 case 'page':
    3367                         $default_action = array('edit.php?post_type=page' => array(__('Edit Pages'), 'edit_pages'));
    3368                         break;
    3369                 case 'upload.php':
    3370                         $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
    3371                         break;
    3372                 case 'media':
    3373                         $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
    3374                         break;
    3375                 case 'link-manager':
    3376                         $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
    3377                         break;
    3378                 case 'link-add':
    3379                         $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
    3380                         break;
    3381                 case 'users':
    3382                         $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
    3383                         break;
    3384                 case 'user':
    3385                         $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
    3386                         break;
    3387                 case 'plugins':
    3388                         $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
    3389                         break;
    3390                 case 'plugin-install':
    3391                         $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
    3392                         break;
    3393                 case 'themes':
    3394                         $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
    3395                         break;
    3396                 case 'theme-install':
    3397                         $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
    3398                         break;
    3399                 default:
    3400                         $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
    3401                         break;
     3362               
     3363        if ( isset($post_type_object) ) {
     3364                switch ( $screen->id ) {
     3365                        case $post_type_object->name:
     3366                                $default_action = array('edit.php?post_type=' . $post_type_object->name => array(sprintf(__('Edit %s'), $post_type_object->label), $post_type_object->edit_type_cap));
     3367                                break;
     3368                        case "edit-{$post_type_object->name}":
     3369                                $default_action = array('post-new.php?post_type=' . $post_type_object->name => array(sprintf(__('New %s'), $post_type_object->singular_label), $post_type_object->edit_type_cap));
     3370                                break;
     3371                }
     3372        }
     3373       
     3374        if ( !$default_action ) {
     3375                switch ( $screen->id ) {
     3376                        case 'upload':
     3377                                $default_action = array('media-new.php' => array(__('New Media'), 'upload_files'));
     3378                                break;
     3379                        case 'media':
     3380                                $default_action = array('upload.php' => array(__('Edit Media'), 'upload_files'));
     3381                                break;
     3382                        case 'link-manager':
     3383                                $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
     3384                                break;
     3385                        case 'link-add':
     3386                                $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
     3387                                break;
     3388                        case 'users':
     3389                                $default_action = array('user-new.php' => array(__('New User'), 'create_users'));
     3390                                break;
     3391                        case 'user':
     3392                                $default_action = array('users.php' => array(__('Edit Users'), 'edit_users'));
     3393                                break;
     3394                        case 'plugins':
     3395                                $default_action = array('plugin-install.php' => array(__('Install Plugins'), 'install_plugins'));
     3396                                break;
     3397                        case 'plugin-install':
     3398                                $default_action = array('plugins.php' => array(__('Manage Plugins'), 'activate_plugins'));
     3399                                break;
     3400                        case 'themes':
     3401                                $default_action = array('theme-install.php' => array(__('Install Themes'), 'install_themes'));
     3402                                break;
     3403                        case 'theme-install':
     3404                                $default_action = array('themes.php' => array(__('Manage Themes'), 'switch_themes'));
     3405                                break;
     3406                        default:
     3407                                $default_action = array('post-new.php' => array(__('New Post'), 'edit_posts'));
     3408                                break;
     3409                }
    34023410        }
    34033411
Note: See TracChangeset for help on using the changeset viewer.