- Timestamp:
- 10/20/2020 06:24:33 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwentyone/functions.php
r49216 r49247 41 41 /* 42 42 * Let WordPress manage the document title. 43 * By adding theme support, we declare that this theme does not use a 44 * hard-coded <title> tag in the document head, and expect WordPress to 45 * provide it for us. 43 * This theme does not use a hard-coded <title> tag in the document head, 44 * WordPress will provide it for us. 46 45 */ 47 46 add_theme_support( 'title-tag' ); … … 127 126 // Add support for editor styles. 128 127 add_theme_support( 'editor-styles' ); 128 $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); 129 if ( 127 > Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) ) { 130 add_theme_support( 'dark-editor-style' ); 131 } 129 132 130 133 $editor_stylesheet_path = './assets/css/style-editor.css'; … … 146 149 array( 147 150 'name' => esc_html__( 'Extra small', 'twentytwentyone' ), 148 'shortName' => esc_html_ _( 'XS', 'twentytwentyone' ),151 'shortName' => esc_html_x( 'XS', 'Font size', 'twentytwentyone' ), 149 152 'size' => 16, 150 153 'slug' => 'extra-small', … … 152 155 array( 153 156 'name' => esc_html__( 'Small', 'twentytwentyone' ), 154 'shortName' => esc_html_ _( 'S', 'twentytwentyone' ),157 'shortName' => esc_html_x( 'S', 'Font size', 'twentytwentyone' ), 155 158 'size' => 18, 156 159 'slug' => 'small', … … 158 161 array( 159 162 'name' => esc_html__( 'Normal', 'twentytwentyone' ), 160 'shortName' => esc_html_ _( 'M', 'twentytwentyone' ),163 'shortName' => esc_html_x( 'M', 'Font size', 'twentytwentyone' ), 161 164 'size' => 20, 162 165 'slug' => 'normal', … … 164 167 array( 165 168 'name' => esc_html__( 'Large', 'twentytwentyone' ), 166 'shortName' => esc_html_ _( 'L', 'twentytwentyone' ),169 'shortName' => esc_html_x( 'L', 'Font size', 'twentytwentyone' ), 167 170 'size' => 24, 168 171 'slug' => 'large', … … 170 173 array( 171 174 'name' => esc_html__( 'Extra Large', 'twentytwentyone' ), 172 'shortName' => esc_html_ _( 'XL', 'twentytwentyone' ),175 'shortName' => esc_html_x( 'XL', 'Font size', 'twentytwentyone' ), 173 176 'size' => 40, 174 177 'slug' => 'extra-large', … … 176 179 array( 177 180 'name' => esc_html__( 'Huge', 'twentytwentyone' ), 178 'shortName' => esc_html_ _( 'XXL', 'twentytwentyone' ),181 'shortName' => esc_html_x( 'XXL', 'Font size', 'twentytwentyone' ), 179 182 'size' => 96, 180 183 'slug' => 'huge', … … 182 185 array( 183 186 'name' => esc_html__( 'Gigantic', 'twentytwentyone' ), 184 'shortName' => esc_html_ _( 'XXXL', 'twentytwentyone' ),187 'shortName' => esc_html_x( 'XXXL', 'Font size', 'twentytwentyone' ), 185 188 'size' => 144, 186 189 'slug' => 'gigantic', … … 523 526 function twentytwentyone_customize_preview_init() { 524 527 wp_enqueue_script( 528 'twentytwentyone-customize-helpers', 529 get_theme_file_uri( '/assets/js/customize-helpers.js' ), 530 array(), 531 wp_get_theme()->get( 'Version' ), 532 true 533 ); 534 535 wp_enqueue_script( 525 536 'twentytwentyone-customize-preview', 526 537 get_theme_file_uri( '/assets/js/customize-preview.js' ), 527 array( 'customize-preview', 'customize-selective-refresh', 'jquery' ),528 get_theme_file_path( 'assets/js/customize-preview.js' ),538 array( 'customize-preview', 'customize-selective-refresh', 'jquery', 'twentytwentyone-customize-helpers' ), 539 wp_get_theme()->get( 'Version' ), 529 540 true 530 541 ); … … 532 543 add_action( 'customize_preview_init', 'twentytwentyone_customize_preview_init' ); 533 544 534 /** 535 * Calculate any classes we may want to add to the main <html> element. 545 546 /** 547 * Enqueue scripts for the customizer. 548 * 549 * @since 1.0.0 550 * 551 * @return void 552 */ 553 function twentytwentyone_customize_controls_enqueue_scripts() { 554 555 wp_enqueue_script( 556 'twentytwentyone-customize-helpers', 557 get_theme_file_uri( '/assets/js/customize-helpers.js' ), 558 array(), 559 wp_get_theme()->get( 'Version' ), 560 true 561 ); 562 563 wp_enqueue_script( 564 'twentytwentyone-customize-controls', 565 get_theme_file_uri( '/assets/js/customize.js' ), 566 array( 'customize-base', 'customize-controls', 'underscore', 'jquery', 'twentytwentyone-customize-helpers' ), 567 wp_get_theme()->get( 'Version' ), 568 true 569 ); 570 571 wp_localize_script( 572 'twentytwentyone-customize-controls', 573 'backgroundColorNotice', 574 array( 575 'message' => esc_html__( 'You currently have dark mode enabled on your device. Changing the color picker will allow you to preview light mode.', 'twentytwentyone' ), 576 ) 577 ); 578 } 579 add_action( 'customize_controls_enqueue_scripts', 'twentytwentyone_customize_controls_enqueue_scripts' ); 580 581 /** 582 * Calculate classes for the main <html> element. 536 583 * 537 584 * @since 1.0.0 … … 540 587 */ 541 588 function twentytwentyone_the_html_classes() { 542 $background_color = get_theme_mod( 'background_color', 'D1E4DD' );543 $ light_colors_default_palette = array( '#D1E4DD', '#D1DFE4', '#D1D1E4', '#E4D1D1', '#E4DAD1', '#EEEADD', '#FFFFFF');544 if ( in_array( strtoupper( '#' . ltrim( $background_color, '#' ) ), $light_colors_default_palette, true) ) {545 echo 'class=" has-default-light-palette-background"';546 } 547 } 589 $background_color = get_theme_mod( 'background_color', 'D1E4DD' ); 590 $should_respect_color_scheme = get_theme_mod( 'respect_user_color_preference', true ); 591 if ( $should_respect_color_scheme && 127 <= Twenty_Twenty_One_Custom_Colors::get_relative_luminance_from_hex( $background_color ) ) { 592 echo 'class="respect-color-scheme-preference"'; 593 } 594 }
Note: See TracChangeset
for help on using the changeset viewer.