Make WordPress Core

Ticket #36952: 36952.2.diff

File 36952.2.diff, 2.0 KB (added by dlh, 8 years ago)
  • src/wp-includes/class-wp-customize-setting.php

     
    587587                $id_base = $this->id_data['base'];
    588588                if ( 'option' === $this->type ) {
    589589                        return get_option( $id_base, $default );
    590                 } else if ( 'theme_mod' ) {
     590                } elseif ( 'theme_mod' === $this->type ) {
    591591                        return get_theme_mod( $id_base, $default );
    592592                } else {
    593593                        /*
     
    616616                                $autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
    617617                        }
    618618                        return update_option( $id_base, $value, $autoload );
    619                 } else if ( 'theme_mod' ) {
     619                } elseif ( 'theme_mod' === $this->type ) {
    620620                        set_theme_mod( $id_base, $value );
    621621                        return true;
    622622                } else {
  • tests/phpunit/tests/customize/setting.php

     
    397397
    398398                // Custom type that does not handle supplying the post value from the customize_value_{$id_base} filter.
    399399                $setting_id = 'custom_without_previewing_value_filter';
     400
    400401                $setting = $this->manager->add_setting( $setting_id, array(
    401402                        'type' => 'custom_preview_test',
    402403                        'default' => 123,
    403404                        'sanitize_callback' => array( $this->manager->nav_menus, 'intval_base10' ),
    404405                ) );
     406
     407                // When #36952 occurs, get_theme_mod() will still return the default
     408                // value if no theme mod exists. Add one to test that it isn't returned.
     409                set_theme_mod( $setting_id, 999 );
    405410                $this->assertSame( 123, $setting->value() );
     411
    406412                $this->manager->set_post_value( $setting_id, '456' );
    407413                $setting->preview();
    408414                $this->assertSame( 456, $setting->value() );
    409415
    410416                unset( $this->custom_type_data_previewed, $this->custom_type_data_saved );
     417                remove_theme_mod( $setting_id );
    411418        }
    412419
    413420        /**