PluginProbe
Elementor Website Builder – more than just a page builder / 3.4.7
Elementor Website Builder – more than just a page builder v3.4.7
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | includes/frontend.php +222 -355 4.2.33.4.7 View file →
@@ -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 *
@@ -166,17 +159,22 @@
166 159 add_action( 'template_redirect', [ $this, 'init' ] );
167 160 add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 5 );
168 161 add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 5 );
169 162
163 + // TODO: a temporary solution to a scenario that the elementor-icons.css file was de-registered and the e-icons font fonts should not be loaded.
164 + add_action( 'wp_enqueue_scripts', function() {
165 + if ( ! wp_style_is( 'elementor-icons', 'registered' ) ) {
166 + $elementor_icons_css_reset = '[class^="eicon"], [class*=" eicon-"] { font-family: "initial"; } [class^="eicon"]:before, [class*=" eicon-"]:before { content: ""; }';
167 +
168 + wp_add_inline_style( 'elementor-frontend', $elementor_icons_css_reset );
169 + }
170 + }, 30 );
171 +
170 172 $this->add_content_filter();
171 173
172 174 // Hack to avoid enqueue post CSS while it's a `the_excerpt` call.
173 175 add_filter( 'get_the_excerpt', [ $this, 'start_excerpt_flag' ], 1 );
174 176 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 177 }
180 178
181 179 /**
182 180 * Get module name.
@@ -233,9 +231,9 @@
233 231
234 232 $document = Plugin::$instance->documents->get( $this->post_id );
235 233
236 234 if ( is_singular() && $document && $document->is_built_with_elementor() ) {
237 - add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], self::ENQUEUED_STYLES_PRIORITY );
235 + add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ] );
238 236 }
239 237
240 238 // Priority 7 to allow google fonts in header template to load in <head> tag
241 239 add_action( 'wp_head', [ $this, 'print_fonts_links' ], 7 );
@@ -245,15 +243,15 @@
245 243
246 244 /**
247 245 * @since 2.0.12
248 246 * @access public
249 - * @param string|array $class_name
247 + * @param string|array $class
250 248 */
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 );
249 + public function add_body_class( $class ) {
250 + if ( is_array( $class ) ) {
251 + $this->body_classes = array_merge( $this->body_classes, $class );
254 252 } else {
255 - $this->body_classes[] = $class_name;
253 + $this->body_classes[] = $class;
256 254 }
257 255 }
258 256
259 257 /**
@@ -263,13 +261,13 @@
263 261 * @access public
264 262 */
265 263 public function add_theme_color_meta_tag() {
266 264 $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend();
267 - $mobile_theme_color = $kit->get_settings( 'mobile_browser_background' );
265 + $mobile_theme_color = $kit->get_settings( 'mobile_theme_color' );
268 266
269 267 if ( ! empty( $mobile_theme_color ) ) {
270 268 ?>
271 - <meta name="theme-color" content="<?php echo esc_attr( $mobile_theme_color ); ?>">
269 + <meta name="theme-color" content="<?php echo esc_html( $mobile_theme_color ); ?>">
272 270 <?php
273 271 }
274 272 }
275 273
@@ -376,12 +374,14 @@
376 374 true
377 375 );
378 376
379 377 wp_register_script(
380 - 'swiper',
381 - $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/v8/' ),
382 - [],
383 - '8.4.5',
378 + 'elementor-waypoints',
379 + $this->get_js_assets_url( 'waypoints', 'assets/lib/waypoints/' ),
380 + [
381 + 'jquery',
382 + ],
383 + '4.0.2',
384 384 true
385 385 );
386 386
387 387 wp_register_script(
@@ -389,9 +389,9 @@
389 389 $this->get_js_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
390 390 [
391 391 'jquery',
392 392 ],
393 - '4.6.13',
393 + '4.1.4',
394 394 true
395 395 );
396 396
397 397 wp_register_script(
@@ -413,15 +413,28 @@
413 413 '0.2.1',
414 414 true
415 415 );
416 416
417 + /**
418 + * @deprecated since 2.7.0 Use Swiper instead
419 + */
417 420 wp_register_script(
421 + 'jquery-slick',
422 + $this->get_js_assets_url( 'slick', 'assets/lib/slick/' ),
423 + [
424 + 'jquery',
425 + ],
426 + '1.8.1',
427 + true
428 + );
429 +
430 + wp_register_script(
418 431 'elementor-dialog',
419 432 $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ),
420 433 [
421 434 'jquery-ui-position',
422 435 ],
423 - '4.9.4',
436 + '4.8.1',
424 437 true
425 438 );
426 439
427 440 wp_register_script(
@@ -446,18 +459,13 @@
446 459
447 460 wp_register_script(
448 461 'elementor-frontend',
449 462 $this->get_js_assets_url( 'frontend' ),
450 - [
451 - 'elementor-frontend-modules',
452 - 'jquery-ui-position',
453 - ],
463 + $this->get_elementor_frontend_dependencies(),
454 464 ELEMENTOR_VERSION,
455 465 true
456 466 );
457 467
458 - $this->register_frontend_handlers();
459 -
460 468 /**
461 469 * After frontend register scripts.
462 470 *
463 471 * Fires after Elementor frontend scripts are registered.
@@ -477,12 +485,8 @@
477 485 * @since 1.2.0
478 486 * @access public
479 487 */
480 488 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 489 /**
486 490 * Before frontend register styles.
487 491 *
488 492 * Fires before Elementor frontend styles are registered.
@@ -501,9 +505,9 @@
501 505 wp_register_style(
502 506 'elementor-icons',
503 507 $this->get_css_assets_url( 'elementor-icons', 'assets/lib/eicons/css/' ),
504 508 [],
505 - Icons_Manager::ELEMENTOR_ICONS_VERSION
509 + '5.13.0'
506 510 );
507 511
508 512 wp_register_style(
509 513 'flatpickr',
@@ -508,9 +512,9 @@
508 512 wp_register_style(
509 513 'flatpickr',
510 514 $this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
511 515 [],
512 - '4.6.13'
516 + '4.1.4'
513 517 );
514 518
515 519 wp_register_style(
516 520 'elementor-gallery',
@@ -518,69 +522,38 @@
518 522 [],
519 523 '1.2.0'
520 524 );
521 525
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 - );
526 + $min_suffix = Utils::is_script_debug() ? '' : '.min';
528 527
529 - wp_register_style(
530 - 'e-swiper',
531 - $this->get_css_assets_url( 'e-swiper', 'assets/css/conditionals/' ),
532 - [ 'swiper' ],
533 - ELEMENTOR_VERSION
534 - );
528 + $direction_suffix = is_rtl() ? '-rtl' : '';
535 529
536 - wp_register_style(
537 - 'swiper',
538 - $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ),
539 - [],
540 - '8.4.5'
541 - );
530 + $frontend_base_file_name = $this->is_optimized_css_mode() ? 'frontend-lite' : 'frontend';
542 531
543 - wp_register_style(
544 - 'elementor-wp-admin-bar',
545 - $this->get_css_assets_url( 'admin-bar', 'assets/css/' ),
546 - [],
547 - ELEMENTOR_VERSION
548 - );
532 + $frontend_file_name = $frontend_base_file_name . $direction_suffix . $min_suffix . '.css';
549 533
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 - );
534 + $frontend_dependencies = [];
556 535
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 - );
536 + $has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints();
563 537
564 - $widgets_with_styles = Plugin::$instance->widgets_manager->widgets_with_styles();
565 - foreach ( $widgets_with_styles as $widget_name ) {
538 + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_dom_optimization' ) ) {
539 + // If The Dom Optimization feature is disabled, register the legacy CSS
566 540 wp_register_style(
567 - "widget-{$widget_name}",
568 - $this->get_css_assets_url( "widget-{$widget_name}", null, true, true ),
569 - [ 'elementor-frontend' ],
541 + 'elementor-frontend-legacy',
542 + $this->get_frontend_file_url( 'frontend-legacy' . $direction_suffix . $min_suffix . '.css', $has_custom_breakpoints ),
543 + [],
570 544 ELEMENTOR_VERSION
571 545 );
546 +
547 + $frontend_dependencies[] = 'elementor-frontend-legacy';
572 548 }
573 549
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 - }
550 + wp_register_style(
551 + 'elementor-frontend',
552 + $this->get_frontend_file_url( $frontend_file_name, $has_custom_breakpoints ),
553 + $frontend_dependencies,
554 + $has_custom_breakpoints ? null : ELEMENTOR_VERSION
555 + );
583 556
584 557 /**
585 558 * After frontend register styles.
586 559 *
@@ -591,23 +564,8 @@
591 564 do_action( 'elementor/frontend/after_register_styles' );
592 565 }
593 566
594 567 /**
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 568 * Enqueue scripts.
611 569 *
612 570 * Enqueue all the frontend scripts.
613 571 *
@@ -623,8 +581,22 @@
623 581 * @since 1.0.0
624 582 */
625 583 do_action( 'elementor/frontend/before_enqueue_scripts' );
626 584
585 + wp_enqueue_script( 'elementor-frontend' );
586 +
587 + if ( ! $this->is_improved_assets_loading() ) {
588 + wp_enqueue_script(
589 + 'preloaded-modules',
590 + $this->get_js_assets_url( 'preloaded-modules', 'assets/js/' ),
591 + [
592 + 'elementor-frontend',
593 + ],
594 + ELEMENTOR_VERSION,
595 + true
596 + );
597 + }
598 +
627 599 $this->print_config();
628 600
629 601 $this->enqueue_conditional_assets();
630 602
@@ -662,19 +634,17 @@
662 634 * @since 1.0.0
663 635 */
664 636 do_action( 'elementor/frontend/before_enqueue_styles' );
665 637
638 + $this->add_elementor_icons_inline_css();
639 +
666 640 // The e-icons are needed in preview mode for the editor icons (plus-icon for new section, folder-icon for the templates library etc.).
667 - if ( ! Plugin::$instance->experiments->is_feature_active( 'e_font_icon_svg' ) || Plugin::$instance->preview->is_preview_mode() ) {
641 + if ( ! $this->is_improved_assets_loading() || Plugin::$instance->preview->is_preview_mode() ) {
668 642 wp_enqueue_style( 'elementor-icons' );
669 643 }
670 644
671 645 wp_enqueue_style( 'elementor-frontend' );
672 646
673 - if ( is_admin_bar_showing() ) {
674 - wp_enqueue_style( 'elementor-wp-admin-bar' );
675 - }
676 -
677 647 /**
678 648 * After frontend styles enqueued.
679 649 *
680 650 * Fires after Elementor frontend styles are enqueued.
@@ -683,44 +653,20 @@
683 653 */
684 654 do_action( 'elementor/frontend/after_enqueue_styles' );
685 655
686 656 if ( ! Plugin::$instance->preview->is_preview_mode() ) {
657 + $this->parse_global_css_code();
658 +
687 659 $post_id = get_the_ID();
688 660 // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages.
689 661 if ( $post_id && is_singular() ) {
690 - do_action( 'elementor/post/render', $post_id );
691 - $this->handle_page_assets( $post_id );
692 -
693 662 $css_file = Post_CSS::create( get_the_ID() );
694 663 $css_file->enqueue();
695 664 }
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 665 }
702 -
703 - do_action( 'elementor/frontend/after_enqueue_post_styles' );
704 666 }
705 667 }
706 668
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 669 /**
724 670 * Get Frontend File URL
725 671 *
726 672 * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
@@ -727,22 +673,27 @@
727 673 * file is generated based on a passed template file name. Otherwise, the URL for the default CSS file is returned.
728 674 *
729 675 * @since 3.4.5
730 676 *
731 - * @access public
677 + * @access private
732 678 *
733 - * @param string $frontend_file_name
679 + * @param string $frontend_file_name
734 680 * @param boolean $custom_file
735 681 *
736 682 * @return string frontend file URL
737 683 */
738 - public function get_frontend_file_url( $frontend_file_name, $custom_file, $css_subfolder = '' ) {
684 + private function get_frontend_file_url( $frontend_file_name, $custom_file ) {
739 685 if ( $custom_file ) {
740 - $frontend_file = $this->get_frontend_file( $frontend_file_name );
686 + $frontend_file = new FrontendFile( 'custom-' . $frontend_file_name, Breakpoints_Manager::get_stylesheet_templates_path() . $frontend_file_name );
741 687
688 + $time = $frontend_file->get_meta( 'time' );
689 +
690 + if ( ! $time ) {
691 + $frontend_file->update();
692 + }
742 693 $frontend_file_url = $frontend_file->get_url();
743 694 } else {
744 - $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $css_subfolder . $frontend_file_name;
695 + $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $frontend_file_name;
745 696 }
746 697
747 698 return $frontend_file_url;
748 699 }
@@ -747,74 +698,8 @@
747 698 return $frontend_file_url;
748 699 }
749 700
750 701 /**
751 - * Get Frontend File Path
752 - *
753 - * Returns the path for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
754 - * file is generated based on a passed template file name. Otherwise, the path for the default CSS file is returned.
755 - *
756 - * @since 3.5.0
757 - * @access public
758 - *
759 - * @param string $frontend_file_name
760 - * @param boolean $custom_file
761 - *
762 - * @return string frontend file path
763 - */
764 - public function get_frontend_file_path( $frontend_file_name, $custom_file ) {
765 - if ( $custom_file ) {
766 - $frontend_file = $this->get_frontend_file( $frontend_file_name );
767 -
768 - $frontend_file_path = $frontend_file->get_path();
769 - } else {
770 - $frontend_file_path = ELEMENTOR_ASSETS_PATH . 'css/' . $frontend_file_name;
771 - }
772 -
773 - return $frontend_file_path;
774 - }
775 -
776 - /**
777 - * Get Frontend File
778 - *
779 - * Returns a frontend file instance.
780 - *
781 - * @since 3.5.0
782 - * @access public
783 - *
784 - * @param string $frontend_file_name
785 - * @param string $file_prefix
786 - * @param string $template_file_path
787 - *
788 - * @return FrontendFile
789 - */
790 - public function get_frontend_file( $frontend_file_name, $file_prefix = 'custom-', $template_file_path = '' ) {
791 - static $cached_frontend_files = [];
792 -
793 - $file_name = $file_prefix . $frontend_file_name;
794 -
795 - if ( isset( $cached_frontend_files[ $file_name ] ) ) {
796 - return $cached_frontend_files[ $file_name ];
797 - }
798 -
799 - if ( ! $template_file_path ) {
800 - $template_file_path = Breakpoints_Manager::get_stylesheet_templates_path() . $frontend_file_name;
801 - }
802 -
803 - $frontend_file = new FrontendFile( $file_name, $template_file_path );
804 -
805 - $time = $frontend_file->get_meta( 'time' );
806 -
807 - if ( ! $time ) {
808 - $frontend_file->update();
809 - }
810 -
811 - $cached_frontend_files[ $file_name ] = $frontend_file;
812 -
813 - return $frontend_file;
814 - }
815 -
816 - /**
817 702 * Enqueue assets conditionally.
818 703 *
819 704 * Enqueue all assets that were pre-enabled.
820 705 *
@@ -846,11 +731,18 @@
846 731 $this->print_fonts_links();
847 732 }
848 733
849 734 /**
850 - * @return array|array[]
735 + * Print fonts links.
736 + *
737 + * Enqueue all the frontend fonts by url.
738 + *
739 + * Fired by `wp_head` action.
740 + *
741 + * @since 1.9.4
742 + * @access public
851 743 */
852 - public function get_list_of_google_fonts_by_type(): array {
744 + public function print_fonts_links() {
853 745 $google_fonts = [
854 746 'google' => [],
855 747 'early' => [],
856 748 ];
@@ -886,36 +778,8 @@
886 778 }
887 779 }
888 780 $this->fonts_to_enqueue = [];
889 781
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 782 $this->enqueue_google_fonts( $google_fonts );
919 783 $this->enqueue_icon_fonts();
920 784 }
921 785
@@ -944,78 +808,13 @@
944 808 wp_enqueue_style( 'elementor-icons-' . $icon_type );
945 809 $this->enqueued_icon_fonts[] = $css_url;
946 810 }
947 811
948 - // Clear enqueued icons.
812 + //clear enqueued icons
949 813 $this->icon_fonts_to_enqueue = [];
950 814 }
951 815
952 816 /**
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 817 * Print Google fonts.
1019 818 *
1020 819 * Enqueue all the frontend Google fonts.
1021 820 *
@@ -1027,10 +826,12 @@
1027 826 * @param array $google_fonts Optional. Google fonts to print in the frontend.
1028 827 * Default is an empty array.
1029 828 */
1030 829 private function enqueue_google_fonts( $google_fonts = [] ) {
1031 - $print_google_fonts = Fonts::is_google_fonts_enabled();
830 + static $google_fonts_index = 0;
1032 831
832 + $print_google_fonts = true;
833 +
1033 834 /**
1034 835 * Print frontend google fonts.
1035 836 *
1036 837 * Filters whether to enqueue Google fonts in the frontend.
@@ -1044,21 +845,70 @@
1044 845 if ( ! $print_google_fonts ) {
1045 846 return;
1046 847 }
1047 848
1048 - $force_enqueue_from_cdn = Plugin::$instance->preview->is_preview_mode();
849 + // Print used fonts
850 + if ( ! empty( $google_fonts['google'] ) ) {
851 + $google_fonts_index++;
1049 852
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 );
853 + foreach ( $google_fonts['google'] as &$font ) {
854 + $font = str_replace( ' ', '+', $font ) . ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
1053 855 }
856 +
857 + // Defining a font-display type to google fonts.
858 + $font_display_url_str = '&display=' . Fonts::get_font_display_setting();
859 +
860 + $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%1$s%2$s', implode( rawurlencode( '|' ), $google_fonts['google'] ), $font_display_url_str );
861 +
862 + $subsets = [
863 + 'ru_RU' => 'cyrillic',
864 + 'bg_BG' => 'cyrillic',
865 + 'he_IL' => 'hebrew',
866 + 'el' => 'greek',
867 + 'vi' => 'vietnamese',
868 + 'uk' => 'cyrillic',
869 + 'cs_CZ' => 'latin-ext',
870 + 'ro_RO' => 'latin-ext',
871 + 'pl_PL' => 'latin-ext',
872 + 'hr_HR' => 'latin-ext',
873 + 'hu_HU' => 'latin-ext',
874 + 'sk_SK' => 'latin-ext',
875 + 'tr_TR' => 'latin-ext',
876 + 'lt_LT' => 'latin-ext',
877 + ];
878 +
879 + /**
880 + * Google font subsets.
881 + *
882 + * Filters the list of Google font subsets from which locale will be enqueued in frontend.
883 + *
884 + * @since 1.0.0
885 + *
886 + * @param array $subsets A list of font subsets.
887 + */
888 + $subsets = apply_filters( 'elementor/frontend/google_font_subsets', $subsets );
889 +
890 + $locale = get_locale();
891 +
892 + if ( isset( $subsets[ $locale ] ) ) {
893 + $fonts_url .= '&subset=' . $subsets[ $locale ];
894 + }
895 +
896 + wp_enqueue_style( 'google-fonts-' . $google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1054 897 }
1055 898
1056 899 if ( ! empty( $google_fonts['early'] ) ) {
1057 900 foreach ( $google_fonts['early'] as $current_font ) {
1058 - Google_Font::enqueue( $current_font, Google_Font::TYPE_EARLYACCESS, $force_enqueue_from_cdn );
901 + $google_fonts_index++;
902 +
903 + //printf( '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/earlyaccess/%s.css">', strtolower( str_replace( ' ', '', $current_font ) ) );
904 +
905 + $font_url = sprintf( 'https://fonts.googleapis.com/earlyaccess/%s.css', strtolower( str_replace( ' ', '', $current_font ) ) );
906 +
907 + wp_enqueue_style( 'google-earlyaccess-' . $google_fonts_index, $font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1059 908 }
1060 909 }
910 +
1061 911 }
1062 912
1063 913 /**
1064 914 * Enqueue fonts.
@@ -1079,8 +929,22 @@
1079 929 $this->registered_fonts[] = $font;
1080 930 }
1081 931
1082 932 /**
933 + * Parse global CSS.
934 + *
935 + * Enqueue the global CSS file.
936 + *
937 + * @since 1.2.0
938 + * @access protected
939 + */
940 + protected function parse_global_css_code() {
941 + $scheme_css_file = Global_CSS::create( 'global.css' );
942 +
943 + $scheme_css_file->enqueue();
944 + }
945 +
946 + /**
1083 947 * Apply builder in content.
1084 948 *
1085 949 * Used to apply the Elementor page editor on the post content.
1086 950 *
@@ -1147,21 +1011,8 @@
1147 1011
1148 1012 $data = $document->get_elements_data();
1149 1013
1150 1014 /**
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 1015 * Frontend builder content data.
1165 1016 *
1166 1017 * Filters the builder content in the frontend.
1167 1018 *
@@ -1186,17 +1037,8 @@
1186 1037 } else {
1187 1038 $css_file = Post_CSS::create( $post_id );
1188 1039 }
1189 1040
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 1041 $css_file->enqueue();
1200 1042 }
1201 1043
1202 1044 ob_start();
@@ -1205,18 +1047,8 @@
1205 1047 if ( is_customize_preview() || wp_doing_ajax() ) {
1206 1048 $with_css = true;
1207 1049 }
1208 1050
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 1051 if ( ! empty( $css_file ) && $with_css ) {
1220 1052 $css_file->print_css();
1221 1053 }
1222 1054
@@ -1257,9 +1089,9 @@
1257 1089 *
1258 1090 * @since 1.0.0
1259 1091 * @access public
1260 1092 *
1261 - * @param int $post_id The post ID.
1093 + * @param int $post_id The post ID.
1262 1094 *
1263 1095 * @param bool $with_css Optional. Whether to retrieve the content with CSS
1264 1096 * or not. Default is false.
1265 1097 *
@@ -1425,9 +1257,9 @@
1425 1257 'isScriptDebug' => Utils::is_script_debug(),
1426 1258 ],
1427 1259 'i18n' => [
1428 1260 'shareOnFacebook' => esc_html__( 'Share on Facebook', 'elementor' ),
1429 - 'shareOnX' => esc_html__( 'Share on X', 'elementor' ),
1261 + 'shareOnTwitter' => esc_html__( 'Share on Twitter', 'elementor' ),
1430 1262 'pinIt' => esc_html__( 'Pin it', 'elementor' ),
1431 1263 'download' => esc_html__( 'Download', 'elementor' ),
1432 1264 'downloadImage' => esc_html__( 'Download image', 'elementor' ),
1433 1265 'fullscreen' => esc_html__( 'Fullscreen', 'elementor' ),
@@ -1436,13 +1268,8 @@
1436 1268 'playVideo' => esc_html__( 'Play Video', 'elementor' ),
1437 1269 'previous' => esc_html__( 'Previous', 'elementor' ),
1438 1270 'next' => esc_html__( 'Next', 'elementor' ),
1439 1271 '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 1272 ],
1446 1273 'is_rtl' => is_rtl(),
1447 1274 // 'breakpoints' object is kept for BC.
1448 1275 'breakpoints' => Responsive::get_breakpoints(),
@@ -1448,9 +1275,8 @@
1448 1275 'breakpoints' => Responsive::get_breakpoints(),
1449 1276 // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0
1450 1277 'responsive' => [
1451 1278 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(),
1452 - 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(),
1453 1279 ],
1454 1280 'version' => ELEMENTOR_VERSION,
1455 1281 'is_static' => $this->is_static_render_mode(),
1456 1282 'experimentalFeatures' => $active_experimental_features,
@@ -1455,16 +1281,9 @@
1455 1281 'is_static' => $this->is_static_render_mode(),
1456 1282 'experimentalFeatures' => $active_experimental_features,
1457 1283 'urls' => [
1458 1284 'assets' => $assets_url,
1459 - 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1460 - 'uploadUrl' => wp_upload_dir()['baseurl'],
1461 1285 ],
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 1286 ];
1468 1287
1469 1288 $settings['settings'] = SettingsManager::get_settings_frontend_config();
1470 1289
@@ -1546,9 +1365,9 @@
1546 1365 *
1547 1366 * @access private
1548 1367 * @since 2.0.4
1549 1368 *
1550 - * @param string $content
1369 + * @param $content
1551 1370 *
1552 1371 * @return string
1553 1372 */
1554 1373 private function process_more_tag( $content ) {
@@ -1596,6 +1415,54 @@
1596 1415 */
1597 1416 $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
1598 1417
1599 1418 return force_balance_tags( $parts['main'] ) . $more_link;
1419 + }
1420 +
1421 + private function is_improved_assets_loading() {
1422 + return Plugin::$instance->experiments->is_feature_active( 'e_optimized_assets_loading' );
1423 + }
1424 +
1425 + private function get_elementor_frontend_dependencies() {
1426 + $dependencies = [
1427 + 'elementor-frontend-modules',
1428 + 'elementor-waypoints',
1429 + 'jquery-ui-position',
1430 + ];
1431 +
1432 + if ( ! $this->is_improved_assets_loading() ) {
1433 + wp_register_script(
1434 + 'swiper',
1435 + $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/' ),
1436 + [],
1437 + '5.3.6',
1438 + true
1439 + );
1440 +
1441 + $dependencies[] = 'swiper';
1442 + $dependencies[] = 'share-link';
1443 + $dependencies[] = 'elementor-dialog';
1444 + }
1445 +
1446 + return $dependencies;
1447 + }
1448 +
1449 + private function is_optimized_css_mode() {
1450 + $is_optimized_css_loading = Plugin::$instance->experiments->is_feature_active( 'e_optimized_css_loading' );
1451 +
1452 + return ! Utils::is_script_debug() && $is_optimized_css_loading && ! Plugin::$instance->preview->is_preview_mode();
1453 + }
1454 +
1455 + private function add_elementor_icons_inline_css() {
1456 + $elementor_icons_library_version = '5.10.0';
1457 +
1458 + /**
1459 + * The e-icons font-face must be printed inline due to custom breakpoints.
1460 + * When using custom breakpoints, the frontend CSS is loaded from the custom-frontend CSS file.
1461 + * The custom frontend file is located in a different path ('uploads' folder).
1462 + * Therefore, it cannot be called from a CSS file that its relative path can vary.
1463 + */
1464 + $elementor_icons_inline_css = sprintf( '@font-face{font-family:eicons;src:url(%1$slib/eicons/fonts/eicons.eot?%2$s);src:url(%1$slib/eicons/fonts/eicons.eot?%2$s#iefix) format("embedded-opentype"),url(%1$slib/eicons/fonts/eicons.woff2?%2$s) format("woff2"),url(%1$slib/eicons/fonts/eicons.woff?%2$s) format("woff"),url(%1$slib/eicons/fonts/eicons.ttf?%2$s) format("truetype"),url(%1$slib/eicons/fonts/eicons.svg?%2$s#eicon) format("svg");font-weight:400;font-style:normal}', ELEMENTOR_ASSETS_URL, $elementor_icons_library_version );
1465 +
1466 + wp_add_inline_style( 'elementor-frontend', $elementor_icons_inline_css );
1600 1467 }
1601 1468 }