From 7bdff387e20103d2e7042291670ea31dc6953203 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 14 Jul 2020 12:31:22 +0000 Subject: [PATCH] General: Rename the `$new_whitelist_options` global variable. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change renames `$new_whitelist_options` to `$new_allowed_options`. This makes the variable’s purpose more clear, and promotes using more inclusive language. For backwards compatibility, the new variable is passed by reference to the old one. Follow up to [48121]. Props ayeshrajans, desrosj, jorbin, SergeyBiryukov. See #50413. Fixes #50434. git-svn-id: https://develop.svn.wordpress.org/trunk@48477 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/plugin.php | 10 ++++++---- src/wp-includes/option.php | 30 +++++++++++++++++++++++------- 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 94d5b856a6..bd757c8a28 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -2167,17 +2167,19 @@ function user_can_access_admin_page() { * See the {@see 'allowed_options'} filter. * * @since 2.7.0 + * @since 5.5.0 `$new_whitelist_options` was renamed to `$new_allowed_options`. + * Please consider writing more inclusive code. * - * @global array $new_whitelist_options + * @global array $new_allowed_options * * @param array $options * @return array */ function option_update_filter( $options ) { - global $new_whitelist_options; + global $new_allowed_options; - if ( is_array( $new_whitelist_options ) ) { - $options = add_allowed_options( $new_whitelist_options, $options ); + if ( is_array( $new_allowed_options ) ) { + $options = add_allowed_options( $new_allowed_options, $options ); } return $options; diff --git a/src/wp-includes/option.php b/src/wp-includes/option.php index be81bd25ad..256795acd9 100644 --- a/src/wp-includes/option.php +++ b/src/wp-includes/option.php @@ -2123,8 +2123,10 @@ function register_initial_settings() { * * @since 2.7.0 * @since 4.7.0 `$args` can be passed to set flags on the setting, similar to `register_meta()`. + * @since 5.5.0 `$new_whitelist_options` was renamed to `$new_allowed_options`. + * Please consider writing more inclusive code. * - * @global array $new_whitelist_options + * @global array $new_allowed_options * @global array $wp_registered_settings * * @param string $option_group A settings group name. Should correspond to an allowed option key name. @@ -2145,7 +2147,13 @@ function register_initial_settings() { * } */ function register_setting( $option_group, $option_name, $args = array() ) { - global $new_whitelist_options, $wp_registered_settings; + global $new_allowed_options, $wp_registered_settings; + + /* + * In 5.5.0, the `$new_whitelist_options` global variable was renamed to `$new_allowed_options`. + * Please consider writing more inclusive code. + */ + $GLOBALS['new_whitelist_options'] = &$new_allowed_options; $defaults = array( 'type' => 'string', @@ -2211,7 +2219,7 @@ function register_setting( $option_group, $option_name, $args = array() ) { $option_group = 'reading'; } - $new_whitelist_options[ $option_group ][] = $option_name; + $new_allowed_options[ $option_group ][] = $option_name; if ( ! empty( $args['sanitize_callback'] ) ) { add_filter( "sanitize_option_{$option_name}", $args['sanitize_callback'] ); @@ -2239,8 +2247,10 @@ function register_setting( $option_group, $option_name, $args = array() ) { * * @since 2.7.0 * @since 4.7.0 `$sanitize_callback` was deprecated. The callback from `register_setting()` is now used instead. + * @since 5.5.0 `$new_whitelist_options` was renamed to `$new_allowed_options`. + * Please consider writing more inclusive code. * - * @global array $new_whitelist_options + * @global array $new_allowed_options * @global array $wp_registered_settings * * @param string $option_group The settings group name used during registration. @@ -2248,7 +2258,13 @@ function register_setting( $option_group, $option_name, $args = array() ) { * @param callable $deprecated Deprecated. */ function unregister_setting( $option_group, $option_name, $deprecated = '' ) { - global $new_whitelist_options, $wp_registered_settings; + global $new_allowed_options, $wp_registered_settings; + + /* + * In 5.5.0, the `$new_whitelist_options` global variable was renamed to `$new_allowed_options`. + * Please consider writing more inclusive code. + */ + $GLOBALS['new_whitelist_options'] = &$new_allowed_options; if ( 'misc' === $option_group ) { _deprecated_argument( @@ -2276,10 +2292,10 @@ function unregister_setting( $option_group, $option_name, $deprecated = '' ) { $option_group = 'reading'; } - $pos = array_search( $option_name, (array) $new_whitelist_options[ $option_group ], true ); + $pos = array_search( $option_name, (array) $new_allowed_options[ $option_group ], true ); if ( false !== $pos ) { - unset( $new_whitelist_options[ $option_group ][ $pos ] ); + unset( $new_allowed_options[ $option_group ][ $pos ] ); } if ( '' !== $deprecated ) {