6
6
*/
7
7
// Exit if accessed directly.
8
8
if ( ! defined ( 'ABSPATH ' ) ) { exit ; }
9
-
10
9
if ( ! class_exists ( 'WP_Bootstrap_Loader ' ) ) {
11
-
10
+
12
11
/**
13
12
* WP_Bootstrap_Loader class.
14
13
*/
15
14
class WP_Bootstrap_Loader {
16
-
15
+
17
16
/**
18
17
* Construct
19
18
*
@@ -27,11 +26,11 @@ function __construct() {
27
26
28
27
// Async & Defer.
29
28
add_filter ('script_loader_tag ' , array ( $ this , 'bootstrap_async ' ), 10 , 2 );
29
+ add_filter ('script_loader_tag ' , array ( $ this , 'jquery_migrate_async ' ), 10 , 3 );
30
30
31
31
// Load Bootstrap for WordPress Editor.
32
32
add_action ( 'admin_init ' , array ( $ this , 'bootstrap_editor_css ' ) );
33
33
}
34
-
35
34
/**
36
35
* Bootstrap Async and Defer.
37
36
*
@@ -40,14 +39,28 @@ function __construct() {
40
39
* @param mixed $handle Handle.
41
40
* @return void
42
41
*/
43
- function bootstrap_async ( $ tag , $ handle ) {
42
+ function bootstrap_async ($ tag , $ handle ) {
44
43
if ( 'bootstrap ' !== $ handle ) {
45
44
return $ tag ;
46
45
}
47
-
48
46
return str_replace ( ' src ' , ' async="async" src ' , $ tag );
49
47
}
50
48
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
+
51
64
/**
52
65
* Loads Bootstrap & Font Awesome Stylesheet & Scripts.
53
66
*
@@ -56,10 +69,11 @@ function bootstrap_async( $tag, $handle ) {
56
69
*/
57
70
function bootstrap_scripts () {
58
71
if ( ! is_admin () ) {
72
+
59
73
// Twitter Bootstrap CSS.
60
74
wp_register_style ( 'bootstrap ' , 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css ' , '' , null , 'all ' );
61
75
wp_enqueue_style ( 'bootstrap ' );
62
-
76
+
63
77
// Load jQuery.
64
78
wp_enqueue_script ( 'jquery ' );
65
79
0 commit comments