PluginProbe
ShopBuilder – WooCommerce Builder For Elementor / 1.1.0
ShopBuilder – WooCommerce Builder For Elementor v1.1.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 +366 -477 2.0.31.1.0 View file →
@@ -1,477 +1,366 @@
1 -<?php
2 -
3 -namespace RadiusTheme\SB\Controllers;
4 -
5 -use RadiusTheme\SB\Helpers\BuilderFns;
6 -use RadiusTheme\SB\Helpers\Fns;
7 -use RadiusTheme\SB\Models\Settings;
8 -use RadiusTheme\SB\Traits\SingletonTrait;
9 -
10 -// Do not allow directly accessing this file.
11 -if ( ! defined( 'ABSPATH' ) ) {
12 - exit( 'This script cannot be accessed directly.' );
13 -}
14 -
15 -class AssetsController {
16 -
17 - use SingletonTrait;
18 -
19 - /**
20 - * Plugin version
21 - *
22 - * @var string
23 - */
24 - private $version;
25 -
26 - /**
27 - * Ajax URL
28 - *
29 - * @var string
30 - */
31 - private static $ajaxurl;
32 -
33 - /**
34 - * Styles.
35 - *
36 - * @var array
37 - */
38 - private $styles = [];
39 -
40 - /**
41 - * Scripts.
42 - *
43 - * @var array
44 - */
45 - private $scripts = [];
46 -
47 - /**
48 - * Class Constructor
49 - */
50 - public function __construct() {
51 - $this->version = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? time() : RTSB_VERSION;
52 -
53 - if ( in_array( 'sitepress-multilingual-cms/sitepress.php', get_option( 'active_plugins' ) ) ) {
54 - self::$ajaxurl = admin_url( 'admin-ajax.php?lang=' . ICL_LANGUAGE_CODE );
55 - } else {
56 - self::$ajaxurl = admin_url( 'admin-ajax.php' );
57 - }
58 -
59 - /**
60 - * Admin scripts.
61 - */
62 - add_action( 'admin_enqueue_scripts', [ $this, 'register_backend_assets' ], 1 );
63 - add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_backend_scripts' ], 15 );
64 -
65 - /**
66 - * Public scripts.
67 - */
68 - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 15 );
69 - /**
70 - * General scripts.
71 - */
72 - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_general_public_scripts' ], 30 );
73 - }
74 -
75 - /**
76 - * Get all frontend scripts.
77 - *
78 - * @return void
79 - */
80 - private function get_public_assets() {
81 - $this->get_public_styles()->get_public_scripts();
82 - }
83 -
84 - /**
85 - * Get public styles.
86 - *
87 - * @return object
88 - */
89 - private function get_public_styles() {
90 - $rtl_suffix = is_rtl() ? '-rtl' : '';
91 - $this->styles[] = [
92 - 'handle' => 'rtsb-fonts',
93 - 'src' => rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ),
94 - ];
95 -
96 - if ( rtsb()->has_pro() ) {
97 - $this->styles[] = [
98 - 'handle' => 'rtsb-noui-slider',
99 - 'src' => rtsbpro()->get_assets_uri( 'vendors/nouislider/nouislider.min.css' ),
100 - ];
101 - }
102 -
103 - $this->styles[] = [
104 - 'handle' => 'rtsb-frontend',
105 - 'src' => rtsb()->get_assets_uri( 'css/frontend/frontend' . $rtl_suffix . '.css' ),
106 - ];
107 -
108 - $this->styles[] = [
109 - 'handle' => 'swiper',
110 - 'src' => rtsb()->get_assets_uri( 'vendor/swiper/css/swiper-bundle.min.css' ),
111 - ];
112 -
113 - if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
114 - $this->styles[] = [
115 - 'handle' => 'photoswipe',
116 - 'src' => plugins_url( 'assets/css/photoswipe/photoswipe.min.css', WC_PLUGIN_FILE ),
117 - ];
118 -
119 - $this->styles[] = [
120 - 'handle' => 'photoswipe-default-skin',
121 - 'src' => plugins_url( 'assets/css/photoswipe/default-skin/default-skin.min.css', WC_PLUGIN_FILE ),
122 - ];
123 -
124 - // Load only for elementor editor page and fix some issue.
125 - $this->styles[] = [
126 - 'handle' => 'elementor-editor-style-fix',
127 - 'src' => rtsb()->get_assets_uri( 'css/backend/elementor-editor-style-fix.css' ),
128 - ];
129 - }
130 -
131 - return $this;
132 - }
133 -
134 - /**
135 - * Get public scripts.
136 - *
137 - * @return object
138 - */
139 - 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 - $this->scripts[] = [
160 - 'handle' => 'swiper',
161 - 'src' => esc_url( $default_swiper_path ),
162 - 'deps' => [ 'jquery' ],
163 - 'footer' => true,
164 - ];
165 -
166 - $this->scripts[] = [
167 - 'handle' => 'rtsb-imagesloaded',
168 - 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ),
169 - 'deps' => [ 'jquery' ],
170 - 'footer' => true,
171 - ];
172 -
173 - $this->scripts[] = [
174 - 'handle' => 'rtsb-tipsy',
175 - 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
176 - 'deps' => [ 'jquery' ],
177 - 'footer' => true,
178 - ];
179 -
180 - if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
181 - $this->scripts[] = [
182 - 'handle' => 'flexslider',
183 - 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
184 - 'deps' => [ 'jquery' ],
185 - 'footer' => true,
186 - ];
187 -
188 - $this->scripts[] = [
189 - 'handle' => 'photoswipe',
190 - 'src' => plugins_url( 'assets/js/photoswipe/photoswipe.js', WC_PLUGIN_FILE ),
191 - 'deps' => [ 'jquery' ],
192 - 'footer' => true,
193 - ];
194 -
195 - $this->scripts[] = [
196 - 'handle' => 'zoom',
197 - 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
198 - 'deps' => [ 'jquery' ],
199 - 'footer' => true,
200 - ];
201 -
202 - $this->scripts[] = [
203 - 'handle' => 'photoswipe-ui-default',
204 - 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
205 - 'deps' => [ 'jquery', 'photoswipe' ],
206 - 'footer' => true,
207 - ];
208 -
209 - $this->scripts[] = [
210 - 'handle' => 'wc-single-product',
211 - 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
212 - 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
213 - 'footer' => true,
214 - ];
215 -
216 - }
217 -
218 - if ( rtsb()->has_pro() ) {
219 - $this->scripts[] = [
220 - 'handle' => 'rtsb-noui-slider',
221 - 'src' => rtsbpro()->get_assets_uri( 'vendors/nouislider/nouislider.min.js' ),
222 - 'deps' => [ 'jquery' ],
223 - 'footer' => true,
224 - ];
225 -
226 - $this->scripts[] = [
227 - 'handle' => 'rtsb-sticky-sidebar',
228 - 'src' => rtsbpro()->get_assets_uri( 'vendors/sticky-sidebar/sticky-sidebar.min.js' ),
229 - 'deps' => [ 'jquery' ],
230 - 'footer' => true,
231 - ];
232 - }
233 -
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 - ];
240 -
241 - return $this;
242 - }
243 -
244 - /**
245 - * Register public scripts.
246 - *
247 - * @return void
248 - */
249 - public function register_public_scripts() {
250 - $this->get_public_assets();
251 -
252 - // Register public styles.
253 - foreach ( $this->styles as $style ) {
254 - wp_register_style( $style['handle'], $style['src'], '', $this->version );
255 - }
256 -
257 - // Register public scripts.
258 - foreach ( $this->scripts as $script ) {
259 - wp_register_script( $script['handle'], $script['src'], $script['deps'], $this->version, $script['footer'] );
260 - }
261 - }
262 -
263 - /**
264 - * Enqueues public scripts.
265 - *
266 - * @return void
267 - */
268 - public function enqueue_public_scripts() {
269 - /**
270 - * Register scripts.
271 - */
272 - $this->register_public_scripts();
273 - /**
274 - * Enqueue scripts.
275 - */
276 - if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
277 - /**
278 - * Styles.
279 - */
280 - wp_enqueue_style( 'swiper' );
281 - wp_enqueue_style( 'photoswipe' );
282 - wp_enqueue_style( 'photoswipe-default-skin' );
283 - wp_enqueue_style( 'elementor-editor-style-fix' );
284 - wp_enqueue_style( 'woocommerce-general' );
285 -
286 - /**
287 - * Scripts.
288 - */
289 - wp_enqueue_script( 'flexslider' );
290 - wp_enqueue_script( 'wc-single-product' );
291 - wp_dequeue_script( 'rtsb-public' );
292 - wp_enqueue_script( 'swiper' );
293 - wp_enqueue_script( 'rtsb-public' );
294 - }
295 -
296 - /**
297 - * Styles.
298 - */
299 - wp_enqueue_style( 'rtsb-fonts' );
300 - wp_enqueue_style( 'rtsb-frontend' );
301 -
302 - /**
303 - * Scripts.
304 - */
305 - wp_enqueue_script( 'rtsb-imagesloaded' );
306 - wp_enqueue_script( 'rtsb-tipsy' );
307 - wp_enqueue_script( 'rtsb-public' );
308 -
309 - /**
310 - * Localize script.
311 - */
312 - self::localizeData();
313 - }
314 -
315 - /**
316 - * Localized Data.
317 - *
318 - * @static
319 - * @return void
320 - */
321 - public static function localizeData() {
322 - wp_localize_script(
323 - 'rtsb-public',
324 - 'rtsbPublicParams',
325 - [
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' => [
333 - 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ),
334 - ],
335 - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
336 - ]
337 - );
338 - }
339 -
340 - /**
341 - * Registers Admin scripts.
342 - *
343 - * @return void
344 - */
345 - public function register_backend_assets() {
346 - /**
347 - * Styles.
348 - */
349 - 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 );
351 - wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
352 -
353 - /**
354 - * Scripts.
355 - */
356 - wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
357 - wp_register_script( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'js/backend/template-builder.js' ), '', $this->version, true );
358 -
359 - }
360 -
361 - /**
362 - * Enqueues admin scripts.
363 - *
364 - * @param string $hook Hooks.
365 - *
366 - * @return void
367 - */
368 - public function enqueue_backend_scripts( $hook ) {
369 -
370 - wp_enqueue_style( 'rtsb-admin-global' );
371 -
372 - global $pagenow;
373 -
374 - if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) {
375 - // Elementor Console Error Fixed For "rtsb-settings" Page.
376 - wp_dequeue_script( 'elementor-admin-top-bar' );
377 - wp_dequeue_script( 'elementor-common' );
378 - wp_dequeue_script( 'elementor-dev-tools' );
379 - wp_dequeue_script( 'elementor-web-cli' );
380 - wp_dequeue_script( 'elementor-import-export-admin' );
381 - wp_dequeue_script( 'elementor-app-loader' );
382 - wp_dequeue_script( 'elementor-admin-modules' );
383 - wp_dequeue_script( 'elementor-admin' );
384 -
385 - wp_dequeue_style( 'elementor-admin-top-bar' );
386 - wp_dequeue_style( 'elementor-admin' );
387 - wp_dequeue_style( 'e-theme-ui-light' );
388 - wp_dequeue_style( 'elementor-common' );
389 -
390 - /**
391 - * Styles.
392 - */
393 - wp_enqueue_style( 'rtsb-admin-app' );
394 -
395 - /**
396 - * Scripts.
397 - */
398 - wp_enqueue_script( 'updates' );
399 - 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 - } else {
415 - $current_screen = get_current_screen();
416 -
417 - if ( 'edit-rtsb_builder' === $current_screen->id ) {
418 - if ( ! function_exists( 'woocommerce_get_asset_url' ) ) {
419 - include_once WC_ABSPATH . 'includes/wc-template-functions.php';
420 - }
421 - /**
422 - * Styles.
423 - */
424 - wp_enqueue_style( 'rtsb-templatebuilder' );
425 -
426 - wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) );
427 -
428 - wp_enqueue_script( 'selectWoo' );
429 - /**
430 - * Scripts.
431 - */
432 - wp_enqueue_script( 'rtsb-templatebuilder' );
433 -
434 - wp_localize_script(
435 - 'rtsb-templatebuilder',
436 - 'rtsbParams',
437 - [
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'
442 - ]
443 - );
444 - }
445 - }
446 - }
447 -
448 - /**
449 - * Enqueues general public scripts.
450 - *
451 - * @return void
452 - */
453 - public function enqueue_general_public_scripts() {
454 - $notification_color = Fns::get_option( 'general', 'notification', 'notification_color', '#004BFF' );
455 - $notification_bgcolor = Fns::get_option( 'general', 'notification', 'notification_bg', '#F5F8FF' );
456 - $notification_button_color = Fns::get_option( 'general', 'notification', 'notification_btn_color', '#0039C0' );
457 -
458 - $dynamic_css = '';
459 -
460 - if ( ! empty( $notification_color ) ) {
461 - $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}";
462 - $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success:before{background-color:{$notification_color}}";
463 - }
464 -
465 - if ( ! empty( $notification_bgcolor ) ) {
466 - $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}";
467 - }
468 -
469 - if ( ! empty( $notification_button_color ) ) {
470 - $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}";
471 - }
472 -
473 - if ( ! empty( $dynamic_css ) ) {
474 - wp_add_inline_style( 'rtsb-frontend', $dynamic_css );
475 - }
476 - }
477 -}
1 +<?php
2 +
3 +namespace RadiusTheme\SB\Controllers;
4 +
5 +use RadiusTheme\SB\Helpers\BuilderFns;
6 +use RadiusTheme\SB\Helpers\Fns;
7 +use RadiusTheme\SB\Models\Settings;
8 +use RadiusTheme\SB\Traits\SingletonTrait;
9 +
10 +// Do not allow directly accessing this file.
11 +if ( ! defined( 'ABSPATH' ) ) {
12 + exit( 'This script cannot be accessed directly.' );
13 +}
14 +
15 +class AssetsController {
16 +
17 + use SingletonTrait;
18 +
19 + /**
20 + * Plugin version
21 + *
22 + * @var string
23 + */
24 + private $version;
25 +
26 + /**
27 + * Ajax URL
28 + *
29 + * @var string
30 + */
31 + private $ajaxurl;
32 +
33 + /**
34 + * Styles.
35 + *
36 + * @var array
37 + */
38 + private $styles = [];
39 +
40 + /**
41 + * Scripts.
42 + *
43 + * @var array
44 + */
45 + private $scripts = [];
46 +
47 + /**
48 + * Class Constructor
49 + */
50 + public function __construct() {
51 + $this->version = ( defined( 'WP_DEBUG' ) && WP_DEBUG ) ? time() : RTSB_VERSION;
52 + if ( in_array( 'sitepress-multilingual-cms/sitepress.php', get_option( 'active_plugins' ) ) ) {
53 + $this->ajaxurl = admin_url( 'admin-ajax.php?lang=' . ICL_LANGUAGE_CODE );
54 + } else {
55 + $this->ajaxurl = admin_url( 'admin-ajax.php' );
56 + }
57 +
58 + /**
59 + * Admin scripts.
60 + */
61 + add_action( 'admin_enqueue_scripts', [ $this, 'register_backend_assets' ], 1 );
62 + add_action( 'admin_enqueue_scripts', [ $this, 'enqueue_backend_scripts' ] );
63 +
64 + /**
65 + * Public scripts.
66 + */
67 + add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_public_scripts' ], 15 );
68 + }
69 +
70 + /**
71 + * Get all frontend scripts.
72 + *
73 + * @return void
74 + */
75 + private function get_public_assets() {
76 + $this->get_public_styles()->get_public_scripts();
77 + }
78 +
79 + /**
80 + * Get public styles.
81 + *
82 + * @return object
83 + */
84 + private function get_public_styles() {
85 + $this->styles[] = [
86 + 'handle' => 'rtsb-fonts',
87 + 'src' => rtsb()->get_assets_uri( 'fonts/rtsbfont.css' ),
88 + ];
89 +
90 + $this->styles[] = [
91 + 'handle' => 'rtsb-frontend',
92 + 'src' => rtsb()->get_assets_uri( 'css/frontend/frontend.css' ),
93 + ];
94 +
95 + $this->styles[] = [
96 + 'handle' => 'swiper',
97 + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/css/swiper-bundle.min.css' ),
98 + ];
99 +
100 + if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
101 + $this->styles[] = [
102 + 'handle' => 'photoswipe',
103 + 'src' => plugins_url( 'assets/css/photoswipe/photoswipe.min.css', WC_PLUGIN_FILE ),
104 + ];
105 +
106 + $this->styles[] = [
107 + 'handle' => 'photoswipe-default-skin',
108 + 'src' => plugins_url( 'assets/css/photoswipe/default-skin/default-skin.min.css', WC_PLUGIN_FILE ),
109 + ];
110 +
111 + // Load only for elementor editor page and fix some issue.
112 + $this->styles[] = [
113 + 'handle' => 'elementor-editor-style-fix',
114 + 'src' => rtsb()->get_assets_uri( 'css/backend/elementor-editor-style-fix.css' ),
115 + ];
116 + }
117 +
118 + return $this;
119 + }
120 +
121 + /**
122 + * Get public scripts.
123 + *
124 + * @return object
125 + */
126 + private function get_public_scripts() {
127 + $this->scripts[] = [
128 + 'handle' => 'swiper',
129 + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' ),
130 + 'deps' => [ 'jquery' ],
131 + 'footer' => true,
132 + ];
133 +
134 + $this->scripts[] = [
135 + 'handle' => 'rtsb-imagesloaded',
136 + 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ),
137 + 'deps' => [ 'jquery' ],
138 + 'footer' => true,
139 + ];
140 +
141 + $this->scripts[] = [
142 + 'handle' => 'rtsb-tipsy',
143 + 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ),
144 + 'deps' => [ 'jquery' ],
145 + 'footer' => true,
146 + ];
147 +
148 + if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) {
149 +
150 + $this->scripts[] = [
151 + 'handle' => 'flexslider',
152 + 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ),
153 + 'deps' => [ 'jquery' ],
154 + 'footer' => true,
155 + ];
156 +
157 + $this->scripts[] = [
158 + 'handle' => 'photoswipe',
159 + 'src' => plugins_url( 'assets/js/photoswipe/photoswipe.js', WC_PLUGIN_FILE ),
160 + 'deps' => [ 'jquery' ],
161 + 'footer' => true,
162 + ];
163 +
164 + $this->scripts[] = [
165 + 'handle' => 'zoom',
166 + 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ),
167 + 'deps' => [ 'jquery' ],
168 + 'footer' => true,
169 + ];
170 +
171 + $this->scripts[] = [
172 + 'handle' => 'photoswipe-ui-default',
173 + 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ),
174 + 'deps' => [ 'jquery', 'photoswipe' ],
175 + 'footer' => true,
176 + ];
177 +
178 + $this->scripts[] = [
179 + 'handle' => 'wc-single-product',
180 + 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ),
181 + 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ],
182 + 'footer' => true,
183 + ];
184 +
185 + }
186 +
187 + $this->scripts[] = [
188 + 'handle' => 'rtsb-public',
189 + 'src' => rtsb()->get_assets_uri( 'js/frontend/frontend.js' ),
190 + 'deps' => [ 'jquery', 'rtsb-imagesloaded', 'swiper' ],
191 + 'footer' => true,
192 + ];
193 +
194 + return $this;
195 + }
196 +
197 + /**
198 + * Register public scripts.
199 + *
200 + * @return void
201 + */
202 + public function register_public_scripts() {
203 + $this->get_public_assets();
204 +
205 + // Register public styles.
206 + foreach ( $this->styles as $style ) {
207 + wp_register_style( $style['handle'], $style['src'], '', $this->version );
208 + }
209 +
210 + // Register public scripts.
211 + foreach ( $this->scripts as $script ) {
212 + wp_register_script( $script['handle'], $script['src'], $script['deps'], $this->version, $script['footer'] );
213 + }
214 + }
215 +
216 + /**
217 + * Enqueues public scripts.
218 + *
219 + * @return void
220 + */
221 + public function enqueue_public_scripts() {
222 + /**
223 + * Register scripts.
224 + */
225 + $this->register_public_scripts();
226 + /**
227 + * Enqueue scripts.
228 + */
229 + if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) {
230 + /**
231 + * Styles.
232 + */
233 + wp_enqueue_style( 'swiper' );
234 + wp_enqueue_style( 'photoswipe' );
235 + wp_enqueue_style( 'photoswipe-default-skin' );
236 + wp_enqueue_style( 'elementor-editor-style-fix' );
237 + // TODO: Need to remove 'woocommerce-general' if conflict arises.
238 + wp_enqueue_style( 'woocommerce-general' );
239 +
240 + /**
241 + * Scripts.
242 + */
243 + wp_enqueue_script( 'flexslider' );
244 + wp_enqueue_script( 'wc-single-product' );
245 + wp_dequeue_script( 'rtsb-public' );
246 + wp_enqueue_script( 'swiper' );
247 + wp_enqueue_script( 'rtsb-public' );
248 + }
249 +
250 + /**
251 + * Styles.
252 + */
253 + wp_enqueue_style( 'rtsb-fonts' );
254 + wp_enqueue_style( 'rtsb-frontend' );
255 +
256 + /**
257 + * Scripts.
258 + */
259 + wp_enqueue_script( 'rtsb-imagesloaded' );
260 + wp_enqueue_script( 'rtsb-tipsy' );
261 + wp_enqueue_script( 'rtsb-public' );
262 +
263 + wp_localize_script(
264 + 'rtsb-public',
265 + 'rtsbPublicParams',
266 + [
267 + 'ajaxUrl' => esc_url( $this->ajaxurl ),
268 + 'homeurl' => home_url(),
269 + 'wcCartUrl' => wc_get_cart_url(),
270 + 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ),
271 + 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ),
272 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
273 + ]
274 + );
275 + }
276 +
277 + /**
278 + * Registers Admin scripts.
279 + *
280 + * @return void
281 + */
282 + public function register_backend_assets() {
283 + /**
284 + * Styles.
285 + */
286 + wp_register_style( 'rtsb-admin-app', rtsb()->get_assets_uri( 'css/backend/admin-settings.css' ), '', $this->version );
287 + wp_register_style( 'rtsb-admin-global', rtsb()->get_assets_uri( 'css/backend/admin-global.css' ), '', $this->version );
288 + wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version );
289 +
290 + /**
291 + * Scripts.
292 + */
293 + wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true );
294 + wp_register_script( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'js/backend/template-builder.js' ), '', $this->version, true );
295 +
296 + }
297 +
298 + /**
299 + * Enqueues admin scripts.
300 + *
301 + * @param string $hook Hooks.
302 + *
303 + * @return void
304 + */
305 + public function enqueue_backend_scripts( $hook ) {
306 +
307 + wp_enqueue_style( 'rtsb-admin-global' );
308 +
309 + if ( 'shopbuilder_page_rtsb-settings' === $hook ) {
310 + /**
311 + * Styles.
312 + */
313 + wp_enqueue_style( 'rtsb-admin-app' );
314 +// add_thickbox();
315 +// wp_enqueue_script( 'plugin-install' );
316 + wp_enqueue_script( 'updates' );
317 +
318 + /**
319 + * Scripts.
320 + */
321 + wp_enqueue_script( 'rtsb-admin-app' );
322 + wp_localize_script(
323 + 'rtsb-admin-app',
324 + 'rtsbParams',
325 + [
326 + 'ajaxurl' => esc_url( $this->ajaxurl ),
327 + 'homeurl' => home_url(),
328 + 'nonce' => wp_create_nonce( rtsb()->nonceText ),
329 + 'sections' => Settings::instance()->get_sections(),
330 + 'pages' => Fns::get_pages(),
331 + ]
332 + );
333 + } else {
334 + $current_screen = get_current_screen();
335 +
336 + if ( 'edit-rtsb_builder' === $current_screen->id ) {
337 + if ( ! function_exists( 'woocommerce_get_asset_url' ) ) {
338 + include_once WC_ABSPATH . 'includes/wc-template-functions.php';
339 + }
340 + /**
341 + * Styles.
342 + */
343 + wp_enqueue_style( 'rtsb-templatebuilder' );
344 +
345 + wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) );
346 +
347 + wp_enqueue_script( 'selectWoo' );
348 + /**
349 + * Scripts.
350 + */
351 + wp_enqueue_script( 'rtsb-templatebuilder' );
352 +
353 +
354 + wp_localize_script(
355 + 'rtsb-templatebuilder',
356 + 'rtsbParams',
357 + [
358 + 'ajaxurl' => esc_url( $this->ajaxurl ),
359 + 'homeurl' => home_url(),
360 + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ),
361 + ]
362 + );
363 + }
364 + }
365 + }
366 +}