Administration: Pass the result of `set-screen-option` filter to the new `set_screen_option_{$option}` filter to ensure backward compatibility.

Rename the `$keep` parameter of both filters to `$screen_option` for clarity, update the documentation to better reflect its purpose.

Follow-up to [47951].

Props Chouby, sswells, SergeyBiryukov.
Merges [48241] to the 4.5 branch.
Fixes #50392.
Built from https://develop.svn.wordpress.org/branches/4.5@48253


git-svn-id: http://core.svn.wordpress.org/branches/4.5@48022 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2020-07-01 09:51:55 +00:00
parent fb5af944fe
commit 36436be2e3
1 changed files with 12 additions and 10 deletions

View File

@ -436,6 +436,8 @@ function set_screen_options() {
return; return;
break; break;
default: default:
$screen_option = false;
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) { if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
/** /**
* Filters a screen option value before it is set. * Filters a screen option value before it is set.
@ -451,12 +453,12 @@ function set_screen_options() {
* *
* @see set_screen_options() * @see set_screen_options()
* *
* @param bool $keep Whether to save or skip saving the screen option value. * @param mixed $screen_option The value to save instead of the option value.
* Default false. * Default false (to skip saving the current option).
* @param string $option The option name. * @param string $option The option name.
* @param int $value The number of rows to use. * @param int $value The option value.
*/ */
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores $screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
} }
/** /**
@ -470,12 +472,12 @@ function set_screen_options() {
* *
* @see set_screen_options() * @see set_screen_options()
* *
* @param bool $keep Whether to save or skip saving the screen option value. * @param mixed $screen_option The value to save instead of the option value.
* Default false. * Default false (to skip saving the current option).
* @param string $option The option name. * @param string $option The option name.
* @param int $value The number of rows to use. * @param int $value The option value.
*/ */
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value ); $value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
if ( false === $value ) if ( false === $value )
return; return;