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