[wp-trac] [WordPress Trac] #18954: Automatically whitelist screen options added via add_screen_option()
WordPress Trac
wp-trac at lists.automattic.com
Fri Oct 14 22:54:08 UTC 2011
#18954: Automatically whitelist screen options added via add_screen_option()
-------------------------+-----------------------------
Reporter: mdawaffe | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: General | Version:
Severity: normal | Keywords:
-------------------------+-----------------------------
{{{set_screen_options()}}} currently maintains a hardcoded whitelist of
screens that can set options.
The list is extendable via the filter:
{{{
apply_filters('set-screen-option', false, $option, $value);
}}}
but that's sort of a pain. If a plugin calls {{{add_screen_option()}}},
it should be added to the whitelist automatically.
Also note that {{{set_screen_options()}}} is called so early, there's no
convenient place for plugins to add to the {{{set-screen-option}}} filter.
The best workaround I've been able to come up with is to manually call
{{{set_screen_options()}}} again inside the page's {{{load-$hook}}}.
Example naive plugin code that does not work in <=3.3.
{{{
# Inside a menu page's load-$hook
// Display per-page settings in screen options
add_screen_option( 'per_page', array( 'label' => __( 'Things' ) ) );
}}}
--
Ticket URL: <http://core.trac.wordpress.org/ticket/18954>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list