PluginProbe
Elementor Website Builder – more than just a page builder / 3.28.0-dev2
Elementor Website Builder – more than just a page builder v3.28.0-dev2
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
elementor / includes / frontend.php

frontend.php in Elementor Website Builder – more than just a page builder 3.28.0-dev2, at includes/frontend.php

1,581 lines 39.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 use Elementor\Core\Base\App;
5 use Elementor\Core\Base\Elements_Iteration_Actions\Assets;
6 use Elementor\Core\Files\Fonts\Google_Font;
7 use Elementor\Core\Frontend\Render_Mode_Manager;
8 use Elementor\Core\Responsive\Files\Frontend as FrontendFile;
9 use Elementor\Core\Files\CSS\Post as Post_CSS;
10 use Elementor\Core\Files\CSS\Post_Preview;
11 use Elementor\Core\Responsive\Responsive;
12 use Elementor\Core\Settings\Manager as SettingsManager;
13 use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
14 use Elementor\Modules\FloatingButtons\Module;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit if accessed directly.
18 }
19
20 /**
21 * Elementor frontend.
22 *
23 * Elementor frontend handler class is responsible for initializing Elementor in
24 * the frontend.
25 *
26 * @since 1.0.0
27 */
28 class Frontend extends App {
29
30 /**
31 * The priority of the content filter.
32 */
33 const THE_CONTENT_FILTER_PRIORITY = 9;
34
35 /**
36 * The priority of the frontend enqueued styles.
37 */
38 const ENQUEUED_STYLES_PRIORITY = 20;
39
40 /**
41 * Post ID.
42 *
43 * Holds the ID of the current post.
44 *
45 * @access private
46 *
47 * @var int Post ID.
48 */
49 private $post_id;
50
51 /**
52 * Fonts to enqueue
53 *
54 * Holds the list of fonts that are being used in the current page.
55 *
56 * @since 1.9.4
57 * @access public
58 *
59 * @var array Used fonts. Default is an empty array.
60 */
61 public $fonts_to_enqueue = [];
62
63 /**
64 * Holds the class that respond to manage the render mode.
65 *
66 * @var Render_Mode_Manager
67 */
68 public $render_mode_manager;
69
70 /**
71 * Registered fonts.
72 *
73 * Holds the list of enqueued fonts in the current page.
74 *
75 * @since 1.0.0
76 * @access private
77 *
78 * @var array Registered fonts. Default is an empty array.
79 */
80 private $registered_fonts = [];
81
82 /**
83 * Icon Fonts to enqueue
84 *
85 * Holds the list of Icon fonts that are being used in the current page.
86 *
87 * @since 2.4.0
88 * @access private
89 *
90 * @var array Used icon fonts. Default is an empty array.
91 */
92 private $icon_fonts_to_enqueue = [];
93
94 /**
95 * Enqueue Icon Fonts
96 *
97 * Holds the list of Icon fonts already enqueued in the current page.
98 *
99 * @since 2.4.0
100 * @access private
101 *
102 * @var array enqueued icon fonts. Default is an empty array.
103 */
104 private $enqueued_icon_fonts = [];
105
106 /**
107 * Whether the page is using Elementor.
108 *
109 * Used to determine whether the current page is using Elementor.
110 *
111 * @since 1.0.0
112 * @access private
113 *
114 * @var bool Whether Elementor is being used. Default is false.
115 */
116 private $_has_elementor_in_page = false;
117
118 /**
119 * Whether the excerpt is being called.
120 *
121 * Used to determine whether the call to `the_content()` came from `get_the_excerpt()`.
122 *
123 * @since 1.0.0
124 * @access private
125 *
126 * @var bool Whether the excerpt is being used. Default is false.
127 */
128 private $_is_excerpt = false;
129
130 /**
131 * Filters removed from the content.
132 *
133 * Hold the list of filters removed from `the_content()`. Used to hold the filters that
134 * conflicted with Elementor while Elementor process the content.
135 *
136 * @since 1.0.0
137 * @access private
138 *
139 * @var array Filters removed from the content. Default is an empty array.
140 */
141 private $content_removed_filters = [];
142
143 /**
144 * @var string[]
145 */
146 private $body_classes = [
147 'elementor-default',
148 ];
149
150 private $google_fonts_index = 0;
151
152 /**
153 * Front End constructor.
154 *
155 * Initializing Elementor front end. Make sure we are not in admin, not and
156 * redirect from old URL structure of Elementor editor.
157 *
158 * @since 1.0.0
159 * @access public
160 */
161 public function __construct() {
162 // We don't need this class in admin side, but in AJAX requests.
163 if ( is_admin() && ! wp_doing_ajax() ) {
164 return;
165 }
166
167 add_action( 'template_redirect', [ $this, 'init_render_mode' ], -1 /* Before admin bar. */ );
168 add_action( 'template_redirect', [ $this, 'init' ] );
169 add_action( 'wp_enqueue_scripts', [ $this, 'register_scripts' ], 5 );
170 add_action( 'wp_enqueue_scripts', [ $this, 'register_styles' ], 5 );
171
172 $this->add_content_filter();
173
174 // Hack to avoid enqueue post CSS while it's a `the_excerpt` call.
175 add_filter( 'get_the_excerpt', [ $this, 'start_excerpt_flag' ], 1 );
176 add_filter( 'get_the_excerpt', [ $this, 'end_excerpt_flag' ], 20 );
177 }
178
179 /**
180 * Get module name.
181 *
182 * Retrieve the module name.
183 *
184 * @since 2.3.0
185 * @access public
186 *
187 * @return string Module name.
188 */
189 public function get_name() {
190 return 'frontend';
191 }
192
193 /**
194 * Init render mode manager.
195 */
196 public function init_render_mode() {
197 if ( Plugin::$instance->editor->is_edit_mode() ) {
198 return;
199 }
200
201 $this->render_mode_manager = new Render_Mode_Manager();
202 }
203
204 /**
205 * Init.
206 *
207 * Initialize Elementor front end. Hooks the needed actions to run Elementor
208 * in the front end, including script and style registration.
209 *
210 * Fired by `template_redirect` action.
211 *
212 * @since 1.0.0
213 * @access public
214 */
215 public function init() {
216 if ( Plugin::$instance->editor->is_edit_mode() ) {
217 return;
218 }
219
220 add_filter( 'body_class', [ $this, 'body_class' ] );
221
222 if ( Plugin::$instance->preview->is_preview_mode() ) {
223 return;
224 }
225
226 if ( current_user_can( 'manage_options' ) ) {
227 Plugin::$instance->init_common();
228 }
229
230 $this->post_id = get_the_ID();
231
232 $document = Plugin::$instance->documents->get( $this->post_id );
233
234 if ( is_singular() && $document && $document->is_built_with_elementor() ) {
235 add_action( 'wp_enqueue_scripts', [ $this, 'enqueue_styles' ], self::ENQUEUED_STYLES_PRIORITY );
236 }
237
238 // Priority 7 to allow google fonts in header template to load in <head> tag
239 add_action( 'wp_head', [ $this, 'print_fonts_links' ], 7 );
240 add_action( 'wp_head', [ $this, 'print_google_fonts_preconnect_tag' ], 8 );
241 add_action( 'wp_head', [ $this, 'add_theme_color_meta_tag' ] );
242 add_action( 'wp_footer', [ $this, 'wp_footer' ] );
243 }
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
257 /**
258 * @since 2.0.12
259 * @access public
260 * @param string|array $class
261 */
262 public function add_body_class( $class ) {
263 if ( is_array( $class ) ) {
264 $this->body_classes = array_merge( $this->body_classes, $class );
265 } else {
266 $this->body_classes[] = $class;
267 }
268 }
269
270 /**
271 * Add Theme Color Meta Tag
272 *
273 * @since 3.0.0
274 * @access public
275 */
276 public function add_theme_color_meta_tag() {
277 $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend();
278 $mobile_theme_color = $kit->get_settings( 'mobile_browser_background' );
279
280 if ( ! empty( $mobile_theme_color ) ) {
281 ?>
282 <meta name="theme-color" content="<?php echo esc_attr( $mobile_theme_color ); ?>">
283 <?php
284 }
285 }
286
287 /**
288 * Body tag classes.
289 *
290 * Add new elementor classes to the body tag.
291 *
292 * Fired by `body_class` filter.
293 *
294 * @since 1.0.0
295 * @access public
296 *
297 * @param array $classes Optional. One or more classes to add to the body tag class list.
298 * Default is an empty array.
299 *
300 * @return array Body tag classes.
301 */
302 public function body_class( $classes = [] ) {
303 $classes = array_merge( $classes, $this->body_classes );
304
305 $id = get_the_ID();
306
307 $document = Plugin::$instance->documents->get( $id );
308
309 if ( is_singular() && $document && $document->is_built_with_elementor() ) {
310 $classes[] = 'elementor-page elementor-page-' . $id;
311 }
312
313 if ( Plugin::$instance->preview->is_preview_mode() ) {
314 $editor_preferences = SettingsManager::get_settings_managers( 'editorPreferences' );
315
316 $show_hidden_elements = $editor_preferences->get_model()->get_settings( 'show_hidden_elements' );
317
318 if ( 'yes' === $show_hidden_elements ) {
319 $classes[] = 'e-preview--show-hidden-elements';
320 }
321 }
322
323 return $classes;
324 }
325
326 /**
327 * Add content filter.
328 *
329 * Remove plain content and render the content generated by Elementor.
330 *
331 * @since 1.8.0
332 * @access public
333 */
334 public function add_content_filter() {
335 add_filter( 'the_content', [ $this, 'apply_builder_in_content' ], self::THE_CONTENT_FILTER_PRIORITY );
336 }
337
338 /**
339 * Remove content filter.
340 *
341 * When the Elementor generated content rendered, we remove the filter to prevent multiple
342 * accuracies. This way we make sure Elementor renders the content only once.
343 *
344 * @since 1.8.0
345 * @access public
346 */
347 public function remove_content_filter() {
348 remove_filter( 'the_content', [ $this, 'apply_builder_in_content' ], self::THE_CONTENT_FILTER_PRIORITY );
349 }
350
351 /**
352 * Registers scripts.
353 *
354 * Registers all the frontend scripts.
355 *
356 * Fired by `wp_enqueue_scripts` action.
357 *
358 * @since 1.2.1
359 * @access public
360 */
361 public function register_scripts() {
362 /**
363 * Before frontend register scripts.
364 *
365 * Fires before Elementor frontend scripts are registered.
366 *
367 * @since 1.2.1
368 */
369 do_action( 'elementor/frontend/before_register_scripts' );
370
371 wp_register_script(
372 'elementor-webpack-runtime',
373 $this->get_js_assets_url( 'webpack.runtime', 'assets/js/' ),
374 [],
375 ELEMENTOR_VERSION,
376 true
377 );
378
379 wp_register_script(
380 'elementor-frontend-modules',
381 $this->get_js_assets_url( 'frontend-modules' ),
382 [
383 'elementor-webpack-runtime',
384 'jquery',
385 ],
386 ELEMENTOR_VERSION,
387 true
388 );
389
390 wp_register_script(
391 'swiper',
392 $this->get_js_assets_url( 'swiper', 'assets/lib/swiper/v8/' ),
393 [],
394 '8.4.5',
395 true
396 );
397
398 wp_register_script(
399 'flatpickr',
400 $this->get_js_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
401 [
402 'jquery',
403 ],
404 '4.6.13',
405 true
406 );
407
408 wp_register_script(
409 'imagesloaded',
410 $this->get_js_assets_url( 'imagesloaded', 'assets/lib/imagesloaded/' ),
411 [
412 'jquery',
413 ],
414 '4.1.0',
415 true
416 );
417
418 wp_register_script(
419 'jquery-numerator',
420 $this->get_js_assets_url( 'jquery-numerator', 'assets/lib/jquery-numerator/' ),
421 [
422 'jquery',
423 ],
424 '0.2.1',
425 true
426 );
427
428 wp_register_script(
429 'elementor-dialog',
430 $this->get_js_assets_url( 'dialog', 'assets/lib/dialog/' ),
431 [
432 'jquery-ui-position',
433 ],
434 '4.9.3',
435 true
436 );
437
438 wp_register_script(
439 'elementor-gallery',
440 $this->get_js_assets_url( 'e-gallery', 'assets/lib/e-gallery/js/' ),
441 [
442 'jquery',
443 ],
444 '1.2.0',
445 true
446 );
447
448 wp_register_script(
449 'share-link',
450 $this->get_js_assets_url( 'share-link', 'assets/lib/share-link/' ),
451 [
452 'jquery',
453 ],
454 ELEMENTOR_VERSION,
455 true
456 );
457
458 wp_register_script(
459 'elementor-frontend',
460 $this->get_js_assets_url( 'frontend' ),
461 [
462 'elementor-frontend-modules',
463 'jquery-ui-position',
464 ],
465 ELEMENTOR_VERSION,
466 true
467 );
468
469 /**
470 * After frontend register scripts.
471 *
472 * Fires after Elementor frontend scripts are registered.
473 *
474 * @since 1.2.1
475 */
476 do_action( 'elementor/frontend/after_register_scripts' );
477 }
478
479 /**
480 * Registers styles.
481 *
482 * Registers all the frontend styles.
483 *
484 * Fired by `wp_enqueue_scripts` action.
485 *
486 * @since 1.2.0
487 * @access public
488 */
489 public function register_styles() {
490 $min_suffix = Utils::is_script_debug() ? '' : '.min';
491 $direction_suffix = is_rtl() ? '-rtl' : '';
492 $has_custom_breakpoints = Plugin::$instance->breakpoints->has_custom_breakpoints();
493
494 /**
495 * Before frontend register styles.
496 *
497 * Fires before Elementor frontend styles are registered.
498 *
499 * @since 1.2.0
500 */
501 do_action( 'elementor/frontend/before_register_styles' );
502
503 wp_register_style(
504 'font-awesome',
505 $this->get_css_assets_url( 'font-awesome', 'assets/lib/font-awesome/css/' ),
506 [],
507 '4.7.0'
508 );
509
510 wp_register_style(
511 'elementor-icons',
512 $this->get_css_assets_url( 'elementor-icons', 'assets/lib/eicons/css/' ),
513 [],
514 Icons_Manager::ELEMENTOR_ICONS_VERSION
515 );
516
517 wp_register_style(
518 'flatpickr',
519 $this->get_css_assets_url( 'flatpickr', 'assets/lib/flatpickr/' ),
520 [],
521 '4.6.13'
522 );
523
524 wp_register_style(
525 'elementor-gallery',
526 $this->get_css_assets_url( 'e-gallery', 'assets/lib/e-gallery/css/' ),
527 [],
528 '1.2.0'
529 );
530
531 wp_register_style(
532 'e-apple-webkit',
533 $this->get_frontend_file_url( 'apple-webkit.min.css', $has_custom_breakpoints, 'conditionals/' ),
534 [],
535 $has_custom_breakpoints ? null : ELEMENTOR_VERSION
536 );
537
538 wp_register_style(
539 'e-swiper',
540 $this->get_css_assets_url( 'e-swiper', 'assets/css/conditionals/' ),
541 [ 'swiper' ],
542 ELEMENTOR_VERSION
543 );
544
545 wp_register_style(
546 'swiper',
547 $this->get_css_assets_url( 'swiper', 'assets/lib/swiper/v8/css/' ),
548 [],
549 '8.4.5'
550 );
551
552 wp_register_style(
553 'elementor-wp-admin-bar',
554 $this->get_css_assets_url( 'admin-bar', 'assets/css/' ),
555 [],
556 ELEMENTOR_VERSION
557 );
558
559 wp_register_style(
560 'e-lightbox',
561 $this->get_frontend_file_url( 'lightbox.min.css', $has_custom_breakpoints, 'conditionals/' ),
562 [],
563 $has_custom_breakpoints ? null : ELEMENTOR_VERSION
564 );
565
566 wp_register_style(
567 'elementor-frontend',
568 $this->get_frontend_file_url( "frontend{$direction_suffix}{$min_suffix}.css", $has_custom_breakpoints ),
569 [],
570 $has_custom_breakpoints ? null : ELEMENTOR_VERSION
571 );
572
573 $widgets_with_styles = Plugin::$instance->widgets_manager->widgets_with_styles();
574 foreach ( $widgets_with_styles as $widget_name ) {
575 wp_register_style(
576 "widget-{$widget_name}",
577 $this->get_css_assets_url( "widget-{$widget_name}", null, true, true ),
578 [ 'elementor-frontend' ],
579 ELEMENTOR_VERSION
580 );
581 }
582
583 $widgets_with_responsive_styles = Plugin::$instance->widgets_manager->widgets_with_responsive_styles();
584 foreach ( $widgets_with_responsive_styles as $widget_name ) {
585 wp_register_style(
586 "widget-{$widget_name}",
587 $this->get_frontend_file_url( "widget-{$widget_name}{$direction_suffix}.min.css", $has_custom_breakpoints ),
588 [ 'elementor-frontend' ],
589 $has_custom_breakpoints ? null : ELEMENTOR_VERSION
590 );
591 }
592
593 /**
594 * After frontend register styles.
595 *
596 * Fires after Elementor frontend styles are registered.
597 *
598 * @since 1.2.0
599 */
600 do_action( 'elementor/frontend/after_register_styles' );
601 }
602
603 /**
604 * Enqueue scripts.
605 *
606 * Enqueue all the frontend scripts.
607 *
608 * @since 1.0.0
609 * @access public
610 */
611 public function enqueue_scripts() {
612 /**
613 * Before frontend enqueue scripts.
614 *
615 * Fires before Elementor frontend scripts are enqueued.
616 *
617 * @since 1.0.0
618 */
619 do_action( 'elementor/frontend/before_enqueue_scripts' );
620
621 wp_enqueue_script( 'elementor-frontend' );
622
623 $this->print_config();
624
625 $this->enqueue_conditional_assets();
626
627 /**
628 * After frontend enqueue scripts.
629 *
630 * Fires after Elementor frontend scripts are enqueued.
631 *
632 * @since 1.0.0
633 */
634 do_action( 'elementor/frontend/after_enqueue_scripts' );
635 }
636
637 /**
638 * Enqueue styles.
639 *
640 * Enqueue all the frontend styles.
641 *
642 * Fired by `wp_enqueue_scripts` action.
643 *
644 * @since 1.0.0
645 * @access public
646 */
647 public function enqueue_styles() {
648 static $is_enqueue_styles_already_triggered;
649
650 if ( ! $is_enqueue_styles_already_triggered ) {
651 $is_enqueue_styles_already_triggered = true;
652
653 /**
654 * Before frontend styles enqueued.
655 *
656 * Fires before Elementor frontend styles are enqueued.
657 *
658 * @since 1.0.0
659 */
660 do_action( 'elementor/frontend/before_enqueue_styles' );
661
662 // The e-icons are needed in preview mode for the editor icons (plus-icon for new section, folder-icon for the templates library etc.).
663 if ( ! Plugin::$instance->experiments->is_feature_active( 'e_font_icon_svg' ) || Plugin::$instance->preview->is_preview_mode() ) {
664 wp_enqueue_style( 'elementor-icons' );
665 }
666
667 wp_enqueue_style( 'elementor-frontend' );
668
669 if ( is_admin_bar_showing() ) {
670 wp_enqueue_style( 'elementor-wp-admin-bar' );
671 }
672
673 /**
674 * After frontend styles enqueued.
675 *
676 * Fires after Elementor frontend styles are enqueued.
677 *
678 * @since 1.0.0
679 */
680 do_action( 'elementor/frontend/after_enqueue_styles' );
681
682 if ( ! Plugin::$instance->preview->is_preview_mode() ) {
683 $post_id = get_the_ID();
684 // Check $post_id for virtual pages. check is singular because the $post_id is set to the first post on archive pages.
685 if ( $post_id && is_singular() ) {
686 $this->handle_page_assets( $post_id );
687
688 $css_file = Post_CSS::create( get_the_ID() );
689 $css_file->enqueue();
690 }
691 }
692 }
693 }
694
695 private function handle_page_assets( $post_id ): void {
696 $page_assets = get_post_meta( $post_id, Assets::ASSETS_META_KEY, true );
697 if ( ! empty( $page_assets ) ) {
698 Plugin::$instance->assets_loader->enable_assets( $page_assets );
699 return;
700 }
701
702 $document = Plugin::$instance->documents->get( $post_id );
703
704 if ( ! $document ) {
705 return;
706 }
707
708 $document->update_runtime_elements();
709 }
710
711 /**
712 * Get Frontend File URL
713 *
714 * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
715 * file is generated based on a passed template file name. Otherwise, the URL for the default CSS file is returned.
716 *
717 * @since 3.4.5
718 *
719 * @access public
720 *
721 * @param string $frontend_file_name
722 * @param boolean $custom_file
723 *
724 * @return string frontend file URL
725 */
726 public function get_frontend_file_url( $frontend_file_name, $custom_file, $css_subfolder = '' ) {
727 if ( $custom_file ) {
728 $frontend_file = $this->get_frontend_file( $frontend_file_name );
729
730 $frontend_file_url = $frontend_file->get_url();
731 } else {
732 $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $css_subfolder . $frontend_file_name;
733 }
734
735 return $frontend_file_url;
736 }
737
738 /**
739 * Get Frontend File Path
740 *
741 * Returns the path for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
742 * file is generated based on a passed template file name. Otherwise, the path for the default CSS file is returned.
743 *
744 * @since 3.5.0
745 * @access public
746 *
747 * @param string $frontend_file_name
748 * @param boolean $custom_file
749 *
750 * @return string frontend file path
751 */
752 public function get_frontend_file_path( $frontend_file_name, $custom_file ) {
753 if ( $custom_file ) {
754 $frontend_file = $this->get_frontend_file( $frontend_file_name );
755
756 $frontend_file_path = $frontend_file->get_path();
757 } else {
758 $frontend_file_path = ELEMENTOR_ASSETS_PATH . 'css/' . $frontend_file_name;
759 }
760
761 return $frontend_file_path;
762 }
763
764 /**
765 * Get Frontend File
766 *
767 * Returns a frontend file instance.
768 *
769 * @since 3.5.0
770 * @access public
771 *
772 * @param string $frontend_file_name
773 * @param string $file_prefix
774 * @param string $template_file_path
775 *
776 * @return FrontendFile
777 */
778 public function get_frontend_file( $frontend_file_name, $file_prefix = 'custom-', $template_file_path = '' ) {
779 static $cached_frontend_files = [];
780
781 $file_name = $file_prefix . $frontend_file_name;
782
783 if ( isset( $cached_frontend_files[ $file_name ] ) ) {
784 return $cached_frontend_files[ $file_name ];
785 }
786
787 if ( ! $template_file_path ) {
788 $template_file_path = Breakpoints_Manager::get_stylesheet_templates_path() . $frontend_file_name;
789 }
790
791 $frontend_file = new FrontendFile( $file_name, $template_file_path );
792
793 $time = $frontend_file->get_meta( 'time' );
794
795 if ( ! $time ) {
796 $frontend_file->update();
797 }
798
799 $cached_frontend_files[ $file_name ] = $frontend_file;
800
801 return $frontend_file;
802 }
803
804 /**
805 * Enqueue assets conditionally.
806 *
807 * Enqueue all assets that were pre-enabled.
808 *
809 * @since 3.3.0
810 * @access private
811 */
812 private function enqueue_conditional_assets() {
813 Plugin::$instance->assets_loader->enqueue_assets();
814 }
815
816 /**
817 * Elementor footer scripts and styles.
818 *
819 * Handle styles and scripts that are not printed in the header.
820 *
821 * Fired by `wp_footer` action.
822 *
823 * @since 1.0.11
824 * @access public
825 */
826 public function wp_footer() {
827 if ( ! $this->_has_elementor_in_page ) {
828 return;
829 }
830
831 $this->enqueue_styles();
832 $this->enqueue_scripts();
833
834 $this->print_fonts_links();
835 }
836
837 /**
838 * @return array|array[]
839 */
840 public function get_list_of_google_fonts_by_type(): array {
841 $google_fonts = [
842 'google' => [],
843 'early' => [],
844 ];
845
846 foreach ( $this->fonts_to_enqueue as $key => $font ) {
847 $font_type = Fonts::get_font_type( $font );
848
849 switch ( $font_type ) {
850 case Fonts::GOOGLE:
851 $google_fonts['google'][] = $font;
852 break;
853
854 case Fonts::EARLYACCESS:
855 $google_fonts['early'][] = $font;
856 break;
857
858 case false:
859 $this->maybe_enqueue_icon_font( $font );
860 break;
861 default:
862 /**
863 * Print font links.
864 *
865 * Fires when Elementor frontend fonts are printed on the HEAD tag.
866 *
867 * The dynamic portion of the hook name, `$font_type`, refers to the font type.
868 *
869 * @since 2.0.0
870 *
871 * @param string $font Font name.
872 */
873 do_action( "elementor/fonts/print_font_links/{$font_type}", $font );
874 }
875 }
876 $this->fonts_to_enqueue = [];
877
878 return $google_fonts;
879 }
880
881 /**
882 * Print fonts links.
883 *
884 * Enqueue all the frontend fonts by url.
885 *
886 * Fired by `wp_head` action.
887 *
888 * @since 1.9.4
889 * @access public
890 */
891 public function print_fonts_links() {
892 $google_fonts = $this->get_list_of_google_fonts_by_type();
893
894 $this->enqueue_google_fonts( $google_fonts );
895 $this->enqueue_icon_fonts();
896 }
897
898 private function maybe_enqueue_icon_font( $icon_font_type ) {
899 if ( ! Icons_Manager::is_migration_allowed() ) {
900 return;
901 }
902
903 $icons_types = Icons_Manager::get_icon_manager_tabs();
904 if ( ! isset( $icons_types[ $icon_font_type ] ) ) {
905 return;
906 }
907
908 $icon_type = $icons_types[ $icon_font_type ];
909 if ( isset( $icon_type['url'] ) ) {
910 $this->icon_fonts_to_enqueue[ $icon_font_type ] = [ $icon_type['url'] ];
911 }
912 }
913
914 private function enqueue_icon_fonts() {
915 if ( empty( $this->icon_fonts_to_enqueue ) || ! Icons_Manager::is_migration_allowed() ) {
916 return;
917 }
918
919 foreach ( $this->icon_fonts_to_enqueue as $icon_type => $css_url ) {
920 wp_enqueue_style( 'elementor-icons-' . $icon_type );
921 $this->enqueued_icon_fonts[] = $css_url;
922 }
923
924 // Clear enqueued icons.
925 $this->icon_fonts_to_enqueue = [];
926 }
927
928 /**
929 * @param array $fonts Stable google fonts ($google_fonts['google']).
930 * @return string
931 */
932 public function get_stable_google_fonts_url( array $fonts ): string {
933 foreach ( $fonts as &$font ) {
934 $font = str_replace( ' ', '+', $font ) . ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
935 }
936
937 // Defining a font-display type to google fonts.
938 $font_display_url_str = '&display=' . Fonts::get_font_display_setting();
939
940 $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%1$s%2$s', implode( rawurlencode( '|' ), $fonts ), $font_display_url_str );
941
942 $subsets = [
943 'ru_RU' => 'cyrillic',
944 'bg_BG' => 'cyrillic',
945 'he_IL' => 'hebrew',
946 'el' => 'greek',
947 'vi' => 'vietnamese',
948 'uk' => 'cyrillic',
949 'cs_CZ' => 'latin-ext',
950 'ro_RO' => 'latin-ext',
951 'pl_PL' => 'latin-ext',
952 'hr_HR' => 'latin-ext',
953 'hu_HU' => 'latin-ext',
954 'sk_SK' => 'latin-ext',
955 'tr_TR' => 'latin-ext',
956 'lt_LT' => 'latin-ext',
957 ];
958
959 /**
960 * Google font subsets.
961 *
962 * Filters the list of Google font subsets from which locale will be enqueued in frontend.
963 *
964 * @since 1.0.0
965 *
966 * @param array $subsets A list of font subsets.
967 */
968 $subsets = apply_filters( 'elementor/frontend/google_font_subsets', $subsets );
969
970 $locale = get_locale();
971
972 if ( isset( $subsets[ $locale ] ) ) {
973 $fonts_url .= '&subset=' . $subsets[ $locale ];
974 }
975
976 return $fonts_url;
977 }
978
979 /**
980 * @param array $fonts Early Access google fonts ($google_fonts['early']).
981 * @return array
982 */
983 public function get_early_access_google_font_urls( array $fonts ): array {
984 $font_urls = [];
985
986 foreach ( $fonts as $font ) {
987 $font_urls[] = sprintf( 'https://fonts.googleapis.com/earlyaccess/%s.css', strtolower( str_replace( ' ', '', $font ) ) );
988 }
989
990 return $font_urls;
991 }
992
993 /**
994 * Print Google fonts.
995 *
996 * Enqueue all the frontend Google fonts.
997 *
998 * Fired by `wp_head` action.
999 *
1000 * @since 1.0.0
1001 * @access private
1002 *
1003 * @param array $google_fonts Optional. Google fonts to print in the frontend.
1004 * Default is an empty array.
1005 */
1006 private function enqueue_google_fonts( $google_fonts = [] ) {
1007 $print_google_fonts = Fonts::is_google_fonts_enabled();
1008
1009 /**
1010 * Print frontend google fonts.
1011 *
1012 * Filters whether to enqueue Google fonts in the frontend.
1013 *
1014 * @since 1.0.0
1015 *
1016 * @param bool $print_google_fonts Whether to enqueue Google fonts. Default is true.
1017 */
1018 $print_google_fonts = apply_filters( 'elementor/frontend/print_google_fonts', $print_google_fonts );
1019
1020 if ( ! $print_google_fonts ) {
1021 return;
1022 }
1023
1024 // Print used fonts
1025 if ( ! empty( $google_fonts['google'] ) ) {
1026 ++$this->google_fonts_index;
1027
1028 if ( Plugin::$instance->experiments->is_feature_active( 'e_local_google_fonts' ) ) {
1029 foreach ( $google_fonts['google'] as $current_font ) {
1030 Google_Font::enqueue( $current_font );
1031 }
1032 } else {
1033 $fonts_url = $this->get_stable_google_fonts_url( $google_fonts['google'] );
1034
1035 wp_enqueue_style( 'google-fonts-' . $this->google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1036 }
1037 }
1038
1039 if ( ! empty( $google_fonts['early'] ) ) {
1040 if ( Plugin::$instance->experiments->is_feature_active( 'e_local_google_fonts' ) ) {
1041 foreach ( $google_fonts['early'] as $current_font ) {
1042 Google_Font::enqueue( $current_font, Google_Font::TYPE_EARLYACCESS );
1043 }
1044 } else {
1045 $early_access_font_urls = $this->get_early_access_google_font_urls( $google_fonts['early'] );
1046
1047 foreach ( $early_access_font_urls as $ea_font_url ) {
1048 ++$this->google_fonts_index;
1049
1050 wp_enqueue_style( 'google-earlyaccess-' . $this->google_fonts_index, $ea_font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1051 }
1052 }
1053 }
1054 }
1055
1056 /**
1057 * Enqueue fonts.
1058 *
1059 * Enqueue all the frontend fonts.
1060 *
1061 * @since 1.2.0
1062 * @access public
1063 *
1064 * @param array $font Fonts to enqueue in the frontend.
1065 */
1066 public function enqueue_font( $font ) {
1067 if ( in_array( $font, $this->registered_fonts ) ) {
1068 return;
1069 }
1070
1071 $this->fonts_to_enqueue[] = $font;
1072 $this->registered_fonts[] = $font;
1073 }
1074
1075 /**
1076 * Apply builder in content.
1077 *
1078 * Used to apply the Elementor page editor on the post content.
1079 *
1080 * @since 1.0.0
1081 * @access public
1082 *
1083 * @param string $content The post content.
1084 *
1085 * @return string The post content.
1086 */
1087 public function apply_builder_in_content( $content ) {
1088 $this->restore_content_filters();
1089
1090 if ( Plugin::$instance->preview->is_preview_mode() || $this->_is_excerpt ) {
1091 return $content;
1092 }
1093
1094 // Remove the filter itself in order to allow other `the_content` in the elements
1095 $this->remove_content_filter();
1096
1097 $post_id = get_the_ID();
1098 $builder_content = $this->get_builder_content( $post_id );
1099
1100 if ( ! empty( $builder_content ) ) {
1101 $content = $builder_content;
1102 $this->remove_content_filters();
1103 }
1104
1105 // Add the filter again for other `the_content` calls
1106 $this->add_content_filter();
1107
1108 return $content;
1109 }
1110
1111 /**
1112 * Retrieve builder content.
1113 *
1114 * Used to render and return the post content with all the Elementor elements.
1115 *
1116 * Note that this method is an internal method, please use `get_builder_content_for_display()`.
1117 *
1118 * @since 1.0.0
1119 * @access public
1120 *
1121 * @param int $post_id The post ID.
1122 * @param bool $with_css Optional. Whether to retrieve the content with CSS
1123 * or not. Default is false.
1124 *
1125 * @return string The post content.
1126 */
1127 public function get_builder_content( $post_id, $with_css = false ) {
1128 if ( post_password_required( $post_id ) ) {
1129 return '';
1130 }
1131
1132 $document = Plugin::$instance->documents->get_doc_for_frontend( $post_id );
1133
1134 if ( ! $document || ! $document->is_built_with_elementor() ) {
1135 return '';
1136 }
1137
1138 // Change the current post, so widgets can use `documents->get_current`.
1139 Plugin::$instance->documents->switch_to_document( $document );
1140
1141 $data = $document->get_elements_data();
1142
1143 /**
1144 * Frontend builder content data.
1145 *
1146 * Filters the builder content in the frontend.
1147 *
1148 * @since 1.0.0
1149 *
1150 * @param array $data The builder content.
1151 * @param int $post_id The post ID.
1152 */
1153 $data = apply_filters( 'elementor/frontend/builder_content_data', $data, $post_id );
1154
1155 do_action( 'elementor/frontend/before_get_builder_content', $document, $this->_is_excerpt );
1156
1157 if ( empty( $data ) ) {
1158 Plugin::$instance->documents->restore_document();
1159
1160 return '';
1161 }
1162
1163 if ( ! $this->_is_excerpt ) {
1164 if ( $document->is_autosave() ) {
1165 $css_file = Post_Preview::create( $document->get_post()->ID );
1166 } else {
1167 $css_file = Post_CSS::create( $post_id );
1168 }
1169
1170 /**
1171 * Builder Content - Before Enqueue CSS File
1172 *
1173 * Allows intervening with a document's CSS file before it is enqueued.
1174 *
1175 * @param $css_file Post_CSS|Post_Preview
1176 */
1177 $css_file = apply_filters( 'elementor/frontend/builder_content/before_enqueue_css_file', $css_file );
1178
1179 $css_file->enqueue();
1180 }
1181
1182 ob_start();
1183
1184 // Handle JS and Customizer requests, with CSS inline.
1185 if ( is_customize_preview() || wp_doing_ajax() ) {
1186 $with_css = true;
1187 }
1188
1189 /**
1190 * Builder Content - With CSS
1191 *
1192 * Allows overriding the `$with_css` parameter which is a factor in determining whether to print the document's
1193 * CSS and font links inline in a `style` tag above the document's markup.
1194 *
1195 * @param $with_css boolean
1196 */
1197 $with_css = apply_filters( 'elementor/frontend/builder_content/before_print_css', $with_css );
1198
1199 if ( ! empty( $css_file ) && $with_css ) {
1200 $css_file->print_css();
1201 }
1202
1203 $document->print_elements_with_wrapper( $data );
1204
1205 $content = ob_get_clean();
1206
1207 $content = $this->process_more_tag( $content );
1208
1209 /**
1210 * Frontend content.
1211 *
1212 * Filters the content in the frontend.
1213 *
1214 * @since 1.0.0
1215 *
1216 * @param string $content The content.
1217 */
1218 $content = apply_filters( 'elementor/frontend/the_content', $content );
1219
1220 if ( ! empty( $content ) ) {
1221 $this->_has_elementor_in_page = true;
1222 }
1223
1224 Plugin::$instance->documents->restore_document();
1225
1226 // BC
1227 // TODO: use Deprecation::do_deprecated_action() in 3.1.0
1228 do_action( 'elementor/frontend/get_builder_content', $document, $this->_is_excerpt, $with_css );
1229
1230 return $content;
1231 }
1232
1233 /**
1234 * Retrieve builder content for display.
1235 *
1236 * Used to render and return the post content with all the Elementor elements.
1237 *
1238 * @since 1.0.0
1239 * @access public
1240 *
1241 * @param int $post_id The post ID.
1242 *
1243 * @param bool $with_css Optional. Whether to retrieve the content with CSS
1244 * or not. Default is false.
1245 *
1246 * @return string The post content.
1247 */
1248 public function get_builder_content_for_display( $post_id, $with_css = false ) {
1249 if ( ! get_post( $post_id ) ) {
1250 return '';
1251 }
1252
1253 $editor = Plugin::$instance->editor;
1254
1255 // Avoid recursion
1256 if ( get_the_ID() === (int) $post_id ) {
1257 $content = '';
1258 if ( $editor->is_edit_mode() ) {
1259 $content = '<div class="elementor-alert elementor-alert-danger">' . esc_html__( 'Invalid Data: The Template ID cannot be the same as the currently edited template. Please choose a different one.', 'elementor' ) . '</div>';
1260 }
1261
1262 return $content;
1263 }
1264
1265 // Set edit mode as false, so don't render settings and etc. use the $is_edit_mode to indicate if we need the CSS inline
1266 $is_edit_mode = $editor->is_edit_mode();
1267 $editor->set_edit_mode( false );
1268
1269 $with_css = $with_css ? true : $is_edit_mode;
1270
1271 $content = $this->get_builder_content( $post_id, $with_css );
1272
1273 // Restore edit mode state
1274 Plugin::$instance->editor->set_edit_mode( $is_edit_mode );
1275
1276 return $content;
1277 }
1278
1279 /**
1280 * Start excerpt flag.
1281 *
1282 * Flags when `the_excerpt` is called. Used to avoid enqueueing CSS in the excerpt.
1283 *
1284 * @since 1.4.3
1285 * @access public
1286 *
1287 * @param string $excerpt The post excerpt.
1288 *
1289 * @return string The post excerpt.
1290 */
1291 public function start_excerpt_flag( $excerpt ) {
1292 $this->_is_excerpt = true;
1293 return $excerpt;
1294 }
1295
1296 /**
1297 * End excerpt flag.
1298 *
1299 * Flags when `the_excerpt` call ended.
1300 *
1301 * @since 1.4.3
1302 * @access public
1303 *
1304 * @param string $excerpt The post excerpt.
1305 *
1306 * @return string The post excerpt.
1307 */
1308 public function end_excerpt_flag( $excerpt ) {
1309 $this->_is_excerpt = false;
1310 return $excerpt;
1311 }
1312
1313 /**
1314 * Remove content filters.
1315 *
1316 * Remove WordPress default filters that conflicted with Elementor.
1317 *
1318 * @since 1.5.0
1319 * @access public
1320 */
1321 public function remove_content_filters() {
1322 $filters = [
1323 'wpautop',
1324 'shortcode_unautop',
1325 'wptexturize',
1326 ];
1327
1328 foreach ( $filters as $filter ) {
1329 // Check if another plugin/theme do not already removed the filter.
1330 if ( has_filter( 'the_content', $filter ) ) {
1331 remove_filter( 'the_content', $filter );
1332 $this->content_removed_filters[] = $filter;
1333 }
1334 }
1335 }
1336
1337 /**
1338 * Has Elementor In Page
1339 *
1340 * Determine whether the current page is using Elementor.
1341 *
1342 * @since 2.0.9
1343 *
1344 * @access public
1345 * @return bool
1346 */
1347 public function has_elementor_in_page() {
1348 return $this->_has_elementor_in_page;
1349 }
1350
1351 public function create_action_hash( $action, array $settings = [] ) {
1352 return '#' . rawurlencode( sprintf( 'elementor-action:action=%1$s&settings=%2$s', $action, base64_encode( wp_json_encode( $settings ) ) ) );
1353 }
1354
1355 /**
1356 * Is the current render mode is static.
1357 *
1358 * @return bool
1359 */
1360 public function is_static_render_mode() {
1361 // The render mode manager is exists only in frontend,
1362 // so by default if it is not exist the method will return false.
1363 if ( ! $this->render_mode_manager ) {
1364 return false;
1365 }
1366
1367 return $this->render_mode_manager->get_current()->is_static();
1368 }
1369
1370 /**
1371 * Get Init Settings
1372 *
1373 * Used to define the default/initial settings of the object. Inheriting classes may implement this method to define
1374 * their own default/initial settings.
1375 *
1376 * @since 2.3.0
1377 *
1378 * @access protected
1379 * @return array
1380 */
1381 protected function get_init_settings() {
1382 $is_preview_mode = Plugin::$instance->preview->is_preview_mode( Plugin::$instance->preview->get_post_id() );
1383
1384 $active_experimental_features = Plugin::$instance->experiments->get_active_features();
1385
1386 $active_experimental_features = array_fill_keys( array_keys( $active_experimental_features ), true );
1387
1388 $assets_url = ELEMENTOR_ASSETS_URL;
1389
1390 /**
1391 * Frontend assets URL
1392 *
1393 * Filters Elementor frontend assets URL.
1394 *
1395 * @since 2.3.0
1396 *
1397 * @param string $assets_url The frontend assets URL. Default is ELEMENTOR_ASSETS_URL.
1398 */
1399 $assets_url = apply_filters( 'elementor/frontend/assets_url', $assets_url );
1400
1401 $settings = [
1402 'environmentMode' => [
1403 'edit' => $is_preview_mode,
1404 'wpPreview' => is_preview(),
1405 'isScriptDebug' => Utils::is_script_debug(),
1406 ],
1407 'i18n' => [
1408 'shareOnFacebook' => esc_html__( 'Share on Facebook', 'elementor' ),
1409 'shareOnTwitter' => esc_html__( 'Share on Twitter', 'elementor' ),
1410 'pinIt' => esc_html__( 'Pin it', 'elementor' ),
1411 'download' => esc_html__( 'Download', 'elementor' ),
1412 'downloadImage' => esc_html__( 'Download image', 'elementor' ),
1413 'fullscreen' => esc_html__( 'Fullscreen', 'elementor' ),
1414 'zoom' => esc_html__( 'Zoom', 'elementor' ),
1415 'share' => esc_html__( 'Share', 'elementor' ),
1416 'playVideo' => esc_html__( 'Play Video', 'elementor' ),
1417 'previous' => esc_html__( 'Previous', 'elementor' ),
1418 'next' => esc_html__( 'Next', 'elementor' ),
1419 'close' => esc_html__( 'Close', 'elementor' ),
1420 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ),
1421 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ),
1422 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ),
1423 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ),
1424 'a11yCarouselPaginationBulletMessage' => __( 'Go to slide', 'elementor' ),
1425 ],
1426 'is_rtl' => is_rtl(),
1427 // 'breakpoints' object is kept for BC.
1428 'breakpoints' => Responsive::get_breakpoints(),
1429 // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0
1430 'responsive' => [
1431 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(),
1432 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(),
1433 ],
1434 'version' => ELEMENTOR_VERSION,
1435 'is_static' => $this->is_static_render_mode(),
1436 'experimentalFeatures' => $active_experimental_features,
1437 'urls' => [
1438 'assets' => $assets_url,
1439 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1440 'uploadUrl' => wp_upload_dir()['baseurl'],
1441 ],
1442 'nonces' => [
1443 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ),
1444 ],
1445 'swiperClass' => 'swiper',
1446 ];
1447
1448 $settings['settings'] = SettingsManager::get_settings_frontend_config();
1449
1450 $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend();
1451 $settings['kit'] = $kit->get_frontend_settings();
1452
1453 if ( is_singular() ) {
1454 $post = get_post();
1455
1456 $title = Utils::urlencode_html_entities( wp_get_document_title() );
1457
1458 // Try to use the 'large' WP image size because the Pinterest share API
1459 // has problems accepting shares with large images sometimes, and the WP 'large' thumbnail is
1460 // the largest default WP image size that will probably not be changed in most sites
1461 $featured_image_url = get_the_post_thumbnail_url( null, 'large' );
1462
1463 // If the large size was nullified, use the full size which cannot be nullified/deleted
1464 if ( ! $featured_image_url ) {
1465 $featured_image_url = get_the_post_thumbnail_url( null, 'full' );
1466 }
1467
1468 $settings['post'] = [
1469 'id' => $post->ID,
1470 'title' => $title,
1471 'excerpt' => $post->post_excerpt,
1472 'featuredImage' => $featured_image_url,
1473 ];
1474 } else {
1475 $settings['post'] = [
1476 'id' => 0,
1477 'title' => wp_get_document_title(),
1478 'excerpt' => get_the_archive_description(),
1479 ];
1480 }
1481
1482 $empty_object = (object) [];
1483
1484 if ( $is_preview_mode ) {
1485 $settings['elements'] = [
1486 'data' => $empty_object,
1487 'editSettings' => $empty_object,
1488 'keys' => $empty_object,
1489 ];
1490 }
1491
1492 if ( is_user_logged_in() ) {
1493 $user = wp_get_current_user();
1494
1495 if ( ! empty( $user->roles ) ) {
1496 $settings['user'] = [
1497 'roles' => $user->roles,
1498 ];
1499 }
1500 }
1501
1502 return $settings;
1503 }
1504
1505 /**
1506 * Restore content filters.
1507 *
1508 * Restore removed WordPress filters that conflicted with Elementor.
1509 *
1510 * @since 1.5.0
1511 * @access public
1512 */
1513 public function restore_content_filters() {
1514 foreach ( $this->content_removed_filters as $filter ) {
1515 add_filter( 'the_content', $filter );
1516 }
1517
1518 $this->content_removed_filters = [];
1519 }
1520
1521 /**
1522 * Process More Tag
1523 *
1524 * Respect the native WP (<!--more-->) tag
1525 *
1526 * @access private
1527 * @since 2.0.4
1528 *
1529 * @param string $content
1530 *
1531 * @return string
1532 */
1533 private function process_more_tag( $content ) {
1534 $post = get_post();
1535 $content = str_replace( '&lt;!--more--&gt;', '<!--more-->', $content );
1536 $parts = get_extended( $content );
1537 if ( empty( $parts['extended'] ) ) {
1538 return $content;
1539 }
1540
1541 if ( is_singular() ) {
1542 return $parts['main'] . '<div id="more-' . $post->ID . '"></div>' . $parts['extended'];
1543 }
1544
1545 if ( empty( $parts['more_text'] ) ) {
1546 $parts['more_text'] = esc_html__( '(more&hellip;)', 'elementor' );
1547 }
1548
1549 $more_link_text = sprintf(
1550 '<span aria-label="%1$s">%2$s</span>',
1551 sprintf(
1552 /* translators: %s: Current post name. */
1553 __( 'Continue reading %s', 'elementor' ),
1554 the_title_attribute( [
1555 'echo' => false,
1556 ] )
1557 ),
1558 $parts['more_text']
1559 );
1560
1561 $more_link = sprintf( ' <a href="%s#more-%s" class="more-link elementor-more-link">%s</a>', get_permalink(), $post->ID, $more_link_text );
1562
1563 /**
1564 * The content "more" link.
1565 *
1566 * Filters the "more" link displayed after the content.
1567 *
1568 * This hook can be used either to change the link syntax or to change the
1569 * text inside the link.
1570 *
1571 * @since 2.0.4
1572 *
1573 * @param string $more_link The more link.
1574 * @param string $more_link_text The text inside the more link.
1575 */
1576 $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
1577
1578 return force_balance_tags( $parts['main'] ) . $more_link;
1579 }
1580 }
1581