6
6
*/
7
7
// Exit if accessed directly.
8
8
if ( ! defined ( 'ABSPATH ' ) ) { exit ; }
9
+
9
10
if ( ! class_exists ( 'WP_Bootstrap_Loader ' ) ) {
10
11
11
12
/**
@@ -25,8 +26,8 @@ function __construct() {
25
26
add_action ( 'wp_enqueue_scripts ' , array ( $ this , 'bootstrap_scripts ' ) );
26
27
27
28
// Async & Defer.
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 );
29
+ add_filter ( 'script_loader_tag ' , array ( $ this , 'bootstrap_async ' ), 10 , 2 );
30
+ add_filter ( 'script_loader_tag ' , array ( $ this , 'jquery_migrate_async ' ), 10 , 3 );
30
31
31
32
// Load Bootstrap for WordPress Editor.
32
33
add_action ( 'admin_init ' , array ( $ this , 'bootstrap_editor_css ' ) );
@@ -40,9 +41,8 @@ function __construct() {
40
41
* @return void
41
42
*/
42
43
function bootstrap_async ($ tag , $ handle ) {
43
- if ( 'bootstrap ' !== $ handle ) {
44
+ if ( 'bootstrap ' !== $ handle )
44
45
return $ tag ;
45
- }
46
46
return str_replace ( ' src ' , ' async="async" src ' , $ tag );
47
47
}
48
48
@@ -55,9 +55,8 @@ function bootstrap_async($tag, $handle) {
55
55
* @return void
56
56
*/
57
57
function jquery_migrate_async ( $ tag , $ handle ) {
58
- if ( 'jquery-migrate ' !== $ handle ) {
58
+ if ( 'jquery-migrate ' !== $ handle )
59
59
return $ tag ;
60
- }
61
60
return str_replace ( ' src ' , ' defer="defer" src ' , $ tag );
62
61
}
63
62
@@ -69,22 +68,17 @@ function jquery_migrate_async( $tag, $handle ) {
69
68
*/
70
69
function bootstrap_scripts () {
71
70
if ( ! is_admin () ) {
72
-
73
71
// Twitter Bootstrap CSS.
74
72
wp_register_style ( 'bootstrap ' , 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css ' , '' , null , 'all ' );
75
73
wp_enqueue_style ( 'bootstrap ' );
76
-
77
74
// Load jQuery.
78
75
wp_enqueue_script ( 'jquery ' );
79
-
80
76
// Twitter Bootstrap Javascript.
81
77
wp_register_script ( 'bootstrap ' , 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js ' , 'jquery ' , null , true );
82
78
wp_enqueue_script ( 'bootstrap ' );
83
-
84
79
// Google Webfont.
85
80
wp_register_script ( 'webfont ' , 'https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js ' , null , null , true );
86
81
wp_enqueue_script ( 'webfont ' );
87
-
88
82
// Load Font Awesome via Google Webfont.
89
83
wp_add_inline_script ( 'webfont ' , 'WebFont.load({custom:{families:["font-awesome"],urls:["https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"]}}); ' );
90
84
}
0 commit comments