PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 2.0.0
ShopBuilder – WooCommerce Builder For Elementor v2.0.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 +84 -249 3.4.12.0.0 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 */
@@ -115,20 +86,13 @@
115 86 *
116 87 * @return object
117 88 */
118 89 private function get_public_styles() {
119 - $rtl_suffix = is_rtl() ? '-rtl' : '';
120 - $rtl_dir = is_rtl() ? trailingslashit( 'rtl' ) : trailingslashit( 'css' );
121 -
122 90 $this->styles[] = [
123 - 'handle' => 'rtsb-odometer',
124 - 'src' => rtsb()->get_assets_uri( 'vendor/odometer/css/odometer.min.css' ),
125 - ];
126 -
127 - $this->styles[] = [
128 91 'handle' => 'rtsb-fonts',
129 92 'src' => rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ),
130 93 ];
94 +
131 95 if ( rtsb()->has_pro() ) {
132 96 $this->styles[] = [
133 97 'handle' => 'rtsb-noui-slider',
134 98 'src' => rtsbpro()->get_assets_uri( 'vendors/nouislider/nouislider.min.css' ),
@@ -134,25 +98,18 @@
134 98 'src' => rtsbpro()->get_assets_uri( 'vendors/nouislider/nouislider.min.css' ),
135 99 ];
136 100 }
137 101
138 - $pro_version = defined( 'RTSBPRO_VERSION' ) ? RTSBPRO_VERSION : '0';
139 - $addon_condition = version_compare( $pro_version, '1.9.0', '<' );
102 + $this->styles[] = [
103 + 'handle' => 'rtsb-frontend',
104 + 'src' => rtsb()->get_assets_uri( 'css/frontend/frontend.css' ),
105 + ];
140 106
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 - }
107 + $this->styles[] = [
108 + 'handle' => 'swiper',
109 + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/css/swiper-bundle.min.css' ),
110 + ];
111 +
155 112 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
156 113 $this->styles[] = [
157 114 'handle' => 'photoswipe',
158 115 'src' => plugins_url( 'assets/css/photoswipe/photoswipe.min.css', WC_PLUGIN_FILE ),
@@ -180,24 +137,19 @@
180 137 */
181 138 private function get_public_scripts() {
182 139 $this->scripts[] = [
183 140 'handle' => 'swiper',
184 - 'src' => esc_url( $this->get_swiper_url() ),
141 + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' ),
185 142 'deps' => [ 'jquery' ],
186 143 'footer' => true,
187 144 ];
145 +
188 146 $this->scripts[] = [
189 - 'handle' => 'rtsb-waypoints',
190 - 'src' => rtsb()->get_assets_uri( 'vendor/waypoints/js/jquery.waypoints.min.js' ),
147 + 'handle' => 'rtsb-imagesloaded',
148 + 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ),
191 149 'deps' => [ 'jquery' ],
192 150 'footer' => true,
193 151 ];
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 - ];
200 152
201 153 $this->scripts[] = [
202 154 'handle' => 'rtsb-tipsy',
203 155 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
@@ -206,9 +158,9 @@
206 158 ];
207 159
208 160 if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
209 161 $this->scripts[] = [
210 - 'handle' => 'wc-flexslider',
162 + 'handle' => 'flexslider',
211 163 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
212 164 'deps' => [ 'jquery' ],
213 165 'footer' => true,
214 166 ];
@@ -220,9 +172,9 @@
220 172 'footer' => true,
221 173 ];
222 174
223 175 $this->scripts[] = [
224 - 'handle' => 'wc-zoom',
176 + 'handle' => 'zoom',
225 177 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
226 178 'deps' => [ 'jquery' ],
227 179 'footer' => true,
228 180 ];
@@ -227,9 +179,9 @@
227 179 'footer' => true,
228 180 ];
229 181
230 182 $this->scripts[] = [
231 - 'handle' => 'wc-photoswipe-ui-default',
183 + 'handle' => 'photoswipe-ui-default',
232 184 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
233 185 'deps' => [ 'jquery', 'photoswipe' ],
234 186 'footer' => true,
235 187 ];
@@ -236,9 +188,9 @@
236 188
237 189 $this->scripts[] = [
238 190 'handle' => 'wc-single-product',
239 191 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
240 - 'deps' => [ 'jquery', 'wc-flexslider', 'photoswipe', 'wc-photoswipe-ui-default', 'wc-zoom' ],
192 + 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
241 193 'footer' => true,
242 194 ];
243 195
244 196 }
@@ -256,34 +208,16 @@
256 208 'src' => rtsbpro()->get_assets_uri( 'vendors/sticky-sidebar/sticky-sidebar.min.js' ),
257 209 'deps' => [ 'jquery' ],
258 210 'footer' => true,
259 211 ];
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 - ];
274 212 }
275 213
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 - }
214 + $this->scripts[] = [
215 + 'handle' => 'rtsb-public',
216 + 'src' => rtsb()->get_assets_uri( 'js/frontend/frontend.js' ),
217 + 'deps' => [ 'jquery', 'rtsb-imagesloaded', 'swiper' ],
218 + 'footer' => true,
219 + ];
286 220
287 221 return $this;
288 222 }
289 223
@@ -293,10 +227,8 @@
293 227 * @return void
294 228 */
295 229 public function register_public_scripts() {
296 230 $this->get_public_assets();
297 - $this->styles = array_filter( $this->styles );
298 - $this->scripts = array_filter( $this->scripts );
299 231
300 232 // Register public styles.
301 233 foreach ( $this->styles as $style ) {
302 234 wp_register_style( $style['handle'], $style['src'], '', $this->version );
@@ -317,9 +249,8 @@
317 249 /**
318 250 * Register scripts.
319 251 */
320 252 $this->register_public_scripts();
321 -
322 253 /**
323 254 * Enqueue scripts.
324 255 */
325 256 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
@@ -325,8 +256,9 @@
325 256 if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
326 257 /**
327 258 * Styles.
328 259 */
260 + wp_enqueue_style( 'swiper' );
329 261 wp_enqueue_style( 'photoswipe' );
330 262 wp_enqueue_style( 'photoswipe-default-skin' );
331 263 wp_enqueue_style( 'elementor-editor-style-fix' );
332 264 wp_enqueue_style( 'woocommerce-general' );
@@ -333,32 +265,28 @@
333 265
334 266 /**
335 267 * Scripts.
336 268 */
337 - $handle = Fns::optimized_handle( 'rtsb-public' );
338 -
339 - wp_enqueue_script( 'wc-flexslider' );
269 + wp_enqueue_script( 'flexslider' );
340 270 wp_enqueue_script( 'wc-single-product' );
341 - wp_dequeue_script( $handle );
271 + wp_dequeue_script( 'rtsb-public' );
342 272 wp_enqueue_script( 'swiper' );
273 + wp_enqueue_script( 'rtsb-public' );
274 + }
343 275
344 - if ( Fns::is_optimization_enabled() ) {
345 - Fns::enqueue_optimized_assets();
346 - } else {
347 - wp_enqueue_script( $handle );
348 - }
349 - }
276 + /**
277 + * Styles.
278 + */
279 + wp_enqueue_style( 'rtsb-fonts' );
280 + wp_enqueue_style( 'rtsb-frontend' );
350 281
282 + /**
283 + * Scripts.
284 + */
285 + wp_enqueue_script( 'rtsb-imagesloaded' );
351 286 wp_enqueue_script( 'rtsb-tipsy' );
287 + wp_enqueue_script( 'rtsb-public' );
352 288
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 - }
360 -
361 289 /**
362 290 * Localize script.
363 291 */
364 292 self::localizeData();
@@ -370,31 +298,22 @@
370 298 * @static
371 299 * @return void
372 300 */
373 301 public static function localizeData() {
374 - $handle = Fns::optimized_handle( 'rtsb-public' );
375 - $ai_data = AIFns::activated_ai_data();
376 302 wp_localize_script(
377 - $handle,
303 + 'rtsb-public',
378 304 'rtsbPublicParams',
379 305 [
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' => [
306 + 'ajaxUrl' => esc_url( self::$ajaxurl ),
307 + 'homeurl' => home_url(),
308 + 'wcCartUrl' => wc_get_cart_url(),
309 + 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ),
310 + 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ),
311 + 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ),
312 + 'notice' => [
393 313 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ),
394 - 'timeOut' => absint( Fns::get_option( 'general', 'notification', 'notification_timeOut', 5 ) ),
395 314 ],
396 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
315 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
397 316 ]
398 317 );
399 318 }
400 319
@@ -407,20 +326,9 @@
407 326 /**
408 327 * Styles.
409 328 */
410 329 wp_register_style( 'rtsb-admin-app', rtsb()->get_assets_uri( 'css/backend/admin-settings.css' ), '', $this->version );
411 - wp_register_style( 'rtsb-fonts', rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.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 - }
330 + wp_register_style( 'rtsb-admin-global', rtsb()->get_assets_uri( 'css/backend/admin-global.css' ), '', $this->version );
423 331 wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
424 332
425 333 /**
426 334 * Scripts.
@@ -426,85 +334,25 @@
426 334 * Scripts.
427 335 */
428 336 wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
429 337 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 - );
338 +
468 339 }
469 340
470 341 /**
471 342 * Enqueues admin scripts.
472 343 *
344 + * @param string $hook Hooks.
345 + *
473 346 * @return void
474 347 */
475 - public function enqueue_backend_scripts() {
476 - ob_start(); ?>
477 - #adminmenu .toplevel_page_rtsb .wp-menu-image img {
478 - width: auto;
479 - height: 22px;
480 - padding: 4px 0;
481 - box-sizing: content-box;
482 - }
483 - .post-type-rtsb_builder li#wp-admin-bar-WPML_ALS_all,
484 - .post-type-rtsb_builder li.language_all{
485 - display: none;
486 - }
348 + public function enqueue_backend_scripts( $hook ) {
487 349
488 - <?php
489 - $admin_global_style = ob_get_clean();
490 - // Speed Optimization.
491 - wp_add_inline_style( 'admin-menu', $admin_global_style );
350 + wp_enqueue_style( 'rtsb-admin-global' );
492 351
493 352 global $pagenow;
494 353
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 -
506 - if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
354 + if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) {
507 355 // Elementor Console Error Fixed For "rtsb-settings" Page.
508 356 wp_dequeue_script( 'elementor-admin-top-bar' );
509 357 wp_dequeue_script( 'elementor-common' );
510 358 wp_dequeue_script( 'elementor-dev-tools' );
@@ -511,9 +359,8 @@
511 359 wp_dequeue_script( 'elementor-web-cli' );
512 360 wp_dequeue_script( 'elementor-import-export-admin' );
513 361 wp_dequeue_script( 'elementor-app-loader' );
514 362 wp_dequeue_script( 'elementor-admin-modules' );
515 - wp_dequeue_script( 'elementor-ai-media-library' );
516 363 wp_dequeue_script( 'elementor-admin' );
517 364
518 365 wp_dequeue_style( 'elementor-admin-top-bar' );
519 366 wp_dequeue_style( 'elementor-admin' );
@@ -520,13 +367,31 @@
520 367 wp_dequeue_style( 'e-theme-ui-light' );
521 368 wp_dequeue_style( 'elementor-common' );
522 369
523 370 /**
371 + * Styles.
372 + */
373 + wp_enqueue_style( 'rtsb-admin-app' );
374 +
375 + /**
524 376 * Scripts.
525 377 */
526 - wp_enqueue_media();
527 378 wp_enqueue_script( 'updates' );
528 379 wp_enqueue_script( 'rtsb-admin-app' );
380 + wp_localize_script(
381 + 'rtsb-admin-app',
382 + 'rtsbParams',
383 + [
384 + 'ajaxurl' => esc_url( self::$ajaxurl ),
385 + 'homeurl' => home_url(),
386 + 'restApiUrl' => esc_url_raw( rest_url() ),
387 + 'rest_nonce' => wp_create_nonce( 'wp_rest' ),
388 + 'nonce' => wp_create_nonce( rtsb()->nonceText ),
389 + 'sections' => Settings::instance()->get_sections(),
390 + 'pages' => Fns::get_pages(),
391 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
392 + ]
393 + );
529 394 } else {
530 395 $current_screen = get_current_screen();
531 396
532 397 if ( 'edit-rtsb_builder' === $current_screen->id ) {
@@ -537,9 +402,9 @@
537 402 * Styles.
538 403 */
539 404 wp_enqueue_style( 'rtsb-templatebuilder' );
540 405
541 - wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
406 + wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) );
542 407
543 408 wp_enqueue_script( 'selectWoo' );
544 409 /**
545 410 * Scripts.
@@ -549,16 +414,12 @@
549 414 wp_localize_script(
550 415 'rtsb-templatebuilder',
551 416 'rtsbParams',
552 417 [
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 - ),
418 + 'ajaxurl' => esc_url( self::$ajaxurl ),
419 + 'homeurl' => home_url(),
420 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
421 + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no'
561 422 ]
562 423 );
563 424 }
564 425 }
@@ -578,9 +439,8 @@
578 439
579 440 if ( ! empty( $notification_color ) ) {
580 441 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}";
581 442 $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}}";
583 443 }
584 444
585 445 if ( ! empty( $notification_bgcolor ) ) {
586 446 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}";
@@ -590,33 +450,8 @@
590 450 $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}";
591 451 }
592 452
593 453 if ( ! empty( $dynamic_css ) ) {
594 - wp_add_inline_style( Fns::optimized_handle( 'rtsb-frontend' ), $dynamic_css );
454 + wp_add_inline_style( 'rtsb-frontend', $dynamic_css );
595 455 }
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;
621 456 }
622 457 }