- Timestamp:
- 12/14/2018 02:32:33 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/5.0 merged: 43808,43821,43842,43860,43892,43904,43909,43926-43929,43956,43961-43963
- Property svn:mergeinfo changed
-
trunk/src/wp-content/themes/twentynineteen/inc/customizer.php
r43808 r44149 1 1 <?php 2 2 /** 3 * Twenty Nineteen ThemeCustomizer3 * Twenty Nineteen: Customizer 4 4 * 5 5 * @package WordPress 6 6 * @subpackage Twenty_Nineteen 7 * @since 1.0.0 7 8 */ 8 9 … … 33 34 ); 34 35 } 36 37 /** 38 * Primary color. 39 */ 40 $wp_customize->add_setting( 41 'primary_color', 42 array( 43 'default' => 'default', 44 'transport' => 'postMessage', 45 'sanitize_callback' => 'twentynineteen_sanitize_color_option', 46 ) 47 ); 48 49 $wp_customize->add_control( 50 'primary_color', 51 array( 52 'type' => 'radio', 53 'label' => __( 'Primary Color', 'twentynineteen' ), 54 'choices' => array( 55 'default' => _x( 'Default', 'primary color', 'twentynineteen' ), 56 'custom' => _x( 'Custom', 'primary color', 'twentynineteen' ), 57 ), 58 'section' => 'colors', 59 'priority' => 5, 60 ) 61 ); 62 63 // Add primary color hue setting and control. 64 $wp_customize->add_setting( 65 'primary_color_hue', 66 array( 67 'default' => 199, 68 'transport' => 'postMessage', 69 'sanitize_callback' => 'absint', 70 ) 71 ); 72 73 $wp_customize->add_control( 74 new WP_Customize_Color_Control( 75 $wp_customize, 76 'primary_color_hue', 77 array( 78 'description' => __( 'Apply a custom color for buttons, links, featured images, etc.', 'twentynineteen' ), 79 'section' => 'colors', 80 'mode' => 'hue', 81 ) 82 ) 83 ); 84 85 // Add image filter setting and control. 86 $wp_customize->add_setting( 87 'image_filter', 88 array( 89 'default' => 1, 90 'sanitize_callback' => 'absint', 91 'transport' => 'postMessage', 92 ) 93 ); 94 95 $wp_customize->add_control( 96 'image_filter', 97 array( 98 'label' => __( 'Apply a filter to featured images using the primary color', 'twentynineteen' ), 99 'section' => 'colors', 100 'type' => 'checkbox', 101 ) 102 ); 35 103 } 36 104 add_action( 'customize_register', 'twentynineteen_customize_register' ); … … 55 123 56 124 /** 57 * Bind s JS handlers to make Theme Customizer preview reload changes asynchronously.125 * Bind JS handlers to instantly live-preview changes. 58 126 */ 59 127 function twentynineteen_customize_preview_js() { 60 wp_enqueue_script( 'twentynineteen-customize r', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );128 wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true ); 61 129 } 62 130 add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' ); 131 132 /** 133 * Load dynamic logic for the customizer controls area. 134 */ 135 function twentynineteen_panels_js() { 136 wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true ); 137 } 138 add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' ); 139 140 /** 141 * Sanitize custom color choice. 142 * 143 * @param string $choice Whether image filter is active. 144 * 145 * @return string 146 */ 147 function twentynineteen_sanitize_color_option( $choice ) { 148 $valid = array( 149 'default', 150 'custom', 151 ); 152 153 if ( in_array( $choice, $valid, true ) ) { 154 return $choice; 155 } 156 157 return 'default'; 158 }
Note: See TracChangeset
for help on using the changeset viewer.