PluginProbe
Booking Calendar / 11.8.4
Booking Calendar v11.8.4
11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 10.11 All 204 releases
← All changes | core/any/class-css-js.php +35 -29 10.1.311.8.4 View file →
@@ -4,13 +4,17 @@
4 4 * @category Load JS and CSS files
5 5 * @author wpdevelop
6 6 *
7 7 * @web-site https://wpbookingcalendar.com/
8 - * @email info@wpbookingcalendar.com
9 - *
8 + * @email info@wpbookingcalendar.com
9 + *
10 10 * @modified 2015-10-28
11 11 */
12 12
13 +if ( ! defined( 'ABSPATH' ) ) {
14 + exit; // Exit if accessed directly.
15 +}
16 +
13 17 abstract class WPBC_JS_CSS {
14 18
15 19 public $objects = array();
16 20 public $type; // css || js
@@ -82,28 +86,31 @@
82 86
83 87 return $is_load;
84 88 }
85 89
86 -
87 - // Register
88 - public function registerScripts() {
89 -
90 - //if ( function_exists( 'wp_dequeue_script' ) )
91 - $this->remove_conflicts( ( is_admin() ? 'admin': 'client' ) );
92 -
93 - foreach( $this->objects as $script ) {
94 -
95 - if ( $this->isLoad( $script['where_to_load'] ) ) {
96 -
97 - if ( $this->getType() == 'css' )
98 - wp_register_style( $script['handle'], $script['src'], $script['deps'], $script['version'] );
99 - else
100 - wp_register_script( $script['handle'], $script['src'], $script['deps'], $script['version'] );
101 - }
102 - }
103 - }
104 -
105 -
90 + /**
91 + * Register Scripts
92 + *
93 + * @return void
94 + */
95 + public function registerScripts() {
96 +
97 + $this->remove_conflicts( ( is_admin() ? 'admin' : 'client' ) );
98 +
99 + foreach ( $this->objects as $script ) {
100 +
101 + if ( $this->isLoad( $script['where_to_load'] ) ) {
102 +
103 + if ( 'css' === $this->getType() ) {
104 + wp_register_style( $script['handle'], $script['src'], $script['deps'], $script['version'] );
105 + } else {
106 + wp_register_script( $script['handle'], $script['src'], $script['deps'], $script['version'], array( 'in_footer' => WPBC_JS_IN_FOOTER ) );
107 + }
108 + }
109 + }
110 + }
111 +
112 +
106 113 // Load scripts or styles here
107 114 public function load(){
108 115
109 116 $is_load_scripts = true;
@@ -108,12 +115,14 @@
108 115
109 116 $is_load_scripts = true;
110 117
111 118 $is_load_scripts = apply_filters( 'wpbc_is_load_script_on_this_page', $is_load_scripts );
119 +
120 + $force = apply_filters( 'wpbc_force_client_assets', false );
121 +
122 + if ( ! $force && ! $is_load_scripts ) return; // Exist, if on some page we do not need to load scripts
112 123
113 - if ( ! $is_load_scripts ) return; // Exist, if on some page we do not need to load scripts
114 124
115 -
116 125 foreach( $this->objects as $num => $script ) {
117 126
118 127 if ( $this->isLoad( $script['where_to_load'] ) ) {
119 128
@@ -130,13 +139,10 @@
130 139 wp_style_add_data( $script['handle'], 'conditional', $script['condition'] );
131 140 } else { // Add additional "dynamic CSS" if the WP version older than 3.6.0 (its function suport since WP 3.3)
132 141 if ( ($num-1) > -1 ) { // Its because "wp_add_inline_style" add the CSS to the already added style. So its require that some other simple style was added before
133 142 wp_enqueue_style( $this->objects[($num-1)]['handle'] );
134 - wp_add_inline_style( $this->objects[($num-1)]['handle'],
135 - sprintf("<!--[if ".$script['condition']."]>\n" .
136 - "<link rel='stylesheet' id='".$script['handle']."-css' href='". $script['src'] ."?ver=" . $script['version'] . "' type='text/css' media='all' />\n" .
137 - "<![endif]-->\n")
138 - );
143 + // phpcs:ignore WordPress.WP.EnqueuedResources.NonEnqueuedStylesheet
144 + wp_add_inline_style( $this->objects[ ( $num - 1 ) ]['handle'], sprintf( "<!--[if " . $script['condition'] . "]>\n" . "<link rel='stylesheet' id='" . $script['handle'] . "-css' href='" . $script['src'] . "?ver=" . $script['version'] . "' type='text/css' media='all' />\n" . "<![endif]-->\n" ) );
139 145 }
140 146 }
141 147 }
142 148