Skip to content

Commit

Permalink
Administration: Pass the result of set-screen-option filter to the …
Browse files Browse the repository at this point in the history
…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 5.2 branch.
Fixes #50392.
Built from https://develop.svn.wordpress.org/branches/5.2@48246


git-svn-id: http://core.svn.wordpress.org/branches/5.2@48015 1a063a9b-81f0-0310-95a4-ce76da25c4cd
  • Loading branch information
SergeyBiryukov committed Jul 1, 2020
1 parent 8b8aef2 commit 94cd779
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions wp-admin/includes/misc.php
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,8 @@ function set_screen_options() {
}
break;
default:
$screen_option = false;

if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
/**
* Filters a screen option value before it is set.
Expand All @@ -654,12 +656,12 @@ function set_screen_options() {
*
* @see set_screen_options()
*
* @param bool $keep Whether to save or skip saving the screen option value.
* Default false.
* @param string $option The option name.
* @param int $value The number of rows to use.
* @param mixed $screen_option The value to save instead of the option value.
* Default false (to skip saving the current option).
* @param string $option The option name.
* @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
}

/**
Expand All @@ -673,12 +675,12 @@ function set_screen_options() {
*
* @see set_screen_options()
*
* @param bool $keep Whether to save or skip saving the screen option value.
* Default false.
* @param string $option The option name.
* @param int $value The number of rows to use.
* @param mixed $screen_option The value to save instead of the option value.
* Default false (to skip saving the current option).
* @param string $option The option name.
* @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 ) {
return;
Expand Down

0 comments on commit 94cd779

Please sign in to comment.