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.
Built from https://develop.svn.wordpress.org/trunk@48142


git-svn-id: http://core.svn.wordpress.org/trunk@47911 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
desrosj 2020-06-23 18:54:16 +00:00
parent 6cf2f816f0
commit c5b1a12a55
6 changed files with 19 additions and 13 deletions

View File

@ -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 {

View File

@ -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();
},

View File

@ -1,2 +1,2 @@
/*! This file is auto-generated */
window.wp=window.wp||{},function(o){wp.passwordStrength={meter:function(e,t,n){return o.isArray(t)||(t=[t.toString()]),e!=n&&n&&0<n.length?5:void 0===window.zxcvbn?-1:zxcvbn(e,t).score},userInputBlacklist:function(){return wp.deprecated("wp.passwordStrength.userInputBlacklist()",{alternative:"wp.passwordStrength.userInputDisallowedList()",plugin:"WordPress",hint:wp.i18n.__("Please consider writing more inclusive code.")}),wp.passwordStrength.userInputDisallowedList()},userInputDisallowedList:function(){var e,t,n,r,i=[],s=[],l=["user_login","first_name","last_name","nickname","display_name","email","url","description","weblog_title","admin_email"];for(i.push(document.title),i.push(document.URL),t=l.length,e=0;e<t;e++)0!==(r=o("#"+l[e])).length&&(i.push(r[0].defaultValue),i.push(r.val()));for(n=i.length,e=0;e<n;e++)i[e]&&(s=s.concat(i[e].replace(/\W/g," ").split(" ")));return s=o.grep(s,function(e,t){return!(""===e||e.length<4)&&o.inArray(e,s)===t})}},window.passwordStrength=wp.passwordStrength.meter}(jQuery);
window.wp=window.wp||{},function(l){var e=wp.i18n.__,n=wp.i18n.sprintf;wp.passwordStrength={meter:function(e,n,t){return l.isArray(n)||(n=[n.toString()]),e!=t&&t&&0<t.length?5:void 0===window.zxcvbn?-1:zxcvbn(e,n).score},userInputBlacklist:function(){return window.console.log(n(e("%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()")),wp.passwordStrength.userInputDisallowedList()},userInputDisallowedList:function(){var e,n,t,r,s=[],i=[],o=["user_login","first_name","last_name","nickname","display_name","email","url","description","weblog_title","admin_email"];for(s.push(document.title),s.push(document.URL),n=o.length,e=0;e<n;e++)0!==(r=l("#"+o[e])).length&&(s.push(r[0].defaultValue),s.push(r.val()));for(t=s.length,e=0;e<t;e++)s[e]&&(i=i.concat(s[e].replace(/\W/g," ").split(" ")));return i=l.grep(i,function(e,n){return!(""===e||e.length<4)&&l.inArray(e,i)===n})}},window.passwordStrength=wp.passwordStrength.meter}(jQuery);

View File

@ -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 );
}
/**

View File

@ -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',

View File

@ -13,7 +13,7 @@
*
* @global string $wp_version
*/
$wp_version = '5.5-alpha-48141';
$wp_version = '5.5-alpha-48142';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.