PluginProbe
Elementor Website Builder – more than just a page builder / 3.25.3
Elementor Website Builder – more than just a page builder v3.25.3
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.25.3, at includes/frontend.php

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