Make WordPress Core


Ignore:
Timestamp:
10/27/2020 01:58:37 AM (5 years ago)
Author:
desrosj
Message:

Twenty Twenty-One: Import the latest changes for 5.6 beta 2.

For a full list of changes since beta 1, see https://github.com/WordPress/twentytwentyone/compare/9e34dca...e580895.

Props poena, melchoyce, luminuu, aristath, justinahinon, jffng, ryelle, kishanjasani, rolfsiebers.
See #51526.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-content/themes/twentytwentyone/functions.php

    r49247 r49320  
    337337
    338338        // Add support for custom units.
     339        // This was removed in WordPress 5.6 but is still required to properly support WP 5.5.
    339340        add_theme_support( 'custom-units' );
    340341    }
     
    416417    }
    417418
     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
    418427    // Main navigation scripts.
    419428    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             true
    426         );
    427429        wp_enqueue_script(
    428430            'twenty-twenty-one-primary-navigation-script',
     
    433435        );
    434436    }
     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    );
    435446}
    436447add_action( 'wp_enqueue_scripts', 'twenty_twenty_one_scripts' );
     
    543554add_action( 'customize_preview_init', 'twentytwentyone_customize_preview_init' );
    544555
    545 
    546556/**
    547557 * Enqueue scripts for the customizer.
     
    560570        true
    561571    );
    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     );
    578572}
    579573add_action( 'customize_controls_enqueue_scripts', 'twentytwentyone_customize_controls_enqueue_scripts' );
     
    587581 */
    588582function 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 */
     597function 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}
     606add_action( 'wp_footer', 'twentytwentyone_add_ie_class' );
Note: See TracChangeset for help on using the changeset viewer.