| @@ -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,9 +87,8 @@ | ||
| 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 | 91 | |
| 122 | 92 | $this->styles[] = [ |
| 123 | 93 | 'handle' => 'rtsb-odometer', |
| 124 | 94 | 'src' => rtsb()->get_assets_uri( 'vendor/odometer/css/odometer.min.css' ), |
| @@ -137,30 +107,26 @@ | ||
| 137 | 107 | |
| 138 | 108 | $pro_version = defined( 'RTSBPRO_VERSION' ) ? RTSBPRO_VERSION : '0'; |
| 139 | 109 | $addon_condition = version_compare( $pro_version, '1.9.0', '<' ); |
| 140 | 110 | |
| 141 | - $optimized = []; | |
| 142 | - | |
| 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 | - } | |
| 111 | + if ( $addon_condition ) { | |
| 158 | 112 | $this->styles[] = [ |
| 159 | - 'handle' => 'rtsb-frontend', | |
| 160 | - 'src' => rtsb()->get_assets_uri( $rtl_dir . 'frontend/frontend' . $rtl_suffix . '.css' ), | |
| 113 | + 'handle' => 'rtsb-general-addons', | |
| 114 | + 'src' => rtsb()->get_assets_uri( 'css/frontend/general-addons' . $rtl_suffix . '.css' ), | |
| 161 | 115 | ]; |
| 162 | 116 | } |
| 117 | + $this->styles[] = [ | |
| 118 | + 'handle' => 'rtsb-frontend', | |
| 119 | + 'src' => rtsb()->get_assets_uri( 'css/frontend/frontend' . $rtl_suffix . '.css' ), | |
| 120 | + ]; | |
| 121 | + | |
| 122 | + /* | |
| 123 | + $this->styles[] = [ | |
| 124 | + 'handle' => 'swiper', | |
| 125 | + 'src' => rtsb()->get_assets_uri( 'vendor/swiper/css/swiper-bundle.min.css' ), | |
| 126 | + ]; | |
| 127 | + */ | |
| 128 | + | |
| 163 | 129 | if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) { |
| 164 | 130 | $this->styles[] = [ |
| 165 | 131 | 'handle' => 'photoswipe', |
| 166 | 132 | 'src' => plugins_url( 'assets/css/photoswipe/photoswipe.min.css', WC_PLUGIN_FILE ), |
| @@ -186,11 +152,30 @@ | ||
| 186 | 152 | * |
| 187 | 153 | * @return object |
| 188 | 154 | */ |
| 189 | 155 | private function get_public_scripts() { |
| 156 | + | |
| 157 | + $default_swiper_path = rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' ); | |
| 158 | + | |
| 159 | + if ( defined( 'ELEMENTOR_ASSETS_PATH' ) ) { | |
| 160 | + $is_swiper8_enable = get_option( 'elementor_experiment-e_swiper_latest' ); | |
| 161 | + | |
| 162 | + if ( 'active' === $is_swiper8_enable || 'default' === $is_swiper8_enable ) { | |
| 163 | + $el_swiper_path = 'lib/swiper/v8/swiper.min.js'; | |
| 164 | + } else { | |
| 165 | + $el_swiper_path = 'lib/swiper/swiper.min.js'; | |
| 166 | + } | |
| 167 | + | |
| 168 | + $elementor_swiper_path = ELEMENTOR_ASSETS_PATH . $el_swiper_path; | |
| 169 | + | |
| 170 | + if ( file_exists( $elementor_swiper_path ) ) { | |
| 171 | + $default_swiper_path = ELEMENTOR_ASSETS_URL . $el_swiper_path; | |
| 172 | + } | |
| 173 | + } | |
| 174 | + | |
| 190 | 175 | $this->scripts[] = [ |
| 191 | 176 | 'handle' => 'swiper', |
| 192 | - 'src' => esc_url( $this->get_swiper_url() ), | |
| 177 | + 'src' => esc_url( $default_swiper_path ), | |
| 193 | 178 | 'deps' => [ 'jquery' ], |
| 194 | 179 | 'footer' => true, |
| 195 | 180 | ]; |
| 196 | 181 | $this->scripts[] = [ |
| @@ -206,8 +191,15 @@ | ||
| 206 | 191 | 'footer' => true, |
| 207 | 192 | ]; |
| 208 | 193 | |
| 209 | 194 | $this->scripts[] = [ |
| 195 | + 'handle' => 'rtsb-imagesloaded', | |
| 196 | + 'src' => rtsb()->get_assets_uri( 'vendor/isotope/imagesloaded.pkgd.min.js' ), | |
| 197 | + 'deps' => [ 'jquery' ], | |
| 198 | + 'footer' => true, | |
| 199 | + ]; | |
| 200 | + | |
| 201 | + $this->scripts[] = [ | |
| 210 | 202 | 'handle' => 'rtsb-tipsy', |
| 211 | 203 | 'src' => rtsb()->get_assets_uri( 'vendor/tipsy/tipsy.min.js' ), |
| 212 | 204 | 'deps' => [ 'jquery' ], |
| 213 | 205 | 'footer' => true, |
| @@ -214,9 +206,9 @@ | ||
| 214 | 206 | ]; |
| 215 | 207 | |
| 216 | 208 | if ( BuilderFns::is_builder_preview() && 'elementor' == Fns::page_edit_with( get_the_ID() ) ) { |
| 217 | 209 | $this->scripts[] = [ |
| 218 | - 'handle' => 'wc-flexslider', | |
| 210 | + 'handle' => 'flexslider', | |
| 219 | 211 | 'src' => plugins_url( 'assets/js/flexslider/jquery.flexslider.js', WC_PLUGIN_FILE ), |
| 220 | 212 | 'deps' => [ 'jquery' ], |
| 221 | 213 | 'footer' => true, |
| 222 | 214 | ]; |
| @@ -228,9 +220,9 @@ | ||
| 228 | 220 | 'footer' => true, |
| 229 | 221 | ]; |
| 230 | 222 | |
| 231 | 223 | $this->scripts[] = [ |
| 232 | - 'handle' => 'wc-zoom', | |
| 224 | + 'handle' => 'zoom', | |
| 233 | 225 | 'src' => plugins_url( 'assets/js/zoom/jquery.zoom.js', WC_PLUGIN_FILE ), |
| 234 | 226 | 'deps' => [ 'jquery' ], |
| 235 | 227 | 'footer' => true, |
| 236 | 228 | ]; |
| @@ -235,9 +227,9 @@ | ||
| 235 | 227 | 'footer' => true, |
| 236 | 228 | ]; |
| 237 | 229 | |
| 238 | 230 | $this->scripts[] = [ |
| 239 | - 'handle' => 'wc-photoswipe-ui-default', | |
| 231 | + 'handle' => 'photoswipe-ui-default', | |
| 240 | 232 | 'src' => plugins_url( 'assets/js/photoswipe/photoswipe-ui-default.js', WC_PLUGIN_FILE ), |
| 241 | 233 | 'deps' => [ 'jquery', 'photoswipe' ], |
| 242 | 234 | 'footer' => true, |
| 243 | 235 | ]; |
| @@ -244,9 +236,9 @@ | ||
| 244 | 236 | |
| 245 | 237 | $this->scripts[] = [ |
| 246 | 238 | 'handle' => 'wc-single-product', |
| 247 | 239 | 'src' => plugins_url( 'assets/js/frontend/single-product.js', WC_PLUGIN_FILE ), |
| 248 | - 'deps' => [ 'jquery', 'wc-flexslider', 'photoswipe', 'wc-photoswipe-ui-default', 'wc-zoom' ], | |
| 240 | + 'deps' => [ 'jquery', 'flexslider', 'photoswipe', 'photoswipe-ui-default', 'zoom' ], | |
| 249 | 241 | 'footer' => true, |
| 250 | 242 | ]; |
| 251 | 243 | |
| 252 | 244 | } |
| @@ -280,26 +272,15 @@ | ||
| 280 | 272 | 'footer' => true, |
| 281 | 273 | ]; |
| 282 | 274 | } |
| 283 | 275 | |
| 284 | - $optimized = []; | |
| 276 | + $this->scripts[] = [ | |
| 277 | + 'handle' => 'rtsb-public', | |
| 278 | + 'src' => rtsb()->get_assets_uri( 'js/frontend/frontend.js' ), | |
| 279 | + 'deps' => [ 'jquery', 'rtsb-imagesloaded', 'swiper' ], | |
| 280 | + 'footer' => true, | |
| 281 | + ]; | |
| 285 | 282 | |
| 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 | 283 | return $this; |
| 303 | 284 | } |
| 304 | 285 | |
| 305 | 286 | /** |
| @@ -308,10 +289,8 @@ | ||
| 308 | 289 | * @return void |
| 309 | 290 | */ |
| 310 | 291 | public function register_public_scripts() { |
| 311 | 292 | $this->get_public_assets(); |
| 312 | - $this->styles = array_filter( $this->styles ); | |
| 313 | - $this->scripts = array_filter( $this->scripts ); | |
| 314 | 293 | |
| 315 | 294 | // Register public styles. |
| 316 | 295 | foreach ( $this->styles as $style ) { |
| 317 | 296 | wp_register_style( $style['handle'], $style['src'], '', $this->version ); |
| @@ -332,9 +311,9 @@ | ||
| 332 | 311 | /** |
| 333 | 312 | * Register scripts. |
| 334 | 313 | */ |
| 335 | 314 | $this->register_public_scripts(); |
| 336 | - | |
| 315 | + // wp_enqueue_style( 'swiper' ); | |
| 337 | 316 | /** |
| 338 | 317 | * Enqueue scripts. |
| 339 | 318 | */ |
| 340 | 319 | if ( BuilderFns::is_builder_preview() && 'elementor' === Fns::page_edit_with( get_the_ID() ) ) { |
| @@ -348,32 +327,28 @@ | ||
| 348 | 327 | |
| 349 | 328 | /** |
| 350 | 329 | * Scripts. |
| 351 | 330 | */ |
| 352 | - $handle = Fns::optimized_handle( 'rtsb-public' ); | |
| 353 | - | |
| 354 | - wp_enqueue_script( 'wc-flexslider' ); | |
| 331 | + wp_enqueue_script( 'flexslider' ); | |
| 355 | 332 | wp_enqueue_script( 'wc-single-product' ); |
| 356 | - wp_dequeue_script( $handle ); | |
| 333 | + wp_dequeue_script( 'rtsb-public' ); | |
| 357 | 334 | wp_enqueue_script( 'swiper' ); |
| 335 | + wp_enqueue_script( 'rtsb-public' ); | |
| 336 | + } | |
| 358 | 337 | |
| 359 | - if ( Fns::is_optimization_enabled() ) { | |
| 360 | - Fns::enqueue_optimized_assets(); | |
| 361 | - } else { | |
| 362 | - wp_enqueue_script( $handle ); | |
| 363 | - } | |
| 364 | - } | |
| 338 | + /** | |
| 339 | + * Styles. | |
| 340 | + */ | |
| 341 | + wp_enqueue_style( 'rtsb-fonts' ); | |
| 342 | + wp_enqueue_style( 'rtsb-frontend' ); | |
| 365 | 343 | |
| 344 | + /** | |
| 345 | + * Scripts. | |
| 346 | + */ | |
| 347 | + wp_enqueue_script( 'rtsb-imagesloaded' ); | |
| 366 | 348 | wp_enqueue_script( 'rtsb-tipsy' ); |
| 349 | + wp_enqueue_script( 'rtsb-public' ); | |
| 367 | 350 | |
| 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 | 351 | /** |
| 377 | 352 | * Localize script. |
| 378 | 353 | */ |
| 379 | 354 | self::localizeData(); |
| @@ -385,31 +360,24 @@ | ||
| 385 | 360 | * @static |
| 386 | 361 | * @return void |
| 387 | 362 | */ |
| 388 | 363 | public static function localizeData() { |
| 389 | - $handle = Fns::optimized_handle( 'rtsb-public' ); | |
| 390 | - $ai_data = AIFns::activated_ai_data(); | |
| 391 | 364 | wp_localize_script( |
| 392 | - $handle, | |
| 365 | + 'rtsb-public', | |
| 393 | 366 | 'rtsbPublicParams', |
| 394 | 367 | [ |
| 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' => [ | |
| 368 | + 'ajaxUrl' => esc_url( self::$ajaxurl ), | |
| 369 | + 'homeurl' => home_url(), | |
| 370 | + 'wcCartUrl' => wc_get_cart_url(), | |
| 371 | + 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ), | |
| 372 | + 'singleCartToastrText' => esc_html__( 'Successfully Added', 'shopbuilder' ), | |
| 373 | + 'singleCartBtnText' => apply_filters( 'rtsb/global/single_add_to_cart_success', esc_html__( 'Added to Cart', 'shopbuilder' ) ), | |
| 374 | + 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ), | |
| 375 | + 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ), | |
| 376 | + 'notice' => [ | |
| 408 | 377 | 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ), |
| 409 | - 'timeOut' => absint( Fns::get_option( 'general', 'notification', 'notification_timeOut', 5 ) ), | |
| 410 | 378 | ], |
| 411 | - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), | |
| 379 | + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), | |
| 412 | 380 | ] |
| 413 | 381 | ); |
| 414 | 382 | } |
| 415 | 383 | |
| @@ -441,54 +409,18 @@ | ||
| 441 | 409 | * Scripts. |
| 442 | 410 | */ |
| 443 | 411 | wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true ); |
| 444 | 412 | 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 | - ); | |
| 483 | 413 | } |
| 484 | 414 | |
| 485 | 415 | /** |
| 486 | 416 | * Enqueues admin scripts. |
| 487 | 417 | * |
| 418 | + * @param string $hook Hooks. | |
| 419 | + * | |
| 488 | 420 | * @return void |
| 489 | 421 | */ |
| 490 | - public function enqueue_backend_scripts() { | |
| 422 | + public function enqueue_backend_scripts( $hook ) { | |
| 491 | 423 | ob_start(); ?> |
| 492 | 424 | #adminmenu .toplevel_page_rtsb .wp-menu-image img { |
| 493 | 425 | width: auto; |
| 494 | 426 | height: 22px; |
| @@ -503,8 +435,9 @@ | ||
| 503 | 435 | <?php |
| 504 | 436 | $admin_global_style = ob_get_clean(); |
| 505 | 437 | // Speed Optimization. |
| 506 | 438 | wp_add_inline_style( 'admin-menu', $admin_global_style ); |
| 439 | + // wp_enqueue_style( 'rtsb-admin-global' ); | |
| 507 | 440 | |
| 508 | 441 | global $pagenow; |
| 509 | 442 | |
| 510 | 443 | $whitelisted_pages = [ 'rtsb-settings', 'rtsb-get-help', 'rtsb-themes' ]; |
| @@ -526,9 +459,8 @@ | ||
| 526 | 459 | wp_dequeue_script( 'elementor-web-cli' ); |
| 527 | 460 | wp_dequeue_script( 'elementor-import-export-admin' ); |
| 528 | 461 | wp_dequeue_script( 'elementor-app-loader' ); |
| 529 | 462 | wp_dequeue_script( 'elementor-admin-modules' ); |
| 530 | - wp_dequeue_script( 'elementor-ai-media-library' ); | |
| 531 | 463 | wp_dequeue_script( 'elementor-admin' ); |
| 532 | 464 | |
| 533 | 465 | wp_dequeue_style( 'elementor-admin-top-bar' ); |
| 534 | 466 | wp_dequeue_style( 'elementor-admin' ); |
| @@ -537,11 +469,28 @@ | ||
| 537 | 469 | |
| 538 | 470 | /** |
| 539 | 471 | * Scripts. |
| 540 | 472 | */ |
| 541 | - wp_enqueue_media(); | |
| 542 | 473 | wp_enqueue_script( 'updates' ); |
| 543 | 474 | wp_enqueue_script( 'rtsb-admin-app' ); |
| 475 | + wp_localize_script( | |
| 476 | + 'rtsb-admin-app', | |
| 477 | + 'rtsbParams', | |
| 478 | + [ | |
| 479 | + 'ajaxurl' => esc_url( self::$ajaxurl ), | |
| 480 | + 'homeurl' => home_url(), | |
| 481 | + 'adminLogo' => rtsb()->get_assets_uri( 'images/icon/ShopBuilder-Logo.svg' ), | |
| 482 | + 'restApiUrl' => esc_url_raw( rest_url() ), | |
| 483 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), | |
| 484 | + 'nonce' => wp_create_nonce( rtsb()->nonceText ), | |
| 485 | + 'pages' => Fns::get_pages(), | |
| 486 | + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no', | |
| 487 | + 'updateRates' => esc_html__( 'Update All Rates', 'shopbuilder' ), | |
| 488 | + 'sections' => Settings::instance()->get_sections(), | |
| 489 | + 'userRoles' => Fns::get_all_user_roles(), | |
| 490 | + 'hasElementor' => defined( 'ELEMENTOR_VERSION' ), | |
| 491 | + ] | |
| 492 | + ); | |
| 544 | 493 | } else { |
| 545 | 494 | $current_screen = get_current_screen(); |
| 546 | 495 | |
| 547 | 496 | if ( 'edit-rtsb_builder' === $current_screen->id ) { |
| @@ -564,16 +513,12 @@ | ||
| 564 | 513 | wp_localize_script( |
| 565 | 514 | 'rtsb-templatebuilder', |
| 566 | 515 | 'rtsbParams', |
| 567 | 516 | [ |
| 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 | - ), | |
| 517 | + 'ajaxurl' => esc_url( self::$ajaxurl ), | |
| 518 | + 'homeurl' => home_url(), | |
| 519 | + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), | |
| 520 | + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no', | |
| 576 | 521 | ] |
| 577 | 522 | ); |
| 578 | 523 | } |
| 579 | 524 | } |
| @@ -593,9 +538,8 @@ | ||
| 593 | 538 | |
| 594 | 539 | if ( ! empty( $notification_color ) ) { |
| 595 | 540 | $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{color:{$notification_color}}"; |
| 596 | 541 | $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 | 542 | } |
| 599 | 543 | |
| 600 | 544 | if ( ! empty( $notification_bgcolor ) ) { |
| 601 | 545 | $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success{background-color:{$notification_bgcolor}}"; |
| @@ -605,33 +549,8 @@ | ||
| 605 | 549 | $dynamic_css .= ".rtsb-shopbuilder-plugin #toast-container .toast-success a{color:{$notification_button_color}}"; |
| 606 | 550 | } |
| 607 | 551 | |
| 608 | 552 | if ( ! empty( $dynamic_css ) ) { |
| 609 | - wp_add_inline_style( Fns::optimized_handle( 'rtsb-frontend' ), $dynamic_css ); | |
| 553 | + wp_add_inline_style( 'rtsb-frontend', $dynamic_css ); | |
| 610 | 554 | } |
| 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 | 555 | } |
| 637 | 556 | } |