Customize: Allow controls to be created with pre-instantiated Setting object(s), or even with plain Value object(s).

* Allow passing settings in keyed object (e.g. `settings: { default: 'id' }  ), or as an array (e.g. `settings: [ 'id' ]`) with first being default; again, `Setting`/`Value` objects may be supplied instead of IDs.
* Allow a single setting to be supplied with just a single `setting` param, either a string or a `Setting`/`Value` object.
* Update `changeset_status` and `scheduled_changeset_date` to be added dynamically with JS and simply passing of `api.state()` instances as `setting`.
* Introduce a `data-customize-setting-key-link` attribute which, unlike `data-customize-setting-link`, allows passing the setting key (e.g. `default`) as opposed to the setting ID.
* Allow `WP_Customize_Control::get_link()` to return `data-customize-setting-key-link` when setting is not registered.
* Eliminate `default_value` from `WP_Customize_Date_Time_Control` since now comes from supplied `Value`.
* Export status choices as `wp.customize.settings.changeset.statusChoices`.
* Export date and time formats as `wp.customize.settings.dateFormat` and `wp.customize.settings.timeFormat` respectively.

Props westonruter, sayedwp.
See #39896, #30738, #30741, #42083.
Fixes #37964, #36167.

Built from https://develop.svn.wordpress.org/trunk@41750


git-svn-id: http://core.svn.wordpress.org/trunk@41584 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter
2017-10-04 20:02:49 +00:00
parent 08b5714221
commit f5bc1d1f52
11 changed files with 276 additions and 218 deletions

View File

@@ -65,14 +65,6 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
*/
public $twelve_hour_format = true;
/**
* Default date/time to be displayed in the control.
*
* @since 4.9.0
* @var string
*/
public $default_value;
/**
* Don't render the control's content - it's rendered with a JS template.
*
@@ -94,7 +86,6 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
$data['allowPastDate'] = (bool) $this->allow_past_date;
$data['twelveHourFormat'] = (bool) $this->twelve_hour_format;
$data['includeTime'] = (bool) $this->include_time;
$data['defaultValue'] = $this->default_value;
return $data;
}