Changeset 37350
- Timestamp:
- 05/02/2016 10:41:36 PM (4 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-customize-setting.php
r37342 r37350 658 658 * 659 659 * @since 3.4.0 660 * @since 4.6.0 Added the `$this` setting instance as the second param. 660 661 * 661 * @param mixed $default The setting default value. Default empty. 662 * @param mixed $default The setting default value. Default empty. 663 * @param WP_Customize_Setting $this The setting instance. 662 664 */ 663 $value = apply_filters( "customize_value_{$id_base}", $value );664 } else 665 $value = apply_filters( "customize_value_{$id_base}", $value, $this ); 666 } elseif ( $this->is_multidimensional_aggregated ) { 665 667 $root_value = self::$aggregated_multidimensionals[ $this->type ][ $id_base ]['root_value']; 666 668 $value = $this->multidimensional_get( $root_value, $this->id_data['keys'], $this->default ); -
trunk/tests/phpunit/tests/customize/setting.php
r36622 r37350 278 278 } 279 279 280 function custom_type_value_filter( $default ) { 280 /** 281 * Filter for `customize_value_{$id_base}`. 282 * 283 * @param mixed $default 284 * @param WP_Customize_Setting $setting 285 * 286 * @return mixed|null 287 */ 288 function custom_type_value_filter( $default, $setting = null ) { 281 289 $name = preg_replace( '/^customize_value_/', '', current_filter() ); 290 $this->assertInstanceOf( 'WP_Customize_Setting', $setting ); 291 $id_data = $setting->id_data(); 292 $this->assertEquals( $name, $id_data['base'] ); 282 293 return $this->custom_type_getter( $name, $default ); 283 294 } … … 315 326 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 316 327 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 317 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );328 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 318 329 $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); 319 330 $this->assertEquals( $default, $setting->value() ); … … 331 342 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 332 343 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 333 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );344 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 334 345 $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); 335 346 $this->assertEquals( $initial_value, $setting->value() ); … … 351 362 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 352 363 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 353 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );364 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 354 365 $this->assertEquals( $this->undefined, $this->custom_type_getter( $name, $this->undefined ) ); 355 366 $this->assertEquals( $default, $setting->value() ); … … 367 378 $setting = new WP_Customize_Setting( $this->manager, $name, compact( 'type', 'default' ) ); 368 379 // Note: #29316 will allow us to have one filter for all settings of a given type, which is what we need. 369 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ) );380 add_filter( "customize_value_{$name}", array( $this, 'custom_type_value_filter' ), 10, 2 ); 370 381 $this->assertEquals( $initial_value, $this->custom_type_getter( $name, $this->undefined ) ); 371 382 $this->assertEquals( $initial_value, $setting->value() );
Note: See TracChangeset
for help on using the changeset viewer.