Make WordPress Core


Ignore:
Timestamp:
10/20/2015 09:18:04 PM (10 years ago)
Author:
westonruter
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-customize-setting.php

    r35302 r35305  
    144144            // Other setting types can opt-in to aggregate multidimensional explicitly.
    145145            $this->aggregate_multidimensional();
     146
     147            // Allow option settings to indicate whether they should be autoloaded.
     148            if ( 'option' === $this->type && isset( $args['autoload'] ) ) {
     149                self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] = $args['autoload'];
     150            }
    146151        }
    147152    }
     
    174179     */
    175180    protected function aggregate_multidimensional() {
    176         if ( empty( $this->id_data['keys'] ) ) {
    177             return;
    178         }
    179 
    180181        $id_base = $this->id_data['base'];
    181182        if ( ! isset( self::$aggregated_multidimensionals[ $this->type ] ) ) {
     
    189190            );
    190191        }
    191         $this->is_multidimensional_aggregated = true;
     192
     193        if ( ! empty( $this->id_data['keys'] ) ) {
     194            $this->is_multidimensional_aggregated = true;
     195        }
    192196    }
    193197
     
    503507        $id_base = $this->id_data['base'];
    504508        if ( 'option' === $this->type ) {
    505             return update_option( $id_base, $value );
     509            $autoload = true;
     510            if ( isset( self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'] ) ) {
     511                $autoload = self::$aggregated_multidimensionals[ $this->type ][ $this->id_data['base'] ]['autoload'];
     512            }
     513            return update_option( $id_base, $value, $autoload );
    506514        } else if ( 'theme_mod' ) {
    507515            set_theme_mod( $id_base, $value );
Note: See TracChangeset for help on using the changeset viewer.