WordPress.org

Make WordPress Core


Ignore:
Timestamp:
12/14/2018 09:23:52 PM (2 years ago)
Author:
desrosj
Message:

Twenty Nineteen: Fixes and improvements.

This commit brings over several changes that occurred upstream in the theme’s GitHub repository into core.

Props kjellr, allancole, dimadin, westonruter.

See #45424.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/5.0/src/wp-content/themes/twentynineteen/functions.php

    r44187 r44196  
    222222    wp_style_add_data( 'twentynineteen-style', 'rtl', 'replace' );
    223223
    224     wp_enqueue_script( 'twentynineteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true );
    225 
    226224    if ( has_nav_menu( 'menu-1' ) ) {
    227225        wp_enqueue_script( 'twentynineteen-priority-menu', get_theme_file_uri( '/js/priority-menu.js' ), array(), '1.0', true );
     
    236234}
    237235add_action( 'wp_enqueue_scripts', 'twentynineteen_scripts' );
     236
     237/**
     238 * Fix skip link focus in IE11.
     239 *
     240 * This does not enqueue the script because it is tiny and because it is only for IE11,
     241 * thus it does not warrant having an entire dedicated blocking script being loaded.
     242 *
     243 * @link https://git.io/vWdr2
     244 */
     245function twentynineteen_skip_link_focus_fix() {
     246    // The following is minified via `terser --compress --mangle -- js/skip-link-focus-fix.js`.
     247    ?>
     248    <script>
     249        /(trident|msie)/i.test(navigator.userAgent)&&document.getElementById&&window.addEventListener&&window.addEventListener("hashchange",function(){var t,e=location.hash.substring(1);/^[A-z0-9_-]+$/.test(e)&&(t=document.getElementById(e))&&(/^(?:a|select|input|button|textarea)$/i.test(t.tagName)||(t.tabIndex=-1),t.focus())},!1);
     250    </script>
     251    <?php
     252}
     253add_action( 'wp_print_footer_scripts', 'twentynineteen_skip_link_focus_fix' );
    238254
    239255/**
Note: See TracChangeset for help on using the changeset viewer.