From c77bb38b3d48c942348ef8e4ca11c4261c6a8a38 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Tue, 20 Oct 2015 21:19:25 +0000 Subject: [PATCH] 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 --- wp-includes/class-wp-customize-setting.php | 20 ++++++++++++++------ wp-includes/version.php | 2 +- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/wp-includes/class-wp-customize-setting.php b/wp-includes/class-wp-customize-setting.php index 65fa2e2234..c7cff51fe5 100644 --- a/wp-includes/class-wp-customize-setting.php +++ b/wp-includes/class-wp-customize-setting.php @@ -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; diff --git a/wp-includes/version.php b/wp-includes/version.php index d687724d4a..65b63fea21 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -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.