PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.2
ShopBuilder – WooCommerce Builder For Elementor v2.0.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 +83 -262 3.4.22.0.2 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 ),
@@ -188,24 +138,19 @@
188 138 */
189 139 private function get_public_scripts() {
190 140 $this->scripts[] = [
191 141 'handle' => 'swiper',
192 - 'src' => esc_url( $this->get_swiper_url() ),
142 + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' ),
193 143 'deps' => [ 'jquery' ],
194 144 'footer' => true,
195 145 ];
146 +
196 147 $this->scripts[] = [
197 - 'handle' => 'rtsb-waypoints',
198 - 'src' => rtsb()->get_assets_uri( 'vendor/waypoints/js/jquery.waypoints.min.js' ),
148 + 'handle' => 'rtsb-imagesloaded',
149 + 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ),
199 150 'deps' => [ 'jquery' ],
200 151 'footer' => true,
201 152 ];
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 153
209 154 $this->scripts[] = [
210 155 'handle' => 'rtsb-tipsy',
211 156 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
@@ -214,9 +159,9 @@
214 159 ];
215 160
216 161 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
217 162 $this->scripts[] = [
218 - 'handle' => 'wc-flexslider',
163 + 'handle' => 'flexslider',
219 164 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
220 165 'deps' => [ 'jquery' ],
221 166 'footer' => true,
222 167 ];
@@ -228,9 +173,9 @@
228 173 'footer' => true,
229 174 ];
230 175
231 176 $this->scripts[] = [
232 - 'handle' => 'wc-zoom',
177 + 'handle' => 'zoom',
233 178 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
234 179 'deps' => [ 'jquery' ],
235 180 'footer' => true,
236 181 ];
@@ -235,9 +180,9 @@
235 180 'footer' => true,
236 181 ];
237 182
238 183 $this->scripts[] = [
239 - 'handle' => 'wc-photoswipe-ui-default',
184 + 'handle' => 'photoswipe-ui-default',
240 185 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
241 186 'deps' => [ 'jquery', 'photoswipe' ],
242 187 'footer' => true,
243 188 ];
@@ -244,9 +189,9 @@
244 189
245 190 $this->scripts[] = [
246 191 'handle' => 'wc-single-product',
247 192 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
248 - 'deps' => [ 'jquery', 'wc-flexslider', 'photoswipe', 'wc-photoswipe-ui-default', 'wc-zoom' ],
193 + 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
249 194 'footer' => true,
250 195 ];
251 196
252 197 }
@@ -264,42 +209,17 @@
264 209 'src' => rtsbpro()->get_assets_uri( 'vendors/sticky-sidebar/sticky-sidebar.min.js' ),
265 210 'deps' => [ 'jquery' ],
266 211 'footer' => true,
267 212 ];
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 213 }
283 214
284 - $optimized = [];
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 + ];
285 221
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 222 return $this;
303 223 }
304 224
305 225 /**
@@ -308,10 +228,8 @@
308 228 * @return void
309 229 */
310 230 public function register_public_scripts() {
311 231 $this->get_public_assets();
312 - $this->styles = array_filter( $this->styles );
313 - $this->scripts = array_filter( $this->scripts );
314 232
315 233 // Register public styles.
316 234 foreach ( $this->styles as $style ) {
317 235 wp_register_style( $style['handle'], $style['src'], '', $this->version );
@@ -332,9 +250,8 @@
332 250 /**
333 251 * Register scripts.
334 252 */
335 253 $this->register_public_scripts();
336 -
337 254 /**
338 255 * Enqueue scripts.
339 256 */
340 257 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
@@ -340,8 +257,9 @@
340 257 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
341 258 /**
342 259 * Styles.
343 260 */
261 + wp_enqueue_style( 'swiper' );
344 262 wp_enqueue_style( 'photoswipe' );
345 263 wp_enqueue_style( 'photoswipe-default-skin' );
346 264 wp_enqueue_style( 'elementor-editor-style-fix' );
347 265 wp_enqueue_style( 'woocommerce-general' );
@@ -348,32 +266,28 @@
348 266
349 267 /**
350 268 * Scripts.
351 269 */
352 - $handle = Fns::optimized_handle( 'rtsb-public' );
353 -
354 - wp_enqueue_script( 'wc-flexslider' );
270 + wp_enqueue_script( 'flexslider' );
355 271 wp_enqueue_script( 'wc-single-product' );
356 - wp_dequeue_script( $handle );
272 + wp_dequeue_script( 'rtsb-public' );
357 273 wp_enqueue_script( 'swiper' );
274 + wp_enqueue_script( 'rtsb-public' );
275 + }
358 276
359 - if ( Fns::is_optimization_enabled() ) {
360 - Fns::enqueue_optimized_assets();
361 - } else {
362 - wp_enqueue_script( $handle );
363 - }
364 - }
277 + /**
278 + * Styles.
279 + */
280 + wp_enqueue_style( 'rtsb-fonts' );
281 + wp_enqueue_style( 'rtsb-frontend' );
365 282
283 + /**
284 + * Scripts.
285 + */
286 + wp_enqueue_script( 'rtsb-imagesloaded' );
366 287 wp_enqueue_script( 'rtsb-tipsy' );
288 + wp_enqueue_script( 'rtsb-public' );
367 289
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 290 /**
377 291 * Localize script.
378 292 */
379 293 self::localizeData();
@@ -385,31 +299,22 @@
385 299 * @static
386 300 * @return void
387 301 */
388 302 public static function localizeData() {
389 - $handle = Fns::optimized_handle( 'rtsb-public' );
390 - $ai_data = AIFns::activated_ai_data();
391 303 wp_localize_script(
392 - $handle,
304 + 'rtsb-public',
393 305 'rtsbPublicParams',
394 306 [
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' => [
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' => [
408 314 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ),
409 - 'timeOut' => absint( Fns::get_option( 'general', 'notification', 'notification_timeOut', 5 ) ),
410 315 ],
411 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
316 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
412 317 ]
413 318 );
414 319 }
415 320
@@ -422,20 +327,9 @@
422 327 /**
423 328 * Styles.
424 329 */
425 330 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 - }
331 + wp_register_style( 'rtsb-admin-global', rtsb()->get_assets_uri( 'css/backend/admin-global.css' ), '', $this->version );
438 332 wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
439 333
440 334 /**
441 335 * Scripts.
@@ -441,85 +335,25 @@
441 335 * Scripts.
442 336 */
443 337 wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
444 338 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 - );
339 +
483 340 }
484 341
485 342 /**
486 343 * Enqueues admin scripts.
487 344 *
345 + * @param string $hook Hooks.
346 + *
488 347 * @return void
489 348 */
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 - }
349 + public function enqueue_backend_scripts( $hook ) {
502 350
503 - <?php
504 - $admin_global_style = ob_get_clean();
505 - // Speed Optimization.
506 - wp_add_inline_style( 'admin-menu', $admin_global_style );
351 + wp_enqueue_style( 'rtsb-admin-global' );
507 352
508 353 global $pagenow;
509 354
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
355 + if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) {
522 356 // Elementor Console Error Fixed For "rtsb-settings" Page.
523 357 wp_dequeue_script( 'elementor-admin-top-bar' );
524 358 wp_dequeue_script( 'elementor-common' );
525 359 wp_dequeue_script( 'elementor-dev-tools' );
@@ -526,9 +360,8 @@
526 360 wp_dequeue_script( 'elementor-web-cli' );
527 361 wp_dequeue_script( 'elementor-import-export-admin' );
528 362 wp_dequeue_script( 'elementor-app-loader' );
529 363 wp_dequeue_script( 'elementor-admin-modules' );
530 - wp_dequeue_script( 'elementor-ai-media-library' );
531 364 wp_dequeue_script( 'elementor-admin' );
532 365
533 366 wp_dequeue_style( 'elementor-admin-top-bar' );
534 367 wp_dequeue_style( 'elementor-admin' );
@@ -535,13 +368,31 @@
535 368 wp_dequeue_style( 'e-theme-ui-light' );
536 369 wp_dequeue_style( 'elementor-common' );
537 370
538 371 /**
372 + * Styles.
373 + */
374 + wp_enqueue_style( 'rtsb-admin-app' );
375 +
376 + /**
539 377 * Scripts.
540 378 */
541 - wp_enqueue_media();
542 379 wp_enqueue_script( 'updates' );
543 380 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 + );
544 395 } else {
545 396 $current_screen = get_current_screen();
546 397
547 398 if ( 'edit-rtsb_builder' === $current_screen->id ) {
@@ -552,9 +403,9 @@
552 403 * Styles.
553 404 */
554 405 wp_enqueue_style( 'rtsb-templatebuilder' );
555 406
556 - wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
407 + wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) );
557 408
558 409 wp_enqueue_script( 'selectWoo' );
559 410 /**
560 411 * Scripts.
@@ -564,16 +415,12 @@
564 415 wp_localize_script(
565 416 'rtsb-templatebuilder',
566 417 'rtsbParams',
567 418 [
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 - ),
419 + 'ajaxurl' => esc_url( self::$ajaxurl ),
420 + 'homeurl' => home_url(),
421 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
422 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
576 423 ]
577 424 );
578 425 }
579 426 }
@@ -593,9 +440,8 @@
593 440
594 441 if ( ! empty( $notification_color ) ) {
595 442 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}";
596 443 $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 444 }
599 445
600 446 if ( ! empty( $notification_bgcolor ) ) {
601 447 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}";
@@ -605,33 +451,8 @@
605 451 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}";
606 452 }
607 453
608 454 if ( ! empty( $dynamic_css ) ) {
609 - wp_add_inline_style( Fns::optimized_handle( 'rtsb-frontend' ), $dynamic_css );
455 + wp_add_inline_style( 'rtsb-frontend', $dynamic_css );
610 456 }
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 457 }
637 458 }