Make WordPress Core


Ignore:
Timestamp:
07/23/2020 03:12:49 AM (4 years ago)
Author:
jorbin
Message:

General: Update code for readability and inclusion

There are two pieces in here:

1) The update to change blacklist to blocklist is moved to disallowed_list. "Block" has a meaning in our code, and there could be ambiguity between this code and code related to blocks.

2) This improves backwards compatibility for code that was accessing the now deprecated code.

Previously: [48477], [48405], [48400], [48121], [48122], [48124], [48142], [48566]

Props: desrosj, SergeyBiryukov, johnjamesjacoby
Fixes: #50413

File:
1 edited

Legend:

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

    r48477 r48575  
    3434    if ( empty( $option ) ) {
    3535        return false;
     36    }
     37
     38    /*
     39     * Until a proper _deprecated_option() function can be introduced,
     40     * redirect requests to deprecated keys to the new, correct ones.
     41     */
     42    $deprecated_keys = array(
     43        'blacklist_keys'    => 'disallowed_keys',
     44        'comment_whitelist' => 'comment_previously_approved',
     45    );
     46
     47    if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
     48        _deprecated_argument(
     49            __FUNCTION__,
     50            '5.5.0',
     51            sprintf(
     52                /* translators: 1: Deprecated option key, 2: New option key. */
     53                __( 'The "%1$s" option key has been renamed to "%2$s".' ),
     54                $option,
     55                $deprecated_keys[ $option ]
     56            )
     57        );
     58        return get_option( $deprecated_keys[ $option ], $default );
    3659    }
    3760
     
    314337    }
    315338
     339    /*
     340     * Until a proper _deprecated_option() function can be introduced,
     341     * redirect requests to deprecated keys to the new, correct ones.
     342     */
     343    $deprecated_keys = array(
     344        'blacklist_keys'    => 'disallowed_keys',
     345        'comment_whitelist' => 'comment_previously_approved',
     346    );
     347
     348    if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
     349        _deprecated_argument(
     350            __FUNCTION__,
     351            '5.5.0',
     352            sprintf(
     353                /* translators: 1: Deprecated option key, 2: New option key. */
     354                __( 'The "%1$s" option key has been renamed to "%2$s".' ),
     355                $option,
     356                $deprecated_keys[ $option ]
     357            )
     358        );
     359        return update_option( $deprecated_keys[ $option ], $value, $autoload );
     360    }
     361
    316362    wp_protect_special_option( $option );
    317363
     
    476522    if ( empty( $option ) ) {
    477523        return false;
     524    }
     525
     526    /*
     527     * Until a proper _deprecated_option() function can be introduced,
     528     * redirect requests to deprecated keys to the new, correct ones.
     529     */
     530    $deprecated_keys = array(
     531        'blacklist_keys'    => 'disallowed_keys',
     532        'comment_whitelist' => 'comment_previously_approved',
     533    );
     534
     535    if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
     536        _deprecated_argument(
     537            __FUNCTION__,
     538            '5.5.0',
     539            sprintf(
     540                /* translators: 1: Deprecated option key, 2: New option key. */
     541                __( 'The "%1$s" option key has been renamed to "%2$s".' ),
     542                $option,
     543                $deprecated_keys[ $option ]
     544            )
     545        );
     546        return add_option( $deprecated_keys[ $option ], $value, $deprecated, $autoload );
    478547    }
    479548
Note: See TracChangeset for help on using the changeset viewer.