Make WordPress Core


Ignore:
Timestamp:
06/22/2020 05:24:34 PM (6 years ago)
Author:
desrosj
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/plugin.php

    r48115 r48121  
    21372137}
    21382138
    2139 /* Whitelist functions */
    2140 
    2141 /**
    2142  * Refreshes the value of the options whitelist available via the 'whitelist_options' hook.
    2143  *
    2144  * See the {@see 'whitelist_options'} filter.
     2139/* Allowed list functions */
     2140
     2141/**
     2142 * Refreshes the value of the allowed options list available via the 'allowed_options' hook.
     2143 *
     2144 * See the {@see 'allowed_options'} filter.
    21452145 *
    21462146 * @since 2.7.0
     
    21552155
    21562156        if ( is_array( $new_whitelist_options ) ) {
    2157                 $options = add_option_whitelist( $new_whitelist_options, $options );
     2157                $options = add_option_allowed_list( $new_whitelist_options, $options );
    21582158        }
    21592159
     
    21622162
    21632163/**
    2164  * Adds an array of options to the options whitelist.
     2164 * Adds an array of options to the list of allowed options.
    21652165 *
    21662166 * @since 2.7.0
    21672167 *
    2168  * @global array $whitelist_options
     2168 * @global array $allowed_options
    21692169 *
    21702170 * @param array        $new_options
     
    21722172 * @return array
    21732173 */
    2174 function add_option_whitelist( $new_options, $options = '' ) {
     2174function add_option_allowed_list( $new_options, $options = '' ) {
    21752175        if ( '' === $options ) {
    2176                 global $whitelist_options;
     2176                global $allowed_options;
    21772177        } else {
    2178                 $whitelist_options = $options;
     2178                $allowed_options = $options;
    21792179        }
    21802180
    21812181        foreach ( $new_options as $page => $keys ) {
    21822182                foreach ( $keys as $key ) {
    2183                         if ( ! isset( $whitelist_options[ $page ] ) || ! is_array( $whitelist_options[ $page ] ) ) {
    2184                                 $whitelist_options[ $page ]   = array();
    2185                                 $whitelist_options[ $page ][] = $key;
     2183                        if ( ! isset( $allowed_options[ $page ] ) || ! is_array( $allowed_options[ $page ] ) ) {
     2184                                $allowed_options[ $page ]   = array();
     2185                                $allowed_options[ $page ][] = $key;
    21862186                        } else {
    2187                                 $pos = array_search( $key, $whitelist_options[ $page ], true );
     2187                                $pos = array_search( $key, $allowed_options[ $page ], true );
    21882188                                if ( false === $pos ) {
    2189                                         $whitelist_options[ $page ][] = $key;
     2189                                        $allowed_options[ $page ][] = $key;
    21902190                                }
    21912191                        }
     
    21932193        }
    21942194
    2195         return $whitelist_options;
    2196 }
    2197 
    2198 /**
    2199  * Removes a list of options from the options whitelist.
    2200  *
    2201  * @since 2.7.0
    2202  *
    2203  * @global array $whitelist_options
     2195        return $allowed_options;
     2196}
     2197
     2198/**
     2199 * Removes a list of options from the allowed options list.
     2200 *
     2201 * @since 5.5.0
     2202 *
     2203 * @global array $allowed_options
    22042204 *
    22052205 * @param array        $del_options
     
    22072207 * @return array
    22082208 */
    2209 function remove_option_whitelist( $del_options, $options = '' ) {
     2209function remove_option_allowed_list( $del_options, $options = '' ) {
    22102210        if ( '' === $options ) {
    2211                 global $whitelist_options;
     2211                global $allowed_options;
    22122212        } else {
    2213                 $whitelist_options = $options;
     2213                $allowed_options = $options;
    22142214        }
    22152215
    22162216        foreach ( $del_options as $page => $keys ) {
    22172217                foreach ( $keys as $key ) {
    2218                         if ( isset( $whitelist_options[ $page ] ) && is_array( $whitelist_options[ $page ] ) ) {
    2219                                 $pos = array_search( $key, $whitelist_options[ $page ], true );
     2218                        if ( isset( $allowed_options[ $page ] ) && is_array( $allowed_options[ $page ] ) ) {
     2219                                $pos = array_search( $key, $allowed_options[ $page ], true );
    22202220                                if ( false !== $pos ) {
    2221                                         unset( $whitelist_options[ $page ][ $pos ] );
     2221                                        unset( $allowed_options[ $page ][ $pos ] );
    22222222                                }
    22232223                        }
     
    22252225        }
    22262226
    2227         return $whitelist_options;
     2227        return $allowed_options;
    22282228}
    22292229
Note: See TracChangeset for help on using the changeset viewer.