PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.1.3
ShopBuilder – WooCommerce Builder For Elementor v2.1.3
3.4.2 3.4.1 3.4.0 2.0.1 2.0.2 2.0.3 2.1.0 2.1.1 2.1.10 2.1.11 2.1.12 2.1.13 2.1.14 2.1.15 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 All 63 releases
← All changes | app/Controllers/AssetsController.php +101 -252 3.4.22.1.3 View file →
@@ -1,17 +1,11 @@
1 1 <?php
2 -/**
3 - * Assets Controller Class
4 - *
5 - * @package RadiusTheme\SB
6 - */
7 2
8 3 namespace RadiusTheme\SB\Controllers;
9 4
10 -use RadiusTheme\SB\AI\AIFns;
5 +use RadiusTheme\SB\Helpers\BuilderFns;
11 6 use RadiusTheme\SB\Helpers\Fns;
12 7 use RadiusTheme\SB\Models\Settings;
13 -use RadiusTheme\SB\Helpers\BuilderFns;
14 8 use RadiusTheme\SB\Traits\SingletonTrait;
15 9
16 10 // Do not allow directly accessing this file.
17 11 if ( ! defined( 'ABSPATH' ) ) {
@@ -17,11 +11,8 @@
17 11 if ( ! defined( 'ABSPATH' ) ) {
18 12 exit( 'This script cannot be accessed directly.' );
19 13 }
20 14
21 -/**
22 - * Assets Controller Class
23 - */
24 15 class AssetsController {
25 16
26 17 use SingletonTrait;
27 18
@@ -53,27 +44,19 @@
53 44 */
54 45 private $scripts = [];
55 46
56 47 /**
57 - * Cached bundled assets.
58 - *
59 - * @var array|null
60 - */
61 - private $cached_bundled_assets = null;
62 -
63 - /**
64 48 * Class Constructor
65 49 */
66 50 public function __construct() {
67 51 $this->version = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? time() : RTSB_VERSION;
68 52
69 - // phpcs:ignore WordPress.PHP.StrictInArray.MissingTrueStrict
70 53 if ( in_array( 'sitepress-multilingual-cms/sitepress.php', get_option( 'active_plugins' ) ) ) {
71 54 self::$ajaxurl = admin_url( 'admin-ajax.php?lang=' . ICL_LANGUAGE_CODE );
72 55 } else {
73 56 self::$ajaxurl = admin_url( 'admin-ajax.php' );
74 57 }
75 - add_filter( 'rtsb/optimizer/scripts/deps', [ $this, 'extend_shared_dependencies' ], 99 );
58 +
76 59 /**
77 60 * Admin scripts.
78 61 */
79 62 add_action( 'admin_enqueue_scripts', [ $this, 'register_backend_assets' ], 1 );
@@ -81,28 +64,16 @@
81 64
82 65 /**
83 66 * Public scripts.
84 67 */
85 - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 25 );
68 + add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 15 );
86 69 /**
87 70 * General scripts.
88 71 */
89 72 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_general_public_scripts' ], 30 );
90 73 }
74 +
91 75 /**
92 - * Shared dependencies.
93 - *
94 - * @param array $deps Dependencies.
95 - *
96 - * @return array
97 - */
98 - public function extend_shared_dependencies( $deps ) {
99 - if ( Fns::is_elementor_widget_active( 'products_slider' ) ) {
100 - $deps[] = 'swiper';
101 - }
102 - return array_unique( $deps );
103 - }
104 - /**
105 76 * Get all frontend scripts.
106 77 *
107 78 * @return void
108 79 */
@@ -116,19 +87,13 @@
116 87 * @return object
117 88 */
118 89 private function get_public_styles() {
119 90 $rtl_suffix = is_rtl() ? '-rtl' : '';
120 - $rtl_dir = is_rtl() ? trailingslashit( 'rtl' ) : trailingslashit( 'css' );
121 -
122 91 $this->styles[] = [
123 - 'handle' => 'rtsb-odometer',
124 - 'src' => rtsb()->get_assets_uri( 'vendor/odometer/css/odometer.min.css' ),
125 - ];
126 -
127 - $this->styles[] = [
128 92 'handle' => 'rtsb-fonts',
129 93 'src' => rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ),
130 94 ];
95 +
131 96 if ( rtsb()->has_pro() ) {
132 97 $this->styles[] = [
133 98 'handle' => 'rtsb-noui-slider',
134 99 'src' => rtsbpro()->get_assets_uri( 'vendors/nouislider/nouislider.min.css' ),
@@ -134,33 +99,18 @@
134 99 'src' => rtsbpro()->get_assets_uri( 'vendors/nouislider/nouislider.min.css' ),
135 100 ];
136 101 }
137 102
138 - $pro_version = defined( 'RTSBPRO_VERSION' ) ? RTSBPRO_VERSION : '0';
139 - $addon_condition = version_compare( $pro_version, '1.9.0', '<' );
103 + $this->styles[] = [
104 + 'handle' => 'rtsb-frontend',
105 + 'src' => rtsb()->get_assets_uri( 'css/frontend/frontend' . $rtl_suffix . '.css' ),
106 + ];
140 107
141 - $optimized = [];
108 + $this->styles[] = [
109 + 'handle' => 'swiper',
110 + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/css/swiper-bundle.min.css' ),
111 + ];
142 112
143 - if ( ! rtsb()->has_pro() && Fns::is_optimization_enabled() ) {
144 - $optimized = AssetRegistry::instance()->load_optimized_assets();
145 - }
146 -
147 - // An empty `src` means the bundle could not be built. Registering it would
148 - // produce a handle WordPress never prints, so use the unbundled assets.
149 - if ( ! empty( $optimized['src'] ) ) {
150 - $this->styles[] = $optimized;
151 - } else {
152 - if ( $addon_condition ) {
153 - $this->styles[] = [
154 - 'handle' => 'rtsb-general-addons',
155 - 'src' => rtsb()->get_assets_uri( $rtl_dir . 'frontend/general-addons' . $rtl_suffix . '.css' ),
156 - ];
157 - }
158 - $this->styles[] = [
159 - 'handle' => 'rtsb-frontend',
160 - 'src' => rtsb()->get_assets_uri( $rtl_dir . 'frontend/frontend' . $rtl_suffix . '.css' ),
161 - ];
162 - }
163 113 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
164 114 $this->styles[] = [
165 115 'handle' => 'photoswipe',
166 116 'src' => plugins_url( 'assets/css/photoswipe/photoswipe.min.css', WC_PLUGIN_FILE ),
@@ -186,26 +136,40 @@
186 136 *
187 137 * @return object
188 138 */
189 139 private function get_public_scripts() {
140 +
141 + $default_swiper_path = rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' );
142 +
143 + if ( defined( 'ELEMENTOR_ASSETS_PATH' ) ) {
144 + $is_swiper8_enable = get_option( 'elementor_experiment-e_swiper_latest' );
145 +
146 + if ( 'active' === $is_swiper8_enable || 'default' === $is_swiper8_enable ) {
147 + $el_swiper_path = 'lib/swiper/v8/swiper.min.js';
148 + } else {
149 + $el_swiper_path = 'lib/swiper/swiper.min.js';
150 + }
151 +
152 + $elementor_swiper_path = ELEMENTOR_ASSETS_PATH . $el_swiper_path;
153 +
154 + if ( file_exists( $elementor_swiper_path ) ) {
155 + $default_swiper_path = ELEMENTOR_ASSETS_URL . $el_swiper_path;
156 + }
157 + }
158 +
190 159 $this->scripts[] = [
191 160 'handle' => 'swiper',
192 - 'src' => esc_url( $this->get_swiper_url() ),
161 + 'src' => esc_url( $default_swiper_path ),
193 162 'deps' => [ 'jquery' ],
194 163 'footer' => true,
195 164 ];
165 +
196 166 $this->scripts[] = [
197 - 'handle' => 'rtsb-waypoints',
198 - 'src' => rtsb()->get_assets_uri( 'vendor/waypoints/js/jquery.waypoints.min.js' ),
167 + 'handle' => 'rtsb-imagesloaded',
168 + 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ),
199 169 'deps' => [ 'jquery' ],
200 170 'footer' => true,
201 171 ];
202 - $this->scripts[] = [
203 - 'handle' => 'rtsb-odometer',
204 - 'src' => rtsb()->get_assets_uri( 'vendor/odometer/js/odometer.min.js' ),
205 - 'deps' => [ 'jquery' ],
206 - 'footer' => true,
207 - ];
208 172
209 173 $this->scripts[] = [
210 174 'handle' => 'rtsb-tipsy',
211 175 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
@@ -214,9 +178,9 @@
214 178 ];
215 179
216 180 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
217 181 $this->scripts[] = [
218 - 'handle' => 'wc-flexslider',
182 + 'handle' => 'flexslider',
219 183 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
220 184 'deps' => [ 'jquery' ],
221 185 'footer' => true,
222 186 ];
@@ -228,9 +192,9 @@
228 192 'footer' => true,
229 193 ];
230 194
231 195 $this->scripts[] = [
232 - 'handle' => 'wc-zoom',
196 + 'handle' => 'zoom',
233 197 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
234 198 'deps' => [ 'jquery' ],
235 199 'footer' => true,
236 200 ];
@@ -235,9 +199,9 @@
235 199 'footer' => true,
236 200 ];
237 201
238 202 $this->scripts[] = [
239 - 'handle' => 'wc-photoswipe-ui-default',
203 + 'handle' => 'photoswipe-ui-default',
240 204 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
241 205 'deps' => [ 'jquery', 'photoswipe' ],
242 206 'footer' => true,
243 207 ];
@@ -244,9 +208,9 @@
244 208
245 209 $this->scripts[] = [
246 210 'handle' => 'wc-single-product',
247 211 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
248 - 'deps' => [ 'jquery', 'wc-flexslider', 'photoswipe', 'wc-photoswipe-ui-default', 'wc-zoom' ],
212 + 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
249 213 'footer' => true,
250 214 ];
251 215
252 216 }
@@ -264,42 +228,17 @@
264 228 'src' => rtsbpro()->get_assets_uri( 'vendors/sticky-sidebar/sticky-sidebar.min.js' ),
265 229 'deps' => [ 'jquery' ],
266 230 'footer' => true,
267 231 ];
268 -
269 - $this->scripts[] = [
270 - 'handle' => 'rtsb-popper',
271 - 'src' => rtsbpro()->get_assets_uri( 'vendors/tippy/popper.min.js' ),
272 - 'deps' => [ 'jquery' ],
273 - 'footer' => true,
274 - ];
275 -
276 - $this->scripts[] = [
277 - 'handle' => 'rtsb-tippy',
278 - 'src' => rtsbpro()->get_assets_uri( 'vendors/tippy/tippy.min.js' ),
279 - 'deps' => [ 'jquery', 'rtsb-popper' ],
280 - 'footer' => true,
281 - ];
282 232 }
283 233
284 - $optimized = [];
234 + $this->scripts[] = [
235 + 'handle' => 'rtsb-public',
236 + 'src' => rtsb()->get_assets_uri( 'js/frontend/frontend.js' ),
237 + 'deps' => [ 'jquery', 'rtsb-imagesloaded', 'swiper' ],
238 + 'footer' => true,
239 + ];
285 240
286 - if ( ! rtsb()->has_pro() && Fns::is_optimization_enabled() ) {
287 - $optimized = AssetRegistry::instance()->load_optimized_assets( 'js' );
288 - }
289 -
290 - // See get_public_styles(): an empty `src` means the bundle build failed.
291 - if ( ! empty( $optimized['src'] ) ) {
292 - $this->scripts[] = $optimized;
293 - } else {
294 - $this->scripts[] = [
295 - 'handle' => 'rtsb-public',
296 - 'src' => rtsb()->get_assets_uri( 'js/frontend/frontend.js' ),
297 - 'deps' => [ 'jquery', 'imagesloaded', 'swiper' ],
298 - 'footer' => true,
299 - ];
300 - }
301 -
302 241 return $this;
303 242 }
304 243
305 244 /**
@@ -308,10 +247,8 @@
308 247 * @return void
309 248 */
310 249 public function register_public_scripts() {
311 250 $this->get_public_assets();
312 - $this->styles = array_filter( $this->styles );
313 - $this->scripts = array_filter( $this->scripts );
314 251
315 252 // Register public styles.
316 253 foreach ( $this->styles as $style ) {
317 254 wp_register_style( $style['handle'], $style['src'], '', $this->version );
@@ -332,9 +269,8 @@
332 269 /**
333 270 * Register scripts.
334 271 */
335 272 $this->register_public_scripts();
336 -
337 273 /**
338 274 * Enqueue scripts.
339 275 */
340 276 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
@@ -340,8 +276,9 @@
340 276 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
341 277 /**
342 278 * Styles.
343 279 */
280 + wp_enqueue_style( 'swiper' );
344 281 wp_enqueue_style( 'photoswipe' );
345 282 wp_enqueue_style( 'photoswipe-default-skin' );
346 283 wp_enqueue_style( 'elementor-editor-style-fix' );
347 284 wp_enqueue_style( 'woocommerce-general' );
@@ -348,32 +285,28 @@
348 285
349 286 /**
350 287 * Scripts.
351 288 */
352 - $handle = Fns::optimized_handle( 'rtsb-public' );
353 -
354 - wp_enqueue_script( 'wc-flexslider' );
289 + wp_enqueue_script( 'flexslider' );
355 290 wp_enqueue_script( 'wc-single-product' );
356 - wp_dequeue_script( $handle );
291 + wp_dequeue_script( 'rtsb-public' );
357 292 wp_enqueue_script( 'swiper' );
293 + wp_enqueue_script( 'rtsb-public' );
294 + }
358 295
359 - if ( Fns::is_optimization_enabled() ) {
360 - Fns::enqueue_optimized_assets();
361 - } else {
362 - wp_enqueue_script( $handle );
363 - }
364 - }
296 + /**
297 + * Styles.
298 + */
299 + wp_enqueue_style( 'rtsb-fonts' );
300 + wp_enqueue_style( 'rtsb-frontend' );
365 301
302 + /**
303 + * Scripts.
304 + */
305 + wp_enqueue_script( 'rtsb-imagesloaded' );
366 306 wp_enqueue_script( 'rtsb-tipsy' );
307 + wp_enqueue_script( 'rtsb-public' );
367 308
368 - if ( Fns::is_optimization_enabled() ) {
369 - Fns::enqueue_optimized_assets();
370 - } else {
371 - wp_enqueue_style( 'rtsb-fonts' );
372 - wp_enqueue_style( 'rtsb-frontend' );
373 - wp_enqueue_script( 'rtsb-public' );
374 - }
375 -
376 309 /**
377 310 * Localize script.
378 311 */
379 312 self::localizeData();
@@ -385,31 +318,22 @@
385 318 * @static
386 319 * @return void
387 320 */
388 321 public static function localizeData() {
389 - $handle = Fns::optimized_handle( 'rtsb-public' );
390 - $ai_data = AIFns::activated_ai_data();
391 322 wp_localize_script(
392 - $handle,
323 + 'rtsb-public',
393 324 'rtsbPublicParams',
394 325 [
395 - 'ajaxUrl' => esc_url( self::$ajaxurl ),
396 - 'aiActivated' => ! empty( $ai_data ),
397 - 'homeurl' => home_url(),
398 - 'shopUrl' => function_exists( 'wc_get_page_permalink' ) ? esc_url( wc_get_page_permalink( 'shop' ) ) : home_url( '/' ),
399 - 'wcCartUrl' => wc_get_cart_url(),
400 - 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ),
401 - 'singleCartToastrText' => esc_html__( 'Successfully Added', 'shopbuilder' ),
402 - 'singleCartBtnText' => apply_filters( 'rtsb/global/single_add_to_cart_success', esc_html__( 'Added to Cart', 'shopbuilder' ) ),
403 - 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ),
404 - 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ),
405 - 'isOptimizationEnabled' => Fns::is_optimization_enabled(),
406 - 'isLoaderEnabled' => Fns::enable_loader(),
407 - 'notice' => [
326 + 'ajaxUrl' => esc_url( self::$ajaxurl ),
327 + 'homeurl' => home_url(),
328 + 'wcCartUrl' => wc_get_cart_url(),
329 + 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ),
330 + 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ),
331 + 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ),
332 + 'notice' => [
408 333 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ),
409 - 'timeOut' => absint( Fns::get_option( 'general', 'notification', 'notification_timeOut', 5 ) ),
410 334 ],
411 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
335 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
412 336 ]
413 337 );
414 338 }
415 339
@@ -422,20 +346,9 @@
422 346 /**
423 347 * Styles.
424 348 */
425 349 wp_register_style( 'rtsb-admin-app', rtsb()->get_assets_uri( 'css/backend/admin-settings.css' ), '', $this->version );
426 - wp_register_style( 'rtsb-fonts', rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ), '', $this->version );
427 -
428 - $current_screen = get_current_screen();
429 -
430 - if ( 'edit-rtsb_builder' === $current_screen->id ) {
431 - if ( ! function_exists( 'woocommerce_get_asset_url' ) ) {
432 - include_once WC_ABSPATH . 'includes/wc-template-functions.php';
433 - }
434 -
435 - wp_deregister_style( 'select2' );
436 - wp_register_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
437 - }
350 + // wp_register_style( 'rtsb-admin-global', rtsb()->get_assets_uri( 'css/backend/admin-global.css' ), '', $this->version );
438 351 wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
439 352
440 353 /**
441 354 * Scripts.
@@ -441,84 +354,33 @@
441 354 * Scripts.
442 355 */
443 356 wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
444 357 wp_register_script( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'js/backend/template-builder.js' ), '', $this->version, true );
445 - wp_localize_script(
446 - 'rtsb-admin-app',
447 - 'rtsbParams',
448 - [
449 - 'ajaxurl' => esc_url( self::$ajaxurl ),
450 - 'homeurl' => home_url(),
451 - 'adminLogo' => rtsb()->get_assets_uri( 'images/icon/ShopBuilder-Logo.svg' ),
452 - 'blackFriday' => rtsb()->get_assets_uri( 'images/black-friday-ribbon.svg' ),
453 - 'restApiUrl' => esc_url_raw( rest_url() ),
454 - 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
455 - 'nonce' => wp_create_nonce( rtsb()->nonceText ),
456 - 'pages' => Fns::get_pages(),
457 - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no',
458 - 'validLicence' => Fns::has_valid_license() ? 'yes' : 'no',
459 - 'proVersion' => defined( 'RTSBPRO_VERSION' ) ? RTSBPRO_VERSION : '0',
460 - 'updateRates' => esc_html__( 'Update All Rates', 'shopbuilder' ),
461 - 'sections' => Settings::instance()->get_sections(),
462 - 'userRoles' => Fns::get_all_user_roles(),
463 - 'hasElementor' => defined( 'ELEMENTOR_VERSION' ),
464 - 'loadElementor' => Fns::should_load_elementor_scripts(),
465 - 'isOptimizationEnabled' => Fns::is_optimization_enabled(),
466 - ]
467 - );
468 - wp_localize_script(
469 - 'rtsb-admin-app',
470 - 'rtsbCaAbandonment',
471 - [
472 - 'mainTitle' => esc_html__( 'Abandoned Carts Follow Up', 'shopbuilder' ),
473 - 'followUpColumnTitle' => [
474 - 'UserName' => esc_html__( 'Name', 'shopbuilder' ),
475 - 'EmailTo' => esc_html__( 'Email To', 'shopbuilder' ),
476 - 'CartTotal' => esc_html__( 'Cart Total', 'shopbuilder' ),
477 - 'OrderStatus' => esc_html__( 'Order Status', 'shopbuilder' ),
478 - 'DateTime' => esc_html__( 'Date / Time', 'shopbuilder' ),
479 - 'Action' => esc_html__( 'Action', 'shopbuilder' ),
480 - ],
481 - ]
482 - );
358 +
483 359 }
484 360
485 361 /**
486 362 * Enqueues admin scripts.
487 363 *
364 + * @param string $hook Hooks.
365 + *
488 366 * @return void
489 367 */
490 - public function enqueue_backend_scripts() {
368 + public function enqueue_backend_scripts( $hook ) {
491 369 ob_start(); ?>
492 370 #adminmenu .toplevel_page_rtsb .wp-menu-image img {
493 371 width: auto;
494 372 height: 22px;
495 373 padding: 4px 0;
496 - box-sizing: content-box;
497 374 }
498 - .post-type-rtsb_builder li#wp-admin-bar-WPML_ALS_all,
499 - .post-type-rtsb_builder li.language_all{
500 - display: none;
501 - }
502 -
503 375 <?php
504 376 $admin_global_style = ob_get_clean();
505 377 // Speed Optimization.
506 378 wp_add_inline_style( 'admin-menu', $admin_global_style );
379 + // wp_enqueue_style( 'rtsb-admin-global' );
507 380
508 381 global $pagenow;
509 382
510 - $whitelisted_pages = [ 'rtsb-settings', 'rtsb-get-help', 'rtsb-themes' ];
511 - $current_page = ! empty( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
512 -
513 - if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && in_array( $current_page, $whitelisted_pages, true ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
514 - /**
515 - * Styles.
516 - */
517 - wp_enqueue_style( 'rtsb-admin-app' );
518 - wp_enqueue_style( 'rtsb-fonts' );
519 - }
520 -
521 383 if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
522 384 // Elementor Console Error Fixed For "rtsb-settings" Page.
523 385 wp_dequeue_script( 'elementor-admin-top-bar' );
524 386 wp_dequeue_script( 'elementor-common' );
@@ -526,9 +388,8 @@
526 388 wp_dequeue_script( 'elementor-web-cli' );
527 389 wp_dequeue_script( 'elementor-import-export-admin' );
528 390 wp_dequeue_script( 'elementor-app-loader' );
529 391 wp_dequeue_script( 'elementor-admin-modules' );
530 - wp_dequeue_script( 'elementor-ai-media-library' );
531 392 wp_dequeue_script( 'elementor-admin' );
532 393
533 394 wp_dequeue_style( 'elementor-admin-top-bar' );
534 395 wp_dequeue_style( 'elementor-admin' );
@@ -535,13 +396,31 @@
535 396 wp_dequeue_style( 'e-theme-ui-light' );
536 397 wp_dequeue_style( 'elementor-common' );
537 398
538 399 /**
400 + * Styles.
401 + */
402 + wp_enqueue_style( 'rtsb-admin-app' );
403 +
404 + /**
539 405 * Scripts.
540 406 */
541 - wp_enqueue_media();
542 407 wp_enqueue_script( 'updates' );
543 408 wp_enqueue_script( 'rtsb-admin-app' );
409 + wp_localize_script(
410 + 'rtsb-admin-app',
411 + 'rtsbParams',
412 + [
413 + 'ajaxurl' => esc_url( self::$ajaxurl ),
414 + 'homeurl' => home_url(),
415 + 'restApiUrl' => esc_url_raw( rest_url() ),
416 + 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
417 + 'nonce' => wp_create_nonce( rtsb()->nonceText ),
418 + 'sections' => Settings::instance()->get_sections(),
419 + 'pages' => Fns::get_pages(),
420 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
421 + ]
422 + );
544 423 } else {
545 424 $current_screen = get_current_screen();
546 425
547 426 if ( 'edit-rtsb_builder' === $current_screen->id ) {
@@ -552,9 +431,9 @@
552 431 * Styles.
553 432 */
554 433 wp_enqueue_style( 'rtsb-templatebuilder' );
555 434
556 - wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
435 + wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) );
557 436
558 437 wp_enqueue_script( 'selectWoo' );
559 438 /**
560 439 * Scripts.
@@ -564,16 +443,12 @@
564 443 wp_localize_script(
565 444 'rtsb-templatebuilder',
566 445 'rtsbParams',
567 446 [
568 - 'ajaxurl' => esc_url( self::$ajaxurl ),
569 - 'homeurl' => home_url(),
570 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
571 - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no',
572 - 'singletonTypes' => apply_filters(
573 - 'rtsb/builder/singleton_types',
574 - array_keys( \RadiusTheme\SB\Helpers\BuilderFns::builder_page_types() )
575 - ),
447 + 'ajaxurl' => esc_url( self::$ajaxurl ),
448 + 'homeurl' => home_url(),
449 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
450 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
576 451 ]
577 452 );
578 453 }
579 454 }
@@ -593,9 +468,8 @@
593 468
594 469 if ( ! empty( $notification_color ) ) {
595 470 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}";
596 471 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success:before{background-color:{$notification_color}}";
597 - $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-close-button{color:{$notification_color}}";
598 472 }
599 473
600 474 if ( ! empty( $notification_bgcolor ) ) {
601 475 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}";
@@ -605,33 +479,8 @@
605 479 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}";
606 480 }
607 481
608 482 if ( ! empty( $dynamic_css ) ) {
609 - wp_add_inline_style( Fns::optimized_handle( 'rtsb-frontend' ), $dynamic_css );
483 + wp_add_inline_style( 'rtsb-frontend', $dynamic_css );
610 484 }
611 - }
612 -
613 - /**
614 - * Get the appropriate Swiper JS file URL.
615 - *
616 - * @return string
617 - */
618 - private function get_swiper_url() {
619 - $default_swiper_url = rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' );
620 -
621 - if ( defined( 'ELEMENTOR_ASSETS_PATH' ) && defined( 'ELEMENTOR_ASSETS_URL' ) ) {
622 - $experiment = get_option( 'elementor_experiment-e_swiper_latest' );
623 -
624 - $el_relative_path = ( 'active' === $experiment || 'default' === $experiment )
625 - ? 'lib/swiper/v8/swiper.min.js'
626 - : 'lib/swiper/swiper.min.js';
627 -
628 - $el_full_path = ELEMENTOR_ASSETS_PATH . $el_relative_path;
629 -
630 - if ( file_exists( $el_full_path ) ) {
631 - return ELEMENTOR_ASSETS_URL . $el_relative_path;
632 - }
633 - }
634 -
635 - return $default_swiper_url;
636 485 }
637 486 }