PluginProbe
Elementor Website Builder – more than just a page builder / 3.24.4
Elementor Website Builder – more than just a page builder v3.24.4
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 +94 -119 4.2.23.24.4 View file →
@@ -2,11 +2,11 @@
2 2 namespace Elementor;
3 3
4 4 use Elementor\Core\Base\App;
5 5 use Elementor\Core\Base\Elements_Iteration_Actions\Assets;
6 -use Elementor\Core\Files\Fonts\Google_Font;
7 6 use Elementor\Core\Frontend\Render_Mode_Manager;
8 7 use Elementor\Core\Responsive\Files\Frontend as FrontendFile;
8 +use Elementor\Core\Files\CSS\Global_CSS;
9 9 use Elementor\Core\Files\CSS\Post as Post_CSS;
10 10 use Elementor\Core\Files\CSS\Post_Preview;
11 11 use Elementor\Core\Responsive\Responsive;
12 12 use Elementor\Core\Settings\Manager as SettingsManager;
@@ -146,9 +146,21 @@
146 146 private $body_classes = [
147 147 'elementor-default',
148 148 ];
149 149
150 + private $google_fonts_index = 0;
151 +
150 152 /**
153 + * @var string
154 + */
155 + private $e_swiper_asset_path;
156 +
157 + /**
158 + * @var string
159 + */
160 + private $e_swiper_version;
161 +
162 + /**
151 163 * Front End constructor.
152 164 *
153 165 * Initializing Elementor front end. Make sure we are not in admin, not and
154 166 * redirect from old URL structure of Elementor editor.
@@ -167,16 +179,13 @@
167 179 add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 5 );
168 180 add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 5 );
169 181
170 182 $this->add_content_filter();
183 + $this->init_swiper_settings();
171 184
172 185 // Hack to avoid enqueue post CSS while it's a `the_excerpt` call.
173 186 add_filter( 'get_the_excerpt', [ $this, 'start_excerpt_flag' ], 1 );
174 187 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 188 }
180 189
181 190 /**
182 191 * Get module name.
@@ -238,22 +247,31 @@
238 247 }
239 248
240 249 // Priority 7 to allow google fonts in header template to load in <head> tag
241 250 add_action( 'wp_head', [ $this, 'print_fonts_links' ], 7 );
251 + add_action( 'wp_head', [ $this, 'print_google_fonts_preconnect_tag' ], 8 );
242 252 add_action( 'wp_head', [ $this, 'add_theme_color_meta_tag' ] );
243 253 add_action( 'wp_footer', [ $this, 'wp_footer' ] );
244 254 }
245 255
256 + public function print_google_fonts_preconnect_tag() {
257 + if ( 0 >= $this->google_fonts_index ) {
258 + return;
259 + }
260 +
261 + echo '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>';
262 + }
263 +
246 264 /**
247 265 * @since 2.0.12
248 266 * @access public
249 - * @param string|array $class_name
267 + * @param string|array $class
250 268 */
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 );
269 + public function add_body_class( $class ) {
270 + if ( is_array( $class ) ) {
271 + $this->body_classes = array_merge( $this->body_classes, $class );
254 272 } else {
255 - $this->body_classes[] = $class_name;
273 + $this->body_classes[] = $class;
256 274 }
257 275 }
258 276
259 277 /**
@@ -323,8 +341,14 @@
323 341 public function add_content_filter() {
324 342 add_filter( 'the_content', [ $this, 'apply_builder_in_content' ], self::THE_CONTENT_FILTER_PRIORITY );
325 343 }
326 344
345 + public function init_swiper_settings() {
346 + $e_swiper_latest = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' );
347 + $this->e_swiper_asset_path = $e_swiper_latest ? 'assets/lib/swiper/v8/' : 'assets/lib/swiper/';
348 + $this->e_swiper_version = $e_swiper_latest ? '8.4.5' : '5.3.6';
349 + }
350 +
327 351 /**
328 352 * Remove content filter.
329 353 *
330 354 * When the Elementor generated content rendered, we remove the filter to prevent multiple
@@ -376,22 +400,14 @@
376 400 true
377 401 );
378 402
379 403 wp_register_script(
380 - 'swiper',
381 - $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/v8/' ),
382 - [],
383 - '8.4.5',
384 - true
385 - );
386 -
387 - wp_register_script(
388 404 'flatpickr',
389 405 $this->get_js_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
390 406 [
391 407 'jquery',
392 408 ],
393 - '4.6.13',
409 + '4.1.4',
394 410 true
395 411 );
396 412
397 413 wp_register_script(
@@ -419,9 +435,9 @@
419 435 $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ),
420 436 [
421 437 'jquery-ui-position',
422 438 ],
423 - '4.9.4',
439 + '4.9.3',
424 440 true
425 441 );
426 442
427 443 wp_register_script(
@@ -454,10 +470,8 @@
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.
@@ -508,9 +522,9 @@
508 522 wp_register_style(
509 523 'flatpickr',
510 524 $this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
511 525 [],
512 - '4.6.13'
526 + '4.1.4'
513 527 );
514 528
515 529 wp_register_style(
516 530 'elementor-gallery',
@@ -520,11 +534,11 @@
520 534 );
521 535
522 536 wp_register_style(
523 537 'e-apple-webkit',
524 - $this->get_frontend_file_url( 'apple-webkit.min.css', $has_custom_breakpoints, 'conditionals/' ),
538 + $this->get_css_assets_url( 'apple-webkit', 'assets/css/conditionals/' ),
525 539 [],
526 - $has_custom_breakpoints ? null : ELEMENTOR_VERSION
540 + ELEMENTOR_VERSION
527 541 );
528 542
529 543 wp_register_style(
530 544 'e-swiper',
@@ -534,11 +548,11 @@
534 548 );
535 549
536 550 wp_register_style(
537 551 'swiper',
538 - $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ),
552 + $this->get_css_assets_url( 'swiper', $this->e_swiper_asset_path . 'css/' ),
539 553 [],
540 - '8.4.5'
554 + $this->e_swiper_version
541 555 );
542 556
543 557 wp_register_style(
544 558 'elementor-wp-admin-bar',
@@ -547,17 +561,10 @@
547 561 ELEMENTOR_VERSION
548 562 );
549 563
550 564 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 - );
556 -
557 - wp_register_style(
558 565 'elementor-frontend',
559 - $this->get_frontend_file_url( "frontend{$min_suffix}.css", $has_custom_breakpoints ),
566 + $this->get_frontend_file_url( "frontend{$direction_suffix}{$min_suffix}.css", $has_custom_breakpoints ),
560 567 [],
561 568 $has_custom_breakpoints ? null : ELEMENTOR_VERSION
562 569 );
563 570
@@ -591,23 +598,8 @@
591 598 do_action( 'elementor/frontend/after_register_styles' );
592 599 }
593 600
594 601 /**
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 602 * Enqueue scripts.
611 603 *
612 604 * Enqueue all the frontend scripts.
613 605 *
@@ -623,8 +615,10 @@
623 615 * @since 1.0.0
624 616 */
625 617 do_action( 'elementor/frontend/before_enqueue_scripts' );
626 618
619 + wp_enqueue_script( 'elementor-frontend' );
620 +
627 621 $this->print_config();
628 622
629 623 $this->enqueue_conditional_assets();
630 624
@@ -669,8 +663,13 @@
669 663 }
670 664
671 665 wp_enqueue_style( 'elementor-frontend' );
672 666
667 + // TODO: Update in version 3.26.0 [ED-15471]
668 + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_swiper_css_conditional_loading' ) ) {
669 + wp_enqueue_style( 'e-swiper' );
670 + }
671 +
673 672 if ( is_admin_bar_showing() ) {
674 673 wp_enqueue_style( 'elementor-wp-admin-bar' );
675 674 }
676 675
@@ -683,44 +682,25 @@
683 682 */
684 683 do_action( 'elementor/frontend/after_enqueue_styles' );
685 684
686 685 if ( ! Plugin::$instance->preview->is_preview_mode() ) {
686 + $this->parse_global_css_code();
687 +
687 688 $post_id = get_the_ID();
688 689 // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages.
689 690 if ( $post_id && is_singular() ) {
690 - do_action( 'elementor/post/render', $post_id );
691 - $this->handle_page_assets( $post_id );
691 + $page_assets = get_post_meta( $post_id, Assets::ASSETS_META_KEY, true );
692 + if ( ! empty( $page_assets ) ) {
693 + Plugin::$instance->assets_loader->enable_assets( $page_assets );
694 + }
692 695
693 696 $css_file = Post_CSS::create( get_the_ID() );
694 697 $css_file->enqueue();
695 698 }
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 699 }
702 -
703 - do_action( 'elementor/frontend/after_enqueue_post_styles' );
704 700 }
705 701 }
706 702
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 703 /**
724 704 * Get Frontend File URL
725 705 *
726 706 * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
@@ -729,20 +709,20 @@
729 709 * @since 3.4.5
730 710 *
731 711 * @access public
732 712 *
733 - * @param string $frontend_file_name
713 + * @param string $frontend_file_name
734 714 * @param boolean $custom_file
735 715 *
736 716 * @return string frontend file URL
737 717 */
738 - public function get_frontend_file_url( $frontend_file_name, $custom_file, $css_subfolder = '' ) {
718 + public function get_frontend_file_url( $frontend_file_name, $custom_file ) {
739 719 if ( $custom_file ) {
740 720 $frontend_file = $this->get_frontend_file( $frontend_file_name );
741 721
742 722 $frontend_file_url = $frontend_file->get_url();
743 723 } else {
744 - $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $css_subfolder . $frontend_file_name;
724 + $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $frontend_file_name;
745 725 }
746 726
747 727 return $frontend_file_url;
748 728 }
@@ -755,9 +735,9 @@
755 735 *
756 736 * @since 3.5.0
757 737 * @access public
758 738 *
759 - * @param string $frontend_file_name
739 + * @param string $frontend_file_name
760 740 * @param boolean $custom_file
761 741 *
762 742 * @return string frontend file path
763 743 */
@@ -900,20 +880,8 @@
900 880 * @since 1.9.4
901 881 * @access public
902 882 */
903 883 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 884 $google_fonts = $this->get_list_of_google_fonts_by_type();
917 885
918 886 $this->enqueue_google_fonts( $google_fonts );
919 887 $this->enqueue_icon_fonts();
@@ -944,9 +912,9 @@
944 912 wp_enqueue_style( 'elementor-icons-' . $icon_type );
945 913 $this->enqueued_icon_fonts[] = $css_url;
946 914 }
947 915
948 - // Clear enqueued icons.
916 + //clear enqueued icons
949 917 $this->icon_fonts_to_enqueue = [];
950 918 }
951 919
952 920 /**
@@ -1044,21 +1012,29 @@
1044 1012 if ( ! $print_google_fonts ) {
1045 1013 return;
1046 1014 }
1047 1015
1048 - $force_enqueue_from_cdn = Plugin::$instance->preview->is_preview_mode();
1016 + // Print used fonts
1017 + if ( ! empty( $google_fonts['google'] ) ) {
1018 + $this->google_fonts_index++;
1049 1019
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 - }
1020 + $fonts_url = $this->get_stable_google_fonts_url( $google_fonts['google'] );
1021 +
1022 + wp_enqueue_style( 'google-fonts-' . $this->google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1054 1023 }
1055 1024
1056 1025 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 );
1026 + $early_access_font_urls = $this->get_early_access_google_font_urls( $google_fonts['early'] );
1027 +
1028 + foreach ( $early_access_font_urls as $ea_font_url ) {
1029 + $this->google_fonts_index++;
1030 +
1031 + //printf( '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/earlyaccess/%s.css">', strtolower( str_replace( ' ', '', $current_font ) ) );
1032 +
1033 + wp_enqueue_style( 'google-earlyaccess-' . $this->google_fonts_index, $ea_font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1059 1034 }
1060 1035 }
1036 +
1061 1037 }
1062 1038
1063 1039 /**
1064 1040 * Enqueue fonts.
@@ -1079,8 +1055,22 @@
1079 1055 $this->registered_fonts[] = $font;
1080 1056 }
1081 1057
1082 1058 /**
1059 + * Parse global CSS.
1060 + *
1061 + * Enqueue the global CSS file.
1062 + *
1063 + * @since 1.2.0
1064 + * @access protected
1065 + */
1066 + protected function parse_global_css_code() {
1067 + $scheme_css_file = Global_CSS::create( 'global.css' );
1068 +
1069 + $scheme_css_file->enqueue();
1070 + }
1071 +
1072 + /**
1083 1073 * Apply builder in content.
1084 1074 *
1085 1075 * Used to apply the Elementor page editor on the post content.
1086 1076 *
@@ -1147,21 +1137,8 @@
1147 1137
1148 1138 $data = $document->get_elements_data();
1149 1139
1150 1140 /**
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 1141 * Frontend builder content data.
1165 1142 *
1166 1143 * Filters the builder content in the frontend.
1167 1144 *
@@ -1257,9 +1234,9 @@
1257 1234 *
1258 1235 * @since 1.0.0
1259 1236 * @access public
1260 1237 *
1261 - * @param int $post_id The post ID.
1238 + * @param int $post_id The post ID.
1262 1239 *
1263 1240 * @param bool $with_css Optional. Whether to retrieve the content with CSS
1264 1241 * or not. Default is false.
1265 1242 *
@@ -1425,9 +1402,9 @@
1425 1402 'isScriptDebug' => Utils::is_script_debug(),
1426 1403 ],
1427 1404 'i18n' => [
1428 1405 'shareOnFacebook' => esc_html__( 'Share on Facebook', 'elementor' ),
1429 - 'shareOnX' => esc_html__( 'Share on X', 'elementor' ),
1406 + 'shareOnTwitter' => esc_html__( 'Share on Twitter', 'elementor' ),
1430 1407 'pinIt' => esc_html__( 'Pin it', 'elementor' ),
1431 1408 'download' => esc_html__( 'Download', 'elementor' ),
1432 1409 'downloadImage' => esc_html__( 'Download image', 'elementor' ),
1433 1410 'fullscreen' => esc_html__( 'Fullscreen', 'elementor' ),
@@ -1436,8 +1413,9 @@
1436 1413 'playVideo' => esc_html__( 'Play Video', 'elementor' ),
1437 1414 'previous' => esc_html__( 'Previous', 'elementor' ),
1438 1415 'next' => esc_html__( 'Next', 'elementor' ),
1439 1416 'close' => esc_html__( 'Close', 'elementor' ),
1417 + 'a11yCarouselWrapperAriaLabel' => __( 'Carousel | Horizontal scrolling: Arrow Left & Right', 'elementor' ),
1440 1418 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ),
1441 1419 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ),
1442 1420 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ),
1443 1421 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ),
@@ -1448,9 +1426,8 @@
1448 1426 'breakpoints' => Responsive::get_breakpoints(),
1449 1427 // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0
1450 1428 'responsive' => [
1451 1429 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(),
1452 - 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(),
1453 1430 ],
1454 1431 'version' => ELEMENTOR_VERSION,
1455 1432 'is_static' => $this->is_static_render_mode(),
1456 1433 'experimentalFeatures' => $active_experimental_features,
@@ -1456,15 +1433,13 @@
1456 1433 'experimentalFeatures' => $active_experimental_features,
1457 1434 'urls' => [
1458 1435 'assets' => $assets_url,
1459 1436 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1460 - 'uploadUrl' => wp_upload_dir()['baseurl'],
1461 1437 ],
1462 1438 'nonces' => [
1463 1439 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ),
1464 - 'atomicFormsSendForm' => wp_create_nonce( 'elementor_pro_atomic_forms_send_form' ),
1465 1440 ],
1466 - 'swiperClass' => 'swiper',
1441 + 'swiperClass' => Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container',
1467 1442 ];
1468 1443
1469 1444 $settings['settings'] = SettingsManager::get_settings_frontend_config();
1470 1445
@@ -1546,9 +1521,9 @@
1546 1521 *
1547 1522 * @access private
1548 1523 * @since 2.0.4
1549 1524 *
1550 - * @param string $content
1525 + * @param $content
1551 1526 *
1552 1527 * @return string
1553 1528 */
1554 1529 private function process_more_tag( $content ) {