- Timestamp:
- 10/17/2014 08:51:46 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentyfifteen/inc/customizer.php
r29942 r29944 28 28 ) ); 29 29 30 $wp_customize->add_control( new Twentyfifteen_Customize_Color_Scheme_Control( $wp_customize,'color_scheme', array(30 $wp_customize->add_control( 'color_scheme', array( 31 31 'label' => esc_html__( 'Color Scheme', 'twentyfifteen' ), 32 32 'section' => 'colors', 33 'type' => 'select', 33 34 'choices' => twentyfifteen_get_color_scheme_choices(), 34 35 'priority' => 1, 35 ) ) );36 ) ); 36 37 37 38 // Add custom sidebar text color setting and control. … … 58 59 } 59 60 add_action( 'customize_register', 'twentyfifteen_customize_register', 11 ); 60 61 /**62 * Custom control for Color Schemes63 *64 * @since Twenty Fifteen 1.065 */66 function twentyfifteen_customize_color_scheme_control() {67 class Twentyfifteen_Customize_Color_Scheme_Control extends WP_Customize_Control {68 public $type = 'colorScheme';69 70 function enqueue() {71 wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls' ), '', true );72 wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() );73 }74 75 public function render_content() {76 if ( empty( $this->choices ) )77 return;78 79 ?>80 <label>81 <?php if ( ! empty( $this->label ) ) : ?>82 <span class="customize-control-title"><?php echo esc_html( $this->label ); ?></span>83 <?php endif;84 if ( ! empty( $this->description ) ) : ?>85 <span class="description customize-control-description"><?php echo $this->description; ?></span>86 <?php endif; ?>87 88 <select <?php $this->link(); ?>>89 <?php90 foreach ( $this->choices as $value => $label )91 echo '<option value="' . esc_attr( $value ) . '"' . selected( $this->value(), $value, false ) . '>' . $label . '</option>';92 ?>93 </select>94 </label>95 <?php96 }97 }98 }99 add_action( 'customize_register', 'twentyfifteen_customize_color_scheme_control', 10 );100 61 101 62 /** … … 662 623 663 624 /** 625 * Binds JS listener to make Customizer color_scheme control. 626 * Passes color scheme data as colorScheme global 627 * 628 * @since Twenty Fifteen 1.0 629 */ 630 function twentyfifteen_customize_control_js() { 631 wp_enqueue_script( 'color-scheme-control', get_template_directory_uri() . '/js/color-scheme-control.js', array( 'customize-controls' ), '', true ); 632 wp_localize_script( 'color-scheme-control', 'colorScheme', twentyfifteen_get_color_schemes() ); 633 } 634 add_action( 'customize_controls_enqueue_scripts', 'twentyfifteen_customize_control_js' ); 635 636 /** 664 637 * Binds JS handlers to make Customizer preview reload changes asynchronously. 665 638 *
Note: See TracChangeset
for help on using the changeset viewer.