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