Make WordPress Core

Changeset 55861


Ignore:
Timestamp:
05/26/2023 05:23:49 PM (11 months ago)
Author:
westonruter
Message:

Bundled Themes: Remove/disable obsolete IE-specific skip-link-focus-fix.

  • Removes script from the wp_print_footer_scripts action in Twenty Nineteen, Twenty Twenty, and Twenty Twenty-One.
  • Switches enqueue functions to just register the scripts in Twenty Fifteen, Twenty Sixteen, and Twenty Seventeen.
  • Rearranges Twenty Seventeen's scripts to connect twentyseventeenScreenReaderText with the global script instead of the unused skip link fix.
  • Updates scripts in Twenty Fifteen and Twenty Sixteen with code from Twenty Seventeen _to run on Internet Explorer only_. Twenty Sixteen needed to keep an adjustment that offsets the toolbar and border.
  • Removes the script from JS files in Twenty Thirteen and Twenty Fourteen and edits their modified dates.

Props sabernhardt, westonruter, joedolson, flixos90, mukesh27.
Fixes #54421.

Location:
trunk/src/wp-content/themes
Files:
12 edited

Legend:

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

    r55476 r55861  
    436436    wp_style_add_data( 'twentyfifteen-ie7', 'conditional', 'lt IE 8' );
    437437
    438     wp_enqueue_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20141028', true );
     438    // Skip-link fix is no longer enqueued by default.
     439    wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', true );
    439440
    440441    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  • trunk/src/wp-content/themes/twentyfifteen/js/skip-link-focus-fix.js

    r30046 r55861  
    11/**
    2  * Makes "skip to content" link work correctly in IE9, Chrome, and Opera
    3  * for better accessibility.
     2 * File skip-link-focus-fix.js.
    43 *
    5  * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
     4 * Helps with accessibility for keyboard only users.
     5 *
     6 * Learn more: https://git.io/vWdr2
    67 */
    78
    89( function() {
    9     var ua = navigator.userAgent.toLowerCase();
     10    var isIe = /(trident|msie)/i.test( navigator.userAgent );
    1011
    11     if ( ( ua.indexOf( 'webkit' ) > -1 || ua.indexOf( 'opera' ) > -1 || ua.indexOf( 'msie' ) > -1 ) &&
    12         document.getElementById && window.addEventListener ) {
     12    if ( isIe && document.getElementById && window.addEventListener ) {
     13        window.addEventListener( 'hashchange', function() {
     14            var id = location.hash.substring( 1 ),
     15                element;
    1316
    14         window.addEventListener( 'hashchange', function() {
    15             var element = document.getElementById( location.hash.substring( 1 ) );
     17            if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) {
     18                return;
     19            }
     20
     21            element = document.getElementById( id );
    1622
    1723            if ( element ) {
    18                 if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.nodeName ) ) {
     24                if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) {
    1925                    element.tabIndex = -1;
    2026                }
  • trunk/src/wp-content/themes/twentyfourteen/functions.php

    r55476 r55861  
    372372    }
    373373
    374     wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20210122', true );
     374    wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', true );
    375375}
    376376add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
  • trunk/src/wp-content/themes/twentyfourteen/js/functions.js

    r50001 r55861  
    22 * Theme functions file.
    33 *
    4  * Contains handlers for navigation, accessibility, header sizing
    5  * footer widgets and Featured Content slider
     4 * Contains handlers for navigation, accessibility, header sizing,
     5 * footer widgets and Featured Content slider.
    66 *
    77 */
     
    3838        } );
    3939    } )();
    40 
    41     /*
    42      * Makes "skip to content" link work correctly in IE9 and Chrome for better
    43      * accessibility.
    44      *
    45      * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
    46      */
    47     _window.on( 'hashchange.twentyfourteen', function() {
    48         var hash = location.hash.substring( 1 ), element;
    49 
    50         if ( ! hash ) {
    51             return;
    52         }
    53 
    54         element = document.getElementById( hash );
    55 
    56         if ( element ) {
    57             if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
    58                 element.tabIndex = -1;
    59             }
    60 
    61             element.focus();
    62 
    63             // Repositions the window on jump-to-anchor to account for header height.
    64             window.scrollBy( 0, -80 );
    65         }
    66     } );
    6740
    6841    $( function() {
  • trunk/src/wp-content/themes/twentynineteen/functions.php

    r54492 r55861  
    285285 * thus it does not warrant having an entire dedicated blocking script being loaded.
    286286 *
     287 * @since Twenty Nineteen 1.0
     288 * @deprecated Twenty Nineteen 2.6 Removed from wp_print_footer_scripts action.
     289 *
    287290 * @link https://git.io/vWdr2
    288291 */
     
    295298    <?php
    296299}
    297 add_action( 'wp_print_footer_scripts', 'twentynineteen_skip_link_focus_fix' );
    298300
    299301/**
  • trunk/src/wp-content/themes/twentyseventeen/functions.php

    r55476 r55861  
    484484    wp_script_add_data( 'html5', 'conditional', 'lt IE 9' );
    485485
    486     wp_enqueue_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', true );
     486    // Skip-link fix is no longer enqueued by default.
     487    wp_register_script( 'twentyseventeen-skip-link-focus-fix', get_theme_file_uri( '/assets/js/skip-link-focus-fix.js' ), array(), '20161114', true );
     488
     489    wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', true );
    487490
    488491    $twentyseventeen_l10n = array(
     
    502505    }
    503506
    504     wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', true );
     507    wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
    505508
    506509    wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', true );
    507 
    508     wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
    509510
    510511    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  • trunk/src/wp-content/themes/twentysixteen/functions.php

    r55476 r55861  
    406406    wp_script_add_data( 'twentysixteen-html5', 'conditional', 'lt IE 9' );
    407407
    408     wp_enqueue_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20170530', true );
     408    // Skip-link fix is no longer enqueued by default.
     409    wp_register_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', true );
    409410
    410411    if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
  • trunk/src/wp-content/themes/twentysixteen/js/skip-link-focus-fix.js

    r40851 r55861  
    11/**
    2  * Makes "skip to content" link work correctly in IE9, Chrome, and Opera
    3  * for better accessibility.
     2 * File skip-link-focus-fix.js.
    43 *
    5  * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
     4 * Helps with accessibility for keyboard only users.
     5 *
     6 * Learn more: https://git.io/vWdr2
    67 */
    78
    8  ( function() {
    9     var isWebkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1,
    10         isOpera  = navigator.userAgent.toLowerCase().indexOf( 'opera' )  > -1,
    11         isIE     = navigator.userAgent.toLowerCase().indexOf( 'msie' )   > -1;
     9( function() {
     10    var isIe = /(trident|msie)/i.test( navigator.userAgent );
    1211
    13     if ( ( isWebkit || isOpera || isIE ) && document.getElementById && window.addEventListener ) {
     12    if ( isIe && document.getElementById && window.addEventListener ) {
    1413        window.addEventListener( 'hashchange', function() {
    1514            var id = location.hash.substring( 1 ),
  • trunk/src/wp-content/themes/twentythirteen/functions.php

    r55476 r55861  
    315315
    316316    // Loads JavaScript file with functionality specific to Twenty Thirteen.
    317     wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20210122', true );
     317    wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', true );
    318318
    319319    // Add Source Sans Pro and Bitter fonts, used in the main stylesheet.
  • trunk/src/wp-content/themes/twentythirteen/js/functions.js

    r50001 r55861  
    102102
    103103    /**
    104      * Makes "skip to content" link work correctly in IE9 and Chrome for better
    105      * accessibility.
    106      *
    107      * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
    108      */
    109     _window.on( 'hashchange.twentythirteen', function() {
    110         var element = document.getElementById( location.hash.substring( 1 ) );
    111 
    112         if ( element ) {
    113             if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) {
    114                 element.tabIndex = -1;
    115             }
    116 
    117             element.focus();
    118         }
    119     } );
    120 
    121     /**
    122104     * Arranges footer widgets vertically.
    123105     */
  • trunk/src/wp-content/themes/twentytwenty/functions.php

    r55427 r55861  
    236236 *
    237237 * @since Twenty Twenty 1.0
     238 * @deprecated Twenty Twenty 2.3 Removed from wp_print_footer_scripts action.
    238239 *
    239240 * @link https://git.io/vWdr2
     
    247248    <?php
    248249}
    249 add_action( 'wp_print_footer_scripts', 'twentytwenty_skip_link_focus_fix' );
    250250
    251251/**
  • trunk/src/wp-content/themes/twentytwentyone/functions.php

    r55409 r55861  
    490490 *
    491491 * @since Twenty Twenty-One 1.0
     492 * @deprecated Twenty Twenty-One 1.9 Removed from wp_print_footer_scripts action.
    492493 *
    493494 * @link https://git.io/vWdr2
     
    509510    }
    510511}
    511 add_action( 'wp_print_footer_scripts', 'twenty_twenty_one_skip_link_focus_fix' );
    512512
    513513/**
Note: See TracChangeset for help on using the changeset viewer.