WordPress.org

Make WordPress Core

Changeset 12797


Ignore:
Timestamp:
01/22/2010 06:27:54 PM (12 years ago)
Author:
ryan
Message:

Introduce set_current_screen(). Set current screen for inline edit ajax requests so post rows can be properly displayed. see #9674

Location:
trunk/wp-admin
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/admin-ajax.php

    r12789 r12797  
    11001100    }
    11011101
     1102    if ( isset($_POST['screen']) )
     1103        set_current_screen($_POST['screen']);
     1104
    11021105    if ( $last = wp_check_post_lock( $post_ID ) ) {
    11031106        $last_user = get_userdata( $last );
  • trunk/wp-admin/admin.php

    r12753 r12797  
    113113// @todo validate typenow against post types.
    114114
    115 /**
    116  * Global object containing info about the current screen.
    117  */
    118 $current_screen = $hook_suffix;
    119 $current_screen = str_replace('.php', '', $current_screen);
    120 $current_screen = str_replace('-new', '', $current_screen);
    121 $current_screen = str_replace('-add', '', $current_screen);
    122 $current_screen = array('id' => $current_screen, 'base' => $current_screen);
    123 $current_screen = (object) $current_screen;
    124 if ( 'edit' == $current_screen->id ) {
    125     if ( empty($typenow) )
    126         $typenow = 'post';
    127     $current_screen->id .= '-' . $typenow;
    128     $current_screen->post_type = $typenow;
    129 } elseif ( 'post' == $current_screen->id ) {
    130     if ( empty($typenow) )
    131         $typenow = 'post';
    132     $current_screen->id = $typenow;
    133     $current_screen->post_type = $typenow;
    134 } else {
    135     $typenow = '';
    136 }
    137 
    138 $current_screen = apply_filters('current_screen', $current_screen);
     115set_current_screen();
    139116
    140117// Handle plugin admin pages.
  • trunk/wp-admin/includes/template.php

    r12789 r12797  
    12661266            <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
    12671267        <?php } ?>
    1268         <input type="hidden" name="post_view" value="<?php echo $m; ?>" />
     1268        <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />
     1269        <input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />
    12691270        <br class="clear" />
    12701271    </p>
     
    38283829}
    38293830
     3831/**
     3832 * Set the current screen object
     3833 *
     3834 * @since 3.0
     3835 *
     3836 * @uses $current_screen
     3837 *
     3838 * @param string $id Screen id, optional.
     3839 */
     3840function set_current_screen( $id =  '' ) {
     3841    global $current_screen, $hook_suffix, $typenow;
     3842
     3843    if ( empty($id) ) {
     3844        $current_screen = $hook_suffix;
     3845        $current_screen = str_replace('.php', '', $current_screen);
     3846        $current_screen = str_replace('-new', '', $current_screen);
     3847        $current_screen = str_replace('-add', '', $current_screen);
     3848        $current_screen = array('id' => $current_screen, 'base' => $current_screen);
     3849    } else {
     3850        if ( false !== strpos($id, '-') )
     3851            list( $id, $typenow ) = explode('-', $id, 2);
     3852        $current_screen = array('id' => $id, 'base' => $id);
     3853    }
     3854   
     3855    $current_screen = (object) $current_screen;
     3856   
     3857    if ( 'edit' == $current_screen->id ) {
     3858        if ( empty($typenow) )
     3859            $typenow = 'post';
     3860        $current_screen->id .= '-' . $typenow;
     3861        $current_screen->post_type = $typenow;
     3862    } elseif ( 'post' == $current_screen->id ) {
     3863        if ( empty($typenow) )
     3864            $typenow = 'post';
     3865        $current_screen->id = $typenow;
     3866        $current_screen->post_type = $typenow;
     3867    } else {
     3868        $typenow = '';
     3869    }
     3870   
     3871    $current_screen = apply_filters('current_screen', $current_screen);
     3872}
     3873
    38303874?>
Note: See TracChangeset for help on using the changeset viewer.