Make WordPress Core

Ticket #50413: approach-1.diff

File approach-1.diff, 2.4 KB (added by desrosj, 3 years ago)
  • src/wp-includes/option.php

     
    3535                return false;
    3636        }
    3737
     38        /*
     39         * Until a proper _deprecated_option() function can be introduced, redirect requests
     40         * 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                _doing_it_wrong(
     49                        sprintf(
     50                                __( '%s option' ),
     51                                $option
     52                        ),
     53                        sprintf(
     54                                __( 'This option key has been renamed to "%s".', '5.5.0' ),
     55                                $deprecated_keys[ $option ]
     56                        ),
     57                        '5.5.0'
     58                );
     59                return get_option( $deprecated_keys[ $option ], $default );
     60        }
     61
    3862        /**
    3963         * Filters the value of an existing option before it is retrieved.
    4064         *
     
    313337                return false;
    314338        }
    315339
     340        /*
     341         * Until a proper _deprecated_option() function can be introduced, redirect requests
     342         * to deprecated keys to the new, correct ones.
     343         */
     344        $deprecated_keys = array(
     345                'blacklist_keys'    => 'blocklist_keys',
     346                'comment_whitelist' => 'comment_previously_approved',
     347        );
     348
     349        if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
     350                _doing_it_wrong(
     351                        sprintf(
     352                                __( '%s option' ),
     353                                $option
     354                        ),
     355                        sprintf(
     356                                __( 'This option key has been renamed to "%s".', '5.5.0' ),
     357                                $deprecated_keys[ $option ]
     358                        ),
     359                        '5.5.0'
     360                );
     361                return update_option( $deprecated_keys[ $option ], $value, $autoload );
     362        }
     363
    316364        wp_protect_special_option( $option );
    317365
    318366        if ( is_object( $value ) ) {
     
    477525                return false;
    478526        }
    479527
     528        /*
     529         * Until a proper _deprecated_option() function can be introduced, redirect requests
     530         * to deprecated keys to the new, correct ones.
     531         */
     532        $deprecated_keys = array(
     533                'blacklist_keys'    => 'blocklist_keys',
     534                'comment_whitelist' => 'comment_previously_approved',
     535        );
     536
     537        if ( ! wp_installing() && isset( $deprecated_keys[ $option ] ) ) {
     538                _doing_it_wrong(
     539                        sprintf(
     540                                __( '%s option' ),
     541                                $option
     542                        ),
     543                        sprintf(
     544                                __( 'This option key has been renamed to "%s".', '5.5.0' ),
     545                                $deprecated_keys[ $option ]
     546                        ),
     547                        '5.5.0'
     548                );
     549                return add_option( $deprecated_keys[ $option ], $value, $deprecated, $autoload );
     550        }
     551
    480552        wp_protect_special_option( $option );
    481553
    482554        if ( is_object( $value ) ) {