| @@ -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 | * |
| @@ -171,12 +164,8 @@ | ||
| 171 | 164 | |
| 172 | 165 | // Hack to avoid enqueue post CSS while it's a `the_excerpt` call. |
| 173 | 166 | add_filter( 'get_the_excerpt', [ $this, 'start_excerpt_flag' ], 1 ); |
| 174 | 167 | 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 | 168 | } |
| 180 | 169 | |
| 181 | 170 | /** |
| 182 | 171 | * Get module name. |
| @@ -233,9 +222,9 @@ | ||
| 233 | 222 | |
| 234 | 223 | $document = Plugin::$instance->documents->get( $this->post_id ); |
| 235 | 224 | |
| 236 | 225 | if ( is_singular() && $document && $document->is_built_with_elementor() ) { |
| 237 | - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], self::ENQUEUED_STYLES_PRIORITY ); | |
| 226 | + add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ] ); | |
| 238 | 227 | } |
| 239 | 228 | |
| 240 | 229 | // Priority 7 to allow google fonts in header template to load in <head> tag |
| 241 | 230 | add_action( 'wp_head', [ $this, 'print_fonts_links' ], 7 ); |
| @@ -245,15 +234,15 @@ | ||
| 245 | 234 | |
| 246 | 235 | /** |
| 247 | 236 | * @since 2.0.12 |
| 248 | 237 | * @access public |
| 249 | - * @param string|array $class_name | |
| 238 | + * @param string|array $class | |
| 250 | 239 | */ |
| 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 ); | |
| 240 | + public function add_body_class( $class ) { | |
| 241 | + if ( is_array( $class ) ) { | |
| 242 | + $this->body_classes = array_merge( $this->body_classes, $class ); | |
| 254 | 243 | } else { |
| 255 | - $this->body_classes[] = $class_name; | |
| 244 | + $this->body_classes[] = $class; | |
| 256 | 245 | } |
| 257 | 246 | } |
| 258 | 247 | |
| 259 | 248 | /** |
| @@ -263,13 +252,13 @@ | ||
| 263 | 252 | * @access public |
| 264 | 253 | */ |
| 265 | 254 | public function add_theme_color_meta_tag() { |
| 266 | 255 | $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend(); |
| 267 | - $mobile_theme_color = $kit->get_settings( 'mobile_browser_background' ); | |
| 256 | + $mobile_theme_color = $kit->get_settings( 'mobile_theme_color' ); | |
| 268 | 257 | |
| 269 | 258 | if ( ! empty( $mobile_theme_color ) ) { |
| 270 | 259 | ?> |
| 271 | - <meta name="theme-color" content="<?php echo esc_attr( $mobile_theme_color ); ?>"> | |
| 260 | + <meta name="theme-color" content="<?php echo esc_html( $mobile_theme_color ); ?>"> | |
| 272 | 261 | <?php |
| 273 | 262 | } |
| 274 | 263 | } |
| 275 | 264 | |
| @@ -376,12 +365,14 @@ | ||
| 376 | 365 | true |
| 377 | 366 | ); |
| 378 | 367 | |
| 379 | 368 | wp_register_script( |
| 380 | - 'swiper', | |
| 381 | - $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/v8/' ), | |
| 382 | - [], | |
| 383 | - '8.4.5', | |
| 369 | + 'elementor-waypoints', | |
| 370 | + $this->get_js_assets_url( 'waypoints', 'assets/lib/waypoints/' ), | |
| 371 | + [ | |
| 372 | + 'jquery', | |
| 373 | + ], | |
| 374 | + '4.0.2', | |
| 384 | 375 | true |
| 385 | 376 | ); |
| 386 | 377 | |
| 387 | 378 | wp_register_script( |
| @@ -389,9 +380,9 @@ | ||
| 389 | 380 | $this->get_js_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ), |
| 390 | 381 | [ |
| 391 | 382 | 'jquery', |
| 392 | 383 | ], |
| 393 | - '4.6.13', | |
| 384 | + '4.1.4', | |
| 394 | 385 | true |
| 395 | 386 | ); |
| 396 | 387 | |
| 397 | 388 | wp_register_script( |
| @@ -419,9 +410,9 @@ | ||
| 419 | 410 | $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ), |
| 420 | 411 | [ |
| 421 | 412 | 'jquery-ui-position', |
| 422 | 413 | ], |
| 423 | - '4.9.4', | |
| 414 | + '4.9.0', | |
| 424 | 415 | true |
| 425 | 416 | ); |
| 426 | 417 | |
| 427 | 418 | wp_register_script( |
| @@ -446,18 +437,13 @@ | ||
| 446 | 437 | |
| 447 | 438 | wp_register_script( |
| 448 | 439 | 'elementor-frontend', |
| 449 | 440 | $this->get_js_assets_url( 'frontend' ), |
| 450 | - [ | |
| 451 | - 'elementor-frontend-modules', | |
| 452 | - 'jquery-ui-position', | |
| 453 | - ], | |
| 441 | + $this->get_elementor_frontend_dependencies(), | |
| 454 | 442 | ELEMENTOR_VERSION, |
| 455 | 443 | true |
| 456 | 444 | ); |
| 457 | 445 | |
| 458 | - $this->register_frontend_handlers(); | |
| 459 | - | |
| 460 | 446 | /** |
| 461 | 447 | * After frontend register scripts. |
| 462 | 448 | * |
| 463 | 449 | * Fires after Elementor frontend scripts are registered. |
| @@ -477,12 +463,8 @@ | ||
| 477 | 463 | * @since 1.2.0 |
| 478 | 464 | * @access public |
| 479 | 465 | */ |
| 480 | 466 | 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 | 467 | /** |
| 486 | 468 | * Before frontend register styles. |
| 487 | 469 | * |
| 488 | 470 | * Fires before Elementor frontend styles are registered. |
| @@ -501,9 +483,9 @@ | ||
| 501 | 483 | wp_register_style( |
| 502 | 484 | 'elementor-icons', |
| 503 | 485 | $this->get_css_assets_url( 'elementor-icons', 'assets/lib/eicons/css/' ), |
| 504 | 486 | [], |
| 505 | - Icons_Manager::ELEMENTOR_ICONS_VERSION | |
| 487 | + '5.14.0' | |
| 506 | 488 | ); |
| 507 | 489 | |
| 508 | 490 | wp_register_style( |
| 509 | 491 | 'flatpickr', |
| @@ -508,9 +490,9 @@ | ||
| 508 | 490 | wp_register_style( |
| 509 | 491 | 'flatpickr', |
| 510 | 492 | $this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ), |
| 511 | 493 | [], |
| 512 | - '4.6.13' | |
| 494 | + '4.1.4' | |
| 513 | 495 | ); |
| 514 | 496 | |
| 515 | 497 | wp_register_style( |
| 516 | 498 | 'elementor-gallery', |
| @@ -518,69 +500,38 @@ | ||
| 518 | 500 | [], |
| 519 | 501 | '1.2.0' |
| 520 | 502 | ); |
| 521 | 503 | |
| 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 | - ); | |
| 504 | + $min_suffix = Utils::is_script_debug() ? '' : '.min'; | |
| 528 | 505 | |
| 529 | - wp_register_style( | |
| 530 | - 'e-swiper', | |
| 531 | - $this->get_css_assets_url( 'e-swiper', 'assets/css/conditionals/' ), | |
| 532 | - [ 'swiper' ], | |
| 533 | - ELEMENTOR_VERSION | |
| 534 | - ); | |
| 506 | + $direction_suffix = is_rtl() ? '-rtl' : ''; | |
| 535 | 507 | |
| 536 | - wp_register_style( | |
| 537 | - 'swiper', | |
| 538 | - $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ), | |
| 539 | - [], | |
| 540 | - '8.4.5' | |
| 541 | - ); | |
| 508 | + $frontend_base_file_name = $this->is_optimized_css_mode() ? 'frontend-lite' : 'frontend'; | |
| 542 | 509 | |
| 543 | - wp_register_style( | |
| 544 | - 'elementor-wp-admin-bar', | |
| 545 | - $this->get_css_assets_url( 'admin-bar', 'assets/css/' ), | |
| 546 | - [], | |
| 547 | - ELEMENTOR_VERSION | |
| 548 | - ); | |
| 510 | + $frontend_file_name = $frontend_base_file_name . $direction_suffix . $min_suffix . '.css'; | |
| 549 | 511 | |
| 550 | - wp_register_style( | |
| 551 | - 'e-lightbox', | |
| 552 | - $this->get_frontend_file_url( 'lightbox.min.css', $has_custom_breakpoints, 'conditionals/' ), | |
| 553 | - [], | |
| 554 | - $has_custom_breakpoints ? null : ELEMENTOR_VERSION | |
| 555 | - ); | |
| 512 | + $frontend_dependencies = []; | |
| 556 | 513 | |
| 557 | - wp_register_style( | |
| 558 | - 'elementor-frontend', | |
| 559 | - $this->get_frontend_file_url( "frontend{$min_suffix}.css", $has_custom_breakpoints ), | |
| 560 | - [], | |
| 561 | - $has_custom_breakpoints ? null : ELEMENTOR_VERSION | |
| 562 | - ); | |
| 514 | + $has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints(); | |
| 563 | 515 | |
| 564 | - $widgets_with_styles = Plugin::$instance->widgets_manager->widgets_with_styles(); | |
| 565 | - foreach ( $widgets_with_styles as $widget_name ) { | |
| 516 | + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) { | |
| 517 | + // If The Dom Optimization feature is disabled, register the legacy CSS | |
| 566 | 518 | wp_register_style( |
| 567 | - "widget-{$widget_name}", | |
| 568 | - $this->get_css_assets_url( "widget-{$widget_name}", null, true, true ), | |
| 569 | - [ 'elementor-frontend' ], | |
| 519 | + 'elementor-frontend-legacy', | |
| 520 | + $this->get_frontend_file_url( 'frontend-legacy' . $direction_suffix . $min_suffix . '.css', $has_custom_breakpoints ), | |
| 521 | + [], | |
| 570 | 522 | ELEMENTOR_VERSION |
| 571 | 523 | ); |
| 524 | + | |
| 525 | + $frontend_dependencies[] = 'elementor-frontend-legacy'; | |
| 572 | 526 | } |
| 573 | 527 | |
| 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 | - } | |
| 528 | + wp_register_style( | |
| 529 | + 'elementor-frontend', | |
| 530 | + $this->get_frontend_file_url( $frontend_file_name, $has_custom_breakpoints ), | |
| 531 | + $frontend_dependencies, | |
| 532 | + $has_custom_breakpoints ? null : ELEMENTOR_VERSION | |
| 533 | + ); | |
| 583 | 534 | |
| 584 | 535 | /** |
| 585 | 536 | * After frontend register styles. |
| 586 | 537 | * |
| @@ -591,23 +542,8 @@ | ||
| 591 | 542 | do_action( 'elementor/frontend/after_register_styles' ); |
| 592 | 543 | } |
| 593 | 544 | |
| 594 | 545 | /** |
| 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 | 546 | * Enqueue scripts. |
| 611 | 547 | * |
| 612 | 548 | * Enqueue all the frontend scripts. |
| 613 | 549 | * |
| @@ -623,8 +559,22 @@ | ||
| 623 | 559 | * @since 1.0.0 |
| 624 | 560 | */ |
| 625 | 561 | do_action( 'elementor/frontend/before_enqueue_scripts' ); |
| 626 | 562 | |
| 563 | + wp_enqueue_script( 'elementor-frontend' ); | |
| 564 | + | |
| 565 | + if ( ! $this->is_improved_assets_loading() ) { | |
| 566 | + wp_enqueue_script( | |
| 567 | + 'preloaded-modules', | |
| 568 | + $this->get_js_assets_url( 'preloaded-modules', 'assets/js/' ), | |
| 569 | + [ | |
| 570 | + 'elementor-frontend', | |
| 571 | + ], | |
| 572 | + ELEMENTOR_VERSION, | |
| 573 | + true | |
| 574 | + ); | |
| 575 | + } | |
| 576 | + | |
| 627 | 577 | $this->print_config(); |
| 628 | 578 | |
| 629 | 579 | $this->enqueue_conditional_assets(); |
| 630 | 580 | |
| @@ -669,12 +619,8 @@ | ||
| 669 | 619 | } |
| 670 | 620 | |
| 671 | 621 | wp_enqueue_style( 'elementor-frontend' ); |
| 672 | 622 | |
| 673 | - if ( is_admin_bar_showing() ) { | |
| 674 | - wp_enqueue_style( 'elementor-wp-admin-bar' ); | |
| 675 | - } | |
| 676 | - | |
| 677 | 623 | /** |
| 678 | 624 | * After frontend styles enqueued. |
| 679 | 625 | * |
| 680 | 626 | * Fires after Elementor frontend styles are enqueued. |
| @@ -683,44 +629,20 @@ | ||
| 683 | 629 | */ |
| 684 | 630 | do_action( 'elementor/frontend/after_enqueue_styles' ); |
| 685 | 631 | |
| 686 | 632 | if ( ! Plugin::$instance->preview->is_preview_mode() ) { |
| 633 | + $this->parse_global_css_code(); | |
| 634 | + | |
| 687 | 635 | $post_id = get_the_ID(); |
| 688 | 636 | // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages. |
| 689 | 637 | if ( $post_id && is_singular() ) { |
| 690 | - do_action( 'elementor/post/render', $post_id ); | |
| 691 | - $this->handle_page_assets( $post_id ); | |
| 692 | - | |
| 693 | 638 | $css_file = Post_CSS::create( get_the_ID() ); |
| 694 | 639 | $css_file->enqueue(); |
| 695 | 640 | } |
| 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 | 641 | } |
| 702 | - | |
| 703 | - do_action( 'elementor/frontend/after_enqueue_post_styles' ); | |
| 704 | 642 | } |
| 705 | 643 | } |
| 706 | 644 | |
| 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 | 645 | /** |
| 724 | 646 | * Get Frontend File URL |
| 725 | 647 | * |
| 726 | 648 | * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom |
| @@ -729,20 +651,20 @@ | ||
| 729 | 651 | * @since 3.4.5 |
| 730 | 652 | * |
| 731 | 653 | * @access public |
| 732 | 654 | * |
| 733 | - * @param string $frontend_file_name | |
| 655 | + * @param string $frontend_file_name | |
| 734 | 656 | * @param boolean $custom_file |
| 735 | 657 | * |
| 736 | 658 | * @return string frontend file URL |
| 737 | 659 | */ |
| 738 | - public function get_frontend_file_url( $frontend_file_name, $custom_file, $css_subfolder = '' ) { | |
| 660 | + public function get_frontend_file_url( $frontend_file_name, $custom_file ) { | |
| 739 | 661 | if ( $custom_file ) { |
| 740 | 662 | $frontend_file = $this->get_frontend_file( $frontend_file_name ); |
| 741 | 663 | |
| 742 | 664 | $frontend_file_url = $frontend_file->get_url(); |
| 743 | 665 | } else { |
| 744 | - $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $css_subfolder . $frontend_file_name; | |
| 666 | + $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $frontend_file_name; | |
| 745 | 667 | } |
| 746 | 668 | |
| 747 | 669 | return $frontend_file_url; |
| 748 | 670 | } |
| @@ -755,9 +677,9 @@ | ||
| 755 | 677 | * |
| 756 | 678 | * @since 3.5.0 |
| 757 | 679 | * @access public |
| 758 | 680 | * |
| 759 | - * @param string $frontend_file_name | |
| 681 | + * @param string $frontend_file_name | |
| 760 | 682 | * @param boolean $custom_file |
| 761 | 683 | * |
| 762 | 684 | * @return string frontend file path |
| 763 | 685 | */ |
| @@ -846,11 +768,18 @@ | ||
| 846 | 768 | $this->print_fonts_links(); |
| 847 | 769 | } |
| 848 | 770 | |
| 849 | 771 | /** |
| 850 | - * @return array|array[] | |
| 772 | + * Print fonts links. | |
| 773 | + * | |
| 774 | + * Enqueue all the frontend fonts by url. | |
| 775 | + * | |
| 776 | + * Fired by `wp_head` action. | |
| 777 | + * | |
| 778 | + * @since 1.9.4 | |
| 779 | + * @access public | |
| 851 | 780 | */ |
| 852 | - public function get_list_of_google_fonts_by_type(): array { | |
| 781 | + public function print_fonts_links() { | |
| 853 | 782 | $google_fonts = [ |
| 854 | 783 | 'google' => [], |
| 855 | 784 | 'early' => [], |
| 856 | 785 | ]; |
| @@ -886,36 +815,8 @@ | ||
| 886 | 815 | } |
| 887 | 816 | } |
| 888 | 817 | $this->fonts_to_enqueue = []; |
| 889 | 818 | |
| 890 | - return $google_fonts; | |
| 891 | - } | |
| 892 | - | |
| 893 | - /** | |
| 894 | - * Print fonts links. | |
| 895 | - * | |
| 896 | - * Enqueue all the frontend fonts by url. | |
| 897 | - * | |
| 898 | - * Fired by `wp_head` action. | |
| 899 | - * | |
| 900 | - * @since 1.9.4 | |
| 901 | - * @access public | |
| 902 | - */ | |
| 903 | - 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 | - $google_fonts = $this->get_list_of_google_fonts_by_type(); | |
| 917 | - | |
| 918 | 819 | $this->enqueue_google_fonts( $google_fonts ); |
| 919 | 820 | $this->enqueue_icon_fonts(); |
| 920 | 821 | } |
| 921 | 822 | |
| @@ -944,78 +845,13 @@ | ||
| 944 | 845 | wp_enqueue_style( 'elementor-icons-' . $icon_type ); |
| 945 | 846 | $this->enqueued_icon_fonts[] = $css_url; |
| 946 | 847 | } |
| 947 | 848 | |
| 948 | - // Clear enqueued icons. | |
| 849 | + //clear enqueued icons | |
| 949 | 850 | $this->icon_fonts_to_enqueue = []; |
| 950 | 851 | } |
| 951 | 852 | |
| 952 | 853 | /** |
| 953 | - * @param array $fonts Stable google fonts ($google_fonts['google']). | |
| 954 | - * @return string | |
| 955 | - */ | |
| 956 | - public function get_stable_google_fonts_url( array $fonts ): string { | |
| 957 | - foreach ( $fonts as &$font ) { | |
| 958 | - $font = str_replace( ' ', '+', $font ) . ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; | |
| 959 | - } | |
| 960 | - | |
| 961 | - // Defining a font-display type to google fonts. | |
| 962 | - $font_display_url_str = '&display=' . Fonts::get_font_display_setting(); | |
| 963 | - | |
| 964 | - $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%1$s%2$s', implode( rawurlencode( '|' ), $fonts ), $font_display_url_str ); | |
| 965 | - | |
| 966 | - $subsets = [ | |
| 967 | - 'ru_RU' => 'cyrillic', | |
| 968 | - 'bg_BG' => 'cyrillic', | |
| 969 | - 'he_IL' => 'hebrew', | |
| 970 | - 'el' => 'greek', | |
| 971 | - 'vi' => 'vietnamese', | |
| 972 | - 'uk' => 'cyrillic', | |
| 973 | - 'cs_CZ' => 'latin-ext', | |
| 974 | - 'ro_RO' => 'latin-ext', | |
| 975 | - 'pl_PL' => 'latin-ext', | |
| 976 | - 'hr_HR' => 'latin-ext', | |
| 977 | - 'hu_HU' => 'latin-ext', | |
| 978 | - 'sk_SK' => 'latin-ext', | |
| 979 | - 'tr_TR' => 'latin-ext', | |
| 980 | - 'lt_LT' => 'latin-ext', | |
| 981 | - ]; | |
| 982 | - | |
| 983 | - /** | |
| 984 | - * Google font subsets. | |
| 985 | - * | |
| 986 | - * Filters the list of Google font subsets from which locale will be enqueued in frontend. | |
| 987 | - * | |
| 988 | - * @since 1.0.0 | |
| 989 | - * | |
| 990 | - * @param array $subsets A list of font subsets. | |
| 991 | - */ | |
| 992 | - $subsets = apply_filters( 'elementor/frontend/google_font_subsets', $subsets ); | |
| 993 | - | |
| 994 | - $locale = get_locale(); | |
| 995 | - | |
| 996 | - if ( isset( $subsets[ $locale ] ) ) { | |
| 997 | - $fonts_url .= '&subset=' . $subsets[ $locale ]; | |
| 998 | - } | |
| 999 | - | |
| 1000 | - return $fonts_url; | |
| 1001 | - } | |
| 1002 | - | |
| 1003 | - /** | |
| 1004 | - * @param array $fonts Early Access google fonts ($google_fonts['early']). | |
| 1005 | - * @return array | |
| 1006 | - */ | |
| 1007 | - public function get_early_access_google_font_urls( array $fonts ): array { | |
| 1008 | - $font_urls = []; | |
| 1009 | - | |
| 1010 | - foreach ( $fonts as $font ) { | |
| 1011 | - $font_urls[] = sprintf( 'https://fonts.googleapis.com/earlyaccess/%s.css', strtolower( str_replace( ' ', '', $font ) ) ); | |
| 1012 | - } | |
| 1013 | - | |
| 1014 | - return $font_urls; | |
| 1015 | - } | |
| 1016 | - | |
| 1017 | - /** | |
| 1018 | 854 | * Print Google fonts. |
| 1019 | 855 | * |
| 1020 | 856 | * Enqueue all the frontend Google fonts. |
| 1021 | 857 | * |
| @@ -1027,10 +863,12 @@ | ||
| 1027 | 863 | * @param array $google_fonts Optional. Google fonts to print in the frontend. |
| 1028 | 864 | * Default is an empty array. |
| 1029 | 865 | */ |
| 1030 | 866 | private function enqueue_google_fonts( $google_fonts = [] ) { |
| 1031 | - $print_google_fonts = Fonts::is_google_fonts_enabled(); | |
| 867 | + static $google_fonts_index = 0; | |
| 1032 | 868 | |
| 869 | + $print_google_fonts = true; | |
| 870 | + | |
| 1033 | 871 | /** |
| 1034 | 872 | * Print frontend google fonts. |
| 1035 | 873 | * |
| 1036 | 874 | * Filters whether to enqueue Google fonts in the frontend. |
| @@ -1044,21 +882,70 @@ | ||
| 1044 | 882 | if ( ! $print_google_fonts ) { |
| 1045 | 883 | return; |
| 1046 | 884 | } |
| 1047 | 885 | |
| 1048 | - $force_enqueue_from_cdn = Plugin::$instance->preview->is_preview_mode(); | |
| 886 | + // Print used fonts | |
| 887 | + if ( ! empty( $google_fonts['google'] ) ) { | |
| 888 | + $google_fonts_index++; | |
| 1049 | 889 | |
| 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 ); | |
| 890 | + foreach ( $google_fonts['google'] as &$font ) { | |
| 891 | + $font = str_replace( ' ', '+', $font ) . ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic'; | |
| 1053 | 892 | } |
| 893 | + | |
| 894 | + // Defining a font-display type to google fonts. | |
| 895 | + $font_display_url_str = '&display=' . Fonts::get_font_display_setting(); | |
| 896 | + | |
| 897 | + $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%1$s%2$s', implode( rawurlencode( '|' ), $google_fonts['google'] ), $font_display_url_str ); | |
| 898 | + | |
| 899 | + $subsets = [ | |
| 900 | + 'ru_RU' => 'cyrillic', | |
| 901 | + 'bg_BG' => 'cyrillic', | |
| 902 | + 'he_IL' => 'hebrew', | |
| 903 | + 'el' => 'greek', | |
| 904 | + 'vi' => 'vietnamese', | |
| 905 | + 'uk' => 'cyrillic', | |
| 906 | + 'cs_CZ' => 'latin-ext', | |
| 907 | + 'ro_RO' => 'latin-ext', | |
| 908 | + 'pl_PL' => 'latin-ext', | |
| 909 | + 'hr_HR' => 'latin-ext', | |
| 910 | + 'hu_HU' => 'latin-ext', | |
| 911 | + 'sk_SK' => 'latin-ext', | |
| 912 | + 'tr_TR' => 'latin-ext', | |
| 913 | + 'lt_LT' => 'latin-ext', | |
| 914 | + ]; | |
| 915 | + | |
| 916 | + /** | |
| 917 | + * Google font subsets. | |
| 918 | + * | |
| 919 | + * Filters the list of Google font subsets from which locale will be enqueued in frontend. | |
| 920 | + * | |
| 921 | + * @since 1.0.0 | |
| 922 | + * | |
| 923 | + * @param array $subsets A list of font subsets. | |
| 924 | + */ | |
| 925 | + $subsets = apply_filters( 'elementor/frontend/google_font_subsets', $subsets ); | |
| 926 | + | |
| 927 | + $locale = get_locale(); | |
| 928 | + | |
| 929 | + if ( isset( $subsets[ $locale ] ) ) { | |
| 930 | + $fonts_url .= '&subset=' . $subsets[ $locale ]; | |
| 931 | + } | |
| 932 | + | |
| 933 | + wp_enqueue_style( 'google-fonts-' . $google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1054 | 934 | } |
| 1055 | 935 | |
| 1056 | 936 | if ( ! empty( $google_fonts['early'] ) ) { |
| 1057 | 937 | foreach ( $google_fonts['early'] as $current_font ) { |
| 1058 | - Google_Font::enqueue( $current_font, Google_Font::TYPE_EARLYACCESS, $force_enqueue_from_cdn ); | |
| 938 | + $google_fonts_index++; | |
| 939 | + | |
| 940 | + //printf( '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/earlyaccess/%s.css">', strtolower( str_replace( ' ', '', $current_font ) ) ); | |
| 941 | + | |
| 942 | + $font_url = sprintf( 'https://fonts.googleapis.com/earlyaccess/%s.css', strtolower( str_replace( ' ', '', $current_font ) ) ); | |
| 943 | + | |
| 944 | + wp_enqueue_style( 'google-earlyaccess-' . $google_fonts_index, $font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1059 | 945 | } |
| 1060 | 946 | } |
| 947 | + | |
| 1061 | 948 | } |
| 1062 | 949 | |
| 1063 | 950 | /** |
| 1064 | 951 | * Enqueue fonts. |
| @@ -1079,8 +966,22 @@ | ||
| 1079 | 966 | $this->registered_fonts[] = $font; |
| 1080 | 967 | } |
| 1081 | 968 | |
| 1082 | 969 | /** |
| 970 | + * Parse global CSS. | |
| 971 | + * | |
| 972 | + * Enqueue the global CSS file. | |
| 973 | + * | |
| 974 | + * @since 1.2.0 | |
| 975 | + * @access protected | |
| 976 | + */ | |
| 977 | + protected function parse_global_css_code() { | |
| 978 | + $scheme_css_file = Global_CSS::create( 'global.css' ); | |
| 979 | + | |
| 980 | + $scheme_css_file->enqueue(); | |
| 981 | + } | |
| 982 | + | |
| 983 | + /** | |
| 1083 | 984 | * Apply builder in content. |
| 1084 | 985 | * |
| 1085 | 986 | * Used to apply the Elementor page editor on the post content. |
| 1086 | 987 | * |
| @@ -1147,21 +1048,8 @@ | ||
| 1147 | 1048 | |
| 1148 | 1049 | $data = $document->get_elements_data(); |
| 1149 | 1050 | |
| 1150 | 1051 | /** |
| 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 | 1052 | * Frontend builder content data. |
| 1165 | 1053 | * |
| 1166 | 1054 | * Filters the builder content in the frontend. |
| 1167 | 1055 | * |
| @@ -1186,17 +1074,8 @@ | ||
| 1186 | 1074 | } else { |
| 1187 | 1075 | $css_file = Post_CSS::create( $post_id ); |
| 1188 | 1076 | } |
| 1189 | 1077 | |
| 1190 | - /** | |
| 1191 | - * Builder Content - Before Enqueue CSS File | |
| 1192 | - * | |
| 1193 | - * Allows intervening with a document's CSS file before it is enqueued. | |
| 1194 | - * | |
| 1195 | - * @param $css_file Post_CSS|Post_Preview | |
| 1196 | - */ | |
| 1197 | - $css_file = apply_filters( 'elementor/frontend/builder_content/before_enqueue_css_file', $css_file ); | |
| 1198 | - | |
| 1199 | 1078 | $css_file->enqueue(); |
| 1200 | 1079 | } |
| 1201 | 1080 | |
| 1202 | 1081 | ob_start(); |
| @@ -1205,18 +1084,8 @@ | ||
| 1205 | 1084 | if ( is_customize_preview() || wp_doing_ajax() ) { |
| 1206 | 1085 | $with_css = true; |
| 1207 | 1086 | } |
| 1208 | 1087 | |
| 1209 | - /** | |
| 1210 | - * Builder Content - With CSS | |
| 1211 | - * | |
| 1212 | - * Allows overriding the `$with_css` parameter which is a factor in determining whether to print the document's | |
| 1213 | - * CSS and font links inline in a `style` tag above the document's markup. | |
| 1214 | - * | |
| 1215 | - * @param $with_css boolean | |
| 1216 | - */ | |
| 1217 | - $with_css = apply_filters( 'elementor/frontend/builder_content/before_print_css', $with_css ); | |
| 1218 | - | |
| 1219 | 1088 | if ( ! empty( $css_file ) && $with_css ) { |
| 1220 | 1089 | $css_file->print_css(); |
| 1221 | 1090 | } |
| 1222 | 1091 | |
| @@ -1257,9 +1126,9 @@ | ||
| 1257 | 1126 | * |
| 1258 | 1127 | * @since 1.0.0 |
| 1259 | 1128 | * @access public |
| 1260 | 1129 | * |
| 1261 | - * @param int $post_id The post ID. | |
| 1130 | + * @param int $post_id The post ID. | |
| 1262 | 1131 | * |
| 1263 | 1132 | * @param bool $with_css Optional. Whether to retrieve the content with CSS |
| 1264 | 1133 | * or not. Default is false. |
| 1265 | 1134 | * |
| @@ -1425,9 +1294,9 @@ | ||
| 1425 | 1294 | 'isScriptDebug' => Utils::is_script_debug(), |
| 1426 | 1295 | ], |
| 1427 | 1296 | 'i18n' => [ |
| 1428 | 1297 | 'shareOnFacebook' => esc_html__( 'Share on Facebook', 'elementor' ), |
| 1429 | - 'shareOnX' => esc_html__( 'Share on X', 'elementor' ), | |
| 1298 | + 'shareOnTwitter' => esc_html__( 'Share on Twitter', 'elementor' ), | |
| 1430 | 1299 | 'pinIt' => esc_html__( 'Pin it', 'elementor' ), |
| 1431 | 1300 | 'download' => esc_html__( 'Download', 'elementor' ), |
| 1432 | 1301 | 'downloadImage' => esc_html__( 'Download image', 'elementor' ), |
| 1433 | 1302 | 'fullscreen' => esc_html__( 'Fullscreen', 'elementor' ), |
| @@ -1436,13 +1305,8 @@ | ||
| 1436 | 1305 | 'playVideo' => esc_html__( 'Play Video', 'elementor' ), |
| 1437 | 1306 | 'previous' => esc_html__( 'Previous', 'elementor' ), |
| 1438 | 1307 | 'next' => esc_html__( 'Next', 'elementor' ), |
| 1439 | 1308 | 'close' => esc_html__( 'Close', 'elementor' ), |
| 1440 | - 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ), | |
| 1441 | - 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ), | |
| 1442 | - 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ), | |
| 1443 | - 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ), | |
| 1444 | - 'a11yCarouselPaginationBulletMessage' => __( 'Go to slide', 'elementor' ), | |
| 1445 | 1309 | ], |
| 1446 | 1310 | 'is_rtl' => is_rtl(), |
| 1447 | 1311 | // 'breakpoints' object is kept for BC. |
| 1448 | 1312 | 'breakpoints' => Responsive::get_breakpoints(), |
| @@ -1448,9 +1312,8 @@ | ||
| 1448 | 1312 | 'breakpoints' => Responsive::get_breakpoints(), |
| 1449 | 1313 | // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0 |
| 1450 | 1314 | 'responsive' => [ |
| 1451 | 1315 | 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(), |
| 1452 | - 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(), | |
| 1453 | 1316 | ], |
| 1454 | 1317 | 'version' => ELEMENTOR_VERSION, |
| 1455 | 1318 | 'is_static' => $this->is_static_render_mode(), |
| 1456 | 1319 | 'experimentalFeatures' => $active_experimental_features, |
| @@ -1455,16 +1318,9 @@ | ||
| 1455 | 1318 | 'is_static' => $this->is_static_render_mode(), |
| 1456 | 1319 | 'experimentalFeatures' => $active_experimental_features, |
| 1457 | 1320 | 'urls' => [ |
| 1458 | 1321 | 'assets' => $assets_url, |
| 1459 | - 'ajaxurl' => admin_url( 'admin-ajax.php' ), | |
| 1460 | - 'uploadUrl' => wp_upload_dir()['baseurl'], | |
| 1461 | 1322 | ], |
| 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', | |
| 1467 | 1323 | ]; |
| 1468 | 1324 | |
| 1469 | 1325 | $settings['settings'] = SettingsManager::get_settings_frontend_config(); |
| 1470 | 1326 | |
| @@ -1546,9 +1402,9 @@ | ||
| 1546 | 1402 | * |
| 1547 | 1403 | * @access private |
| 1548 | 1404 | * @since 2.0.4 |
| 1549 | 1405 | * |
| 1550 | - * @param string $content | |
| 1406 | + * @param $content | |
| 1551 | 1407 | * |
| 1552 | 1408 | * @return string |
| 1553 | 1409 | */ |
| 1554 | 1410 | private function process_more_tag( $content ) { |
| @@ -1596,6 +1452,40 @@ | ||
| 1596 | 1452 | */ |
| 1597 | 1453 | $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text ); |
| 1598 | 1454 | |
| 1599 | 1455 | return force_balance_tags( $parts['main'] ) . $more_link; |
| 1456 | + } | |
| 1457 | + | |
| 1458 | + private function is_improved_assets_loading() { | |
| 1459 | + return Plugin::$instance->experiments->is_feature_active( 'e_optimized_assets_loading' ); | |
| 1460 | + } | |
| 1461 | + | |
| 1462 | + private function get_elementor_frontend_dependencies() { | |
| 1463 | + $dependencies = [ | |
| 1464 | + 'elementor-frontend-modules', | |
| 1465 | + 'elementor-waypoints', | |
| 1466 | + 'jquery-ui-position', | |
| 1467 | + ]; | |
| 1468 | + | |
| 1469 | + if ( ! $this->is_improved_assets_loading() ) { | |
| 1470 | + wp_register_script( | |
| 1471 | + 'swiper', | |
| 1472 | + $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/' ), | |
| 1473 | + [], | |
| 1474 | + '5.3.6', | |
| 1475 | + true | |
| 1476 | + ); | |
| 1477 | + | |
| 1478 | + $dependencies[] = 'swiper'; | |
| 1479 | + $dependencies[] = 'share-link'; | |
| 1480 | + $dependencies[] = 'elementor-dialog'; | |
| 1481 | + } | |
| 1482 | + | |
| 1483 | + return $dependencies; | |
| 1484 | + } | |
| 1485 | + | |
| 1486 | + private function is_optimized_css_mode() { | |
| 1487 | + $is_optimized_css_loading = Plugin::$instance->experiments->is_feature_active( 'e_optimized_css_loading' ); | |
| 1488 | + | |
| 1489 | + return ! Utils::is_script_debug() && $is_optimized_css_loading && ! Plugin::$instance->preview->is_preview_mode(); | |
| 1600 | 1490 | } |
| 1601 | 1491 | } |