Skip to content

Commit 99d5878

Browse files
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 5.0 branch. Fixes #50392. git-svn-id: https://develop.svn.wordpress.org/branches/5.0@48248 602fd350-edb4-49c9-b593-d223f7449a82
1 parent cabad76 commit 99d5878

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

src/wp-admin/includes/misc.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,8 @@ function set_screen_options() {
620620
return;
621621
break;
622622
default:
623+
$screen_option = false;
624+
623625
if ( '_page' === substr( $option, -5 ) || 'layout_columns' === $option ) {
624626
/**
625627
* Filters a screen option value before it is set.
@@ -635,12 +637,12 @@ function set_screen_options() {
635637
*
636638
* @see set_screen_options()
637639
*
638-
* @param bool $keep Whether to save or skip saving the screen option value.
639-
* Default false.
640-
* @param string $option The option name.
641-
* @param int $value The number of rows to use.
640+
* @param mixed $screen_option The value to save instead of the option value.
641+
* Default false (to skip saving the current option).
642+
* @param string $option The option name.
643+
* @param int $value The option value.
642644
*/
643-
$value = apply_filters( 'set-screen-option', false, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
645+
$screen_option = apply_filters( 'set-screen-option', $screen_option, $option, $value ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.UseUnderscores
644646
}
645647

646648
/**
@@ -654,12 +656,12 @@ function set_screen_options() {
654656
*
655657
* @see set_screen_options()
656658
*
657-
* @param bool $keep Whether to save or skip saving the screen option value.
658-
* Default false.
659-
* @param string $option The option name.
660-
* @param int $value The number of rows to use.
659+
* @param mixed $screen_option The value to save instead of the option value.
660+
* Default false (to skip saving the current option).
661+
* @param string $option The option name.
662+
* @param int $value The option value.
661663
*/
662-
$value = apply_filters( "set_screen_option_{$option}", false, $option, $value );
664+
$value = apply_filters( "set_screen_option_{$option}", $screen_option, $option, $value );
663665

664666
if ( false === $value )
665667
return;

0 commit comments

Comments
 (0)