Opened 20 months ago

Last modified 18 months ago

#18954 new enhancement

Automatically whitelist screen options added via add_screen_option()

Reported by: mdawaffe Owned by:
Priority: normal Milestone: Future Release
Component: General Version:
Severity: normal Keywords: 3.4-early
Cc: Ken@…

Description

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' ) ) );

Change History (2)

  • Keywords 3.4-early added
  • Milestone changed from Awaiting Review to Future Release

We may be able to get away with killing this whitelist come 3.4.

  • Cc Ken@… added
Note: See TracTickets for help on using tickets.