WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 3 months ago

#18954 new enhancement

Automatically whitelist screen options added via add_screen_option()

Reported by: mdawaffe Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Plugins Keywords: needs-patch
Focuses: administration Cc:

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 (5)

comment:1 nacin2 years ago

  • 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.

comment:2 WraithKenny2 years ago

  • Cc Ken@… added

comment:3 nacin3 months ago

  • Component changed from General to Plugins

comment:4 nacin3 months ago

  • Component changed from Plugins to Admin APIs
  • Keywords needs-patch added; 3.4-early removed

comment:5 nacin3 months ago

  • Component changed from Admin APIs to Plugins
  • Focuses administration added

Sorry for the noise.

Note: See TracTickets for help on using tickets.