Skip to content

Commit 404fd63

Browse files
committed
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. git-svn-id: https://develop.svn.wordpress.org/trunk@55861 602fd350-edb4-49c9-b593-d223f7449a82
1 parent d46c47f commit 404fd63

File tree

12 files changed

+40
-75
lines changed

12 files changed

+40
-75
lines changed

src/wp-content/themes/twentyfifteen/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,8 @@ function twentyfifteen_scripts() {
435435
wp_enqueue_style( 'twentyfifteen-ie7', get_template_directory_uri() . '/css/ie7.css', array( 'twentyfifteen-style' ), '20141210' );
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' ) ) {
441442
wp_enqueue_script( 'comment-reply' );

src/wp-content/themes/twentyfifteen/js/skip-link-focus-fix.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,27 @@
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-
11-
if ( ( ua.indexOf( 'webkit' ) > -1 || ua.indexOf( 'opera' ) > -1 || ua.indexOf( 'msie' ) > -1 ) &&
12-
document.getElementById && window.addEventListener ) {
10+
var isIe = /(trident|msie)/i.test( navigator.userAgent );
1311

12+
if ( isIe && document.getElementById && window.addEventListener ) {
1413
window.addEventListener( 'hashchange', function() {
15-
var element = document.getElementById( location.hash.substring( 1 ) );
14+
var id = location.hash.substring( 1 ),
15+
element;
16+
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
}
2127

src/wp-content/themes/twentyfourteen/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ function twentyfourteen_scripts() {
371371
);
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
}
376376
add_action( 'wp_enqueue_scripts', 'twentyfourteen_scripts' );
377377

src/wp-content/themes/twentyfourteen/js/functions.js

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
/**
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
*/
88
( function( $ ) {
@@ -38,33 +38,6 @@
3838
} );
3939
} )();
4040

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-
} );
67-
6841
$( function() {
6942
// Search toggle.
7043
$( '.search-toggle' ).on( 'click.twentyfourteen', function( event ) {

src/wp-content/themes/twentynineteen/functions.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,9 @@ function twentynineteen_scripts() {
284284
* This does not enqueue the script because it is tiny and because it is only for IE11,
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
*/
289292
function twentynineteen_skip_link_focus_fix() {
@@ -294,7 +297,6 @@ function twentynineteen_skip_link_focus_fix() {
294297
</script>
295298
<?php
296299
}
297-
add_action( 'wp_print_footer_scripts', 'twentynineteen_skip_link_focus_fix' );
298300

299301
/**
300302
* Enqueue supplemental block editor styles.

src/wp-content/themes/twentyseventeen/functions.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,10 @@ function twentyseventeen_scripts() {
483483
wp_enqueue_script( 'html5', get_theme_file_uri( '/assets/js/html5.js' ), array(), '20161020' );
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(
489492
'quote' => twentyseventeen_get_svg( array( 'icon' => 'quote-right' ) ),
@@ -501,12 +504,10 @@ function twentyseventeen_scripts() {
501504
);
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 );
507510

508-
wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
509-
510511
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
511512
wp_enqueue_script( 'comment-reply' );
512513
}

src/wp-content/themes/twentysixteen/functions.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,8 @@ function twentysixteen_scripts() {
405405
wp_enqueue_script( 'twentysixteen-html5', get_template_directory_uri() . '/js/html5.js', array(), '3.7.3' );
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' ) ) {
411412
wp_enqueue_script( 'comment-reply' );

src/wp-content/themes/twentysixteen/js/skip-link-focus-fix.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
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 ),
1615
element;

src/wp-content/themes/twentythirteen/functions.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,7 @@ function twentythirteen_scripts_styles() {
314314
}
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.
320320
$font_version = ( 0 === strpos( (string) twentythirteen_fonts_url(), get_template_directory_uri() . '/' ) ) ? '20230328' : null;

src/wp-content/themes/twentythirteen/js/functions.js

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -100,24 +100,6 @@
100100
onResizeARIA();
101101
} );
102102

103-
/**
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-
121103
/**
122104
* Arranges footer widgets vertically.
123105
*/

0 commit comments

Comments
 (0)