Skip to content

Commit 08058d9

Browse files
authored
Update wp-bootstrap-loader.php
1 parent 2bc0d55 commit 08058d9

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

wp-bootstrap-loader.php

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@
66
*/
77
// Exit if accessed directly.
88
if ( ! defined( 'ABSPATH' ) ) { exit; }
9-
109
if ( ! class_exists( 'WP_Bootstrap_Loader' ) ) {
11-
10+
1211
/**
1312
* WP_Bootstrap_Loader class.
1413
*/
1514
class WP_Bootstrap_Loader {
16-
15+
1716
/**
1817
* Construct
1918
*
@@ -27,11 +26,11 @@ function __construct() {
2726

2827
// Async & Defer.
2928
add_filter('script_loader_tag', array( $this, 'bootstrap_async' ), 10, 2);
29+
add_filter('script_loader_tag', array( $this, 'jquery_migrate_async' ), 10, 3);
3030

3131
// Load Bootstrap for WordPress Editor.
3232
add_action( 'admin_init', array( $this, 'bootstrap_editor_css' ) );
3333
}
34-
3534
/**
3635
* Bootstrap Async and Defer.
3736
*
@@ -40,14 +39,28 @@ function __construct() {
4039
* @param mixed $handle Handle.
4140
* @return void
4241
*/
43-
function bootstrap_async( $tag, $handle ) {
42+
function bootstrap_async($tag, $handle) {
4443
if ( 'bootstrap' !== $handle ) {
4544
return $tag;
4645
}
47-
4846
return str_replace( ' src', ' async="async" src', $tag );
4947
}
5048

49+
/**
50+
* jquery_migrate_async function.
51+
*
52+
* @access public
53+
* @param mixed $tag Tag.
54+
* @param mixed $handle Handle.
55+
* @return void
56+
*/
57+
function jquery_migrate_async( $tag, $handle ) {
58+
if ( 'jquery-migrate' !== $handle ) {
59+
return $tag;
60+
}
61+
return str_replace( ' src', ' defer="defer" src', $tag );
62+
}
63+
5164
/**
5265
* Loads Bootstrap & Font Awesome Stylesheet & Scripts.
5366
*
@@ -56,10 +69,11 @@ function bootstrap_async( $tag, $handle ) {
5669
*/
5770
function bootstrap_scripts() {
5871
if ( ! is_admin() ) {
72+
5973
// Twitter Bootstrap CSS.
6074
wp_register_style( 'bootstrap', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css', '', null, 'all' );
6175
wp_enqueue_style( 'bootstrap' );
62-
76+
6377
// Load jQuery.
6478
wp_enqueue_script( 'jquery' );
6579

0 commit comments

Comments
 (0)