Make WordPress Core


Ignore:
Timestamp:
02/11/2015 06:24:01 AM (10 years ago)
Author:
dd32
Message:

Ensure that WP_Customize_Setting::value() returns default value for setting if not dirty.

There was regression introduced by #28580 where only changed (dirty) settings now are POST'ed to the Customizer preview.

  • Allow WP_Customize_Manager::post_value() to accept a second $default argument.
  • Introduce WP_Customize_Manager::unsanitized_post_values() for accessing previously-private member variable _post_values.
  • Do require_once instead of require for Customizer classes.
  • Add unit tests for WP_Customize_Manager and WP_Customize_Setting.

Props westonruter, boonebgorges.
Merges [31329] [31339] [31342] [31360] to the 4.1 branch.
Fixes #30988.

Location:
branches/4.1
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/4.1

  • branches/4.1/tests/phpunit/tests/customize/setting.php

    r31329 r31410  
    216216            $this->arrayHasKey( 'bar', $base_value );
    217217            $this->assertEquals( $base_initial_value['foo'], $base_value['foo'] );
    218             $this->assertEquals( $base_initial_value['bar'], call_user_func( $type_options['getter'], $base_name, $this->undefined )['bar'] );
     218
     219            $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
     220            $this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
    219221            $this->assertEquals( $initial_value, $setting->value() );
    220222            $setting->preview();
     
    225227            $this->assertEquals( $this->post_data_overrides[ $name ], $base_value['foo'] );
    226228            $this->arrayHasKey( 'bar', call_user_func( $type_options['getter'], $base_name, $this->undefined ) );
    227             $this->assertEquals( $base_initial_value['bar'], call_user_func( $type_options['getter'], $base_name, $this->undefined )['bar'] );
     229
     230            $getter = call_user_func( $type_options['getter'], $base_name, $this->undefined );
     231            $this->assertEquals( $base_initial_value['bar'], $getter['bar'] );
    228232        }
    229233    }
Note: See TracChangeset for help on using the changeset viewer.