| @@ -2,9 +2,8 @@ | ||
| 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; |
| 9 | 8 | use Elementor\Core\Files\CSS\Post as Post_CSS; |
| 10 | 9 | use Elementor\Core\Files\CSS\Post_Preview; |
| @@ -146,9 +145,21 @@ | ||
| 146 | 145 | private $body_classes = [ |
| 147 | 146 | 'elementor-default', |
| 148 | 147 | ]; |
| 149 | 148 | |
| 149 | + private $google_fonts_index = 0; | |
| 150 | + | |
| 150 | 151 | /** |
| 152 | + * @var string | |
| 153 | + */ | |
| 154 | + private $e_swiper_asset_path; | |
| 155 | + | |
| 156 | + /** | |
| 157 | + * @var string | |
| 158 | + */ | |
| 159 | + private $e_swiper_version; | |
| 160 | + | |
| 161 | + /** | |
| 151 | 162 | * Front End constructor. |
| 152 | 163 | * |
| 153 | 164 | * Initializing Elementor front end. Make sure we are not in admin, not and |
| 154 | 165 | * redirect from old URL structure of Elementor editor. |
| @@ -167,16 +178,13 @@ | ||
| 167 | 178 | add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 5 ); |
| 168 | 179 | add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 5 ); |
| 169 | 180 | |
| 170 | 181 | $this->add_content_filter(); |
| 182 | + $this->init_swiper_settings(); | |
| 171 | 183 | |
| 172 | 184 | // Hack to avoid enqueue post CSS while it's a `the_excerpt` call. |
| 173 | 185 | add_filter( 'get_the_excerpt', [ $this, 'start_excerpt_flag' ], 1 ); |
| 174 | 186 | 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 | 187 | } |
| 180 | 188 | |
| 181 | 189 | /** |
| 182 | 190 | * Get module name. |
| @@ -238,22 +246,31 @@ | ||
| 238 | 246 | } |
| 239 | 247 | |
| 240 | 248 | // Priority 7 to allow google fonts in header template to load in <head> tag |
| 241 | 249 | add_action( 'wp_head', [ $this, 'print_fonts_links' ], 7 ); |
| 250 | + add_action( 'wp_head', [ $this, 'print_google_fonts_preconnect_tag' ], 8 ); | |
| 242 | 251 | add_action( 'wp_head', [ $this, 'add_theme_color_meta_tag' ] ); |
| 243 | 252 | add_action( 'wp_footer', [ $this, 'wp_footer' ] ); |
| 244 | 253 | } |
| 245 | 254 | |
| 255 | + public function print_google_fonts_preconnect_tag() { | |
| 256 | + if ( 0 >= $this->google_fonts_index ) { | |
| 257 | + return; | |
| 258 | + } | |
| 259 | + | |
| 260 | + echo '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>'; | |
| 261 | + } | |
| 262 | + | |
| 246 | 263 | /** |
| 247 | 264 | * @since 2.0.12 |
| 248 | 265 | * @access public |
| 249 | - * @param string|array $class_name | |
| 266 | + * @param string|array $class | |
| 250 | 267 | */ |
| 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 ); | |
| 268 | + public function add_body_class( $class ) { | |
| 269 | + if ( is_array( $class ) ) { | |
| 270 | + $this->body_classes = array_merge( $this->body_classes, $class ); | |
| 254 | 271 | } else { |
| 255 | - $this->body_classes[] = $class_name; | |
| 272 | + $this->body_classes[] = $class; | |
| 256 | 273 | } |
| 257 | 274 | } |
| 258 | 275 | |
| 259 | 276 | /** |
| @@ -323,8 +340,14 @@ | ||
| 323 | 340 | public function add_content_filter() { |
| 324 | 341 | add_filter( 'the_content', [ $this, 'apply_builder_in_content' ], self::THE_CONTENT_FILTER_PRIORITY ); |
| 325 | 342 | } |
| 326 | 343 | |
| 344 | + public function init_swiper_settings() { | |
| 345 | + $e_swiper_latest = Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ); | |
| 346 | + $this->e_swiper_asset_path = $e_swiper_latest ? 'assets/lib/swiper/v8/' : 'assets/lib/swiper/'; | |
| 347 | + $this->e_swiper_version = $e_swiper_latest ? '8.4.5' : '5.3.6'; | |
| 348 | + } | |
| 349 | + | |
| 327 | 350 | /** |
| 328 | 351 | * Remove content filter. |
| 329 | 352 | * |
| 330 | 353 | * When the Elementor generated content rendered, we remove the filter to prevent multiple |
| @@ -376,22 +399,14 @@ | ||
| 376 | 399 | true |
| 377 | 400 | ); |
| 378 | 401 | |
| 379 | 402 | 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 | 403 | 'flatpickr', |
| 389 | 404 | $this->get_js_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ), |
| 390 | 405 | [ |
| 391 | 406 | 'jquery', |
| 392 | 407 | ], |
| 393 | - '4.6.13', | |
| 408 | + '4.1.4', | |
| 394 | 409 | true |
| 395 | 410 | ); |
| 396 | 411 | |
| 397 | 412 | wp_register_script( |
| @@ -419,9 +434,9 @@ | ||
| 419 | 434 | $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ), |
| 420 | 435 | [ |
| 421 | 436 | 'jquery-ui-position', |
| 422 | 437 | ], |
| 423 | - '4.9.4', | |
| 438 | + '4.9.3', | |
| 424 | 439 | true |
| 425 | 440 | ); |
| 426 | 441 | |
| 427 | 442 | wp_register_script( |
| @@ -454,10 +469,8 @@ | ||
| 454 | 469 | ELEMENTOR_VERSION, |
| 455 | 470 | true |
| 456 | 471 | ); |
| 457 | 472 | |
| 458 | - $this->register_frontend_handlers(); | |
| 459 | - | |
| 460 | 473 | /** |
| 461 | 474 | * After frontend register scripts. |
| 462 | 475 | * |
| 463 | 476 | * Fires after Elementor frontend scripts are registered. |
| @@ -508,9 +521,9 @@ | ||
| 508 | 521 | wp_register_style( |
| 509 | 522 | 'flatpickr', |
| 510 | 523 | $this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ), |
| 511 | 524 | [], |
| 512 | - '4.6.13' | |
| 525 | + '4.1.4' | |
| 513 | 526 | ); |
| 514 | 527 | |
| 515 | 528 | wp_register_style( |
| 516 | 529 | 'elementor-gallery', |
| @@ -534,11 +547,11 @@ | ||
| 534 | 547 | ); |
| 535 | 548 | |
| 536 | 549 | wp_register_style( |
| 537 | 550 | 'swiper', |
| 538 | - $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ), | |
| 551 | + $this->get_css_assets_url( 'swiper', $this->e_swiper_asset_path . 'css/' ), | |
| 539 | 552 | [], |
| 540 | - '8.4.5' | |
| 553 | + $this->e_swiper_version | |
| 541 | 554 | ); |
| 542 | 555 | |
| 543 | 556 | wp_register_style( |
| 544 | 557 | 'elementor-wp-admin-bar', |
| @@ -555,9 +568,9 @@ | ||
| 555 | 568 | ); |
| 556 | 569 | |
| 557 | 570 | wp_register_style( |
| 558 | 571 | 'elementor-frontend', |
| 559 | - $this->get_frontend_file_url( "frontend{$min_suffix}.css", $has_custom_breakpoints ), | |
| 572 | + $this->get_frontend_file_url( "frontend{$direction_suffix}{$min_suffix}.css", $has_custom_breakpoints ), | |
| 560 | 573 | [], |
| 561 | 574 | $has_custom_breakpoints ? null : ELEMENTOR_VERSION |
| 562 | 575 | ); |
| 563 | 576 | |
| @@ -591,23 +604,8 @@ | ||
| 591 | 604 | do_action( 'elementor/frontend/after_register_styles' ); |
| 592 | 605 | } |
| 593 | 606 | |
| 594 | 607 | /** |
| 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 | 608 | * Enqueue scripts. |
| 611 | 609 | * |
| 612 | 610 | * Enqueue all the frontend scripts. |
| 613 | 611 | * |
| @@ -623,8 +621,10 @@ | ||
| 623 | 621 | * @since 1.0.0 |
| 624 | 622 | */ |
| 625 | 623 | do_action( 'elementor/frontend/before_enqueue_scripts' ); |
| 626 | 624 | |
| 625 | + wp_enqueue_script( 'elementor-frontend' ); | |
| 626 | + | |
| 627 | 627 | $this->print_config(); |
| 628 | 628 | |
| 629 | 629 | $this->enqueue_conditional_assets(); |
| 630 | 630 | |
| @@ -669,8 +669,13 @@ | ||
| 669 | 669 | } |
| 670 | 670 | |
| 671 | 671 | wp_enqueue_style( 'elementor-frontend' ); |
| 672 | 672 | |
| 673 | + // TODO: Update in version 3.26.0 [ED-15471] | |
| 674 | + if ( ! Plugin::$instance->experiments->is_feature_active( 'e_swiper_css_conditional_loading' ) ) { | |
| 675 | + wp_enqueue_style( 'e-swiper' ); | |
| 676 | + } | |
| 677 | + | |
| 673 | 678 | if ( is_admin_bar_showing() ) { |
| 674 | 679 | wp_enqueue_style( 'elementor-wp-admin-bar' ); |
| 675 | 680 | } |
| 676 | 681 | |
| @@ -686,41 +691,20 @@ | ||
| 686 | 691 | if ( ! Plugin::$instance->preview->is_preview_mode() ) { |
| 687 | 692 | $post_id = get_the_ID(); |
| 688 | 693 | // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages. |
| 689 | 694 | if ( $post_id && is_singular() ) { |
| 690 | - do_action( 'elementor/post/render', $post_id ); | |
| 691 | - $this->handle_page_assets( $post_id ); | |
| 695 | + $page_assets = get_post_meta( $post_id, Assets::ASSETS_META_KEY, true ); | |
| 696 | + if ( ! empty( $page_assets ) ) { | |
| 697 | + Plugin::$instance->assets_loader->enable_assets( $page_assets ); | |
| 698 | + } | |
| 692 | 699 | |
| 693 | 700 | $css_file = Post_CSS::create( get_the_ID() ); |
| 694 | 701 | $css_file->enqueue(); |
| 695 | 702 | } |
| 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 | 703 | } |
| 702 | - | |
| 703 | - do_action( 'elementor/frontend/after_enqueue_post_styles' ); | |
| 704 | 704 | } |
| 705 | 705 | } |
| 706 | 706 | |
| 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 | 707 | /** |
| 724 | 708 | * Get Frontend File URL |
| 725 | 709 | * |
| 726 | 710 | * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom |
| @@ -729,9 +713,9 @@ | ||
| 729 | 713 | * @since 3.4.5 |
| 730 | 714 | * |
| 731 | 715 | * @access public |
| 732 | 716 | * |
| 733 | - * @param string $frontend_file_name | |
| 717 | + * @param string $frontend_file_name | |
| 734 | 718 | * @param boolean $custom_file |
| 735 | 719 | * |
| 736 | 720 | * @return string frontend file URL |
| 737 | 721 | */ |
| @@ -755,9 +739,9 @@ | ||
| 755 | 739 | * |
| 756 | 740 | * @since 3.5.0 |
| 757 | 741 | * @access public |
| 758 | 742 | * |
| 759 | - * @param string $frontend_file_name | |
| 743 | + * @param string $frontend_file_name | |
| 760 | 744 | * @param boolean $custom_file |
| 761 | 745 | * |
| 762 | 746 | * @return string frontend file path |
| 763 | 747 | */ |
| @@ -900,20 +884,8 @@ | ||
| 900 | 884 | * @since 1.9.4 |
| 901 | 885 | * @access public |
| 902 | 886 | */ |
| 903 | 887 | 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 | 888 | $google_fonts = $this->get_list_of_google_fonts_by_type(); |
| 917 | 889 | |
| 918 | 890 | $this->enqueue_google_fonts( $google_fonts ); |
| 919 | 891 | $this->enqueue_icon_fonts(); |
| @@ -944,9 +916,9 @@ | ||
| 944 | 916 | wp_enqueue_style( 'elementor-icons-' . $icon_type ); |
| 945 | 917 | $this->enqueued_icon_fonts[] = $css_url; |
| 946 | 918 | } |
| 947 | 919 | |
| 948 | - // Clear enqueued icons. | |
| 920 | + //clear enqueued icons | |
| 949 | 921 | $this->icon_fonts_to_enqueue = []; |
| 950 | 922 | } |
| 951 | 923 | |
| 952 | 924 | /** |
| @@ -1044,21 +1016,29 @@ | ||
| 1044 | 1016 | if ( ! $print_google_fonts ) { |
| 1045 | 1017 | return; |
| 1046 | 1018 | } |
| 1047 | 1019 | |
| 1048 | - $force_enqueue_from_cdn = Plugin::$instance->preview->is_preview_mode(); | |
| 1020 | + // Print used fonts | |
| 1021 | + if ( ! empty( $google_fonts['google'] ) ) { | |
| 1022 | + $this->google_fonts_index++; | |
| 1049 | 1023 | |
| 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 | - } | |
| 1024 | + $fonts_url = $this->get_stable_google_fonts_url( $google_fonts['google'] ); | |
| 1025 | + | |
| 1026 | + wp_enqueue_style( 'google-fonts-' . $this->google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1054 | 1027 | } |
| 1055 | 1028 | |
| 1056 | 1029 | 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 ); | |
| 1030 | + $early_access_font_urls = $this->get_early_access_google_font_urls( $google_fonts['early'] ); | |
| 1031 | + | |
| 1032 | + foreach ( $early_access_font_urls as $ea_font_url ) { | |
| 1033 | + $this->google_fonts_index++; | |
| 1034 | + | |
| 1035 | + //printf( '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/earlyaccess/%s.css">', strtolower( str_replace( ' ', '', $current_font ) ) ); | |
| 1036 | + | |
| 1037 | + wp_enqueue_style( 'google-earlyaccess-' . $this->google_fonts_index, $ea_font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1059 | 1038 | } |
| 1060 | 1039 | } |
| 1040 | + | |
| 1061 | 1041 | } |
| 1062 | 1042 | |
| 1063 | 1043 | /** |
| 1064 | 1044 | * Enqueue fonts. |
| @@ -1147,21 +1127,8 @@ | ||
| 1147 | 1127 | |
| 1148 | 1128 | $data = $document->get_elements_data(); |
| 1149 | 1129 | |
| 1150 | 1130 | /** |
| 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 | 1131 | * Frontend builder content data. |
| 1165 | 1132 | * |
| 1166 | 1133 | * Filters the builder content in the frontend. |
| 1167 | 1134 | * |
| @@ -1257,9 +1224,9 @@ | ||
| 1257 | 1224 | * |
| 1258 | 1225 | * @since 1.0.0 |
| 1259 | 1226 | * @access public |
| 1260 | 1227 | * |
| 1261 | - * @param int $post_id The post ID. | |
| 1228 | + * @param int $post_id The post ID. | |
| 1262 | 1229 | * |
| 1263 | 1230 | * @param bool $with_css Optional. Whether to retrieve the content with CSS |
| 1264 | 1231 | * or not. Default is false. |
| 1265 | 1232 | * |
| @@ -1436,8 +1403,9 @@ | ||
| 1436 | 1403 | 'playVideo' => esc_html__( 'Play Video', 'elementor' ), |
| 1437 | 1404 | 'previous' => esc_html__( 'Previous', 'elementor' ), |
| 1438 | 1405 | 'next' => esc_html__( 'Next', 'elementor' ), |
| 1439 | 1406 | 'close' => esc_html__( 'Close', 'elementor' ), |
| 1407 | + 'a11yCarouselWrapperAriaLabel' => __( 'Carousel | Horizontal scrolling: Arrow Left & Right', 'elementor' ), | |
| 1440 | 1408 | 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ), |
| 1441 | 1409 | 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ), |
| 1442 | 1410 | 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ), |
| 1443 | 1411 | 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ), |
| @@ -1460,11 +1428,10 @@ | ||
| 1460 | 1428 | 'uploadUrl' => wp_upload_dir()['baseurl'], |
| 1461 | 1429 | ], |
| 1462 | 1430 | 'nonces' => [ |
| 1463 | 1431 | 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ), |
| 1464 | - 'atomicFormsSendForm' => wp_create_nonce( 'elementor_pro_atomic_forms_send_form' ), | |
| 1465 | 1432 | ], |
| 1466 | - 'swiperClass' => 'swiper', | |
| 1433 | + 'swiperClass' => Plugin::$instance->experiments->is_feature_active( 'e_swiper_latest' ) ? 'swiper' : 'swiper-container', | |
| 1467 | 1434 | ]; |
| 1468 | 1435 | |
| 1469 | 1436 | $settings['settings'] = SettingsManager::get_settings_frontend_config(); |
| 1470 | 1437 | |
| @@ -1546,9 +1513,9 @@ | ||
| 1546 | 1513 | * |
| 1547 | 1514 | * @access private |
| 1548 | 1515 | * @since 2.0.4 |
| 1549 | 1516 | * |
| 1550 | - * @param string $content | |
| 1517 | + * @param $content | |
| 1551 | 1518 | * |
| 1552 | 1519 | * @return string |
| 1553 | 1520 | */ |
| 1554 | 1521 | private function process_more_tag( $content ) { |