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