From a731cbed8e52982c938921d34ef422f3e33716d3 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 22 Jan 2010 18:27:54 +0000 Subject: [PATCH] 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 --- wp-admin/admin-ajax.php | 3 +++ wp-admin/admin.php | 25 +----------------- wp-admin/includes/template.php | 46 +++++++++++++++++++++++++++++++++- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/wp-admin/admin-ajax.php b/wp-admin/admin-ajax.php index 35d9e88bbb..62f465df44 100644 --- a/wp-admin/admin-ajax.php +++ b/wp-admin/admin-ajax.php @@ -1099,6 +1099,9 @@ case 'inline-save': 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 ) ) { $last_user = get_userdata( $last ); $last_user_name = $last_user ? $last_user->display_name : __( 'Someone' ); diff --git a/wp-admin/admin.php b/wp-admin/admin.php index 0cab633c39..d8b8b00083 100644 --- a/wp-admin/admin.php +++ b/wp-admin/admin.php @@ -112,30 +112,7 @@ else $typenow = ''; // @todo validate typenow against post types. -/** - * 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); +set_current_screen(); // Handle plugin admin pages. if ( isset($plugin_page) ) { diff --git a/wp-admin/includes/template.php b/wp-admin/includes/template.php index 2468e1f414..a2ff5ca298 100644 --- a/wp-admin/includes/template.php +++ b/wp-admin/includes/template.php @@ -1265,7 +1265,8 @@ function inline_edit_row( $screen ) { ?> - + +

@@ -3827,4 +3828,47 @@ function compression_test() { $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); +} + ?>