[wp-trac] [WordPress Trac] #50036: WP_Screen action property not correct on post edit pages

WordPress Trac noreply at wordpress.org
Thu Apr 30 10:53:54 UTC 2020


#50036: WP_Screen action property not correct on post edit pages
----------------------------+-----------------------------
 Reporter:  DarkoG          |      Owner:  (none)
     Type:  enhancement     |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  General         |    Version:  trunk
 Severity:  minor           |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Hello,

 I noticed that the `WP_Screen` current screen `action` property is not
 properly initialized on the post edit pages regardless of the post type.

 Dump of the WP_Screen object on Add New Post page (accessible via url
 `/wp-admin/post-new.php`):

 {{{
 object(WP_Screen)[817]
   public 'action' => string 'add' (length=3)
   public 'base' => string 'post' (length=4)
   private 'columns' => int 0
   public 'id' => string 'post' (length=4)
   protected 'in_admin' => string 'site' (length=4)
   public 'is_network' => boolean false
   public 'is_user' => boolean false
   public 'parent_base' => null
   public 'parent_file' => null
   public 'post_type' => string 'post' (length=4)
   public 'taxonomy' => string '' (length=0)
   private '_help_tabs' =>
     array (size=0)
       empty
   private '_help_sidebar' => string '' (length=0)
   private '_screen_reader_content' =>
     array (size=0)
       empty
   private '_options' =>
     array (size=0)
       empty
   private '_show_screen_options' => null
   private '_screen_settings' => null
   public 'is_block_editor' => boolean true
 }}}

 Dump of the WP_Screen object on Edit Post page (accessible via `wp-
 admin/post.php?post=1&action=edit`) :


 {{{
 /home/vagrant/code/general/wp.test/wp-content/plugins/wp-breaking-
 news/includes/class-wpbn-metabox.php:23:
 object(WP_Screen)[818]
   public 'action' => string '' (length=0)
   public 'base' => string 'post' (length=4)
   private 'columns' => int 0
   public 'id' => string 'post' (length=4)
   protected 'in_admin' => string 'site' (length=4)
   public 'is_network' => boolean false
   public 'is_user' => boolean false
   public 'parent_base' => null
   public 'parent_file' => null
   public 'post_type' => string 'post' (length=4)
   public 'taxonomy' => string '' (length=0)
   private '_help_tabs' =>
     array (size=0)
       empty
   private '_help_sidebar' => string '' (length=0)
   private '_screen_reader_content' =>
     array (size=0)
       empty
   private '_options' =>
     array (size=0)
       empty
   private '_show_screen_options' => null
   private '_screen_settings' => null
   public 'is_block_editor' => boolean true
 }}}

 It will be much better if the `action` property is `edit` on this screen,
 it will make it easier to check if it edit page. Currently i have to do
 something like this

 {{{#!php
 <?php
 $screen  = get_current_screen();
 $is_edit = $screen->id === 'post' && isset($_GET['action']) &&
 $_GET['action'] === 'edit';
 }}}

 Expected behavior will be:

 {{{#!php
 <?php
 $screen  = get_current_screen();
 $is_edit = $screen->id === 'post' && $screen->action === 'edit';
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/50036>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list