WordPress.org

Make WordPress Core


Ignore:
Timestamp:
02/08/2015 11:10:05 PM (5 years ago)
Author:
ocean90
Message:

Customizer: Introduce an API to create WP_Customize_Settings for dynamically-created settings.

  • Introduce WP_Customize_Manager::add_dynamic_settings() to register dynamically-created settings.
  • Introduce customize_dynamic_setting_args filter to pass an array of args to a dynamic setting's constructor.
  • Add unit tests for WP_Customize_Manager and WP_Customize_Widgets.
  • See WP_Customize_Widgets as an example.

props westonruter.
fixes #30936.

File:
1 edited

Legend:

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

    r31329 r31370  
    5454
    5555    protected $id_data = array();
    56 
    57     /**
    58      * Cached and sanitized $_POST value for the setting.
    59      *
    60      * @access private
    61      * @var mixed
    62      */
    63     private $_post_value;
    6456
    6557    /**
     
    164156    public function _preview_filter( $original ) {
    165157        $undefined = new stdClass(); // symbol hack
    166         $post_value = $this->manager->post_value( $this, $undefined );
     158        $post_value = $this->post_value( $undefined );
    167159        if ( $undefined === $post_value ) {
    168160            $value = $this->_original_value;
     
    212204     */
    213205    final public function post_value( $default = null ) {
    214         // Check for a cached value
    215         if ( isset( $this->_post_value ) )
    216             return $this->_post_value;
    217 
    218         // Call the manager for the post value
    219         $result = $this->manager->post_value( $this );
    220 
    221         if ( isset( $result ) )
    222             return $this->_post_value = $result;
    223         else
    224             return $default;
     206        return $this->manager->post_value( $this, $default );
    225207    }
    226208
Note: See TracChangeset for help on using the changeset viewer.