| @@ -146,8 +146,10 @@ | ||
| 146 | 146 | private $body_classes = [ |
| 147 | 147 | 'elementor-default', |
| 148 | 148 | ]; |
| 149 | 149 | |
| 150 | + private $google_fonts_index = 0; | |
| 151 | + | |
| 150 | 152 | /** |
| 151 | 153 | * Front End constructor. |
| 152 | 154 | * |
| 153 | 155 | * Initializing Elementor front end. Make sure we are not in admin, not and |
| @@ -171,12 +173,8 @@ | ||
| 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. |
| @@ -238,22 +236,35 @@ | ||
| 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 ); |
| 240 | + add_action( 'wp_head', [ $this, 'print_google_fonts_preconnect_tag' ], 8 ); | |
| 242 | 241 | add_action( 'wp_head', [ $this, 'add_theme_color_meta_tag' ] ); |
| 243 | 242 | add_action( 'wp_footer', [ $this, 'wp_footer' ] ); |
| 244 | 243 | } |
| 245 | 244 | |
| 245 | + public function print_google_fonts_preconnect_tag() { | |
| 246 | + if ( 0 >= $this->google_fonts_index ) { | |
| 247 | + return; | |
| 248 | + } | |
| 249 | + | |
| 250 | + if ( Plugin::$instance->experiments->is_feature_active( 'e_local_google_fonts' ) ) { | |
| 251 | + return; | |
| 252 | + } | |
| 253 | + | |
| 254 | + echo '<link rel="preconnect" href="https://fonts.gstatic.com/" crossorigin>'; | |
| 255 | + } | |
| 256 | + | |
| 246 | 257 | /** |
| 247 | 258 | * @since 2.0.12 |
| 248 | 259 | * @access public |
| 249 | - * @param string|array $class_name | |
| 260 | + * @param string|array $class | |
| 250 | 261 | */ |
| 251 | - public function add_body_class( $class_name ) { | |
| 252 | - if ( is_array( $class_name ) ) { | |
| 253 | - $this->body_classes = array_merge( $this->body_classes, $class_name ); | |
| 262 | + public function add_body_class( $class ) { | |
| 263 | + if ( is_array( $class ) ) { | |
| 264 | + $this->body_classes = array_merge( $this->body_classes, $class ); | |
| 254 | 265 | } else { |
| 255 | - $this->body_classes[] = $class_name; | |
| 266 | + $this->body_classes[] = $class; | |
| 256 | 267 | } |
| 257 | 268 | } |
| 258 | 269 | |
| 259 | 270 | /** |
| @@ -454,10 +465,8 @@ | ||
| 454 | 465 | ELEMENTOR_VERSION, |
| 455 | 466 | true |
| 456 | 467 | ); |
| 457 | 468 | |
| 458 | - $this->register_frontend_handlers(); | |
| 459 | - | |
| 460 | 469 | /** |
| 461 | 470 | * After frontend register scripts. |
| 462 | 471 | * |
| 463 | 472 | * Fires after Elementor frontend scripts are registered. |
| @@ -555,9 +564,9 @@ | ||
| 555 | 564 | ); |
| 556 | 565 | |
| 557 | 566 | wp_register_style( |
| 558 | 567 | 'elementor-frontend', |
| 559 | - $this->get_frontend_file_url( "frontend{$min_suffix}.css", $has_custom_breakpoints ), | |
| 568 | + $this->get_frontend_file_url( "frontend{$direction_suffix}{$min_suffix}.css", $has_custom_breakpoints ), | |
| 560 | 569 | [], |
| 561 | 570 | $has_custom_breakpoints ? null : ELEMENTOR_VERSION |
| 562 | 571 | ); |
| 563 | 572 | |
| @@ -591,23 +600,8 @@ | ||
| 591 | 600 | do_action( 'elementor/frontend/after_register_styles' ); |
| 592 | 601 | } |
| 593 | 602 | |
| 594 | 603 | /** |
| 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 | 604 | * Enqueue scripts. |
| 611 | 605 | * |
| 612 | 606 | * Enqueue all the frontend scripts. |
| 613 | 607 | * |
| @@ -686,22 +680,14 @@ | ||
| 686 | 680 | if ( ! Plugin::$instance->preview->is_preview_mode() ) { |
| 687 | 681 | $post_id = get_the_ID(); |
| 688 | 682 | // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages. |
| 689 | 683 | if ( $post_id && is_singular() ) { |
| 690 | - do_action( 'elementor/post/render', $post_id ); | |
| 691 | 684 | $this->handle_page_assets( $post_id ); |
| 692 | 685 | |
| 693 | 686 | $css_file = Post_CSS::create( get_the_ID() ); |
| 694 | 687 | $css_file->enqueue(); |
| 695 | 688 | } |
| 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 | 689 | } |
| 702 | - | |
| 703 | - do_action( 'elementor/frontend/after_enqueue_post_styles' ); | |
| 704 | 690 | } |
| 705 | 691 | } |
| 706 | 692 | |
| 707 | 693 | private function handle_page_assets( $post_id ): void { |
| @@ -900,20 +886,8 @@ | ||
| 900 | 886 | * @since 1.9.4 |
| 901 | 887 | * @access public |
| 902 | 888 | */ |
| 903 | 889 | 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 | 890 | $google_fonts = $this->get_list_of_google_fonts_by_type(); |
| 917 | 891 | |
| 918 | 892 | $this->enqueue_google_fonts( $google_fonts ); |
| 919 | 893 | $this->enqueue_icon_fonts(); |
| @@ -1044,19 +1018,36 @@ | ||
| 1044 | 1018 | if ( ! $print_google_fonts ) { |
| 1045 | 1019 | return; |
| 1046 | 1020 | } |
| 1047 | 1021 | |
| 1048 | - $force_enqueue_from_cdn = Plugin::$instance->preview->is_preview_mode(); | |
| 1022 | + // Print used fonts | |
| 1023 | + if ( ! empty( $google_fonts['google'] ) ) { | |
| 1024 | + ++$this->google_fonts_index; | |
| 1049 | 1025 | |
| 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 ); | |
| 1026 | + if ( Plugin::$instance->experiments->is_feature_active( 'e_local_google_fonts' ) ) { | |
| 1027 | + foreach ( $google_fonts['google'] as $current_font ) { | |
| 1028 | + Google_Font::enqueue( $current_font ); | |
| 1029 | + } | |
| 1030 | + } else { | |
| 1031 | + $fonts_url = $this->get_stable_google_fonts_url( $google_fonts['google'] ); | |
| 1032 | + | |
| 1033 | + wp_enqueue_style( 'google-fonts-' . $this->google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1053 | 1034 | } |
| 1054 | 1035 | } |
| 1055 | 1036 | |
| 1056 | 1037 | 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 ); | |
| 1038 | + if ( Plugin::$instance->experiments->is_feature_active( 'e_local_google_fonts' ) ) { | |
| 1039 | + foreach ( $google_fonts['early'] as $current_font ) { | |
| 1040 | + Google_Font::enqueue( $current_font, Google_Font::TYPE_EARLYACCESS ); | |
| 1041 | + } | |
| 1042 | + } else { | |
| 1043 | + $early_access_font_urls = $this->get_early_access_google_font_urls( $google_fonts['early'] ); | |
| 1044 | + | |
| 1045 | + foreach ( $early_access_font_urls as $ea_font_url ) { | |
| 1046 | + ++$this->google_fonts_index; | |
| 1047 | + | |
| 1048 | + wp_enqueue_style( 'google-earlyaccess-' . $this->google_fonts_index, $ea_font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion | |
| 1049 | + } | |
| 1059 | 1050 | } |
| 1060 | 1051 | } |
| 1061 | 1052 | } |
| 1062 | 1053 | |
| @@ -1147,21 +1138,8 @@ | ||
| 1147 | 1138 | |
| 1148 | 1139 | $data = $document->get_elements_data(); |
| 1149 | 1140 | |
| 1150 | 1141 | /** |
| 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 | 1142 | * Frontend builder content data. |
| 1165 | 1143 | * |
| 1166 | 1144 | * Filters the builder content in the frontend. |
| 1167 | 1145 | * |
| @@ -1460,9 +1438,8 @@ | ||
| 1460 | 1438 | 'uploadUrl' => wp_upload_dir()['baseurl'], |
| 1461 | 1439 | ], |
| 1462 | 1440 | 'nonces' => [ |
| 1463 | 1441 | 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ), |
| 1464 | - 'atomicFormsSendForm' => wp_create_nonce( 'elementor_pro_atomic_forms_send_form' ), | |
| 1465 | 1442 | ], |
| 1466 | 1443 | 'swiperClass' => 'swiper', |
| 1467 | 1444 | ]; |
| 1468 | 1445 | |