Twenty Fifteen: Removing unused custom color controls.
Props cainm, fixes #29982 and #29959. Built from https://develop.svn.wordpress.org/trunk@29944 git-svn-id: http://core.svn.wordpress.org/trunk@29694 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
507fee2825
commit
9ed425438f
|
@ -27,12 +27,13 @@ function twentyfifteen_customize_register( $wp_customize ) {
|
|||
'sanitize_callback' => 'twentyfifteen_sanitize_color_scheme',
|
||||
) );
|
||||
|
||||
$wp_customize->add_control( new Twentyfifteen_Customize_Color_Scheme_Control( $wp_customize, 'color_scheme', array(
|
||||
$wp_customize->add_control( 'color_scheme', array(
|
||||
'label' => esc_html__( 'Color Scheme', 'twentyfifteen' ),
|
||||
'section' => 'colors',
|
||||
'type' => 'select',
|
||||
'choices' => twentyfifteen_get_color_scheme_choices(),
|
||||
'priority' => 1,
|
||||
) ) );
|
||||
) );
|
||||
|
||||
// Add custom sidebar text color setting and control.
|
||||
$wp_customize->add_setting( 'sidebar_textcolor', array(
|
||||
|
@ -58,46 +59,6 @@ function twentyfifteen_customize_register( $wp_customize ) {
|
|||
}
|
||||
add_action( 'customize_register', 'twentyfifteen_customize_register', 11 );
|
||||
|
||||
/**
|
||||
* Custom control for Color Schemes
|
||||
*
|
||||
* @since Twenty Fifteen 1.0
|
||||
*/
|
||||
function twentyfifteen_customize_color_scheme_control() {
|
||||
class Twentyfifteen_Customize_Color_Scheme_Control extends WP_Customize_Control {
|
||||
public $type = 'colorScheme';
|
||||
|
||||
function enqueue() {
|
||||
wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls' ), '', true );
|
||||
wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );
|
||||
}
|
||||
|
||||
public function render_content() {
|
||||
if ( empty( $this->choices ) )
|
||||
return;
|
||||
|
||||
?>
|
||||
<label>
|
||||
<?php if ( ! empty( $this->label ) ) : ?>
|
||||
<span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>
|
||||
<?php endif;
|
||||
if ( ! empty( $this->description ) ) : ?>
|
||||
<span class="description customize-control-description"><?php echo $this->description; ?></span>
|
||||
<?php endif; ?>
|
||||
|
||||
<select <?php $this->link(); ?>>
|
||||
<?php
|
||||
foreach ( $this->choices as $value => $label )
|
||||
echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
}
|
||||
add_action( 'customize_register', 'twentyfifteen_customize_color_scheme_control', 10 );
|
||||
|
||||
/**
|
||||
* Register color schemes for Twenty Fifteen.
|
||||
* Can be filtered with twentyfifteen_color_schemes.
|
||||
|
@ -660,6 +621,18 @@ function twentyfifteen_color_scheme_css() {
|
|||
}
|
||||
add_action( 'wp_enqueue_scripts', 'twentyfifteen_color_scheme_css' );
|
||||
|
||||
/**
|
||||
* Binds JS listener to make Customizer color_scheme control.
|
||||
* Passes color scheme data as colorScheme global
|
||||
*
|
||||
* @since Twenty Fifteen 1.0
|
||||
*/
|
||||
function twentyfifteen_customize_control_js() {
|
||||
wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls' ), '', true );
|
||||
wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );
|
||||
}
|
||||
add_action( 'customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js' );
|
||||
|
||||
/**
|
||||
* Binds JS handlers to make Customizer preview reload changes asynchronously.
|
||||
*
|
||||
|
|
|
@ -6,45 +6,47 @@
|
|||
*/
|
||||
|
||||
( function( wp ) {
|
||||
wp.customize.controlConstructor.colorScheme = wp.customize.Control.extend( {
|
||||
wp.customize.controlConstructor.select = wp.customize.Control.extend( {
|
||||
ready: function() {
|
||||
var parentSection = this.container.closest( '.control-section' ),
|
||||
headerTextColor = parentSection.find( '#customize-control-header_textcolor .color-picker-hex' ),
|
||||
backgroundColor = parentSection.find( '#customize-control-background_color .color-picker-hex' ),
|
||||
sidebarColor = parentSection.find( '#customize-control-header_background_color .color-picker-hex' ),
|
||||
sidebarTextColor = parentSection.find( '#customize-control-sidebar_textcolor .color-picker-hex' );
|
||||
if ( 'color_scheme' === this.id ) {
|
||||
var parentSection = this.container.closest( '.control-section' ),
|
||||
headerTextColor = parentSection.find( '#customize-control-header_textcolor .color-picker-hex' ),
|
||||
backgroundColor = parentSection.find( '#customize-control-background_color .color-picker-hex' ),
|
||||
sidebarColor = parentSection.find( '#customize-control-header_background_color .color-picker-hex' ),
|
||||
sidebarTextColor = parentSection.find( '#customize-control-sidebar_textcolor .color-picker-hex' );
|
||||
|
||||
this.setting.bind( 'change', function( value ) {
|
||||
// if Header Text is not hidden, update value
|
||||
if ( 'blank' !== wp.customize( 'header_textcolor' ).get() ) {
|
||||
wp.customize( 'header_textcolor' ).set( colorScheme[value].colors[4] );
|
||||
headerTextColor.val( colorScheme[value].colors[4] )
|
||||
this.setting.bind( 'change', function( value ) {
|
||||
// if Header Text is not hidden, update value
|
||||
if ( 'blank' !== wp.customize( 'header_textcolor' ).get() ) {
|
||||
wp.customize( 'header_textcolor' ).set( colorScheme[value].colors[4] );
|
||||
headerTextColor.val( colorScheme[value].colors[4] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[4] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[4] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[4] );
|
||||
}
|
||||
|
||||
// update Background Color
|
||||
wp.customize( 'background_color' ).set( colorScheme[value].colors[0] );
|
||||
backgroundColor.val( colorScheme[value].colors[0] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[0] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[0] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[0] );
|
||||
|
||||
// update Header/Sidebar Background Color
|
||||
wp.customize( 'header_background_color' ).set( colorScheme[value].colors[1] );
|
||||
sidebarColor.val( colorScheme[value].colors[1] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[1] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[1] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[1] );
|
||||
|
||||
// update Sidebar Text Color
|
||||
wp.customize( 'sidebar_textcolor' ).set( colorScheme[value].colors[4] );
|
||||
sidebarTextColor.val( colorScheme[value].colors[4] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[4] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[4] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[4] );
|
||||
}
|
||||
|
||||
// update Background Color
|
||||
wp.customize( 'background_color' ).set( colorScheme[value].colors[0] );
|
||||
backgroundColor.val( colorScheme[value].colors[0] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[0] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[0] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[0] );
|
||||
|
||||
// update Header/Sidebar Background Color
|
||||
wp.customize( 'header_background_color' ).set( colorScheme[value].colors[1] );
|
||||
sidebarColor.val( colorScheme[value].colors[1] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[1] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[1] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[1] );
|
||||
|
||||
// update Sidebar Text Color
|
||||
wp.customize( 'sidebar_textcolor' ).set( colorScheme[value].colors[4] );
|
||||
sidebarTextColor.val( colorScheme[value].colors[4] )
|
||||
.data( 'data-default-color', colorScheme[value].colors[4] )
|
||||
.wpColorPicker( 'color', colorScheme[value].colors[4] )
|
||||
.wpColorPicker( 'defaultColor', colorScheme[value].colors[4] );
|
||||
} );
|
||||
} );
|
||||
}
|
||||
}
|
||||
} );
|
||||
} )( this.wp );
|
Loading…
Reference in New Issue