PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.4.2
ShopBuilder – WooCommerce Builder For Elementor v3.4.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 +262 -102 2.0.33.4.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,33 @@
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 - ];
141 + $optimized = [];
112 142
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 + }
113 163 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
114 164 $this->styles[] = [
115 165 'handle' => 'photoswipe',
116 166 'src' => plugins_url( 'assets/css/photoswipe/photoswipe.min.css', WC_PLUGIN_FILE ),
@@ -136,40 +186,26 @@
136 186 *
137 187 * @return object
138 188 */
139 189 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 190 $this->scripts[] = [
160 191 'handle' => 'swiper',
161 - 'src' => esc_url( $default_swiper_path ),
192 + 'src' => esc_url( $this->get_swiper_url() ),
162 193 'deps' => [ 'jquery' ],
163 194 'footer' => true,
164 195 ];
165 -
166 196 $this->scripts[] = [
167 - 'handle' => 'rtsb-imagesloaded',
168 - 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ),
197 + 'handle' => 'rtsb-waypoints',
198 + 'src' => rtsb()->get_assets_uri( 'vendor/waypoints/js/jquery.waypoints.min.js' ),
169 199 'deps' => [ 'jquery' ],
170 200 'footer' => true,
171 201 ];
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 + ];
172 208
173 209 $this->scripts[] = [
174 210 'handle' => 'rtsb-tipsy',
175 211 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
@@ -178,9 +214,9 @@
178 214 ];
179 215
180 216 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
181 217 $this->scripts[] = [
182 - 'handle' => 'flexslider',
218 + 'handle' => 'wc-flexslider',
183 219 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
184 220 'deps' => [ 'jquery' ],
185 221 'footer' => true,
186 222 ];
@@ -192,9 +228,9 @@
192 228 'footer' => true,
193 229 ];
194 230
195 231 $this->scripts[] = [
196 - 'handle' => 'zoom',
232 + 'handle' => 'wc-zoom',
197 233 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
198 234 'deps' => [ 'jquery' ],
199 235 'footer' => true,
200 236 ];
@@ -199,9 +235,9 @@
199 235 'footer' => true,
200 236 ];
201 237
202 238 $this->scripts[] = [
203 - 'handle' => 'photoswipe-ui-default',
239 + 'handle' => 'wc-photoswipe-ui-default',
204 240 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
205 241 'deps' => [ 'jquery', 'photoswipe' ],
206 242 'footer' => true,
207 243 ];
@@ -208,9 +244,9 @@
208 244
209 245 $this->scripts[] = [
210 246 'handle' => 'wc-single-product',
211 247 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
212 - 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
248 + 'deps' => [ 'jquery', 'wc-flexslider', 'photoswipe', 'wc-photoswipe-ui-default', 'wc-zoom' ],
213 249 'footer' => true,
214 250 ];
215 251
216 252 }
@@ -228,17 +264,42 @@
228 264 'src' => rtsbpro()->get_assets_uri( 'vendors/sticky-sidebar/sticky-sidebar.min.js' ),
229 265 'deps' => [ 'jquery' ],
230 266 'footer' => true,
231 267 ];
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 + ];
232 282 }
233 283
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 - ];
284 + $optimized = [];
240 285
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 +
241 302 return $this;
242 303 }
243 304
244 305 /**
@@ -247,8 +308,10 @@
247 308 * @return void
248 309 */
249 310 public function register_public_scripts() {
250 311 $this->get_public_assets();
312 + $this->styles = array_filter( $this->styles );
313 + $this->scripts = array_filter( $this->scripts );
251 314
252 315 // Register public styles.
253 316 foreach ( $this->styles as $style ) {
254 317 wp_register_style( $style['handle'], $style['src'], '', $this->version );
@@ -269,8 +332,9 @@
269 332 /**
270 333 * Register scripts.
271 334 */
272 335 $this->register_public_scripts();
336 +
273 337 /**
274 338 * Enqueue scripts.
275 339 */
276 340 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
@@ -276,9 +340,8 @@
276 340 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
277 341 /**
278 342 * Styles.
279 343 */
280 - wp_enqueue_style( 'swiper' );
281 344 wp_enqueue_style( 'photoswipe' );
282 345 wp_enqueue_style( 'photoswipe-default-skin' );
283 346 wp_enqueue_style( 'elementor-editor-style-fix' );
284 347 wp_enqueue_style( 'woocommerce-general' );
@@ -285,27 +348,31 @@
285 348
286 349 /**
287 350 * Scripts.
288 351 */
289 - wp_enqueue_script( 'flexslider' );
352 + $handle = Fns::optimized_handle( 'rtsb-public' );
353 +
354 + wp_enqueue_script( 'wc-flexslider' );
290 355 wp_enqueue_script( 'wc-single-product' );
291 - wp_dequeue_script( 'rtsb-public' );
356 + wp_dequeue_script( $handle );
292 357 wp_enqueue_script( 'swiper' );
293 - wp_enqueue_script( 'rtsb-public' );
358 +
359 + if ( Fns::is_optimization_enabled() ) {
360 + Fns::enqueue_optimized_assets();
361 + } else {
362 + wp_enqueue_script( $handle );
363 + }
294 364 }
295 365
296 - /**
297 - * Styles.
298 - */
299 - wp_enqueue_style( 'rtsb-fonts' );
300 - wp_enqueue_style( 'rtsb-frontend' );
366 + wp_enqueue_script( 'rtsb-tipsy' );
301 367
302 - /**
303 - * Scripts.
304 - */
305 - wp_enqueue_script( 'rtsb-imagesloaded' );
306 - wp_enqueue_script( 'rtsb-tipsy' );
307 - wp_enqueue_script( 'rtsb-public' );
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 + }
308 375
309 376 /**
310 377 * Localize script.
311 378 */
@@ -318,22 +385,31 @@
318 385 * @static
319 386 * @return void
320 387 */
321 388 public static function localizeData() {
389 + $handle = Fns::optimized_handle( 'rtsb-public' );
390 + $ai_data = AIFns::activated_ai_data();
322 391 wp_localize_script(
323 - 'rtsb-public',
392 + $handle,
324 393 'rtsbPublicParams',
325 394 [
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' => [
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' => [
333 408 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ),
409 + 'timeOut' => absint( Fns::get_option( 'general', 'notification', 'notification_timeOut', 5 ) ),
334 410 ],
335 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
411 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
336 412 ]
337 413 );
338 414 }
339 415
@@ -346,9 +422,20 @@
346 422 /**
347 423 * Styles.
348 424 */
349 425 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 );
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 + }
351 438 wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
352 439
353 440 /**
354 441 * Scripts.
@@ -354,25 +441,85 @@
354 441 * Scripts.
355 442 */
356 443 wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
357 444 wp_register_script( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'js/backend/template-builder.js' ), '', $this->version, true );
358 -
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 + );
359 483 }
360 484
361 485 /**
362 486 * Enqueues admin scripts.
363 487 *
364 - * @param string $hook Hooks.
365 - *
366 488 * @return void
367 489 */
368 - public function enqueue_backend_scripts( $hook ) {
490 + public function enqueue_backend_scripts() {
491 + ob_start(); ?>
492 + #adminmenu .toplevel_page_rtsb .wp-menu-image img {
493 + width: auto;
494 + height: 22px;
495 + padding: 4px 0;
496 + box-sizing: content-box;
497 + }
498 + .post-type-rtsb_builder li#wp-admin-bar-WPML_ALS_all,
499 + .post-type-rtsb_builder li.language_all{
500 + display: none;
501 + }
369 502
370 - wp_enqueue_style( 'rtsb-admin-global' );
503 + <?php
504 + $admin_global_style = ob_get_clean();
505 + // Speed Optimization.
506 + wp_add_inline_style( 'admin-menu', $admin_global_style );
371 507
372 508 global $pagenow;
373 509
374 - if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) {
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 + if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
375 522 // Elementor Console Error Fixed For "rtsb-settings" Page.
376 523 wp_dequeue_script( 'elementor-admin-top-bar' );
377 524 wp_dequeue_script( 'elementor-common' );
378 525 wp_dequeue_script( 'elementor-dev-tools' );
@@ -379,8 +526,9 @@
379 526 wp_dequeue_script( 'elementor-web-cli' );
380 527 wp_dequeue_script( 'elementor-import-export-admin' );
381 528 wp_dequeue_script( 'elementor-app-loader' );
382 529 wp_dequeue_script( 'elementor-admin-modules' );
530 + wp_dequeue_script( 'elementor-ai-media-library' );
383 531 wp_dequeue_script( 'elementor-admin' );
384 532
385 533 wp_dequeue_style( 'elementor-admin-top-bar' );
386 534 wp_dequeue_style( 'elementor-admin' );
@@ -387,31 +535,13 @@
387 535 wp_dequeue_style( 'e-theme-ui-light' );
388 536 wp_dequeue_style( 'elementor-common' );
389 537
390 538 /**
391 - * Styles.
392 - */
393 - wp_enqueue_style( 'rtsb-admin-app' );
394 -
395 - /**
396 539 * Scripts.
397 540 */
541 + wp_enqueue_media();
398 542 wp_enqueue_script( 'updates' );
399 543 wp_enqueue_script( 'rtsb-admin-app' );
400 - wp_localize_script(
401 - 'rtsb-admin-app',
402 - 'rtsbParams',
403 - [
404 - 'ajaxurl' => esc_url( self::$ajaxurl ),
405 - 'homeurl' => home_url(),
406 - 'restApiUrl' => esc_url_raw( rest_url() ),
407 - 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
408 - 'nonce' => wp_create_nonce( rtsb()->nonceText ),
409 - 'sections' => Settings::instance()->get_sections(),
410 - 'pages' => Fns::get_pages(),
411 - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
412 - ]
413 - );
414 544 } else {
415 545 $current_screen = get_current_screen();
416 546
417 547 if ( 'edit-rtsb_builder' === $current_screen->id ) {
@@ -422,9 +552,9 @@
422 552 * Styles.
423 553 */
424 554 wp_enqueue_style( 'rtsb-templatebuilder' );
425 555
426 - wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) );
556 + wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
427 557
428 558 wp_enqueue_script( 'selectWoo' );
429 559 /**
430 560 * Scripts.
@@ -434,12 +564,16 @@
434 564 wp_localize_script(
435 565 'rtsb-templatebuilder',
436 566 'rtsbParams',
437 567 [
438 - 'ajaxurl' => esc_url( self::$ajaxurl ),
439 - 'homeurl' => home_url(),
440 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
441 - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
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 + ),
442 576 ]
443 577 );
444 578 }
445 579 }
@@ -459,8 +593,9 @@
459 593
460 594 if ( ! empty( $notification_color ) ) {
461 595 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}";
462 596 $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}}";
463 598 }
464 599
465 600 if ( ! empty( $notification_bgcolor ) ) {
466 601 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}";
@@ -470,8 +605,33 @@
470 605 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}";
471 606 }
472 607
473 608 if ( ! empty( $dynamic_css ) ) {
474 - wp_add_inline_style( 'rtsb-frontend', $dynamic_css );
609 + wp_add_inline_style( Fns::optimized_handle( 'rtsb-frontend' ), $dynamic_css );
475 610 }
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;
476 636 }
477 637 }