| @@ -1,18 +1,16 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | namespace Elementor; |
| 3 | 3 | |
| 4 | 4 | use Elementor\Core\Base\App; |
| 5 | -use Elementor\Core\Base\Elements_Iteration_Actions\Assets; | |
| 6 | -use Elementor\Core\Files\Fonts\Google_Font; | |
| 7 | 5 | use Elementor\Core\Frontend\Render_Mode_Manager; |
| 8 | 6 | use Elementor\Core\Responsive\Files\Frontend as FrontendFile; |
| 7 | +use Elementor\Core\Files\CSS\Global_CSS; | |
| 9 | 8 | use Elementor\Core\Files\CSS\Post as Post_CSS; |
| 10 | 9 | use Elementor\Core\Files\CSS\Post_Preview; |
| 11 | 10 | use Elementor\Core\Responsive\Responsive; |
| 12 | 11 | use Elementor\Core\Settings\Manager as SettingsManager; |
| 13 | 12 | use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager; |
| 14 | -use Elementor\Modules\FloatingButtons\Module; | |
| 15 | 13 | |
| 16 | 14 | if ( ! defined( 'ABSPATH' ) ) { |
| 17 | 15 | exit; // Exit if accessed directly. |
| 18 | 16 | } |
| @@ -32,13 +30,8 @@ | ||
| 32 | 30 | */ |
| 33 | 31 | const THE_CONTENT_FILTER_PRIORITY = 9; |
| 34 | 32 | |
| 35 | 33 | /** |
| 36 | - * The priority of the frontend enqueued styles. | |
| 37 | - */ | |
| 38 | - const ENQUEUED_STYLES_PRIORITY = 20; | |
| 39 | - | |
| 40 | - /** | |
| 41 | 34 | * Post ID. |
| 42 | 35 | * |
| 43 | 36 | * Holds the ID of the current post. |
| 44 | 37 | * |
| @@ -146,9 +139,21 @@ | ||
| 146 | 139 | private $body_classes = [ |
| 147 | 140 | 'elementor-default', |
| 148 | 141 | ]; |
| 149 | 142 | |
| 143 | + private $google_fonts_index = 0; | |
| 144 | + | |
| 150 | 145 | /** |
| 146 | + * @var string | |
| 147 | + */ | |
| 148 | + private $e_swiper_asset_path; | |
| 149 | + | |
| 150 | + /** | |
| 151 | + * @var string | |
| 152 | + */ | |
| 153 | + private $e_swiper_version; | |
| 154 | + | |
| 155 | + /** | |
| 151 | 156 | * Front End constructor. |
| 152 | 157 | * |
| 153 | 158 | * Initializing Elementor front end. Make sure we are not in admin, not and |
| 154 | 159 | * redirect from old URL structure of Elementor editor. |
| @@ -167,16 +172,13 @@ | ||
| 167 | 172 | add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 5 ); |
| 168 | 173 | add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 5 ); |
| 169 | 174 | |
| 170 | 175 | $this->add_content_filter(); |
| 176 | + $this->init_swiper_settings(); | |
| 171 | 177 | |
| 172 | 178 | // Hack to avoid enqueue post CSS while it's a `the_excerpt` call. |
| 173 | 179 | add_filter( 'get_the_excerpt', [ $this, 'start_excerpt_flag' ], 1 ); |
| 174 | 180 | add_filter( 'get_the_excerpt', [ $this, 'end_excerpt_flag' ], 20 ); |
| 175 | - | |
| 176 | - if ( version_compare( get_bloginfo( 'version' ), '6.9', '>=' ) ) { | |
| 177 | - add_filter( 'wp_should_output_buffer_template_for_enhancement', '__return_false', 1 ); | |
| 178 | - } | |
| 179 | 181 | } |
| 180 | 182 | |
| 181 | 183 | /** |
| 182 | 184 | * Get module name. |
| @@ -233,27 +235,36 @@ | ||
| 233 | 235 | |
| 234 | 236 | $document = Plugin::$instance->documents->get( $this->post_id ); |
| 235 | 237 | |
| 236 | 238 | if ( is_singular() && $document && $document->is_built_with_elementor() ) { |
| 237 | - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], self::ENQUEUED_STYLES_PRIORITY ); | |
| 239 | + add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ] ); | |
| 238 | 240 | } |
| 239 | 241 | |
| 240 | 242 | // Priority 7 to allow google fonts in header template to load in <head> tag |
| 241 | 243 | add_action( 'wp_head', [ $this, 'print_fonts_links' ], 7 ); |
| 244 | + add_action( 'wp_head', [ $this, 'print_google_fonts_preconnect_tag' ], 8 ); | |
| 242 | 245 | add_action( 'wp_head', [ $this, 'add_theme_color_meta_tag' ] ); |
| 243 | 246 | add_action( 'wp_footer', [ $this, 'wp_footer' ] ); |
| 244 | 247 | } |
| 245 | 248 | |
| 249 | + public function print_google_fonts_preconnect_tag() { | |
| 250 | + if ( 0 >= $this->google_fonts_index ) { | |
| 251 | + return; | |
| 252 | + } | |
| 253 | + | |
| 254 | + echo '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>'; | |
| 255 | + } | |
| 256 | + | |
| 246 | 257 | /** |
| 247 | 258 | * @since 2.0.12 |
| 248 | 259 | * @access public |
| 249 | - * @param string|array $class_name | |
| 260 | + * @param string|array $class | |
| 250 | 261 | */ |
| 251 | - public function add_body_class( $class_name ) { | |
| 252 | - if ( is_array( $class_name ) ) { | |
| 253 | - $this->body_classes = array_merge( $this->body_classes, $class_name ); | |
| 262 | + public function add_body_class( $class ) { | |
| 263 | + if ( is_array( $class ) ) { | |
| 264 | + $this->body_classes = array_merge( $this->body_classes, $class ); | |
| 254 | 265 | } else { |
| 255 | - $this->body_classes[] = $class_name; | |
| 266 | + $this->body_classes[] = $class; | |
| 256 | 267 | } |
| 257 | 268 | } |
| 258 | 269 | |
| 259 | 270 | /** |
| @@ -323,8 +334,14 @@ | ||
| 323 | 334 | public function add_content_filter() { |
| 324 | 335 | add_filter( 'the_content', [ $this, 'apply_builder_in_content' ], self::THE_CONTENT_FILTER_PRIORITY ); |
| 325 | 336 | } |
| 326 | 337 | |
| 338 | + public function init_swiper_settings() { | |
| 339 | + $e_swiper_latest = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ); | |
| 340 | + $this->e_swiper_asset_path = $e_swiper_latest ? 'assets/lib/swiper/v8/' : 'assets/lib/swiper/'; | |
| 341 | + $this->e_swiper_version = $e_swiper_latest ? '8.4.5' : '5.3.6'; | |
| 342 | + } | |
| 343 | + | |
| 327 | 344 | /** |
| 328 | 345 | * Remove content filter. |
| 329 | 346 | * |
| 330 | 347 | * When the Elementor generated content rendered, we remove the filter to prevent multiple |
| @@ -376,12 +393,14 @@ | ||
| 376 | 393 | true |
| 377 | 394 | ); |
| 378 | 395 | |
| 379 | 396 | wp_register_script( |
| 380 | - 'swiper', | |
| 381 | - $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/v8/' ), | |
| 382 | - [], | |
| 383 | - '8.4.5', | |
| 397 | + 'elementor-waypoints', | |
| 398 | + $this->get_js_assets_url( 'waypoints', 'assets/lib/waypoints/' ), | |
| 399 | + [ | |
| 400 | + 'jquery', | |
| 401 | + ], | |
| 402 | + '4.0.2', | |
| 384 | 403 | true |
| 385 | 404 | ); |
| 386 | 405 | |
| 387 | 406 | wp_register_script( |
| @@ -389,9 +408,9 @@ | ||
| 389 | 408 | $this->get_js_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ), |
| 390 | 409 | [ |
| 391 | 410 | 'jquery', |
| 392 | 411 | ], |
| 393 | - '4.6.13', | |
| 412 | + '4.1.4', | |
| 394 | 413 | true |
| 395 | 414 | ); |
| 396 | 415 | |
| 397 | 416 | wp_register_script( |
| @@ -419,9 +438,9 @@ | ||
| 419 | 438 | $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ), |
| 420 | 439 | [ |
| 421 | 440 | 'jquery-ui-position', |
| 422 | 441 | ], |
| 423 | - '4.9.4', | |
| 442 | + '4.9.0', | |
| 424 | 443 | true |
| 425 | 444 | ); |
| 426 | 445 | |
| 427 | 446 | wp_register_script( |
| @@ -446,18 +465,13 @@ | ||
| 446 | 465 | |
| 447 | 466 | wp_register_script( |
| 448 | 467 | 'elementor-frontend', |
| 449 | 468 | $this->get_js_assets_url( 'frontend' ), |
| 450 | - [ | |
| 451 | - 'elementor-frontend-modules', | |
| 452 | - 'jquery-ui-position', | |
| 453 | - ], | |
| 469 | + $this->get_elementor_frontend_dependencies(), | |
| 454 | 470 | ELEMENTOR_VERSION, |
| 455 | 471 | true |
| 456 | 472 | ); |
| 457 | 473 | |
| 458 | - $this->register_frontend_handlers(); | |
| 459 | - | |
| 460 | 474 | /** |
| 461 | 475 | * After frontend register scripts. |
| 462 | 476 | * |
| 463 | 477 | * Fires after Elementor frontend scripts are registered. |
| @@ -477,12 +491,8 @@ | ||
| 477 | 491 | * @since 1.2.0 |
| 478 | 492 | * @access public |
| 479 | 493 | */ |
| 480 | 494 | public function register_styles() { |
| 481 | - $min_suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 482 | - $direction_suffix = is_rtl() ? '-rtl' : ''; | |
| 483 | - $has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints(); | |
| 484 | - | |
| 485 | 495 | /** |
| 486 | 496 | * Before frontend register styles. |
| 487 | 497 | * |
| 488 | 498 | * Fires before Elementor frontend styles are registered. |
| @@ -508,9 +518,9 @@ | ||
| 508 | 518 | wp_register_style( |
| 509 | 519 | 'flatpickr', |
| 510 | 520 | $this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ), |
| 511 | 521 | [], |
| 512 | - '4.6.13' | |
| 522 | + '4.1.4' | |
| 513 | 523 | ); |
| 514 | 524 | |
| 515 | 525 | wp_register_style( |
| 516 | 526 | 'elementor-gallery', |
| @@ -518,70 +528,46 @@ | ||
| 518 | 528 | [], |
| 519 | 529 | '1.2.0' |
| 520 | 530 | ); |
| 521 | 531 | |
| 522 | - wp_register_style( | |
| 523 | - 'e-apple-webkit', | |
| 524 | - $this->get_frontend_file_url( 'apple-webkit.min.css', $has_custom_breakpoints, 'conditionals/' ), | |
| 525 | - [], | |
| 526 | - $has_custom_breakpoints ? null : ELEMENTOR_VERSION | |
| 527 | - ); | |
| 532 | + $min_suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 528 | 533 | |
| 529 | - wp_register_style( | |
| 530 | - 'e-swiper', | |
| 531 | - $this->get_css_assets_url( 'e-swiper', 'assets/css/conditionals/' ), | |
| 532 | - [ 'swiper' ], | |
| 533 | - ELEMENTOR_VERSION | |
| 534 | - ); | |
| 534 | + $direction_suffix = is_rtl() ? '-rtl' : ''; | |
| 535 | 535 | |
| 536 | - wp_register_style( | |
| 537 | - 'swiper', | |
| 538 | - $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ), | |
| 539 | - [], | |
| 540 | - '8.4.5' | |
| 541 | - ); | |
| 536 | + $frontend_base_file_name = $this->is_optimized_css_mode() ? 'frontend-lite' : 'frontend'; | |
| 542 | 537 | |
| 543 | - wp_register_style( | |
| 544 | - 'elementor-wp-admin-bar', | |
| 545 | - $this->get_css_assets_url( 'admin-bar', 'assets/css/' ), | |
| 546 | - [], | |
| 547 | - ELEMENTOR_VERSION | |
| 548 | - ); | |
| 538 | + $frontend_file_name = $frontend_base_file_name . $direction_suffix . $min_suffix . '.css'; | |
| 549 | 539 | |
| 540 | + $frontend_dependencies = []; | |
| 541 | + | |
| 542 | + $has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints(); | |
| 543 | + | |
| 544 | + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { | |
| 545 | + // If The Dom Optimization feature is disabled, register the legacy CSS | |
| 546 | + wp_register_style( | |
| 547 | + 'elementor-frontend-legacy', | |
| 548 | + $this->get_frontend_file_url( 'frontend-legacy' . $direction_suffix . $min_suffix . '.css', $has_custom_breakpoints ), | |
| 549 | + [], | |
| 550 | + ELEMENTOR_VERSION | |
| 551 | + ); | |
| 552 | + | |
| 553 | + $frontend_dependencies[] = 'elementor-frontend-legacy'; | |
| 554 | + } | |
| 555 | + | |
| 550 | 556 | wp_register_style( |
| 551 | - 'e-lightbox', | |
| 552 | - $this->get_frontend_file_url( 'lightbox.min.css', $has_custom_breakpoints, 'conditionals/' ), | |
| 553 | - [], | |
| 557 | + 'elementor-frontend', | |
| 558 | + $this->get_frontend_file_url( $frontend_file_name, $has_custom_breakpoints ), | |
| 559 | + $frontend_dependencies, | |
| 554 | 560 | $has_custom_breakpoints ? null : ELEMENTOR_VERSION |
| 555 | 561 | ); |
| 556 | 562 | |
| 557 | 563 | wp_register_style( |
| 558 | - 'elementor-frontend', | |
| 559 | - $this->get_frontend_file_url( "frontend{$min_suffix}.css", $has_custom_breakpoints ), | |
| 564 | + 'swiper', | |
| 565 | + $this->get_css_assets_url( 'swiper', $this->e_swiper_asset_path . 'css/' ), | |
| 560 | 566 | [], |
| 561 | - $has_custom_breakpoints ? null : ELEMENTOR_VERSION | |
| 567 | + $this->e_swiper_version | |
| 562 | 568 | ); |
| 563 | 569 | |
| 564 | - $widgets_with_styles = Plugin::$instance->widgets_manager->widgets_with_styles(); | |
| 565 | - foreach ( $widgets_with_styles as $widget_name ) { | |
| 566 | - wp_register_style( | |
| 567 | - "widget-{$widget_name}", | |
| 568 | - $this->get_css_assets_url( "widget-{$widget_name}", null, true, true ), | |
| 569 | - [ 'elementor-frontend' ], | |
| 570 | - ELEMENTOR_VERSION | |
| 571 | - ); | |
| 572 | - } | |
| 573 | - | |
| 574 | - $widgets_with_responsive_styles = Plugin::$instance->widgets_manager->widgets_with_responsive_styles(); | |
| 575 | - foreach ( $widgets_with_responsive_styles as $widget_name ) { | |
| 576 | - wp_register_style( | |
| 577 | - "widget-{$widget_name}", | |
| 578 | - $this->get_frontend_file_url( "widget-{$widget_name}{$direction_suffix}.min.css", $has_custom_breakpoints ), | |
| 579 | - [ 'elementor-frontend' ], | |
| 580 | - $has_custom_breakpoints ? null : ELEMENTOR_VERSION | |
| 581 | - ); | |
| 582 | - } | |
| 583 | - | |
| 584 | 570 | /** |
| 585 | 571 | * After frontend register styles. |
| 586 | 572 | * |
| 587 | 573 | * Fires after Elementor frontend styles are registered. |
| @@ -591,23 +577,8 @@ | ||
| 591 | 577 | do_action( 'elementor/frontend/after_register_styles' ); |
| 592 | 578 | } |
| 593 | 579 | |
| 594 | 580 | /** |
| 595 | - * Register frontend handlers. | |
| 596 | - * | |
| 597 | - * Registers all the frontend handlers for widgets and elements. | |
| 598 | - * | |
| 599 | - * Fired by `wp_enqueue_scripts` action. | |
| 600 | - * | |
| 601 | - * @since 3.25.0 | |
| 602 | - * @access public | |
| 603 | - */ | |
| 604 | - public function register_frontend_handlers() { | |
| 605 | - Plugin::$instance->widgets_manager->register_frontend_handlers(); | |
| 606 | - Plugin::$instance->elements_manager->register_frontend_handlers(); | |
| 607 | - } | |
| 608 | - | |
| 609 | - /** | |
| 610 | 581 | * Enqueue scripts. |
| 611 | 582 | * |
| 612 | 583 | * Enqueue all the frontend scripts. |
| 613 | 584 | * |
| @@ -623,8 +594,22 @@ | ||
| 623 | 594 | * @since 1.0.0 |
| 624 | 595 | */ |
| 625 | 596 | do_action( 'elementor/frontend/before_enqueue_scripts' ); |
| 626 | 597 | |
| 598 | + wp_enqueue_script( 'elementor-frontend' ); | |
| 599 | + | |
| 600 | + if ( ! $this->is_improved_assets_loading() ) { | |
| 601 | + wp_enqueue_script( | |
| 602 | + 'preloaded-modules', | |
| 603 | + $this->get_js_assets_url( 'preloaded-modules', 'assets/js/' ), | |
| 604 | + [ | |
| 605 | + 'elementor-frontend', | |
| 606 | + ], | |
| 607 | + ELEMENTOR_VERSION, | |
| 608 | + true | |
| 609 | + ); | |
| 610 | + } | |
| 611 | + | |
| 627 | 612 | $this->print_config(); |
| 628 | 613 | |
| 629 | 614 | $this->enqueue_conditional_assets(); |
| 630 | 615 | |
| @@ -669,11 +654,9 @@ | ||
| 669 | 654 | } |
| 670 | 655 | |
| 671 | 656 | wp_enqueue_style( 'elementor-frontend' ); |
| 672 | 657 | |
| 673 | - if ( is_admin_bar_showing() ) { | |
| 674 | - wp_enqueue_style( 'elementor-wp-admin-bar' ); | |
| 675 | - } | |
| 658 | + wp_enqueue_style( 'swiper' ); | |
| 676 | 659 | |
| 677 | 660 | /** |
| 678 | 661 | * After frontend styles enqueued. |
| 679 | 662 | * |
| @@ -683,44 +666,20 @@ | ||
| 683 | 666 | */ |
| 684 | 667 | do_action( 'elementor/frontend/after_enqueue_styles' ); |
| 685 | 668 | |
| 686 | 669 | if ( ! Plugin::$instance->preview->is_preview_mode() ) { |
| 670 | + $this->parse_global_css_code(); | |
| 671 | + | |
| 687 | 672 | $post_id = get_the_ID(); |
| 688 | 673 | // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages. |
| 689 | 674 | if ( $post_id && is_singular() ) { |
| 690 | - do_action( 'elementor/post/render', $post_id ); | |
| 691 | - $this->handle_page_assets( $post_id ); | |
| 692 | - | |
| 693 | 675 | $css_file = Post_CSS::create( get_the_ID() ); |
| 694 | 676 | $css_file->enqueue(); |
| 695 | 677 | } |
| 696 | - } else { | |
| 697 | - $post_id = Plugin::$instance->preview->get_post_id(); | |
| 698 | - if ( $post_id ) { | |
| 699 | - do_action( 'elementor/post/render', $post_id ); | |
| 700 | - } | |
| 701 | 678 | } |
| 702 | - | |
| 703 | - do_action( 'elementor/frontend/after_enqueue_post_styles' ); | |
| 704 | 679 | } |
| 705 | 680 | } |
| 706 | 681 | |
| 707 | - private function handle_page_assets( $post_id ): void { | |
| 708 | - $page_assets = get_post_meta( $post_id, Assets::ASSETS_META_KEY, true ); | |
| 709 | - if ( ! empty( $page_assets ) ) { | |
| 710 | - Plugin::$instance->assets_loader->enable_assets( $page_assets ); | |
| 711 | - return; | |
| 712 | - } | |
| 713 | - | |
| 714 | - $document = Plugin::$instance->documents->get( $post_id ); | |
| 715 | - | |
| 716 | - if ( ! $document ) { | |
| 717 | - return; | |
| 718 | - } | |
| 719 | - | |
| 720 | - $document->update_runtime_elements(); | |
| 721 | - } | |
| 722 | - | |
| 723 | 682 | /** |
| 724 | 683 | * Get Frontend File URL |
| 725 | 684 | * |
| 726 | 685 | * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom |
| @@ -729,20 +688,20 @@ | ||
| 729 | 688 | * @since 3.4.5 |
| 730 | 689 | * |
| 731 | 690 | * @access public |
| 732 | 691 | * |
| 733 | - * @param string $frontend_file_name | |
| 692 | + * @param string $frontend_file_name | |
| 734 | 693 | * @param boolean $custom_file |
| 735 | 694 | * |
| 736 | 695 | * @return string frontend file URL |
| 737 | 696 | */ |
| 738 | - public function get_frontend_file_url( $frontend_file_name, $custom_file, $css_subfolder = '' ) { | |
| 697 | + public function get_frontend_file_url( $frontend_file_name, $custom_file ) { | |
| 739 | 698 | if ( $custom_file ) { |
| 740 | 699 | $frontend_file = $this->get_frontend_file( $frontend_file_name ); |
| 741 | 700 | |
| 742 | 701 | $frontend_file_url = $frontend_file->get_url(); |
| 743 | 702 | } else { |
| 744 | - $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $css_subfolder . $frontend_file_name; | |
| 703 | + $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $frontend_file_name; | |
| 745 | 704 | } |
| 746 | 705 | |
| 747 | 706 | return $frontend_file_url; |
| 748 | 707 | } |
| @@ -755,9 +714,9 @@ | ||
| 755 | 714 | * |
| 756 | 715 | * @since 3.5.0 |
| 757 | 716 | * @access public |
| 758 | 717 | * |
| 759 | - * @param string $frontend_file_name | |
| 718 | + * @param string $frontend_file_name | |
| 760 | 719 | * @param boolean $custom_file |
| 761 | 720 | * |
| 762 | 721 | * @return string frontend file path |
| 763 | 722 | */ |
| @@ -900,20 +859,8 @@ | ||
| 900 | 859 | * @since 1.9.4 |
| 901 | 860 | * @access public |
| 902 | 861 | */ |
| 903 | 862 | public function print_fonts_links() { |
| 904 | - /** | |
| 905 | - * Register font styles. | |
| 906 | - * | |
| 907 | - * Fires before fonts are processed, allowing add-ons to register | |
| 908 | - * proper stylesheets for their custom font types via the WordPress API. | |
| 909 | - * | |
| 910 | - * @since 3.29.0 | |
| 911 | - * | |
| 912 | - * @param string[] $fonts_to_enqueue List of font families to be enqueued. | |
| 913 | - */ | |
| 914 | - do_action( 'elementor/fonts/register_styles', $this->fonts_to_enqueue ); | |
| 915 | - | |
| 916 | 863 | $google_fonts = $this->get_list_of_google_fonts_by_type(); |
| 917 | 864 | |
| 918 | 865 | $this->enqueue_google_fonts( $google_fonts ); |
| 919 | 866 | $this->enqueue_icon_fonts(); |
| @@ -944,9 +891,9 @@ | ||
| 944 | 891 | wp_enqueue_style( 'elementor-icons-' . $icon_type ); |
| 945 | 892 | $this->enqueued_icon_fonts[] = $css_url; |
| 946 | 893 | } |
| 947 | 894 | |
| 948 | - // Clear enqueued icons. | |
| 895 | + //clear enqueued icons | |
| 949 | 896 | $this->icon_fonts_to_enqueue = []; |
| 950 | 897 | } |
| 951 | 898 | |
| 952 | 899 | /** |
| @@ -1044,21 +991,29 @@ | ||
| 1044 | 991 | if ( ! $print_google_fonts ) { |
| 1045 | 992 | return; |
| 1046 | 993 | } |
| 1047 | 994 | |
| 1048 | - $force_enqueue_from_cdn = Plugin::$instance->preview->is_preview_mode(); | |
| 995 | + // Print used fonts | |
| 996 | + if ( ! empty( $google_fonts['google'] ) ) { | |
| 997 | + $this->google_fonts_index++; | |
| 1049 | 998 | |
| 1050 | - if ( ! empty( $google_fonts['google'] ) ) { | |
| 1051 | - foreach ( $google_fonts['google'] as $current_font ) { | |
| 1052 | - Google_Font::enqueue( $current_font, Google_Font::TYPE_DEFAULT, $force_enqueue_from_cdn ); | |
| 1053 | - } | |
| 999 | + $fonts_url = $this->get_stable_google_fonts_url( $google_fonts['google'] ); | |
| 1000 | + | |
| 1001 | + wp_enqueue_style( 'google-fonts-' . $this->google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1054 | 1002 | } |
| 1055 | 1003 | |
| 1056 | 1004 | if ( ! empty( $google_fonts['early'] ) ) { |
| 1057 | - foreach ( $google_fonts['early'] as $current_font ) { | |
| 1058 | - Google_Font::enqueue( $current_font, Google_Font::TYPE_EARLYACCESS, $force_enqueue_from_cdn ); | |
| 1005 | + $early_access_font_urls = $this->get_early_access_google_font_urls( $google_fonts['early'] ); | |
| 1006 | + | |
| 1007 | + foreach ( $early_access_font_urls as $ea_font_url ) { | |
| 1008 | + $this->google_fonts_index++; | |
| 1009 | + | |
| 1010 | + //printf( '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/earlyaccess/%s.css">', strtolower( str_replace( ' ', '', $current_font ) ) ); | |
| 1011 | + | |
| 1012 | + wp_enqueue_style( 'google-earlyaccess-' . $this->google_fonts_index, $ea_font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1059 | 1013 | } |
| 1060 | 1014 | } |
| 1015 | + | |
| 1061 | 1016 | } |
| 1062 | 1017 | |
| 1063 | 1018 | /** |
| 1064 | 1019 | * Enqueue fonts. |
| @@ -1079,8 +1034,22 @@ | ||
| 1079 | 1034 | $this->registered_fonts[] = $font; |
| 1080 | 1035 | } |
| 1081 | 1036 | |
| 1082 | 1037 | /** |
| 1038 | + * Parse global CSS. | |
| 1039 | + * | |
| 1040 | + * Enqueue the global CSS file. | |
| 1041 | + * | |
| 1042 | + * @since 1.2.0 | |
| 1043 | + * @access protected | |
| 1044 | + */ | |
| 1045 | + protected function parse_global_css_code() { | |
| 1046 | + $scheme_css_file = Global_CSS::create( 'global.css' ); | |
| 1047 | + | |
| 1048 | + $scheme_css_file->enqueue(); | |
| 1049 | + } | |
| 1050 | + | |
| 1051 | + /** | |
| 1083 | 1052 | * Apply builder in content. |
| 1084 | 1053 | * |
| 1085 | 1054 | * Used to apply the Elementor page editor on the post content. |
| 1086 | 1055 | * |
| @@ -1147,21 +1116,8 @@ | ||
| 1147 | 1116 | |
| 1148 | 1117 | $data = $document->get_elements_data(); |
| 1149 | 1118 | |
| 1150 | 1119 | /** |
| 1151 | - * Filters document elements data after loading. | |
| 1152 | - * | |
| 1153 | - * Allows modification of elements data when loading (not saving). | |
| 1154 | - * Useful for migrations, transformations, or data enrichment. | |
| 1155 | - * | |
| 1156 | - * @since 4.0.0 | |
| 1157 | - * | |
| 1158 | - * @param array $data The elements data array. | |
| 1159 | - * @param \Elementor\Core\Base\Document $document The document instance. | |
| 1160 | - */ | |
| 1161 | - $data = apply_filters( 'elementor/document/load/data', $data, $document ); | |
| 1162 | - | |
| 1163 | - /** | |
| 1164 | 1120 | * Frontend builder content data. |
| 1165 | 1121 | * |
| 1166 | 1122 | * Filters the builder content in the frontend. |
| 1167 | 1123 | * |
| @@ -1257,9 +1213,9 @@ | ||
| 1257 | 1213 | * |
| 1258 | 1214 | * @since 1.0.0 |
| 1259 | 1215 | * @access public |
| 1260 | 1216 | * |
| 1261 | - * @param int $post_id The post ID. | |
| 1217 | + * @param int $post_id The post ID. | |
| 1262 | 1218 | * |
| 1263 | 1219 | * @param bool $with_css Optional. Whether to retrieve the content with CSS |
| 1264 | 1220 | * or not. Default is false. |
| 1265 | 1221 | * |
| @@ -1436,8 +1392,9 @@ | ||
| 1436 | 1392 | 'playVideo' => esc_html__( 'Play Video', 'elementor' ), |
| 1437 | 1393 | 'previous' => esc_html__( 'Previous', 'elementor' ), |
| 1438 | 1394 | 'next' => esc_html__( 'Next', 'elementor' ), |
| 1439 | 1395 | 'close' => esc_html__( 'Close', 'elementor' ), |
| 1396 | + 'a11yCarouselWrapperAriaLabel' => __( 'Carousel | Horizontal scrolling: Arrow Left & Right', 'elementor' ), | |
| 1440 | 1397 | 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ), |
| 1441 | 1398 | 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ), |
| 1442 | 1399 | 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ), |
| 1443 | 1400 | 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ), |
| @@ -1448,9 +1405,8 @@ | ||
| 1448 | 1405 | 'breakpoints' => Responsive::get_breakpoints(), |
| 1449 | 1406 | // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0 |
| 1450 | 1407 | 'responsive' => [ |
| 1451 | 1408 | 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(), |
| 1452 | - 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(), | |
| 1453 | 1409 | ], |
| 1454 | 1410 | 'version' => ELEMENTOR_VERSION, |
| 1455 | 1411 | 'is_static' => $this->is_static_render_mode(), |
| 1456 | 1412 | 'experimentalFeatures' => $active_experimental_features, |
| @@ -1455,16 +1411,10 @@ | ||
| 1455 | 1411 | 'is_static' => $this->is_static_render_mode(), |
| 1456 | 1412 | 'experimentalFeatures' => $active_experimental_features, |
| 1457 | 1413 | 'urls' => [ |
| 1458 | 1414 | 'assets' => $assets_url, |
| 1459 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 1460 | - 'uploadUrl' => wp_upload_dir()['baseurl'], | |
| 1461 | 1415 | ], |
| 1462 | - 'nonces' => [ | |
| 1463 | - 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ), | |
| 1464 | - 'atomicFormsSendForm' => wp_create_nonce( 'elementor_pro_atomic_forms_send_form' ), | |
| 1465 | - ], | |
| 1466 | - 'swiperClass' => 'swiper', | |
| 1416 | + 'swiperClass' => Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container', | |
| 1467 | 1417 | ]; |
| 1468 | 1418 | |
| 1469 | 1419 | $settings['settings'] = SettingsManager::get_settings_frontend_config(); |
| 1470 | 1420 | |
| @@ -1546,9 +1496,9 @@ | ||
| 1546 | 1496 | * |
| 1547 | 1497 | * @access private |
| 1548 | 1498 | * @since 2.0.4 |
| 1549 | 1499 | * |
| 1550 | - * @param string $content | |
| 1500 | + * @param $content | |
| 1551 | 1501 | * |
| 1552 | 1502 | * @return string |
| 1553 | 1503 | */ |
| 1554 | 1504 | private function process_more_tag( $content ) { |
| @@ -1596,6 +1546,40 @@ | ||
| 1596 | 1546 | */ |
| 1597 | 1547 | $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text ); |
| 1598 | 1548 | |
| 1599 | 1549 | return force_balance_tags( $parts['main'] ) . $more_link; |
| 1550 | + } | |
| 1551 | + | |
| 1552 | + private function is_improved_assets_loading() { | |
| 1553 | + return Plugin::$instance->experiments->is_feature_active( 'e_optimized_assets_loading' ); | |
| 1554 | + } | |
| 1555 | + | |
| 1556 | + private function get_elementor_frontend_dependencies() { | |
| 1557 | + $dependencies = [ | |
| 1558 | + 'elementor-frontend-modules', | |
| 1559 | + 'elementor-waypoints', | |
| 1560 | + 'jquery-ui-position', | |
| 1561 | + ]; | |
| 1562 | + | |
| 1563 | + if ( ! $this->is_improved_assets_loading() ) { | |
| 1564 | + wp_register_script( | |
| 1565 | + 'swiper', | |
| 1566 | + $this->get_js_assets_url( 'swiper', $this->e_swiper_asset_path ), | |
| 1567 | + [], | |
| 1568 | + $this->e_swiper_version, | |
| 1569 | + true | |
| 1570 | + ); | |
| 1571 | + | |
| 1572 | + $dependencies[] = 'swiper'; | |
| 1573 | + $dependencies[] = 'share-link'; | |
| 1574 | + $dependencies[] = 'elementor-dialog'; | |
| 1575 | + } | |
| 1576 | + | |
| 1577 | + return $dependencies; | |
| 1578 | + } | |
| 1579 | + | |
| 1580 | + private function is_optimized_css_mode() { | |
| 1581 | + $is_optimized_css_loading = Plugin::$instance->experiments->is_feature_active( 'e_optimized_css_loading' ); | |
| 1582 | + | |
| 1583 | + return ! Utils::is_script_debug() && $is_optimized_css_loading && ! Plugin::$instance->preview->is_preview_mode(); | |
| 1600 | 1584 | } |
| 1601 | 1585 | } |