Customizer: Ensure WP_Customize_Setting::update() returns boolean value.

Adds unit tests for `WP_Customize_Setting::save()` (and `WP_Customize_Setting::update()`), along with the actions `customize_update_{$type}`, and `customize_save_{$id_base}` which they trigger.

Fixes #34140.


git-svn-id: https://develop.svn.wordpress.org/trunk@34838 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter
2015-10-05 21:57:32 +00:00
parent d8c9450179
commit 84e475dd80
2 changed files with 65 additions and 4 deletions

View File

@@ -304,12 +304,13 @@ class WP_Customize_Setting {
* @since 3.4.0
*
* @param mixed $value The value to update.
* @return mixed The result of saving the value.
* @return bool The result of saving the value.
*/
protected function update( $value ) {
switch( $this->type ) {
switch ( $this->type ) {
case 'theme_mod' :
return $this->_update_theme_mod( $value );
$this->_update_theme_mod( $value );
return true;
case 'option' :
return $this->_update_option( $value );
@@ -327,7 +328,9 @@ class WP_Customize_Setting {
* @param mixed $value Value of the setting.
* @param WP_Customize_Setting $this WP_Customize_Setting instance.
*/
return do_action( 'customize_update_' . $this->type, $value, $this );
do_action( "customize_update_{$this->type}", $value, $this );
return has_action( "customize_update_{$this->type}" );
}
}