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

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