- Timestamp:
- 10/27/2020 01:58:37 AM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-content/themes/twentytwentyone/functions.php
r49247 r49320 337 337 338 338 // Add support for custom units. 339 // This was removed in WordPress 5.6 but is still required to properly support WP 5.5. 339 340 add_theme_support( 'custom-units' ); 340 341 } … … 416 417 } 417 418 419 wp_register_script( 420 'twenty-twenty-one-ie11-polyfills', 421 get_template_directory_uri() . '/assets/js/polyfills.js', 422 array(), 423 wp_get_theme()->get( 'Version' ), 424 true 425 ); 426 418 427 // Main navigation scripts. 419 428 if ( has_nav_menu( 'primary' ) ) { 420 wp_register_script(421 'twenty-twenty-one-ie11-polyfills',422 get_template_directory_uri() . '/assets/js/polyfills.js',423 array(),424 wp_get_theme()->get( 'Version' ),425 true426 );427 429 wp_enqueue_script( 428 430 'twenty-twenty-one-primary-navigation-script', … … 433 435 ); 434 436 } 437 438 // Responsive embeds script. 439 wp_enqueue_script( 440 'twenty-twenty-one-responsive-embeds-script', 441 get_template_directory_uri() . '/assets/js/responsive-embeds.js', 442 array( 'twenty-twenty-one-ie11-polyfills' ), 443 wp_get_theme()->get( 'Version' ), 444 true 445 ); 435 446 } 436 447 add_action( 'wp_enqueue_scripts', 'twenty_twenty_one_scripts' ); … … 543 554 add_action( 'customize_preview_init', 'twentytwentyone_customize_preview_init' ); 544 555 545 546 556 /** 547 557 * Enqueue scripts for the customizer. … … 560 570 true 561 571 ); 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 true569 );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 572 } 579 573 add_action( 'customize_controls_enqueue_scripts', 'twentytwentyone_customize_controls_enqueue_scripts' ); … … 587 581 */ 588 582 function twentytwentyone_the_html_classes() { 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 } 583 $classes = apply_filters( 'twentytwentyone_html_classes', '' ); 584 if ( ! $classes ) { 585 return; 586 } 587 echo 'class="' . esc_attr( $classes ) . '"'; 588 } 589 590 /** 591 * Add "is-IE" class to body if the user is on Internet Explorer. 592 * 593 * @since 1.0.0 594 * 595 * @return void 596 */ 597 function twentytwentyone_add_ie_class() { 598 ?> 599 <script> 600 if ( -1 !== navigator.userAgent.indexOf( 'MSIE' ) || -1 !== navigator.appVersion.indexOf( 'Trident/' ) ) { 601 document.body.classList.add( 'is-IE' ); 602 } 603 </script> 604 <?php 605 } 606 add_action( 'wp_footer', 'twentytwentyone_add_ie_class' );
Note: See TracChangeset
for help on using the changeset viewer.