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

git-svn-id: http://svn.automattic.com/wordpress/trunk@12797 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2010-01-22 18:27:54 +00:00
parent 92bf8d124c
commit a731cbed8e
3 changed files with 49 additions and 25 deletions

View File

@ -1099,6 +1099,9 @@ case 'inline-save':
die( __('You are not allowed to edit this post.') ); die( __('You are not allowed to edit this post.') );
} }
if ( isset($_POST['screen']) )
set_current_screen($_POST['screen']);
if ( $last = wp_check_post_lock( $post_ID ) ) { if ( $last = wp_check_post_lock( $post_ID ) ) {
$last_user = get_userdata( $last ); $last_user = get_userdata( $last );
$last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' );

View File

@ -112,30 +112,7 @@ else
$typenow = ''; $typenow = '';
// @todo validate typenow against post types. // @todo validate typenow against post types.
/** set_current_screen();
* Global object containing info about the current screen.
*/
$current_screen = $hook_suffix;
$current_screen = str_replace('.php', '', $current_screen);
$current_screen = str_replace('-new', '', $current_screen);
$current_screen = str_replace('-add', '', $current_screen);
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
$current_screen = (object) $current_screen;
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} else {
$typenow = '';
}
$current_screen = apply_filters('current_screen', $current_screen);
// Handle plugin admin pages. // Handle plugin admin pages.
if ( isset($plugin_page) ) { if ( isset($plugin_page) ) {

View File

@ -1265,7 +1265,8 @@ function inline_edit_row( $screen ) {
?> ?>
<input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" /> <input accesskey="s" class="button-primary alignright" type="submit" name="bulk_edit" value="<?php echo esc_attr( $update_text ); ?>" />
<?php } ?> <?php } ?>
<input type="hidden" name="post_view" value="<?php echo $m; ?>" /> <input type="hidden" name="post_view" value="<?php echo esc_attr($m); ?>" />
<input type="hidden" name="screen" value="<?php echo esc_attr($screen->id); ?>" />
<br class="clear" /> <br class="clear" />
</p> </p>
</td></tr> </td></tr>
@ -3827,4 +3828,47 @@ function compression_test() {
<?php <?php
} }
/**
* Set the current screen object
*
* @since 3.0
*
* @uses $current_screen
*
* @param string $id Screen id, optional.
*/
function set_current_screen( $id = '' ) {
global $current_screen, $hook_suffix, $typenow;
if ( empty($id) ) {
$current_screen = $hook_suffix;
$current_screen = str_replace('.php', '', $current_screen);
$current_screen = str_replace('-new', '', $current_screen);
$current_screen = str_replace('-add', '', $current_screen);
$current_screen = array('id' => $current_screen, 'base' => $current_screen);
} else {
if ( false !== strpos($id, '-') )
list( $id, $typenow ) = explode('-', $id, 2);
$current_screen = array('id' => $id, 'base' => $id);
}
$current_screen = (object) $current_screen;
if ( 'edit' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id .= '-' . $typenow;
$current_screen->post_type = $typenow;
} elseif ( 'post' == $current_screen->id ) {
if ( empty($typenow) )
$typenow = 'post';
$current_screen->id = $typenow;
$current_screen->post_type = $typenow;
} else {
$typenow = '';
}
$current_screen = apply_filters('current_screen', $current_screen);
}
?> ?>