mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-08-12 04:40:26 +00:00
Customize: Move control's fallback selection of default content template to renderContent method to align with sections and panels.
* Only use default control content template when a more specific template doesn't exist. * Remove extraneous whitespace from being output in `WP_Customize_Control::render()` method. * Move Custom Header template printing to `customize_controls_print_footer_scripts` action. See #30738. git-svn-id: https://develop.svn.wordpress.org/trunk@41935 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -3362,7 +3362,7 @@
|
||||
},
|
||||
|
||||
initialize: function( id, options ) {
|
||||
var control = this, deferredSettingIds = [], settings, gatherSettings, standardTypes;
|
||||
var control = this, deferredSettingIds = [], settings, gatherSettings;
|
||||
|
||||
control.params = _.extend( {}, control.defaults );
|
||||
|
||||
@@ -3401,30 +3401,8 @@
|
||||
control.container = $( control.selector ); // Likely dead, per above. See #28709.
|
||||
}
|
||||
|
||||
standardTypes = [
|
||||
'button',
|
||||
'checkbox',
|
||||
'date',
|
||||
'datetime-local',
|
||||
'email',
|
||||
'month',
|
||||
'number',
|
||||
'password',
|
||||
'radio',
|
||||
'range',
|
||||
'search',
|
||||
'select',
|
||||
'tel',
|
||||
'time',
|
||||
'text',
|
||||
'textarea',
|
||||
'week',
|
||||
'url'
|
||||
];
|
||||
if ( control.params.templateId ) {
|
||||
control.templateSelector = control.params.templateId;
|
||||
} else if ( _.contains( standardTypes, control.params.type ) && control.container.is( ':empty' ) ) {
|
||||
control.templateSelector = 'customize-control-default-content';
|
||||
} else {
|
||||
control.templateSelector = 'customize-control-' + control.params.type + '-content';
|
||||
}
|
||||
@@ -3886,12 +3864,39 @@
|
||||
* @since 4.1.0
|
||||
*/
|
||||
renderContent: function () {
|
||||
var template,
|
||||
control = this;
|
||||
var control = this, template, standardTypes, templateId;
|
||||
|
||||
standardTypes = [
|
||||
'button',
|
||||
'checkbox',
|
||||
'date',
|
||||
'datetime-local',
|
||||
'email',
|
||||
'month',
|
||||
'number',
|
||||
'password',
|
||||
'radio',
|
||||
'range',
|
||||
'search',
|
||||
'select',
|
||||
'tel',
|
||||
'time',
|
||||
'text',
|
||||
'textarea',
|
||||
'week',
|
||||
'url'
|
||||
];
|
||||
|
||||
templateId = control.templateSelector;
|
||||
|
||||
// Use default content template when a standard HTML type is used and there isn't a more specific template existing.
|
||||
if ( templateId === 'customize-control-' + control.params.type + '-content' && _.contains( standardTypes, control.params.type ) && ! document.getElementById( 'tmpl-' + templateId ) ) {
|
||||
templateId = 'customize-control-default-content';
|
||||
}
|
||||
|
||||
// Replace the container element's content with the control.
|
||||
if ( 0 !== $( '#tmpl-' + control.templateSelector ).length ) {
|
||||
template = wp.template( control.templateSelector );
|
||||
if ( document.getElementById( 'tmpl-' + templateId ) ) {
|
||||
template = wp.template( templateId );
|
||||
if ( template && control.container ) {
|
||||
control.container.html( template( control.params ) );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user