- Timestamp:
- 10/30/2018 02:13:07 AM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/5.0/src/wp-content/themes/twentynineteen/inc/customizer.php
r43808 r43842 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 * Custom colors. 39 */ 40 $wp_customize->add_setting( 41 'colorscheme', 42 array( 43 'default' => 'default', 44 'transport' => 'postMessage', 45 'sanitize_callback' => 'twentynineteen_sanitize_color_option', 46 ) 47 ); 48 49 $wp_customize->add_control( 50 'colorscheme', 51 array( 52 'type' => 'radio', 53 'label' => __( 'Color Scheme', 'twentynineteen' ), 54 'choices' => array( 55 'default' => __( 'Default', 'twentynineteen' ), 56 'custom' => __( 'Custom', 'twentynineteen' ), 57 ), 58 'section' => 'colors', 59 'priority' => 5, 60 ) 61 ); 62 63 // Add primary color setting and control. 64 $wp_customize->add_setting( 65 'colorscheme_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 'colorscheme_hue', 77 array( 78 'label' => __( 'Primary Color' ), 79 'description' => __( 'Changes the Color of the Featured Image overlay, Buttons, Links etc.' ), 80 'section' => 'colors', 81 'mode' => 'hue', 82 ) 83 ) 84 ); 85 86 $wp_customize->add_setting( 87 'image_filter', 88 array( 89 'default' => 'active', 90 'sanitize_callback' => 'twentynineteen_sanitize_image_filter', 91 'transport' => 'postMessage', 92 ) 93 ); 94 95 $wp_customize->add_control( 96 'image_filter', 97 array( 98 'label' => __( 'Featured Image Color Filter', 'twentynineteen' ), 99 'section' => 'colors', 100 'type' => 'radio', 101 'description' => __( "Twenty Nineteen adds a color filter to featured images using your site's primary color. If you disable this effect, the theme will use a black filter in individual posts to keep text readable when it appears on top of the featured image.", 'twentynineteen' ) . '<br/><span style="font-style: normal; display: block; margin-top: 16px;">' . __( 'On Featured Images, apply', 'twentynineteen' ) . '</span>', 102 'choices' => array( 103 'active' => __( 'A color filter', 'twentynineteen' ), 104 'inactive' => __( 'A black filter', 'twentynineteen' ), 105 ), 106 ) 107 ); 35 108 } 36 109 add_action( 'customize_register', 'twentynineteen_customize_register' ); … … 55 128 56 129 /** 57 * Bind s JS handlers to make Theme Customizer preview reload changes asynchronously.130 * Bind JS handlers to instantly live-preview changes. 58 131 */ 59 132 function twentynineteen_customize_preview_js() { 60 wp_enqueue_script( 'twentynineteen-customize r', get_template_directory_uri() . '/js/customizer.js', array( 'customize-preview' ), '20151215', true );133 wp_enqueue_script( 'twentynineteen-customize-preview', get_theme_file_uri( '/js/customize-preview.js' ), array( 'customize-preview' ), '20151215', true ); 61 134 } 62 135 add_action( 'customize_preview_init', 'twentynineteen_customize_preview_js' ); 136 137 /** 138 * Load dynamic logic for the customizer controls area. 139 */ 140 function twentynineteen_panels_js() { 141 wp_enqueue_script( 'twentynineteen-customize-controls', get_theme_file_uri( '/js/customize-controls.js' ), array(), '1.0', true ); 142 } 143 add_action( 'customize_controls_enqueue_scripts', 'twentynineteen_panels_js' ); 144 145 /** 146 * Sanitize image filter choice. 147 * 148 * @param string $choice Whether image filter is active. 149 * 150 * @return string 151 */ 152 function twentynineteen_sanitize_color_option( $choice ) { 153 $valid = array( 154 'default', 155 'custom', 156 ); 157 158 if ( in_array( $choice, $valid, true ) ) { 159 return $choice; 160 } 161 162 return 'default'; 163 } 164 /** 165 * Sanitize image filter choice. 166 * 167 * @param string $choice Whether image filter is active. 168 * 169 * @return string 170 */ 171 function twentynineteen_sanitize_image_filter( $choice ) { 172 $valid = array( 173 'active', 174 'inactive', 175 ); 176 177 if ( in_array( $choice, $valid, true ) ) { 178 return $choice; 179 } 180 181 return 'active'; 182 }
Note: See TracChangeset
for help on using the changeset viewer.