Customizer: Allow new `option` settings to not be saved as autoloaded by passing an `autoload` arg value of `false`.

The `autoload` argument value is passed along to `update_option()` which has accepted an `$autoload` parameter since [31628].

Props westonruter, dlh.
See #26394.
Fixes #33499.

Built from https://develop.svn.wordpress.org/trunk@35305


git-svn-id: http://core.svn.wordpress.org/trunk@35271 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2015-10-20 21:19:25 +00:00
parent 1e1e7a9fc9
commit c77bb38b3d
2 changed files with 15 additions and 7 deletions

View File

@ -143,6 +143,11 @@ class WP_Customize_Setting {
if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
// Other setting types can opt-in to aggregate multidimensional explicitly.
$this->aggregate_multidimensional();
// Allow option settings to indicate whether they should be autoloaded.
if ( 'option' === $this->type && isset( $args['autoload'] ) ) {
self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] = $args['autoload'];
}
}
}
@ -173,10 +178,6 @@ class WP_Customize_Setting {
* @access protected
*/
protected function aggregate_multidimensional() {
if ( empty( $this->id_data['keys'] ) ) {
return;
}
$id_base = $this->id_data['base'];
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
self::$aggregated_multidimensionals[ $this->type ] = array();
@ -188,7 +189,10 @@ class WP_Customize_Setting {
'root_value' => $this->get_root_value( array() ), // Root value for initial state, manipulated by preview and update calls.
);
}
$this->is_multidimensional_aggregated = true;
if ( ! empty( $this->id_data['keys'] ) ) {
$this->is_multidimensional_aggregated = true;
}
}
/**
@ -502,7 +506,11 @@ class WP_Customize_Setting {
protected function set_root_value( $value ) {
$id_base = $this->id_data['base'];
if ( 'option' === $this->type ) {
return update_option( $id_base, $value );
$autoload = true;
if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) {
$autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
}
return update_option( $id_base, $value, $autoload );
} else if ( 'theme_mod' ) {
set_theme_mod( $id_base, $value );
return true;

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.4-alpha-35304';
$wp_version = '4.4-alpha-35305';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.