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