[wp-trac] [WordPress Trac] #16513: Editing a page sets $current_screen->post_type to 'post'

WordPress Trac wp-trac at lists.automattic.com
Thu Feb 10 02:57:45 UTC 2011


#16513: Editing a page sets $current_screen->post_type to 'post'
--------------------------+-----------------------------
 Reporter:  markjaquith   |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:  3.0
 Severity:  normal        |   Keywords:
--------------------------+-----------------------------
 Install this:

 {{{
 <?php
 /*
 Plugin Name: Write Page Load
 Author: Mark Jaquith
 */

 function cws_write_page_load_admin_init() {
         add_action( 'load-post-new.php', 'cws_write_page_load' );
         add_action( 'load-post.php',     'cws_write_page_load' );
 }

 add_action( 'admin_init', 'cws_write_page_load_admin_init' );

 function cws_write_page_load() {
         global $current_screen;
         echo "<br /><br />"; // Grr, admin bar
         var_dump( $current_screen);
 }

 }}}

 Go to new page screen. It properly outputs this:

 {{{
 object(stdClass)#159 (6) { ["id"]=> string(4) "page" ["base"]=> string(4)
 "post" ["action"]=> string(3) "add" ["post_type"]=> string(4) "page"
 ["is_network"]=> bool(false) ["is_user"]=> bool(false) }
 }}}

 Edit an existing page. It outputs this:

 {{{
 object(stdClass)#159 (6) { ["id"]=> string(4) "post" ["base"]=> string(4)
 "post" ["action"]=> string(0) "" ["post_type"]=> string(4) "post"
 ["is_network"]=> bool(false) ["is_user"]=> bool(false) }
 }}}

 That seems wrong. {{{$_GET['post_type']}}} is not set, so it seems to fall
 back to "post"

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/16513>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list