From 4e30de26c647c3f82c83bb7ac20ee38e9a5322e9 Mon Sep 17 00:00:00 2001 From: Weston Ruter Date: Fri, 26 May 2023 17:25:23 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@55861 git-svn-id: http://core.svn.wordpress.org/trunk@55373 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-content/themes/twentyfifteen/functions.php | 3 +- .../twentyfifteen/js/skip-link-focus-fix.js | 24 ++++++++------ .../themes/twentyfourteen/functions.php | 2 +- .../themes/twentyfourteen/js/functions.js | 31 ++----------------- .../themes/twentynineteen/functions.php | 4 ++- .../themes/twentyseventeen/functions.php | 9 +++--- wp-content/themes/twentysixteen/functions.php | 3 +- .../twentysixteen/js/skip-link-focus-fix.js | 15 +++++---- .../themes/twentythirteen/functions.php | 2 +- .../themes/twentythirteen/js/functions.js | 18 ----------- wp-content/themes/twentytwenty/functions.php | 2 +- .../themes/twentytwentyone/functions.php | 2 +- wp-includes/version.php | 2 +- 13 files changed, 41 insertions(+), 76 deletions(-) diff --git a/wp-content/themes/twentyfifteen/functions.php b/wp-content/themes/twentyfifteen/functions.php index 0528a01be9..25f5a22eeb 100644 --- a/wp-content/themes/twentyfifteen/functions.php +++ b/wp-content/themes/twentyfifteen/functions.php @@ -435,7 +435,8 @@ function twentyfifteen_scripts() { wp_enqueue_style( 'twentyfifteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentyfifteen-style' ), '20141210' ); wp_style_add_data( 'twentyfifteen-ie7', 'conditional', 'lt IE 8' ); - wp_enqueue_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20141028', true ); + // Skip-link fix is no longer enqueued by default. + wp_register_script( 'twentyfifteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); diff --git a/wp-content/themes/twentyfifteen/js/skip-link-focus-fix.js b/wp-content/themes/twentyfifteen/js/skip-link-focus-fix.js index 5e1a48a101..e7808bc920 100644 --- a/wp-content/themes/twentyfifteen/js/skip-link-focus-fix.js +++ b/wp-content/themes/twentyfifteen/js/skip-link-focus-fix.js @@ -1,21 +1,27 @@ /** - * Makes "skip to content" link work correctly in IE9, Chrome, and Opera - * for better accessibility. + * File skip-link-focus-fix.js. * - * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ + * Helps with accessibility for keyboard only users. + * + * Learn more: https://git.io/vWdr2 */ ( function() { - var ua = navigator.userAgent.toLowerCase(); - - if ( ( ua.indexOf( 'webkit' ) > -1 || ua.indexOf( 'opera' ) > -1 || ua.indexOf( 'msie' ) > -1 ) && - document.getElementById && window.addEventListener ) { + var isIe = /(trident|msie)/i.test( navigator.userAgent ); + if ( isIe && document.getElementById && window.addEventListener ) { window.addEventListener( 'hashchange', function() { - var element = document.getElementById( location.hash.substring( 1 ) ); + var id = location.hash.substring( 1 ), + element; + + if ( ! ( /^[A-z0-9_-]+$/.test( id ) ) ) { + return; + } + + element = document.getElementById( id ); if ( element ) { - if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.nodeName ) ) { + if ( ! ( /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) ) { element.tabIndex = -1; } diff --git a/wp-content/themes/twentyfourteen/functions.php b/wp-content/themes/twentyfourteen/functions.php index 22305e5b97..4441910d67 100644 --- a/wp-content/themes/twentyfourteen/functions.php +++ b/wp-content/themes/twentyfourteen/functions.php @@ -371,7 +371,7 @@ function twentyfourteen_scripts() { ); } - wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20210122', true ); + wp_enqueue_script( 'twentyfourteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', true ); } add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' ); diff --git a/wp-content/themes/twentyfourteen/js/functions.js b/wp-content/themes/twentyfourteen/js/functions.js index 557cc9f87b..d9588ee48d 100644 --- a/wp-content/themes/twentyfourteen/js/functions.js +++ b/wp-content/themes/twentyfourteen/js/functions.js @@ -1,8 +1,8 @@ /** * Theme functions file. * - * Contains handlers for navigation, accessibility, header sizing - * footer widgets and Featured Content slider + * Contains handlers for navigation, accessibility, header sizing, + * footer widgets and Featured Content slider. * */ ( function( $ ) { @@ -38,33 +38,6 @@ } ); } )(); - /* - * Makes "skip to content" link work correctly in IE9 and Chrome for better - * accessibility. - * - * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ - */ - _window.on( 'hashchange.twentyfourteen', function() { - var hash = location.hash.substring( 1 ), element; - - if ( ! hash ) { - return; - } - - element = document.getElementById( hash ); - - if ( element ) { - if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) { - element.tabIndex = -1; - } - - element.focus(); - - // Repositions the window on jump-to-anchor to account for header height. - window.scrollBy( 0, -80 ); - } - } ); - $( function() { // Search toggle. $( '.search-toggle' ).on( 'click.twentyfourteen', function( event ) { diff --git a/wp-content/themes/twentynineteen/functions.php b/wp-content/themes/twentynineteen/functions.php index 98c4108577..99f7c21e6e 100644 --- a/wp-content/themes/twentynineteen/functions.php +++ b/wp-content/themes/twentynineteen/functions.php @@ -284,6 +284,9 @@ add_action( 'wp_enqueue_scripts', 'twentynineteen_scripts' ); * This does not enqueue the script because it is tiny and because it is only for IE11, * thus it does not warrant having an entire dedicated blocking script being loaded. * + * @since Twenty Nineteen 1.0 + * @deprecated Twenty Nineteen 2.6 Removed from wp_print_footer_scripts action. + * * @link https://git.io/vWdr2 */ function twentynineteen_skip_link_focus_fix() { @@ -294,7 +297,6 @@ function twentynineteen_skip_link_focus_fix() { twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ), @@ -501,12 +504,10 @@ function twentyseventeen_scripts() { ); } - wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '20211130', true ); + wp_localize_script( 'twentyseventeen-global', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n ); wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.3', true ); - wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n ); - if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); } diff --git a/wp-content/themes/twentysixteen/functions.php b/wp-content/themes/twentysixteen/functions.php index d098a1ebde..1125bc72bd 100644 --- a/wp-content/themes/twentysixteen/functions.php +++ b/wp-content/themes/twentysixteen/functions.php @@ -405,7 +405,8 @@ function twentysixteen_scripts() { wp_enqueue_script( 'twentysixteen-html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.3' ); wp_script_add_data( 'twentysixteen-html5', 'conditional', 'lt IE 9' ); - wp_enqueue_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20170530', true ); + // Skip-link fix is no longer enqueued by default. + wp_register_script( 'twentysixteen-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20230526', true ); if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) { wp_enqueue_script( 'comment-reply' ); diff --git a/wp-content/themes/twentysixteen/js/skip-link-focus-fix.js b/wp-content/themes/twentysixteen/js/skip-link-focus-fix.js index ae8a5da10a..c84152edc0 100644 --- a/wp-content/themes/twentysixteen/js/skip-link-focus-fix.js +++ b/wp-content/themes/twentysixteen/js/skip-link-focus-fix.js @@ -1,16 +1,15 @@ /** - * Makes "skip to content" link work correctly in IE9, Chrome, and Opera - * for better accessibility. + * File skip-link-focus-fix.js. * - * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ + * Helps with accessibility for keyboard only users. + * + * Learn more: https://git.io/vWdr2 */ - ( function() { - var isWebkit = navigator.userAgent.toLowerCase().indexOf( 'webkit' ) > -1, - isOpera = navigator.userAgent.toLowerCase().indexOf( 'opera' ) > -1, - isIE = navigator.userAgent.toLowerCase().indexOf( 'msie' ) > -1; +( function() { + var isIe = /(trident|msie)/i.test( navigator.userAgent ); - if ( ( isWebkit || isOpera || isIE ) && document.getElementById && window.addEventListener ) { + if ( isIe && document.getElementById && window.addEventListener ) { window.addEventListener( 'hashchange', function() { var id = location.hash.substring( 1 ), element; diff --git a/wp-content/themes/twentythirteen/functions.php b/wp-content/themes/twentythirteen/functions.php index 8383b4cba3..72301b4a53 100644 --- a/wp-content/themes/twentythirteen/functions.php +++ b/wp-content/themes/twentythirteen/functions.php @@ -314,7 +314,7 @@ function twentythirteen_scripts_styles() { } // Loads JavaScript file with functionality specific to Twenty Thirteen. - wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20210122', true ); + wp_enqueue_script( 'twentythirteen-script', get_template_directory_uri() . '/js/functions.js', array( 'jquery' ), '20230526', true ); // Add Source Sans Pro and Bitter fonts, used in the main stylesheet. $font_version = ( 0 === strpos( (string) twentythirteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null; diff --git a/wp-content/themes/twentythirteen/js/functions.js b/wp-content/themes/twentythirteen/js/functions.js index 4b1102ebe9..8287fc8a59 100644 --- a/wp-content/themes/twentythirteen/js/functions.js +++ b/wp-content/themes/twentythirteen/js/functions.js @@ -100,24 +100,6 @@ onResizeARIA(); } ); - /** - * Makes "skip to content" link work correctly in IE9 and Chrome for better - * accessibility. - * - * @link http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/ - */ - _window.on( 'hashchange.twentythirteen', function() { - var element = document.getElementById( location.hash.substring( 1 ) ); - - if ( element ) { - if ( ! /^(?:a|select|input|button|textarea)$/i.test( element.tagName ) ) { - element.tabIndex = -1; - } - - element.focus(); - } - } ); - /** * Arranges footer widgets vertically. */ diff --git a/wp-content/themes/twentytwenty/functions.php b/wp-content/themes/twentytwenty/functions.php index 38fc4d8a48..b721b991e1 100644 --- a/wp-content/themes/twentytwenty/functions.php +++ b/wp-content/themes/twentytwenty/functions.php @@ -235,6 +235,7 @@ add_action( 'wp_enqueue_scripts', 'twentytwenty_register_scripts' ); * thus it does not warrant having an entire dedicated blocking script being loaded. * * @since Twenty Twenty 1.0 + * @deprecated Twenty Twenty 2.3 Removed from wp_print_footer_scripts action. * * @link https://git.io/vWdr2 */ @@ -246,7 +247,6 @@ function twentytwenty_skip_link_focus_fix() {