Customize: Prevent using default template for a base control when it has content rendered on the server.

Also prevent invalid `type` attribute from being added to a `select` element.

See #30738.
Fixes #42286.


git-svn-id: https://develop.svn.wordpress.org/trunk@41952 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Weston Ruter 2017-10-20 03:29:30 +00:00
parent d204ba3c00
commit 620eb3052c
2 changed files with 7 additions and 2 deletions

View File

@ -3897,8 +3897,12 @@
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 ) ) {
// Use default content template when a standard HTML type is used, there isn't a more specific template existing, and the control container is empty.
if ( templateId === 'customize-control-' + control.params.type + '-content' &&
_.contains( standardTypes, control.params.type ) &&
! document.getElementById( 'tmpl-' + templateId ) &&
0 === control.container.children().length )
{
templateId = 'customize-control-default-content';
}

View File

@ -4019,6 +4019,7 @@ final class WP_Customize_Manager {
<# }); #>
>{{ inputAttrs.value }}</textarea>
<# } else if ( 'select' === data.type ) { #>
<# delete inputAttrs.type; #>
<select
<# _.each( _.extend( inputAttrs ), function( value, key ) { #>
{{{ key }}}="{{ value }}"