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

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