mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 06:37:06 +00:00
General: Remove “whitelist” and “blacklist” in favor of more clear and inclusive language.
“The WordPress open source community cares about diversity. We strive to maintain a welcoming environment where everyone can feel included.” With this commit, all occurrences of “whitelist” and “blacklist” (with the single exception of the `$new_whitelist_options` global variable) are removed. A new ticket has been opened to explore renaming the `$new_whitelist_options` variable (#50434). Changing to more specific names or rewording sentences containing these terms not only makes the code more inclusive, but also helps provide clarity. These terms are often ambiguous. What is being blocked or allowed is not always immediately clear. This can make it more difficult for non-native English speakers to read through the codebase. Words matter. If one contributor feels more welcome because these terms are removed, this was worth the effort. Props strangerstudios, jorbin, desrosj, joemcgill, timothyblynjacobs, ocean90, ayeshrajans, davidbaumwald, earnjam. See #48900, #50434. Fixes #50413. git-svn-id: https://develop.svn.wordpress.org/trunk@48121 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -74,7 +74,7 @@ add_filter( 'heartbeat_settings', 'wp_heartbeat_set_suspension' );
|
||||
add_action( 'admin_head-nav-menus.php', '_wp_delete_orphaned_draft_menu_items' );
|
||||
|
||||
// Plugin hooks.
|
||||
add_filter( 'whitelist_options', 'option_update_filter' );
|
||||
add_filter( 'allowed_options', 'option_update_filter' );
|
||||
|
||||
// Plugin Install hooks.
|
||||
add_action( 'install_plugins_featured', 'install_dashboard' );
|
||||
|
||||
@@ -47,10 +47,10 @@ class WP_Plugins_List_Table extends WP_List_Table {
|
||||
)
|
||||
);
|
||||
|
||||
$status_whitelist = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled' );
|
||||
$allowed_statuses = array( 'active', 'inactive', 'recently_activated', 'upgrade', 'mustuse', 'dropins', 'search', 'paused', 'auto-update-enabled', 'auto-update-disabled' );
|
||||
|
||||
$status = 'all';
|
||||
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $status_whitelist, true ) ) {
|
||||
if ( isset( $_REQUEST['plugin_status'] ) && in_array( $_REQUEST['plugin_status'], $allowed_statuses, true ) ) {
|
||||
$status = $_REQUEST['plugin_status'];
|
||||
}
|
||||
|
||||
|
||||
@@ -1776,8 +1776,9 @@ class WP_Site_Health {
|
||||
/**
|
||||
* Test if HTTP requests are blocked.
|
||||
*
|
||||
* It's possible to block all outgoing communication (with the possibility of whitelisting hosts) via the
|
||||
* HTTP API. This may create problems for users as many features are running as services these days.
|
||||
* It's possible to block all outgoing communication (with the possibility of allowing certain
|
||||
* hosts) via the HTTP API. This may create problems for users as many features are running as
|
||||
* services these days.
|
||||
*
|
||||
* @since 5.2.0
|
||||
*
|
||||
@@ -1833,8 +1834,8 @@ class WP_Site_Health {
|
||||
$result['description'] .= sprintf(
|
||||
'<p>%s</p>',
|
||||
sprintf(
|
||||
/* translators: 1: Name of the constant used. 2: List of hostnames whitelisted. */
|
||||
__( 'HTTP requests have been blocked by the %1$s constant, with some hosts whitelisted: %2$s.' ),
|
||||
/* translators: 1: Name of the constant used. 2: List of allowed hostnames. */
|
||||
__( 'HTTP requests have been blocked by the %1$s constant, with some allowed hosts: %2$s.' ),
|
||||
'<code>WP_HTTP_BLOCK_EXTERNAL</code>',
|
||||
implode( ',', $hosts )
|
||||
)
|
||||
|
||||
@@ -159,8 +159,8 @@ function wp_dropdown_cats( $currentcat = 0, $currentparent = 0, $parent = 0, $le
|
||||
* @deprecated 3.0.0 Use register_setting()
|
||||
* @see register_setting()
|
||||
*
|
||||
* @param string $option_group A settings group name. Should correspond to a whitelisted option key name.
|
||||
* Default whitelisted option key names include 'general', 'discussion', 'media',
|
||||
* @param string $option_group A settings group name. Should correspond to an allowed option key name.
|
||||
* Default allowed option key names include 'general', 'discussion', 'media',
|
||||
* 'reading', 'writing', 'misc', 'options', and 'privacy'.
|
||||
* @param string $option_name The name of an option to sanitize and save.
|
||||
* @param callable $sanitize_callback A callback function that sanitizes the option's value.
|
||||
@@ -1530,7 +1530,7 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Data_Export_Reque
|
||||
$args['screen'] = 'export-personal-data';
|
||||
}
|
||||
|
||||
parent::__construct( $args );
|
||||
parent::__construct( $args );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2136,12 +2136,12 @@ function user_can_access_admin_page() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Whitelist functions */
|
||||
/* Allowed list functions */
|
||||
|
||||
/**
|
||||
* Refreshes the value of the options whitelist available via the 'whitelist_options' hook.
|
||||
* Refreshes the value of the allowed options list available via the 'allowed_options' hook.
|
||||
*
|
||||
* See the {@see 'whitelist_options'} filter.
|
||||
* See the {@see 'allowed_options'} filter.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
@@ -2154,77 +2154,77 @@ function option_update_filter( $options ) {
|
||||
global $new_whitelist_options;
|
||||
|
||||
if ( is_array( $new_whitelist_options ) ) {
|
||||
$options = add_option_whitelist( $new_whitelist_options, $options );
|
||||
$options = add_option_allowed_list( $new_whitelist_options, $options );
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds an array of options to the options whitelist.
|
||||
* Adds an array of options to the list of allowed options.
|
||||
*
|
||||
* @since 2.7.0
|
||||
*
|
||||
* @global array $whitelist_options
|
||||
* @global array $allowed_options
|
||||
*
|
||||
* @param array $new_options
|
||||
* @param string|array $options
|
||||
* @return array
|
||||
*/
|
||||
function add_option_whitelist( $new_options, $options = '' ) {
|
||||
function add_option_allowed_list( $new_options, $options = '' ) {
|
||||
if ( '' === $options ) {
|
||||
global $whitelist_options;
|
||||
global $allowed_options;
|
||||
} else {
|
||||
$whitelist_options = $options;
|
||||
$allowed_options = $options;
|
||||
}
|
||||
|
||||
foreach ( $new_options as $page => $keys ) {
|
||||
foreach ( $keys as $key ) {
|
||||
if ( ! isset( $whitelist_options[ $page ] ) || ! is_array( $whitelist_options[ $page ] ) ) {
|
||||
$whitelist_options[ $page ] = array();
|
||||
$whitelist_options[ $page ][] = $key;
|
||||
if ( ! isset( $allowed_options[ $page ] ) || ! is_array( $allowed_options[ $page ] ) ) {
|
||||
$allowed_options[ $page ] = array();
|
||||
$allowed_options[ $page ][] = $key;
|
||||
} else {
|
||||
$pos = array_search( $key, $whitelist_options[ $page ], true );
|
||||
$pos = array_search( $key, $allowed_options[ $page ], true );
|
||||
if ( false === $pos ) {
|
||||
$whitelist_options[ $page ][] = $key;
|
||||
$allowed_options[ $page ][] = $key;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $whitelist_options;
|
||||
return $allowed_options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes a list of options from the options whitelist.
|
||||
* Removes a list of options from the allowed options list.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @global array $whitelist_options
|
||||
* @global array $allowed_options
|
||||
*
|
||||
* @param array $del_options
|
||||
* @param string|array $options
|
||||
* @return array
|
||||
*/
|
||||
function remove_option_whitelist( $del_options, $options = '' ) {
|
||||
function remove_option_allowed_list( $del_options, $options = '' ) {
|
||||
if ( '' === $options ) {
|
||||
global $whitelist_options;
|
||||
global $allowed_options;
|
||||
} else {
|
||||
$whitelist_options = $options;
|
||||
$allowed_options = $options;
|
||||
}
|
||||
|
||||
foreach ( $del_options as $page => $keys ) {
|
||||
foreach ( $keys as $key ) {
|
||||
if ( isset( $whitelist_options[ $page ] ) && is_array( $whitelist_options[ $page ] ) ) {
|
||||
$pos = array_search( $key, $whitelist_options[ $page ], true );
|
||||
if ( isset( $allowed_options[ $page ] ) && is_array( $allowed_options[ $page ] ) ) {
|
||||
$pos = array_search( $key, $allowed_options[ $page ], true );
|
||||
if ( false !== $pos ) {
|
||||
unset( $whitelist_options[ $page ][ $pos ] );
|
||||
unset( $allowed_options[ $page ][ $pos ] );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $whitelist_options;
|
||||
return $allowed_options;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2234,7 +2234,7 @@ function get_block_categories( $post ) {
|
||||
function get_block_editor_server_block_settings() {
|
||||
$block_registry = WP_Block_Type_Registry::get_instance();
|
||||
$blocks = array();
|
||||
$fields_to_pick = array(
|
||||
$fields_to_pick = array(
|
||||
'title' => 'title',
|
||||
'description' => 'description',
|
||||
'icon' => 'icon',
|
||||
|
||||
@@ -446,8 +446,6 @@ function populate_options( array $options = array() ) {
|
||||
'recently_edited' => '',
|
||||
'template' => $template,
|
||||
'stylesheet' => $stylesheet,
|
||||
'comment_whitelist' => 1,
|
||||
'blacklist_keys' => '',
|
||||
'comment_registration' => 0,
|
||||
'html_type' => 'text/html',
|
||||
|
||||
@@ -532,6 +530,10 @@ function populate_options( array $options = array() ) {
|
||||
|
||||
// 5.3.0
|
||||
'admin_email_lifespan' => ( time() + 6 * MONTH_IN_SECONDS ),
|
||||
|
||||
// 5.5.0
|
||||
'blocklist_keys' => '',
|
||||
'comment_previously_approved' => 1,
|
||||
);
|
||||
|
||||
// 3.3.0
|
||||
@@ -550,7 +552,7 @@ function populate_options( array $options = array() ) {
|
||||
$options = wp_parse_args( $options, $defaults );
|
||||
|
||||
// Set autoload to no for these options.
|
||||
$fat_options = array( 'moderation_keys', 'recently_edited', 'blacklist_keys', 'uninstall_plugins' );
|
||||
$fat_options = array( 'moderation_keys', 'recently_edited', 'blocklist_keys', 'uninstall_plugins' );
|
||||
|
||||
$keys = "'" . implode( "', '", array_keys( $options ) ) . "'";
|
||||
$existing_options = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name in ( $keys )" ); // phpcs:ignore WordPress.DB.PreparedSQL.NotPrepared
|
||||
@@ -1140,7 +1142,7 @@ function populate_network_meta( $network_id, array $meta = array() ) {
|
||||
$allowed_themes[ WP_DEFAULT_THEME ] = true;
|
||||
}
|
||||
|
||||
// If WP_DEFAULT_THEME doesn't exist, also whitelist the latest core default theme.
|
||||
// If WP_DEFAULT_THEME doesn't exist, also include the latest core default theme.
|
||||
if ( ! wp_get_theme( WP_DEFAULT_THEME )->exists() ) {
|
||||
$core_default = WP_Theme::get_core_default_theme();
|
||||
if ( $core_default ) {
|
||||
|
||||
@@ -835,7 +835,7 @@ function upgrade_all() {
|
||||
upgrade_530();
|
||||
}
|
||||
|
||||
if ( $wp_current_db_version < 47597 ) {
|
||||
if ( $wp_current_db_version < 48082 ) {
|
||||
upgrade_550();
|
||||
}
|
||||
|
||||
@@ -2168,6 +2168,15 @@ function upgrade_530() {
|
||||
function upgrade_550() {
|
||||
update_option( 'finished_updating_comment_type', 0 );
|
||||
wp_schedule_single_event( time() + ( 1 * MINUTE_IN_SECONDS ), 'wp_update_comment_type_batch' );
|
||||
|
||||
// Use more clear and inclusive language.
|
||||
$blocklist = get_option( 'blacklist_keys', '' );
|
||||
update_option( 'blocklist_keys', $blocklist );
|
||||
delete_option( 'blacklist_keys' );
|
||||
|
||||
$comment_previously_approved = get_option( 'comment_whitelist', '' );
|
||||
update_option( 'comment_previously_approved', $comment_previously_approved );
|
||||
delete_option( 'comment_whitelist' );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -181,7 +181,7 @@ printf( __( 'Comments should be displayed with the %s comments at the top of eac
|
||||
<input name="comment_moderation" type="checkbox" id="comment_moderation" value="1" <?php checked( '1', get_option( 'comment_moderation' ) ); ?> />
|
||||
<?php _e( 'Comment must be manually approved' ); ?> </label>
|
||||
<br />
|
||||
<label for="comment_whitelist"><input type="checkbox" name="comment_whitelist" id="comment_whitelist" value="1" <?php checked( '1', get_option( 'comment_whitelist' ) ); ?> /> <?php _e( 'Comment author must have a previously approved comment' ); ?></label>
|
||||
<label for="comment_previously_approved"><input type="checkbox" name="comment_previously_approved" id="comment_previously_approved" value="1" <?php checked( '1', get_option( 'comment_previously_approved' ) ); ?> /> <?php _e( 'Comment author must have a previously approved comment' ); ?></label>
|
||||
</fieldset></td>
|
||||
</tr>
|
||||
<tr>
|
||||
@@ -206,9 +206,9 @@ printf(
|
||||
<tr>
|
||||
<th scope="row"><?php _e( 'Comment Blocklist' ); ?></th>
|
||||
<td><fieldset><legend class="screen-reader-text"><span><?php _e( 'Comment Blocklist' ); ?></span></legend>
|
||||
<p><label for="blacklist_keys"><?php _e( 'When a comment contains any of these words in its content, author name, URL, email, IP address, or browser’s user agent string, it will be put in the Trash. One word or IP address per line. It will match inside words, so “press” will match “WordPress”.' ); ?></label></p>
|
||||
<p><label for="blocklist_keys"><?php _e( 'When a comment contains any of these words in its content, author name, URL, email, IP address, or browser’s user agent string, it will be put in the Trash. One word or IP address per line. It will match inside words, so “press” will match “WordPress”.' ); ?></label></p>
|
||||
<p>
|
||||
<textarea name="blacklist_keys" rows="10" cols="50" id="blacklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blacklist_keys' ) ); ?></textarea>
|
||||
<textarea name="blocklist_keys" rows="10" cols="50" id="blocklist_keys" class="large-text code"><?php echo esc_textarea( get_option( 'blocklist_keys' ) ); ?></textarea>
|
||||
</p>
|
||||
</fieldset></td>
|
||||
</tr>
|
||||
|
||||
+35
-25
@@ -80,7 +80,7 @@ if ( is_multisite() && ! current_user_can( 'manage_network_options' ) && 'update
|
||||
);
|
||||
}
|
||||
|
||||
$whitelist_options = array(
|
||||
$allowed_options = array(
|
||||
'general' => array(
|
||||
'blogname',
|
||||
'blogdescription',
|
||||
@@ -100,10 +100,10 @@ $whitelist_options = array(
|
||||
'moderation_notify',
|
||||
'comment_moderation',
|
||||
'require_name_email',
|
||||
'comment_whitelist',
|
||||
'comment_previously_approved',
|
||||
'comment_max_links',
|
||||
'moderation_keys',
|
||||
'blacklist_keys',
|
||||
'blocklist_keys',
|
||||
'show_avatars',
|
||||
'avatar_rating',
|
||||
'avatar_default',
|
||||
@@ -146,36 +146,36 @@ $whitelist_options = array(
|
||||
'default_post_format',
|
||||
),
|
||||
);
|
||||
$whitelist_options['misc'] = array();
|
||||
$whitelist_options['options'] = array();
|
||||
$whitelist_options['privacy'] = array();
|
||||
$allowed_options['misc'] = array();
|
||||
$allowed_options['options'] = array();
|
||||
$allowed_options['privacy'] = array();
|
||||
|
||||
$mail_options = array( 'mailserver_url', 'mailserver_port', 'mailserver_login', 'mailserver_pass' );
|
||||
|
||||
if ( ! in_array( get_option( 'blog_charset' ), array( 'utf8', 'utf-8', 'UTF8', 'UTF-8' ), true ) ) {
|
||||
$whitelist_options['reading'][] = 'blog_charset';
|
||||
$allowed_options['reading'][] = 'blog_charset';
|
||||
}
|
||||
|
||||
if ( get_site_option( 'initial_db_version' ) < 32453 ) {
|
||||
$whitelist_options['writing'][] = 'use_smilies';
|
||||
$whitelist_options['writing'][] = 'use_balanceTags';
|
||||
$allowed_options['writing'][] = 'use_smilies';
|
||||
$allowed_options['writing'][] = 'use_balanceTags';
|
||||
}
|
||||
|
||||
if ( ! is_multisite() ) {
|
||||
if ( ! defined( 'WP_SITEURL' ) ) {
|
||||
$whitelist_options['general'][] = 'siteurl';
|
||||
$allowed_options['general'][] = 'siteurl';
|
||||
}
|
||||
if ( ! defined( 'WP_HOME' ) ) {
|
||||
$whitelist_options['general'][] = 'home';
|
||||
$allowed_options['general'][] = 'home';
|
||||
}
|
||||
|
||||
$whitelist_options['general'][] = 'users_can_register';
|
||||
$whitelist_options['general'][] = 'default_role';
|
||||
$allowed_options['general'][] = 'users_can_register';
|
||||
$allowed_options['general'][] = 'default_role';
|
||||
|
||||
$whitelist_options['writing'] = array_merge( $whitelist_options['writing'], $mail_options );
|
||||
$whitelist_options['writing'][] = 'ping_sites';
|
||||
$allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options );
|
||||
$allowed_options['writing'][] = 'ping_sites';
|
||||
|
||||
$whitelist_options['media'][] = 'uploads_use_yearmonth_folders';
|
||||
$allowed_options['media'][] = 'uploads_use_yearmonth_folders';
|
||||
|
||||
/*
|
||||
* If upload_url_path is not the default (empty),
|
||||
@@ -183,8 +183,8 @@ if ( ! is_multisite() ) {
|
||||
* they can be edited, otherwise they're locked.
|
||||
*/
|
||||
if ( get_option( 'upload_url_path' ) || ( get_option( 'upload_path' ) != 'wp-content/uploads' && get_option( 'upload_path' ) ) ) {
|
||||
$whitelist_options['media'][] = 'upload_path';
|
||||
$whitelist_options['media'][] = 'upload_url_path';
|
||||
$allowed_options['media'][] = 'upload_path';
|
||||
$allowed_options['media'][] = 'upload_url_path';
|
||||
}
|
||||
} else {
|
||||
/**
|
||||
@@ -195,18 +195,28 @@ if ( ! is_multisite() ) {
|
||||
* @param bool $enabled Whether post-by-email configuration is enabled. Default true.
|
||||
*/
|
||||
if ( apply_filters( 'enable_post_by_email_configuration', true ) ) {
|
||||
$whitelist_options['writing'] = array_merge( $whitelist_options['writing'], $mail_options );
|
||||
$allowed_options['writing'] = array_merge( $allowed_options['writing'], $mail_options );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the options whitelist.
|
||||
* Filters the allowed options list.
|
||||
*
|
||||
* @since 2.7.0
|
||||
* @deprecated 5.5.0 Use {@see 'allowed_options'} instead.
|
||||
*
|
||||
* @param array $whitelist_options The options whitelist.
|
||||
* @param array $allowed_options The allowed options list.
|
||||
*/
|
||||
$whitelist_options = apply_filters( 'whitelist_options', $whitelist_options );
|
||||
$allowed_options = apply_filters_deprecated( 'whitelist_options', array( $allowed_options ), '5.5.0', 'apply_filters_deprecated', __( 'Please consider writing more inclusive code.' ) );
|
||||
|
||||
/**
|
||||
* Filters the allowed options list.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param array $allowed_options The allowed options list.
|
||||
*/
|
||||
$allowed_options = apply_filters( 'allowed_options', $allowed_options );
|
||||
|
||||
if ( 'update' === $action ) { // We are saving settings sent from a settings page.
|
||||
if ( 'options' === $option_page && ! isset( $_POST['option_page'] ) ) { // This is for back compat and will eventually be removed.
|
||||
@@ -217,11 +227,11 @@ if ( 'update' === $action ) { // We are saving settings sent from a settings pag
|
||||
check_admin_referer( $option_page . '-options' );
|
||||
}
|
||||
|
||||
if ( ! isset( $whitelist_options[ $option_page ] ) ) {
|
||||
if ( ! isset( $allowed_options[ $option_page ] ) ) {
|
||||
wp_die(
|
||||
sprintf(
|
||||
/* translators: %s: The options page name. */
|
||||
__( '<strong>Error</strong>: Options page %s not found in the options whitelist.' ),
|
||||
__( '<strong>Error</strong>: Options page %s not found in the allowed options list.' ),
|
||||
'<code>' . esc_html( $option_page ) . '</code>'
|
||||
)
|
||||
);
|
||||
@@ -233,7 +243,7 @@ if ( 'update' === $action ) { // We are saving settings sent from a settings pag
|
||||
}
|
||||
$options = explode( ',', wp_unslash( $_POST['page_options'] ) );
|
||||
} else {
|
||||
$options = $whitelist_options[ $option_page ];
|
||||
$options = $allowed_options[ $option_page ];
|
||||
}
|
||||
|
||||
if ( 'general' === $option_page ) {
|
||||
|
||||
Reference in New Issue
Block a user