Make WordPress Core

Changeset 15253


Ignore:
Timestamp:
06/14/2010 07:33:04 PM (15 years ago)
Author:
ryan
Message:

Differentiate between edit and new via an action field for the screen. Fix favorite_actions(). fixes #13876

File:
1 edited

Legend:

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

    r15242 r15253  
    33173317 */
    33183318function favorite_actions( $screen = null ) {
    3319     global $post_type_object;
    3320 
    33213319    $default_action = false;
    33223320
     
    33243322        $screen = convert_to_screen($screen);
    33253323
    3326     if ( isset($post_type_object) ) {
    3327         switch ( $screen->id ) {
    3328             case $post_type_object->name:
    3329                 $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->edit_item, $post_type_object->cap->edit_posts));
    3330                 break;
    3331             case "edit-{$post_type_object->name}":
    3332                 $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));
    3333                 break;
    3334         }
     3324    if ( isset($screen->post_type) ) {
     3325        $post_type_object = get_post_type_object($screen->post_type);
     3326        if ( 'add' != $screen->action )
     3327            $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));
     3328        else
     3329            $default_action = array('edit.php?post_type=' . $post_type_object->name => array($post_type_object->labels->name, $post_type_object->cap->edit_posts));
    33353330    }
    33363331
     
    33443339                break;
    33453340            case 'link-manager':
    3346                 $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
    3347                 break;
    3348             case 'link-add':
    3349                 $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
     3341            case 'link':
     3342                if ( 'add' != $screen->action )
     3343                    $default_action = array('link-add.php' => array(__('New Link'), 'manage_links'));
     3344                else
     3345                    $default_action = array('link-manager.php' => array(__('Edit Links'), 'manage_links'));
    33503346                break;
    33513347            case 'users':
     
    39033899    global $current_screen, $hook_suffix, $typenow, $taxnow;
    39043900
     3901    $action = '';
     3902
    39053903    if ( empty($id) ) {
    39063904        $current_screen = $hook_suffix;
    39073905        $current_screen = str_replace('.php', '', $current_screen);
     3906        if ( preg_match('/-add|-new$/', $current_screen) )
     3907            $action = 'add';
    39083908        $current_screen = str_replace('-new', '', $current_screen);
    39093909        $current_screen = str_replace('-add', '', $current_screen);
     
    39233923
    39243924    $current_screen = (object) $current_screen;
     3925
     3926    $current_screen->action = $action;
    39253927
    39263928    // Map index to dashboard
Note: See TracChangeset for help on using the changeset viewer.