mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-06-28 22:30:04 +00:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@31370 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -54,14 +54,6 @@ class WP_Customize_Setting {
|
||||
|
||||
protected $id_data = array();
|
||||
|
||||
/**
|
||||
* Cached and sanitized $_POST value for the setting.
|
||||
*
|
||||
* @access private
|
||||
* @var mixed
|
||||
*/
|
||||
private $_post_value;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
@@ -163,7 +155,7 @@ class WP_Customize_Setting {
|
||||
*/
|
||||
public function _preview_filter( $original ) {
|
||||
$undefined = new stdClass(); // symbol hack
|
||||
$post_value = $this->manager->post_value( $this, $undefined );
|
||||
$post_value = $this->post_value( $undefined );
|
||||
if ( $undefined === $post_value ) {
|
||||
$value = $this->_original_value;
|
||||
} else {
|
||||
@@ -211,17 +203,7 @@ class WP_Customize_Setting {
|
||||
* @return mixed The default value on failure, otherwise the sanitized value.
|
||||
*/
|
||||
final public function post_value( $default = null ) {
|
||||
// Check for a cached value
|
||||
if ( isset( $this->_post_value ) )
|
||||
return $this->_post_value;
|
||||
|
||||
// Call the manager for the post value
|
||||
$result = $this->manager->post_value( $this );
|
||||
|
||||
if ( isset( $result ) )
|
||||
return $this->_post_value = $result;
|
||||
else
|
||||
return $default;
|
||||
return $this->manager->post_value( $this, $default );
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user