mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-22 17:18:32 +01: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. Built from https://develop.svn.wordpress.org/trunk@41935 git-svn-id: http://core.svn.wordpress.org/trunk@41769 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
c81acd7cef
commit
f8d16c8aed
@ -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 ) );
|
||||
}
|
||||
|
4
wp-admin/js/customize-controls.min.js
vendored
4
wp-admin/js/customize-controls.min.js
vendored
File diff suppressed because one or more lines are too long
@ -421,9 +421,9 @@ class WP_Customize_Control {
|
||||
$id = 'customize-control-' . str_replace( array( '[', ']' ), array( '-', '' ), $this->id );
|
||||
$class = 'customize-control customize-control-' . $this->type;
|
||||
|
||||
?><li id="<?php echo esc_attr( $id ); ?>" class="<?php echo esc_attr( $class ); ?>">
|
||||
<?php $this->render_content(); ?>
|
||||
</li><?php
|
||||
printf( '<li id="%s" class="%s">', esc_attr( $id ), esc_attr( $class ) );
|
||||
$this->render_content();
|
||||
echo '</li>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -77,6 +77,8 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
|
||||
return;
|
||||
}
|
||||
|
||||
add_action( 'customize_controls_print_footer_scripts', array( $this, 'print_header_image_template' ) );
|
||||
|
||||
// Process default headers and uploaded headers.
|
||||
$custom_image_header->process_default_headers();
|
||||
$this->default_headers = $custom_image_header->get_default_header_images();
|
||||
@ -157,7 +159,6 @@ class WP_Customize_Header_Image_Control extends WP_Customize_Image_Control {
|
||||
/**
|
||||
*/
|
||||
public function render_content() {
|
||||
$this->print_header_image_template();
|
||||
$visibility = $this->get_current_image_src() ? '' : ' style="display:none" ';
|
||||
$width = absint( get_theme_support( 'custom-header', 'width' ) );
|
||||
$height = absint( get_theme_support( 'custom-header', 'height' ) );
|
||||
|
@ -4,7 +4,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '4.9-beta2-41934';
|
||||
$wp_version = '4.9-beta2-41935';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user