Changeset 46357 for trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
- Timestamp:
- 09/30/2019 05:40:14 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwenty/classes/class-twentytwenty-customize.php
r46271 r46357 155 155 ); 156 156 157 /**158 * Custom Accent Colors.159 */160 $accent_color_options = self::get_color_options();161 162 // Loop over the color options and add them to the customizer.163 foreach ( $accent_color_options as $color_option_name => $color_option ) {164 165 $wp_customize->add_setting(166 $color_option_name,167 array(168 'default' => $color_option['default'],169 'sanitize_callback' => 'sanitize_hex_color',170 )171 );172 173 $wp_customize->add_control(174 new WP_Customize_Color_Control(175 $wp_customize,176 $color_option_name,177 array(178 'label' => $color_option['label'],179 'section' => 'colors',180 'priority' => 10,181 )182 )183 );184 185 }186 187 157 // Update background color with postMessage, so inline CSS output is updated as well. 188 158 $wp_customize->get_setting( 'background_color' )->transport = 'postMessage'; … … 198 168 'priority' => 40, 199 169 'capability' => 'edit_theme_options', 200 'description' => __( 'S ettings for thistheme.', 'twentytwenty' ),170 'description' => __( 'Specific settings for the Twenty Twenty theme.', 'twentytwenty' ), 201 171 ) 202 172 ); … … 208 178 array( 209 179 'capability' => 'edit_theme_options', 210 'default' => false,180 'default' => true, 211 181 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), 212 182 ) … … 216 186 'enable_header_search', 217 187 array( 218 'type' => 'checkbox', 219 'section' => 'options', 220 'priority' => 10, 221 'label' => __( 'Show search in header', 'twentytwenty' ), 222 'description' => __( 'Uncheck to hide the search in the header.', 'twentytwenty' ), 188 'type' => 'checkbox', 189 'section' => 'options', 190 'priority' => 10, 191 'label' => __( 'Show search in header', 'twentytwenty' ), 223 192 ) 224 193 ); … … 238 207 'blog_content', 239 208 array( 240 'type' => 'radio', 241 'section' => 'options', 242 'priority' => 10, 243 'label' => __( 'On archive pages, posts show:', 'twentytwenty' ), 244 'description' => __( 'Search results always show the summary.', 'twentytwenty' ), 245 'choices' => array( 209 'type' => 'radio', 210 'section' => 'options', 211 'priority' => 10, 212 'label' => __( 'On archive pages, posts show:', 'twentytwenty' ), 213 'choices' => array( 246 214 'full' => __( 'Full text', 'twentytwenty' ), 247 215 'summary' => __( 'Summary', 'twentytwenty' ), … … 271 239 'default' => true, 272 240 'sanitize_callback' => array( __CLASS__, 'sanitize_checkbox' ), 241 'transport' => 'postMessage', 273 242 ) 274 243 ); … … 281 250 'label' => __( 'Fixed Background Image', 'twentytwenty' ), 282 251 'description' => __( 'Creates a parallax effect when the visitor scrolls.', 'twentytwenty' ), 252 ) 253 ); 254 255 $wp_customize->selective_refresh->add_partial( 256 'cover_template_fixed_background', 257 array( 258 'selector' => '.cover-header', 259 'type' => 'cover_fixed', 283 260 ) 284 261 ); … … 347 324 ); 348 325 349 /* Overlay Blend Mode ------------ */ 350 351 $wp_customize->add_setting( 352 'cover_template_overlay_blend_mode', 353 array( 354 'default' => 'multiply', 355 'sanitize_callback' => array( __CLASS__, 'sanitize_select' ), 356 ) 357 ); 358 359 $wp_customize->add_control( 360 'cover_template_overlay_blend_mode', 361 array( 362 'label' => __( 'Image Overlay Blend Mode', 'twentytwenty' ), 363 'description' => __( 'How the overlay color will blend with the image. Some browsers, like Internet Explorer and Edge, only support the "Normal" mode.', 'twentytwenty' ), 326 /* Overlay Color Opacity --------- */ 327 328 $wp_customize->add_setting( 329 'cover_template_overlay_opacity', 330 array( 331 'default' => 80, 332 'sanitize_callback' => 'absint', 333 'transport' => 'postMessage', 334 ) 335 ); 336 337 $wp_customize->add_control( 338 'cover_template_overlay_opacity', 339 array( 340 'label' => __( 'Image Overlay Opacity', 'twentytwenty' ), 341 'description' => __( 'Make sure that the contrast is high enough so that the text is readable.', 'twentytwenty' ), 364 342 'section' => 'cover_template_options', 365 'type' => 'select', 366 'choices' => array( 367 'normal' => __( 'Normal', 'twentytwenty' ), 368 'multiply' => __( 'Multiply', 'twentytwenty' ), 369 'screen' => __( 'Screen', 'twentytwenty' ), 370 'overlay' => __( 'Overlay', 'twentytwenty' ), 371 'darken' => __( 'Darken', 'twentytwenty' ), 372 'lighten' => __( 'Lighten', 'twentytwenty' ), 373 'color-dodge' => __( 'Color Dodge', 'twentytwenty' ), 374 'color-burn' => __( 'Color Burn', 'twentytwenty' ), 375 'hard-light' => __( 'Hard Light', 'twentytwenty' ), 376 'soft-light' => __( 'Soft Light', 'twentytwenty' ), 377 'difference' => __( 'Difference', 'twentytwenty' ), 378 'exclusion' => __( 'Exclusion', 'twentytwenty' ), 379 'hue' => __( 'Hue', 'twentytwenty' ), 380 'saturation' => __( 'Saturation', 'twentytwenty' ), 381 'color' => __( 'Color', 'twentytwenty' ), 382 'luminosity' => __( 'Luminosity', 'twentytwenty' ), 383 ), 384 ) 385 ); 386 387 /* Overlay Color Opacity --------- */ 388 389 $wp_customize->add_setting( 343 'type' => 'range', 344 'input_attrs' => twentytwenty_customize_opacity_range(), 345 ) 346 ); 347 348 $wp_customize->selective_refresh->add_partial( 390 349 'cover_template_overlay_opacity', 391 350 array( 392 'default' => '80', 393 'sanitize_callback' => array( __CLASS__, 'sanitize_select' ), 394 ) 395 ); 396 397 $wp_customize->add_control( 398 'cover_template_overlay_opacity', 399 array( 400 'label' => __( 'Image Overlay Opacity', 'twentytwenty' ), 401 'description' => __( 'Make sure that the value is high enough that the text is readable.', 'twentytwenty' ), 402 'section' => 'cover_template_options', 403 'type' => 'select', 404 'choices' => array( 405 '0' => __( '0%', 'twentytwenty' ), 406 '10' => __( '10%', 'twentytwenty' ), 407 '20' => __( '20%', 'twentytwenty' ), 408 '30' => __( '30%', 'twentytwenty' ), 409 '40' => __( '40%', 'twentytwenty' ), 410 '50' => __( '50%', 'twentytwenty' ), 411 '60' => __( '60%', 'twentytwenty' ), 412 '70' => __( '70%', 'twentytwenty' ), 413 '80' => __( '80%', 'twentytwenty' ), 414 '90' => __( '90%', 'twentytwenty' ), 415 '100' => __( '100%', 'twentytwenty' ), 416 ), 417 ) 418 ); 419 351 'selector' => '.cover-color-overlay', 352 'type' => 'cover_opacity', 353 ) 354 ); 420 355 } 421 356 … … 442 377 443 378 return $value; 444 }445 446 /**447 * Return the sitewide color options included.448 * Note: These values are shared between the block editor styles and the customizer,449 * and abstracted to this function.450 */451 public static function get_color_options() {452 return apply_filters( 'twentytwenty_accent_color_options', array() );453 379 } 454 380 … … 512 438 } 513 439 } 440 441 442 /** 443 * Input attributes for cover overlay opacity option. 444 * 445 * @return array Array containing attribute names and their values. 446 */ 447 function twentytwenty_customize_opacity_range() { 448 /** 449 * Filter the input attributes for opacity 450 * 451 * @param array $attrs { 452 * The attributes 453 * 454 * @type int $min Minimum value 455 * @type int $max Maximum value 456 * @type int $step Interval between numbers 457 * } 458 */ 459 return apply_filters( 460 'twentytwenty_customize_opacity_range', 461 array( 462 'min' => 0, 463 'max' => 90, 464 'step' => 5, 465 ) 466 ); 467 }
Note: See TracChangeset
for help on using the changeset viewer.