PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 3.3.0
ShopBuilder – WooCommerce Builder For Elementor v3.3.0
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 +232 -105 2.1.143.3.0 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 */
@@ -86,14 +115,20 @@
86 115 *
87 116 * @return object
88 117 */
89 118 private function get_public_styles() {
90 - $rtl_suffix = is_rtl() ? '-rtl' : '';
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 ),
@@ -136,40 +178,26 @@
136 178 *
137 179 * @return object
138 180 */
139 181 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 182 $this->scripts[] = [
160 183 'handle' => 'swiper',
161 - 'src' => esc_url( $default_swiper_path ),
184 + 'src' => esc_url( $this->get_swiper_url() ),
162 185 'deps' => [ 'jquery' ],
163 186 'footer' => true,
164 187 ];
165 -
166 188 $this->scripts[] = [
167 - 'handle' => 'rtsb-imagesloaded',
168 - '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' ),
169 191 'deps' => [ 'jquery' ],
170 192 'footer' => true,
171 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 + ];
172 200
173 201 $this->scripts[] = [
174 202 'handle' => 'rtsb-tipsy',
175 203 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
@@ -178,9 +206,9 @@
178 206 ];
179 207
180 208 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
181 209 $this->scripts[] = [
182 - 'handle' => 'flexslider',
210 + 'handle' => 'wc-flexslider',
183 211 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
184 212 'deps' => [ 'jquery' ],
185 213 'footer' => true,
186 214 ];
@@ -192,9 +220,9 @@
192 220 'footer' => true,
193 221 ];
194 222
195 223 $this->scripts[] = [
196 - 'handle' => 'zoom',
224 + 'handle' => 'wc-zoom',
197 225 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
198 226 'deps' => [ 'jquery' ],
199 227 'footer' => true,
200 228 ];
@@ -199,9 +227,9 @@
199 227 'footer' => true,
200 228 ];
201 229
202 230 $this->scripts[] = [
203 - 'handle' => 'photoswipe-ui-default',
231 + 'handle' => 'wc-photoswipe-ui-default',
204 232 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
205 233 'deps' => [ 'jquery', 'photoswipe' ],
206 234 'footer' => true,
207 235 ];
@@ -208,9 +236,9 @@
208 236
209 237 $this->scripts[] = [
210 238 'handle' => 'wc-single-product',
211 239 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
212 - 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
240 + 'deps' => [ 'jquery', 'wc-flexslider', 'photoswipe', 'wc-photoswipe-ui-default', 'wc-zoom' ],
213 241 'footer' => true,
214 242 ];
215 243
216 244 }
@@ -228,16 +256,34 @@
228 256 'src' => rtsbpro()->get_assets_uri( 'vendors/sticky-sidebar/sticky-sidebar.min.js' ),
229 257 'deps' => [ 'jquery' ],
230 258 'footer' => true,
231 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 + ];
232 274 }
233 275
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 - ];
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 + }
240 286
241 287 return $this;
242 288 }
243 289
@@ -247,8 +293,10 @@
247 293 * @return void
248 294 */
249 295 public function register_public_scripts() {
250 296 $this->get_public_assets();
297 + $this->styles = array_filter( $this->styles );
298 + $this->scripts = array_filter( $this->scripts );
251 299
252 300 // Register public styles.
253 301 foreach ( $this->styles as $style ) {
254 302 wp_register_style( $style['handle'], $style['src'], '', $this->version );
@@ -269,8 +317,9 @@
269 317 /**
270 318 * Register scripts.
271 319 */
272 320 $this->register_public_scripts();
321 +
273 322 /**
274 323 * Enqueue scripts.
275 324 */
276 325 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
@@ -276,9 +325,8 @@
276 325 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
277 326 /**
278 327 * Styles.
279 328 */
280 - wp_enqueue_style( 'swiper' );
281 329 wp_enqueue_style( 'photoswipe' );
282 330 wp_enqueue_style( 'photoswipe-default-skin' );
283 331 wp_enqueue_style( 'elementor-editor-style-fix' );
284 332 wp_enqueue_style( 'woocommerce-general' );
@@ -285,27 +333,31 @@
285 333
286 334 /**
287 335 * Scripts.
288 336 */
289 - wp_enqueue_script( 'flexslider' );
337 + $handle = Fns::optimized_handle( 'rtsb-public' );
338 +
339 + wp_enqueue_script( 'wc-flexslider' );
290 340 wp_enqueue_script( 'wc-single-product' );
291 - wp_dequeue_script( 'rtsb-public' );
341 + wp_dequeue_script( $handle );
292 342 wp_enqueue_script( 'swiper' );
293 - 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 + }
294 349 }
295 350
296 - /**
297 - * Styles.
298 - */
299 - wp_enqueue_style( 'rtsb-fonts' );
300 - wp_enqueue_style( 'rtsb-frontend' );
351 + wp_enqueue_script( 'rtsb-tipsy' );
301 352
302 - /**
303 - * Scripts.
304 - */
305 - wp_enqueue_script( 'rtsb-imagesloaded' );
306 - wp_enqueue_script( 'rtsb-tipsy' );
307 - 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 + }
308 360
309 361 /**
310 362 * Localize script.
311 363 */
@@ -318,24 +370,31 @@
318 370 * @static
319 371 * @return void
320 372 */
321 373 public static function localizeData() {
374 + $handle = Fns::optimized_handle( 'rtsb-public' );
375 + $ai_data = AIFns::activated_ai_data();
322 376 wp_localize_script(
323 - 'rtsb-public',
377 + $handle,
324 378 'rtsbPublicParams',
325 379 [
326 - 'ajaxUrl' => esc_url( self::$ajaxurl ),
327 - 'homeurl' => home_url(),
328 - 'wcCartUrl' => wc_get_cart_url(),
329 - 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ),
330 - 'singleCartToastrText' => esc_html__( 'Successfully Added', 'shopbuilder' ),
331 - 'singleCartBtnText' => apply_filters( 'rtsb/global/single_add_to_cart_success', esc_html__( 'Added to Cart', 'shopbuilder' ) ),
332 - 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ),
333 - 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ),
334 - 'notice' => [
380 + 'ajaxUrl' => esc_url( self::$ajaxurl ),
381 + 'aiActivated' => ! empty( $ai_data ),
382 + 'homeurl' => home_url(),
383 + 'shopUrl' => function_exists( 'wc_get_page_permalink' ) ? esc_url( wc_get_page_permalink( 'shop' ) ) : home_url( '/' ),
384 + 'wcCartUrl' => wc_get_cart_url(),
385 + 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ),
386 + 'singleCartToastrText' => esc_html__( 'Successfully Added', 'shopbuilder' ),
387 + 'singleCartBtnText' => apply_filters( 'rtsb/global/single_add_to_cart_success', esc_html__( 'Added to Cart', 'shopbuilder' ) ),
388 + 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ),
389 + 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ),
390 + 'isOptimizationEnabled' => Fns::is_optimization_enabled(),
391 + 'isLoaderEnabled' => Fns::enable_loader(),
392 + 'notice' => [
335 393 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ),
394 + 'timeOut' => absint( Fns::get_option( 'general', 'notification', 'notification_timeOut', 5 ) ),
336 395 ],
337 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
396 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
338 397 ]
339 398 );
340 399 }
341 400
@@ -349,9 +408,19 @@
349 408 * Styles.
350 409 */
351 410 wp_register_style( 'rtsb-admin-app', rtsb()->get_assets_uri( 'css/backend/admin-settings.css' ), '', $this->version );
352 411 wp_register_style( 'rtsb-fonts', rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ), '', $this->version );
353 - // wp_register_style( 'rtsb-admin-global', rtsb()->get_assets_uri( 'css/backend/admin-global.css' ), '', $this->version );
412 +
413 + $current_screen = get_current_screen();
414 +
415 + if ( 'edit-rtsb_builder' === $current_screen->id ) {
416 + if ( ! function_exists( 'woocommerce_get_asset_url' ) ) {
417 + include_once WC_ABSPATH . 'includes/wc-template-functions.php';
418 + }
419 +
420 + wp_deregister_style( 'select2' );
421 + wp_register_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
422 + }
354 423 wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
355 424
356 425 /**
357 426 * Scripts.
@@ -357,23 +426,60 @@
357 426 * Scripts.
358 427 */
359 428 wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
360 429 wp_register_script( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'js/backend/template-builder.js' ), '', $this->version, true );
430 + wp_localize_script(
431 + 'rtsb-admin-app',
432 + 'rtsbParams',
433 + [
434 + 'ajaxurl' => esc_url( self::$ajaxurl ),
435 + 'homeurl' => home_url(),
436 + 'adminLogo' => rtsb()->get_assets_uri( 'images/icon/ShopBuilder-Logo.svg' ),
437 + 'blackFriday' => rtsb()->get_assets_uri( 'images/black-friday-ribbon.svg' ),
438 + 'restApiUrl' => esc_url_raw( rest_url() ),
439 + 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
440 + 'nonce' => wp_create_nonce( rtsb()->nonceText ),
441 + 'pages' => Fns::get_pages(),
442 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no',
443 + 'validLicence' => Fns::has_valid_license() ? 'yes' : 'no',
444 + 'proVersion' => defined( 'RTSBPRO_VERSION' ) ? RTSBPRO_VERSION : '0',
445 + 'updateRates' => esc_html__( 'Update All Rates', 'shopbuilder' ),
446 + 'sections' => Settings::instance()->get_sections(),
447 + 'userRoles' => Fns::get_all_user_roles(),
448 + 'hasElementor' => defined( 'ELEMENTOR_VERSION' ),
449 + 'loadElementor' => Fns::should_load_elementor_scripts(),
450 + 'isOptimizationEnabled' => Fns::is_optimization_enabled(),
451 + ]
452 + );
453 + wp_localize_script(
454 + 'rtsb-admin-app',
455 + 'rtsbCaAbandonment',
456 + [
457 + 'mainTitle' => esc_html__( 'Abandoned Carts Follow Up', 'shopbuilder' ),
458 + 'followUpColumnTitle' => [
459 + 'UserName' => esc_html__( 'Name', 'shopbuilder' ),
460 + 'EmailTo' => esc_html__( 'Email To', 'shopbuilder' ),
461 + 'CartTotal' => esc_html__( 'Cart Total', 'shopbuilder' ),
462 + 'OrderStatus' => esc_html__( 'Order Status', 'shopbuilder' ),
463 + 'DateTime' => esc_html__( 'Date / Time', 'shopbuilder' ),
464 + 'Action' => esc_html__( 'Action', 'shopbuilder' ),
465 + ],
466 + ]
467 + );
361 468 }
362 469
363 470 /**
364 471 * Enqueues admin scripts.
365 472 *
366 - * @param string $hook Hooks.
367 - *
368 473 * @return void
369 474 */
370 - public function enqueue_backend_scripts( $hook ) {
475 + public function enqueue_backend_scripts() {
371 476 ob_start(); ?>
372 477 #adminmenu .toplevel_page_rtsb .wp-menu-image img {
373 478 width: auto;
374 479 height: 22px;
375 480 padding: 4px 0;
481 + box-sizing: content-box;
376 482 }
377 483 .post-type-rtsb_builder li#wp-admin-bar-WPML_ALS_all,
378 484 .post-type-rtsb_builder li.language_all{
379 485 display: none;
@@ -382,12 +488,22 @@
382 488 <?php
383 489 $admin_global_style = ob_get_clean();
384 490 // Speed Optimization.
385 491 wp_add_inline_style( 'admin-menu', $admin_global_style );
386 - // wp_enqueue_style( 'rtsb-admin-global' );
387 492
388 493 global $pagenow;
389 494
495 + $whitelisted_pages = [ 'rtsb-settings', 'rtsb-get-help', 'rtsb-themes' ];
496 + $current_page = ! empty( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended
497 +
498 + if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && in_array( $current_page, $whitelisted_pages, true ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
499 + /**
500 + * Styles.
501 + */
502 + wp_enqueue_style( 'rtsb-admin-app' );
503 + wp_enqueue_style( 'rtsb-fonts' );
504 + }
505 +
390 506 if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
391 507 // Elementor Console Error Fixed For "rtsb-settings" Page.
392 508 wp_dequeue_script( 'elementor-admin-top-bar' );
393 509 wp_dequeue_script( 'elementor-common' );
@@ -395,8 +511,9 @@
395 511 wp_dequeue_script( 'elementor-web-cli' );
396 512 wp_dequeue_script( 'elementor-import-export-admin' );
397 513 wp_dequeue_script( 'elementor-app-loader' );
398 514 wp_dequeue_script( 'elementor-admin-modules' );
515 + wp_dequeue_script( 'elementor-ai-media-library' );
399 516 wp_dequeue_script( 'elementor-admin' );
400 517
401 518 wp_dequeue_style( 'elementor-admin-top-bar' );
402 519 wp_dequeue_style( 'elementor-admin' );
@@ -403,33 +520,13 @@
403 520 wp_dequeue_style( 'e-theme-ui-light' );
404 521 wp_dequeue_style( 'elementor-common' );
405 522
406 523 /**
407 - * Styles.
408 - */
409 - wp_enqueue_style( 'rtsb-admin-app' );
410 - wp_enqueue_style( 'rtsb-fonts' );
411 -
412 - /**
413 524 * Scripts.
414 525 */
526 + wp_enqueue_media();
415 527 wp_enqueue_script( 'updates' );
416 528 wp_enqueue_script( 'rtsb-admin-app' );
417 - wp_localize_script(
418 - 'rtsb-admin-app',
419 - 'rtsbParams',
420 - [
421 - 'ajaxurl' => esc_url( self::$ajaxurl ),
422 - 'homeurl' => home_url(),
423 - 'adminLogo' => rtsb()->get_assets_uri( 'images/icon/ShopBuilder-Logo.svg' ),
424 - 'restApiUrl' => esc_url_raw( rest_url() ),
425 - 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
426 - 'nonce' => wp_create_nonce( rtsb()->nonceText ),
427 - 'sections' => Settings::instance()->get_sections(),
428 - 'pages' => Fns::get_pages(),
429 - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no',
430 - ]
431 - );
432 529 } else {
433 530 $current_screen = get_current_screen();
434 531
435 532 if ( 'edit-rtsb_builder' === $current_screen->id ) {
@@ -452,12 +549,16 @@
452 549 wp_localize_script(
453 550 'rtsb-templatebuilder',
454 551 'rtsbParams',
455 552 [
456 - 'ajaxurl' => esc_url( self::$ajaxurl ),
457 - 'homeurl' => home_url(),
458 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
459 - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no',
553 + 'ajaxurl' => esc_url( self::$ajaxurl ),
554 + 'homeurl' => home_url(),
555 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
556 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no',
557 + 'singletonTypes' => apply_filters(
558 + 'rtsb/builder/singleton_types',
559 + array_keys( \RadiusTheme\SB\Helpers\BuilderFns::builder_page_types() )
560 + ),
460 561 ]
461 562 );
462 563 }
463 564 }
@@ -477,8 +578,9 @@
477 578
478 579 if ( ! empty( $notification_color ) ) {
479 580 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}";
480 581 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success:before{background-color:{$notification_color}}";
582 + $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-close-button{color:{$notification_color}}";
481 583 }
482 584
483 585 if ( ! empty( $notification_bgcolor ) ) {
484 586 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}";
@@ -488,8 +590,33 @@
488 590 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}";
489 591 }
490 592
491 593 if ( ! empty( $dynamic_css ) ) {
492 - wp_add_inline_style( 'rtsb-frontend', $dynamic_css );
594 + wp_add_inline_style( Fns::optimized_handle( 'rtsb-frontend' ), $dynamic_css );
493 595 }
596 + }
597 +
598 + /**
599 + * Get the appropriate Swiper JS file URL.
600 + *
601 + * @return string
602 + */
603 + private function get_swiper_url() {
604 + $default_swiper_url = rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' );
605 +
606 + if ( defined( 'ELEMENTOR_ASSETS_PATH' ) && defined( 'ELEMENTOR_ASSETS_URL' ) ) {
607 + $experiment = get_option( 'elementor_experiment-e_swiper_latest' );
608 +
609 + $el_relative_path = ( 'active' === $experiment || 'default' === $experiment )
610 + ? 'lib/swiper/v8/swiper.min.js'
611 + : 'lib/swiper/swiper.min.js';
612 +
613 + $el_full_path = ELEMENTOR_ASSETS_PATH . $el_relative_path;
614 +
615 + if ( file_exists( $el_full_path ) ) {
616 + return ELEMENTOR_ASSETS_URL . $el_relative_path;
617 + }
618 + }
619 +
620 + return $default_swiper_url;
494 621 }
495 622 }