mirror of
https://github.com/WordPress/WordPress.git
synced 2024-06-26 14:54:57 +02:00
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:
parent
1e1e7a9fc9
commit
c77bb38b3d
|
@ -143,6 +143,11 @@ class WP_Customize_Setting {
|
||||||
if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
|
if ( 'option' === $this->type || 'theme_mod' === $this->type ) {
|
||||||
// Other setting types can opt-in to aggregate multidimensional explicitly.
|
// Other setting types can opt-in to aggregate multidimensional explicitly.
|
||||||
$this->aggregate_multidimensional();
|
$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
|
* @access protected
|
||||||
*/
|
*/
|
||||||
protected function aggregate_multidimensional() {
|
protected function aggregate_multidimensional() {
|
||||||
if ( empty( $this->id_data['keys'] ) ) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$id_base = $this->id_data['base'];
|
$id_base = $this->id_data['base'];
|
||||||
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
|
if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
|
||||||
self::$aggregated_multidimensionals[ $this->type ] = array();
|
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.
|
'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 ) {
|
protected function set_root_value( $value ) {
|
||||||
$id_base = $this->id_data['base'];
|
$id_base = $this->id_data['base'];
|
||||||
if ( 'option' === $this->type ) {
|
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' ) {
|
} else if ( 'theme_mod' ) {
|
||||||
set_theme_mod( $id_base, $value );
|
set_theme_mod( $id_base, $value );
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user