From 19c9963d9d5091d1da66e1a84c148d18c5ad25b5 Mon Sep 17 00:00:00 2001 From: Jonathan Desrosiers Date: Tue, 23 Jun 2020 18:53:00 +0000 Subject: [PATCH] General: Rename `(add|remove)_option_allowed_list()` to `(add|remove)_allowed_option()`. The new names make the purpose more clear. It also adds consistency with the `$allowed_options` global variable. Also in this change, the `wp-deprecated` dependency has been removed from the password strength meter in favor of a `window.console.log()` call to avoid adding 3 dependencies for one deprecated notice. Props SergeyBiryukov, ocean90, desrosj Fixes #50413. git-svn-id: https://develop.svn.wordpress.org/trunk@48142 602fd350-edb4-49c9-b593-d223f7449a82 --- src/js/_enqueues/wp/password-strength-meter.js | 16 +++++++++++----- src/wp-admin/includes/plugin.php | 4 ++-- src/wp-includes/deprecated.php | 6 +++--- src/wp-includes/script-loader.php | 2 +- 4 files changed, 17 insertions(+), 11 deletions(-) diff --git a/src/js/_enqueues/wp/password-strength-meter.js b/src/js/_enqueues/wp/password-strength-meter.js index 43a38ba403..a2e0510862 100644 --- a/src/js/_enqueues/wp/password-strength-meter.js +++ b/src/js/_enqueues/wp/password-strength-meter.js @@ -6,6 +6,8 @@ window.wp = window.wp || {}; (function($){ + var __ = wp.i18n.__, + sprintf = wp.i18n.sprintf; /** * Contains functions to determine the password strength. @@ -58,11 +60,15 @@ window.wp = window.wp || {}; * @return {string[]} The array of words to be disallowed. */ userInputBlacklist : function() { - wp.deprecated( 'wp.passwordStrength.userInputBlacklist()', { - alternative: 'wp.passwordStrength.userInputDisallowedList()', - plugin: 'WordPress', - hint: wp.i18n.__( 'Please consider writing more inclusive code.' ) - } ); + window.console.log( + sprintf( + /* translators: 1: Deprecated JSfunction name, 2: Version number, 3: Alternative function name. */ + __( '%1$s is deprecated since version %2$s! Use %3$s instead. Please consider writing more inclusive code.' ), + 'wp.passwordStrength.userInputBlacklist()', + '5.5.0', + 'wp.passwordStrength.userInputDisallowedList()' + ) + ); return wp.passwordStrength.userInputDisallowedList(); }, diff --git a/src/wp-admin/includes/plugin.php b/src/wp-admin/includes/plugin.php index 3492b15ee2..3220c8182f 100644 --- a/src/wp-admin/includes/plugin.php +++ b/src/wp-admin/includes/plugin.php @@ -2154,7 +2154,7 @@ function option_update_filter( $options ) { global $new_whitelist_options; if ( is_array( $new_whitelist_options ) ) { - $options = add_option_allowed_list( $new_whitelist_options, $options ); + $options = add_allowed_options( $new_whitelist_options, $options ); } return $options; @@ -2171,7 +2171,7 @@ function option_update_filter( $options ) { * @param string|array $options * @return array */ -function add_option_allowed_list( $new_options, $options = '' ) { +function add_allowed_options( $new_options, $options = '' ) { if ( '' === $options ) { global $allowed_options; } else { diff --git a/src/wp-includes/deprecated.php b/src/wp-includes/deprecated.php index 7a55903f4d..ad0af4c12e 100644 --- a/src/wp-includes/deprecated.php +++ b/src/wp-includes/deprecated.php @@ -4042,7 +4042,7 @@ function _wp_register_meta_args_whitelist( $args, $default_args ) { * Adds an array of options to the list of allowed options. * * @since 2.7.0 - * @deprecated 5.5.0 Use add_option_allowed_list() instead. + * @deprecated 5.5.0 Use add_allowed_options() instead. * Please consider writing more inclusive code. * * @global array $allowed_options @@ -4052,9 +4052,9 @@ function _wp_register_meta_args_whitelist( $args, $default_args ) { * @return array */ function add_option_whitelist( $new_options, $options = '' ) { - _deprecated_function( __FUNCTION__, '5.5.0', 'add_option_allowed_list()' ); + _deprecated_function( __FUNCTION__, '5.5.0', 'add_allowed_options()' ); - return add_option_allowed_list( $new_options, $options ); + return add_allowed_options( $new_options, $options ); } /** diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php index f31ae3b32c..ec7290cea3 100644 --- a/src/wp-includes/script-loader.php +++ b/src/wp-includes/script-loader.php @@ -1064,7 +1064,7 @@ function wp_default_scripts( $scripts ) { ) ); - $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'wp-deprecated', 'zxcvbn-async' ), false, 1 ); + $scripts->add( 'password-strength-meter', "/wp-admin/js/password-strength-meter$suffix.js", array( 'jquery', 'zxcvbn-async' ), false, 1 ); did_action( 'init' ) && $scripts->localize( 'password-strength-meter', 'pwsL10n',