[wp-trac] [WordPress Trac] #18785: Modernize screen functions

WordPress Trac wp-trac at lists.automattic.com
Sun Oct 23 19:03:13 UTC 2011


#18785: Modernize screen functions
------------------------------+-----------------------
 Reporter:  nacin             |       Owner:  nacin
     Type:  task (blessed)    |      Status:  assigned
 Priority:  normal            |   Milestone:  3.3
Component:  Administration    |     Version:  3.3
 Severity:  normal            |  Resolution:
 Keywords:  has-patch commit  |
------------------------------+-----------------------
Changes (by nacin):

 * keywords:  needs-patch => has-patch commit


Comment:

 [attachment:18785.2.diff] resolves this ticket.

 It makes WP_Screen behave as a registry of singletons. convert_to_screen()
 calls WP_Screen::get($hook_name), and set_current_screen() calls
 WP_Screen::get() (and then ->set_current_screen() to ensure the globals
 are correct).

 WP_Screen::get() runs through the screen ID building steps, and then uses
 that ID to either return a new WP_Screen, or to return a WP_Screen object
 already in the $_registry.

 Aside from the rework, this patch does a lot of good things here.

  * wp-admin/post.php no longer has a mess of ugly code to determine the
 selected post type. This code is cleaned and brought into WP_Screen::get()
 (when setting the current screen only), and then carried over to edit.php
 and edit-tags.php as well. This fixes #14886 for both post types and
 taxonomies, meaning that $current_screen holds proper data the moment it
 is created, requires no corrections in post.php, and no longer lies
 otherwise.

  * Eliminates the use of static variables to hold state. Keeps the old
 compat help in a single static variable to ensure legacy filters can
 operate against it (specifically contextual_help_list).

  * Has get_screen_icon() use the $current_screen object to make
 determinations, rather than a messy use of globals ($typenow) and
 comparisons ($screen == $current_screen).

  * Clarifies the multiple interpretations of $id by trying to an argument
 called $hook_name when appropriate.

  * Deprecates favorite_actions(). Removes unused globals like
 $wp_list_table. Streamlines some logic in show_screen_options().

  * Locks up the constructor to ensure we have complete control over how
 the API is leveraged.

 I have a few tests in progress for this as well.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18785#comment:57>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list