Make WordPress Core

Ticket #50413: 50413.5.diff

File 50413.5.diff, 2.6 KB (added by SergeyBiryukov, 3 years ago)
  • src/wp-includes/option.php

     
    3535                return false;
    3636        }
    3737
     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'    => 'blocklist_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 );
     59        }
     60
    3861        /**
    3962         * Filters the value of an existing option before it is retrieved.
    4063         *
     
    313336                return false;
    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'    => 'blocklist_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
    318364        if ( is_object( $value ) ) {
     
    477523                return false;
    478524        }
    479525
     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'    => 'blocklist_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 );
     547        }
     548
    480549        wp_protect_special_option( $option );
    481550
    482551        if ( is_object( $value ) ) {