From 620eb3052cb6b5a7a7daa31e4a077730f7dc40d7 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 20 Oct 2017 03:29:30 +0000 Subject: [PATCH] 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 --- src/wp-admin/js/customize-controls.js | 8 ++++++-- src/wp-includes/class-wp-customize-manager.php | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/wp-admin/js/customize-controls.js b/src/wp-admin/js/customize-controls.js index 4f0cf05265..3faa76cc7a 100644 --- a/src/wp-admin/js/customize-controls.js +++ b/src/wp-admin/js/customize-controls.js @@ -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'; } diff --git a/src/wp-includes/class-wp-customize-manager.php b/src/wp-includes/class-wp-customize-manager.php index c1eb1f31dd..54aeca9847 100644 --- a/src/wp-includes/class-wp-customize-manager.php +++ b/src/wp-includes/class-wp-customize-manager.php @@ -4019,6 +4019,7 @@ final class WP_Customize_Manager { <# }); #> >{{ inputAttrs.value }} <# } else if ( 'select' === data.type ) { #> + <# delete inputAttrs.type; #>