| @@ -86,9 +86,9 @@ | ||
| 86 | 86 | * |
| 87 | 87 | * @return object |
| 88 | 88 | */ |
| 89 | 89 | private function get_public_styles() { |
| 90 | - $rtl_suffix = is_rtl() ? '-rtl' : ''; | |
| 90 | + $rtl_suffix = is_rtl() ? '-rtl' : ''; | |
| 91 | 91 | $this->styles[] = [ |
| 92 | 92 | 'handle' => 'rtsb-fonts', |
| 93 | 93 | 'src' => rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ), |
| 94 | 94 | ]; |
| @@ -136,11 +136,30 @@ | ||
| 136 | 136 | * |
| 137 | 137 | * @return object |
| 138 | 138 | */ |
| 139 | 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 | + | |
| 140 | 159 | $this->scripts[] = [ |
| 141 | 160 | 'handle' => 'swiper', |
| 142 | - 'src' => rtsb()->get_assets_uri( 'vendor/swiper/js/swiper-bundle.min.js' ), | |
| 161 | + 'src' => esc_url( $default_swiper_path ), | |
| 143 | 162 | 'deps' => [ 'jquery' ], |
| 144 | 163 | 'footer' => true, |
| 145 | 164 | ]; |
| 146 | 165 | |
| @@ -303,18 +322,20 @@ | ||
| 303 | 322 | wp_localize_script( |
| 304 | 323 | 'rtsb-public', |
| 305 | 324 | 'rtsbPublicParams', |
| 306 | 325 | [ |
| 307 | - 'ajaxUrl' => esc_url( self::$ajaxurl ), | |
| 308 | - 'homeurl' => home_url(), | |
| 309 | - 'wcCartUrl' => wc_get_cart_url(), | |
| 310 | - 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ), | |
| 311 | - 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ), | |
| 312 | - 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ), | |
| 313 | - 'notice' => [ | |
| 326 | + 'ajaxUrl' => esc_url( self::$ajaxurl ), | |
| 327 | + 'homeurl' => home_url(), | |
| 328 | + 'wcCartUrl' => wc_get_cart_url(), | |
| 329 | + 'addedToCartText' => esc_html__( 'Product Added', 'shopbuilder' ), | |
| 330 | + 'singleCartToastrText' => esc_html__( 'Successfully Added', 'shopbuilder' ), | |
| 331 | + 'singleCartBtnText' => apply_filters( 'rtsb/global/single_add_to_cart_success', esc_html__( 'Added to Cart', 'shopbuilder' ) ), | |
| 332 | + 'browseCartText' => esc_html__( 'Browse Cart', 'shopbuilder' ), | |
| 333 | + 'noProductsText' => apply_filters( 'rtsb/global/no_products_text', esc_html__( 'No more products to load', 'shopbuilder' ) ), | |
| 334 | + 'notice' => [ | |
| 314 | 335 | 'position' => Fns::get_option( 'general', 'notification', 'notification_position', 'center-center' ), |
| 315 | 336 | ], |
| 316 | - rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), | |
| 337 | + rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), | |
| 317 | 338 | ] |
| 318 | 339 | ); |
| 319 | 340 | } |
| 320 | 341 | |
| @@ -327,9 +348,20 @@ | ||
| 327 | 348 | /** |
| 328 | 349 | * Styles. |
| 329 | 350 | */ |
| 330 | 351 | wp_register_style( 'rtsb-admin-app', rtsb()->get_assets_uri( 'css/backend/admin-settings.css' ), '', $this->version ); |
| 331 | - wp_register_style( 'rtsb-admin-global', rtsb()->get_assets_uri( 'css/backend/admin-global.css' ), '', $this->version ); | |
| 352 | + wp_register_style( 'rtsb-fonts', rtsb()->get_assets_uri( 'css/frontend/rtsb-fonts.css' ), '', $this->version ); | |
| 353 | + | |
| 354 | + $current_screen = get_current_screen(); | |
| 355 | + | |
| 356 | + if ( 'edit-rtsb_builder' === $current_screen->id ) { | |
| 357 | + if ( ! function_exists( 'woocommerce_get_asset_url' ) ) { | |
| 358 | + include_once WC_ABSPATH . 'includes/wc-template-functions.php'; | |
| 359 | + } | |
| 360 | + | |
| 361 | + wp_deregister_style( 'select2' ); | |
| 362 | + wp_register_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 363 | + } | |
| 332 | 364 | wp_register_style( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'css/backend/template-builder.css' ), '', $this->version ); |
| 333 | 365 | |
| 334 | 366 | /** |
| 335 | 367 | * Scripts. |
| @@ -335,9 +367,8 @@ | ||
| 335 | 367 | * Scripts. |
| 336 | 368 | */ |
| 337 | 369 | wp_register_script( 'rtsb-admin-app', rtsb()->get_assets_uri( 'js/backend/admin-settings.js' ), '', $this->version, true ); |
| 338 | 370 | wp_register_script( 'rtsb-templatebuilder', rtsb()->get_assets_uri( 'js/backend/template-builder.js' ), '', $this->version, true ); |
| 339 | - | |
| 340 | 371 | } |
| 341 | 372 | |
| 342 | 373 | /** |
| 343 | 374 | * Enqueues admin scripts. |
| @@ -346,14 +377,39 @@ | ||
| 346 | 377 | * |
| 347 | 378 | * @return void |
| 348 | 379 | */ |
| 349 | 380 | public function enqueue_backend_scripts( $hook ) { |
| 381 | + ob_start(); ?> | |
| 382 | + #adminmenu .toplevel_page_rtsb .wp-menu-image img { | |
| 383 | + width: auto; | |
| 384 | + height: 22px; | |
| 385 | + padding: 4px 0; | |
| 386 | + } | |
| 387 | + .post-type-rtsb_builder li#wp-admin-bar-WPML_ALS_all, | |
| 388 | + .post-type-rtsb_builder li.language_all{ | |
| 389 | + display: none; | |
| 390 | + } | |
| 350 | 391 | |
| 351 | - wp_enqueue_style( 'rtsb-admin-global' ); | |
| 392 | + <?php | |
| 393 | + $admin_global_style = ob_get_clean(); | |
| 394 | + // Speed Optimization. | |
| 395 | + wp_add_inline_style( 'admin-menu', $admin_global_style ); | |
| 396 | + // wp_enqueue_style( 'rtsb-admin-global' ); | |
| 352 | 397 | |
| 353 | 398 | global $pagenow; |
| 354 | 399 | |
| 355 | - if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) { | |
| 400 | + $whitelisted_pages = [ 'rtsb-settings', 'rtsb-get-help', 'rtsb-themes' ]; | |
| 401 | + $current_page = ! empty( $_GET['page'] ) ? sanitize_text_field( wp_unslash( $_GET['page'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 402 | + | |
| 403 | + if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && in_array( $current_page, $whitelisted_pages, true ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 404 | + /** | |
| 405 | + * Styles. | |
| 406 | + */ | |
| 407 | + wp_enqueue_style( 'rtsb-admin-app' ); | |
| 408 | + wp_enqueue_style( 'rtsb-fonts' ); | |
| 409 | + } | |
| 410 | + | |
| 411 | + if ( 'admin.php' === $pagenow && ! empty( $_GET['page'] ) && 'rtsb-settings' === $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended | |
| 356 | 412 | // Elementor Console Error Fixed For "rtsb-settings" Page. |
| 357 | 413 | wp_dequeue_script( 'elementor-admin-top-bar' ); |
| 358 | 414 | wp_dequeue_script( 'elementor-common' ); |
| 359 | 415 | wp_dequeue_script( 'elementor-dev-tools' ); |
| @@ -368,13 +424,8 @@ | ||
| 368 | 424 | wp_dequeue_style( 'e-theme-ui-light' ); |
| 369 | 425 | wp_dequeue_style( 'elementor-common' ); |
| 370 | 426 | |
| 371 | 427 | /** |
| 372 | - * Styles. | |
| 373 | - */ | |
| 374 | - wp_enqueue_style( 'rtsb-admin-app' ); | |
| 375 | - | |
| 376 | - /** | |
| 377 | 428 | * Scripts. |
| 378 | 429 | */ |
| 379 | 430 | wp_enqueue_script( 'updates' ); |
| 380 | 431 | wp_enqueue_script( 'rtsb-admin-app' ); |
| @@ -381,16 +432,19 @@ | ||
| 381 | 432 | wp_localize_script( |
| 382 | 433 | 'rtsb-admin-app', |
| 383 | 434 | 'rtsbParams', |
| 384 | 435 | [ |
| 385 | - 'ajaxurl' => esc_url( self::$ajaxurl ), | |
| 386 | - 'homeurl' => home_url(), | |
| 387 | - 'restApiUrl' => esc_url_raw( rest_url() ), | |
| 388 | - 'rest_nonce' => wp_create_nonce( 'wp_rest' ), | |
| 389 | - 'nonce' => wp_create_nonce( rtsb()->nonceText ), | |
| 390 | - 'sections' => Settings::instance()->get_sections(), | |
| 391 | - 'pages' => Fns::get_pages(), | |
| 392 | - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no' | |
| 436 | + 'ajaxurl' => esc_url( self::$ajaxurl ), | |
| 437 | + 'homeurl' => home_url(), | |
| 438 | + 'adminLogo' => rtsb()->get_assets_uri( 'images/icon/ShopBuilder-Logo.svg' ), | |
| 439 | + 'restApiUrl' => esc_url_raw( rest_url() ), | |
| 440 | + 'rest_nonce' => wp_create_nonce( 'wp_rest' ), | |
| 441 | + 'nonce' => wp_create_nonce( rtsb()->nonceText ), | |
| 442 | + 'pages' => Fns::get_pages(), | |
| 443 | + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no', | |
| 444 | + 'updateRates' => esc_html__( 'Update All Rates', 'shopbuilder' ), | |
| 445 | + 'sections' => Settings::instance()->get_sections(), | |
| 446 | + 'userRoles' => Fns::get_all_user_roles(), | |
| 393 | 447 | ] |
| 394 | 448 | ); |
| 395 | 449 | } else { |
| 396 | 450 | $current_screen = get_current_screen(); |
| @@ -403,9 +457,9 @@ | ||
| 403 | 457 | * Styles. |
| 404 | 458 | */ |
| 405 | 459 | wp_enqueue_style( 'rtsb-templatebuilder' ); |
| 406 | 460 | |
| 407 | - wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); | |
| 461 | + wp_enqueue_style( 'select2', plugins_url( 'assets/css/select2.css', WC_PLUGIN_FILE ) ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 408 | 462 | |
| 409 | 463 | wp_enqueue_script( 'selectWoo' ); |
| 410 | 464 | /** |
| 411 | 465 | * Scripts. |
| @@ -418,9 +472,9 @@ | ||
| 418 | 472 | [ |
| 419 | 473 | 'ajaxurl' => esc_url( self::$ajaxurl ), |
| 420 | 474 | 'homeurl' => home_url(), |
| 421 | 475 | rtsb()->nonceId => wp_create_nonce( rtsb()->nonceText ), |
| 422 | - 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no' | |
| 476 | + 'hasPro' => rtsb()->has_pro() ? 'yes' : 'no', | |
| 423 | 477 | ] |
| 424 | 478 | ); |
| 425 | 479 | } |
| 426 | 480 | } |