PluginProbe ʕ •ᴥ•ʔ
Elementor Website Builder – more than just a page builder / 3.26.0-beta2
Elementor Website Builder – more than just a page builder v3.26.0-beta2
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 1 year ago container 1 year ago controls 1 year ago editor-templates 1 year ago elements 1 year ago interfaces 1 year ago libraries 1 year ago managers 1 year ago settings 1 year ago template-library 1 year ago widgets 1 year ago api.php 1 year ago autoloader.php 1 year ago beta-testers.php 3 years ago compatibility.php 1 year ago conditions.php 3 years ago db.php 2 years ago editor-assets-api.php 1 year ago embed.php 1 year ago fonts.php 1 year ago frontend.php 1 year ago heartbeat.php 3 years ago maintenance-mode.php 2 years ago maintenance.php 3 years ago plugin.php 1 year ago preview.php 1 year ago rollback.php 3 years ago shapes.php 1 year ago stylesheet.php 1 year ago tracker.php 1 year ago user.php 2 years ago utils.php 1 year ago
frontend.php
1562 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\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 $page_assets = get_post_meta( $post_id, Assets::ASSETS_META_KEY, true );
690 if ( ! empty( $page_assets ) ) {
691 Plugin::$instance->assets_loader->enable_assets( $page_assets );
692 }
693
694 $css_file = Post_CSS::create( get_the_ID() );
695 $css_file->enqueue();
696 }
697 }
698 }
699 }
700
701 /**
702 * Get Frontend File URL
703 *
704 * Returns the URL for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
705 * file is generated based on a passed template file name. Otherwise, the URL for the default CSS file is returned.
706 *
707 * @since 3.4.5
708 *
709 * @access public
710 *
711 * @param string $frontend_file_name
712 * @param boolean $custom_file
713 *
714 * @return string frontend file URL
715 */
716 public function get_frontend_file_url( $frontend_file_name, $custom_file, $css_subfolder = '' ) {
717 if ( $custom_file ) {
718 $frontend_file = $this->get_frontend_file( $frontend_file_name );
719
720 $frontend_file_url = $frontend_file->get_url();
721 } else {
722 $frontend_file_url = ELEMENTOR_ASSETS_URL . 'css/' . $css_subfolder . $frontend_file_name;
723 }
724
725 return $frontend_file_url;
726 }
727
728 /**
729 * Get Frontend File Path
730 *
731 * Returns the path for the CSS file to be loaded in the front end. If requested via the second parameter, a custom
732 * file is generated based on a passed template file name. Otherwise, the path for the default CSS file is returned.
733 *
734 * @since 3.5.0
735 * @access public
736 *
737 * @param string $frontend_file_name
738 * @param boolean $custom_file
739 *
740 * @return string frontend file path
741 */
742 public function get_frontend_file_path( $frontend_file_name, $custom_file ) {
743 if ( $custom_file ) {
744 $frontend_file = $this->get_frontend_file( $frontend_file_name );
745
746 $frontend_file_path = $frontend_file->get_path();
747 } else {
748 $frontend_file_path = ELEMENTOR_ASSETS_PATH . 'css/' . $frontend_file_name;
749 }
750
751 return $frontend_file_path;
752 }
753
754 /**
755 * Get Frontend File
756 *
757 * Returns a frontend file instance.
758 *
759 * @since 3.5.0
760 * @access public
761 *
762 * @param string $frontend_file_name
763 * @param string $file_prefix
764 * @param string $template_file_path
765 *
766 * @return FrontendFile
767 */
768 public function get_frontend_file( $frontend_file_name, $file_prefix = 'custom-', $template_file_path = '' ) {
769 static $cached_frontend_files = [];
770
771 $file_name = $file_prefix . $frontend_file_name;
772
773 if ( isset( $cached_frontend_files[ $file_name ] ) ) {
774 return $cached_frontend_files[ $file_name ];
775 }
776
777 if ( ! $template_file_path ) {
778 $template_file_path = Breakpoints_Manager::get_stylesheet_templates_path() . $frontend_file_name;
779 }
780
781 $frontend_file = new FrontendFile( $file_name, $template_file_path );
782
783 $time = $frontend_file->get_meta( 'time' );
784
785 if ( ! $time ) {
786 $frontend_file->update();
787 }
788
789 $cached_frontend_files[ $file_name ] = $frontend_file;
790
791 return $frontend_file;
792 }
793
794 /**
795 * Enqueue assets conditionally.
796 *
797 * Enqueue all assets that were pre-enabled.
798 *
799 * @since 3.3.0
800 * @access private
801 */
802 private function enqueue_conditional_assets() {
803 Plugin::$instance->assets_loader->enqueue_assets();
804 }
805
806 /**
807 * Elementor footer scripts and styles.
808 *
809 * Handle styles and scripts that are not printed in the header.
810 *
811 * Fired by `wp_footer` action.
812 *
813 * @since 1.0.11
814 * @access public
815 */
816 public function wp_footer() {
817 if ( ! $this->_has_elementor_in_page ) {
818 return;
819 }
820
821 $this->enqueue_styles();
822 $this->enqueue_scripts();
823
824 $this->print_fonts_links();
825 }
826
827 /**
828 * @return array|array[]
829 */
830 public function get_list_of_google_fonts_by_type(): array {
831 $google_fonts = [
832 'google' => [],
833 'early' => [],
834 ];
835
836 foreach ( $this->fonts_to_enqueue as $key => $font ) {
837 $font_type = Fonts::get_font_type( $font );
838
839 switch ( $font_type ) {
840 case Fonts::GOOGLE:
841 $google_fonts['google'][] = $font;
842 break;
843
844 case Fonts::EARLYACCESS:
845 $google_fonts['early'][] = $font;
846 break;
847
848 case false:
849 $this->maybe_enqueue_icon_font( $font );
850 break;
851 default:
852 /**
853 * Print font links.
854 *
855 * Fires when Elementor frontend fonts are printed on the HEAD tag.
856 *
857 * The dynamic portion of the hook name, `$font_type`, refers to the font type.
858 *
859 * @since 2.0.0
860 *
861 * @param string $font Font name.
862 */
863 do_action( "elementor/fonts/print_font_links/{$font_type}", $font );
864 }
865 }
866 $this->fonts_to_enqueue = [];
867
868 return $google_fonts;
869 }
870
871 /**
872 * Print fonts links.
873 *
874 * Enqueue all the frontend fonts by url.
875 *
876 * Fired by `wp_head` action.
877 *
878 * @since 1.9.4
879 * @access public
880 */
881 public function print_fonts_links() {
882 $google_fonts = $this->get_list_of_google_fonts_by_type();
883
884 $this->enqueue_google_fonts( $google_fonts );
885 $this->enqueue_icon_fonts();
886 }
887
888 private function maybe_enqueue_icon_font( $icon_font_type ) {
889 if ( ! Icons_Manager::is_migration_allowed() ) {
890 return;
891 }
892
893 $icons_types = Icons_Manager::get_icon_manager_tabs();
894 if ( ! isset( $icons_types[ $icon_font_type ] ) ) {
895 return;
896 }
897
898 $icon_type = $icons_types[ $icon_font_type ];
899 if ( isset( $icon_type['url'] ) ) {
900 $this->icon_fonts_to_enqueue[ $icon_font_type ] = [ $icon_type['url'] ];
901 }
902 }
903
904 private function enqueue_icon_fonts() {
905 if ( empty( $this->icon_fonts_to_enqueue ) || ! Icons_Manager::is_migration_allowed() ) {
906 return;
907 }
908
909 foreach ( $this->icon_fonts_to_enqueue as $icon_type => $css_url ) {
910 wp_enqueue_style( 'elementor-icons-' . $icon_type );
911 $this->enqueued_icon_fonts[] = $css_url;
912 }
913
914 //clear enqueued icons
915 $this->icon_fonts_to_enqueue = [];
916 }
917
918 /**
919 * @param array $fonts Stable google fonts ($google_fonts['google']).
920 * @return string
921 */
922 public function get_stable_google_fonts_url( array $fonts ): string {
923 foreach ( $fonts as &$font ) {
924 $font = str_replace( ' ', '+', $font ) . ':100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic';
925 }
926
927 // Defining a font-display type to google fonts.
928 $font_display_url_str = '&display=' . Fonts::get_font_display_setting();
929
930 $fonts_url = sprintf( 'https://fonts.googleapis.com/css?family=%1$s%2$s', implode( rawurlencode( '|' ), $fonts ), $font_display_url_str );
931
932 $subsets = [
933 'ru_RU' => 'cyrillic',
934 'bg_BG' => 'cyrillic',
935 'he_IL' => 'hebrew',
936 'el' => 'greek',
937 'vi' => 'vietnamese',
938 'uk' => 'cyrillic',
939 'cs_CZ' => 'latin-ext',
940 'ro_RO' => 'latin-ext',
941 'pl_PL' => 'latin-ext',
942 'hr_HR' => 'latin-ext',
943 'hu_HU' => 'latin-ext',
944 'sk_SK' => 'latin-ext',
945 'tr_TR' => 'latin-ext',
946 'lt_LT' => 'latin-ext',
947 ];
948
949 /**
950 * Google font subsets.
951 *
952 * Filters the list of Google font subsets from which locale will be enqueued in frontend.
953 *
954 * @since 1.0.0
955 *
956 * @param array $subsets A list of font subsets.
957 */
958 $subsets = apply_filters( 'elementor/frontend/google_font_subsets', $subsets );
959
960 $locale = get_locale();
961
962 if ( isset( $subsets[ $locale ] ) ) {
963 $fonts_url .= '&subset=' . $subsets[ $locale ];
964 }
965
966 return $fonts_url;
967 }
968
969 /**
970 * @param array $fonts Early Access google fonts ($google_fonts['early']).
971 * @return array
972 */
973 public function get_early_access_google_font_urls( array $fonts ): array {
974 $font_urls = [];
975
976 foreach ( $fonts as $font ) {
977 $font_urls[] = sprintf( 'https://fonts.googleapis.com/earlyaccess/%s.css', strtolower( str_replace( ' ', '', $font ) ) );
978 }
979
980 return $font_urls;
981 }
982
983 /**
984 * Print Google fonts.
985 *
986 * Enqueue all the frontend Google fonts.
987 *
988 * Fired by `wp_head` action.
989 *
990 * @since 1.0.0
991 * @access private
992 *
993 * @param array $google_fonts Optional. Google fonts to print in the frontend.
994 * Default is an empty array.
995 */
996 private function enqueue_google_fonts( $google_fonts = [] ) {
997 $print_google_fonts = Fonts::is_google_fonts_enabled();
998
999 /**
1000 * Print frontend google fonts.
1001 *
1002 * Filters whether to enqueue Google fonts in the frontend.
1003 *
1004 * @since 1.0.0
1005 *
1006 * @param bool $print_google_fonts Whether to enqueue Google fonts. Default is true.
1007 */
1008 $print_google_fonts = apply_filters( 'elementor/frontend/print_google_fonts', $print_google_fonts );
1009
1010 if ( ! $print_google_fonts ) {
1011 return;
1012 }
1013
1014 // Print used fonts
1015 if ( ! empty( $google_fonts['google'] ) ) {
1016 $this->google_fonts_index++;
1017
1018 $fonts_url = $this->get_stable_google_fonts_url( $google_fonts['google'] );
1019
1020 wp_enqueue_style( 'google-fonts-' . $this->google_fonts_index, $fonts_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1021 }
1022
1023 if ( ! empty( $google_fonts['early'] ) ) {
1024 $early_access_font_urls = $this->get_early_access_google_font_urls( $google_fonts['early'] );
1025
1026 foreach ( $early_access_font_urls as $ea_font_url ) {
1027 $this->google_fonts_index++;
1028
1029 //printf( '<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/earlyaccess/%s.css">', strtolower( str_replace( ' ', '', $current_font ) ) );
1030
1031 wp_enqueue_style( 'google-earlyaccess-' . $this->google_fonts_index, $ea_font_url ); // phpcs:ignore WordPress.WP.EnqueuedResourceParameters.MissingVersion
1032 }
1033 }
1034
1035 }
1036
1037 /**
1038 * Enqueue fonts.
1039 *
1040 * Enqueue all the frontend fonts.
1041 *
1042 * @since 1.2.0
1043 * @access public
1044 *
1045 * @param array $font Fonts to enqueue in the frontend.
1046 */
1047 public function enqueue_font( $font ) {
1048 if ( in_array( $font, $this->registered_fonts ) ) {
1049 return;
1050 }
1051
1052 $this->fonts_to_enqueue[] = $font;
1053 $this->registered_fonts[] = $font;
1054 }
1055
1056 /**
1057 * Apply builder in content.
1058 *
1059 * Used to apply the Elementor page editor on the post content.
1060 *
1061 * @since 1.0.0
1062 * @access public
1063 *
1064 * @param string $content The post content.
1065 *
1066 * @return string The post content.
1067 */
1068 public function apply_builder_in_content( $content ) {
1069 $this->restore_content_filters();
1070
1071 if ( Plugin::$instance->preview->is_preview_mode() || $this->_is_excerpt ) {
1072 return $content;
1073 }
1074
1075 // Remove the filter itself in order to allow other `the_content` in the elements
1076 $this->remove_content_filter();
1077
1078 $post_id = get_the_ID();
1079 $builder_content = $this->get_builder_content( $post_id );
1080
1081 if ( ! empty( $builder_content ) ) {
1082 $content = $builder_content;
1083 $this->remove_content_filters();
1084 }
1085
1086 // Add the filter again for other `the_content` calls
1087 $this->add_content_filter();
1088
1089 return $content;
1090 }
1091
1092 /**
1093 * Retrieve builder content.
1094 *
1095 * Used to render and return the post content with all the Elementor elements.
1096 *
1097 * Note that this method is an internal method, please use `get_builder_content_for_display()`.
1098 *
1099 * @since 1.0.0
1100 * @access public
1101 *
1102 * @param int $post_id The post ID.
1103 * @param bool $with_css Optional. Whether to retrieve the content with CSS
1104 * or not. Default is false.
1105 *
1106 * @return string The post content.
1107 */
1108 public function get_builder_content( $post_id, $with_css = false ) {
1109 if ( post_password_required( $post_id ) ) {
1110 return '';
1111 }
1112
1113 $document = Plugin::$instance->documents->get_doc_for_frontend( $post_id );
1114
1115 if ( ! $document || ! $document->is_built_with_elementor() ) {
1116 return '';
1117 }
1118
1119 // Change the current post, so widgets can use `documents->get_current`.
1120 Plugin::$instance->documents->switch_to_document( $document );
1121
1122 $data = $document->get_elements_data();
1123
1124 /**
1125 * Frontend builder content data.
1126 *
1127 * Filters the builder content in the frontend.
1128 *
1129 * @since 1.0.0
1130 *
1131 * @param array $data The builder content.
1132 * @param int $post_id The post ID.
1133 */
1134 $data = apply_filters( 'elementor/frontend/builder_content_data', $data, $post_id );
1135
1136 do_action( 'elementor/frontend/before_get_builder_content', $document, $this->_is_excerpt );
1137
1138 if ( empty( $data ) ) {
1139 Plugin::$instance->documents->restore_document();
1140
1141 return '';
1142 }
1143
1144 if ( ! $this->_is_excerpt ) {
1145 if ( $document->is_autosave() ) {
1146 $css_file = Post_Preview::create( $document->get_post()->ID );
1147 } else {
1148 $css_file = Post_CSS::create( $post_id );
1149 }
1150
1151 /**
1152 * Builder Content - Before Enqueue CSS File
1153 *
1154 * Allows intervening with a document's CSS file before it is enqueued.
1155 *
1156 * @param $css_file Post_CSS|Post_Preview
1157 */
1158 $css_file = apply_filters( 'elementor/frontend/builder_content/before_enqueue_css_file', $css_file );
1159
1160 $css_file->enqueue();
1161 }
1162
1163 ob_start();
1164
1165 // Handle JS and Customizer requests, with CSS inline.
1166 if ( is_customize_preview() || wp_doing_ajax() ) {
1167 $with_css = true;
1168 }
1169
1170 /**
1171 * Builder Content - With CSS
1172 *
1173 * Allows overriding the `$with_css` parameter which is a factor in determining whether to print the document's
1174 * CSS and font links inline in a `style` tag above the document's markup.
1175 *
1176 * @param $with_css boolean
1177 */
1178 $with_css = apply_filters( 'elementor/frontend/builder_content/before_print_css', $with_css );
1179
1180 if ( ! empty( $css_file ) && $with_css ) {
1181 $css_file->print_css();
1182 }
1183
1184 $document->print_elements_with_wrapper( $data );
1185
1186 $content = ob_get_clean();
1187
1188 $content = $this->process_more_tag( $content );
1189
1190 /**
1191 * Frontend content.
1192 *
1193 * Filters the content in the frontend.
1194 *
1195 * @since 1.0.0
1196 *
1197 * @param string $content The content.
1198 */
1199 $content = apply_filters( 'elementor/frontend/the_content', $content );
1200
1201 if ( ! empty( $content ) ) {
1202 $this->_has_elementor_in_page = true;
1203 }
1204
1205 Plugin::$instance->documents->restore_document();
1206
1207 // BC
1208 // TODO: use Deprecation::do_deprecated_action() in 3.1.0
1209 do_action( 'elementor/frontend/get_builder_content', $document, $this->_is_excerpt, $with_css );
1210
1211 return $content;
1212 }
1213
1214 /**
1215 * Retrieve builder content for display.
1216 *
1217 * Used to render and return the post content with all the Elementor elements.
1218 *
1219 * @since 1.0.0
1220 * @access public
1221 *
1222 * @param int $post_id The post ID.
1223 *
1224 * @param bool $with_css Optional. Whether to retrieve the content with CSS
1225 * or not. Default is false.
1226 *
1227 * @return string The post content.
1228 */
1229 public function get_builder_content_for_display( $post_id, $with_css = false ) {
1230 if ( ! get_post( $post_id ) ) {
1231 return '';
1232 }
1233
1234 $editor = Plugin::$instance->editor;
1235
1236 // Avoid recursion
1237 if ( get_the_ID() === (int) $post_id ) {
1238 $content = '';
1239 if ( $editor->is_edit_mode() ) {
1240 $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>';
1241 }
1242
1243 return $content;
1244 }
1245
1246 // 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
1247 $is_edit_mode = $editor->is_edit_mode();
1248 $editor->set_edit_mode( false );
1249
1250 $with_css = $with_css ? true : $is_edit_mode;
1251
1252 $content = $this->get_builder_content( $post_id, $with_css );
1253
1254 // Restore edit mode state
1255 Plugin::$instance->editor->set_edit_mode( $is_edit_mode );
1256
1257 return $content;
1258 }
1259
1260 /**
1261 * Start excerpt flag.
1262 *
1263 * Flags when `the_excerpt` is called. Used to avoid enqueueing CSS in the excerpt.
1264 *
1265 * @since 1.4.3
1266 * @access public
1267 *
1268 * @param string $excerpt The post excerpt.
1269 *
1270 * @return string The post excerpt.
1271 */
1272 public function start_excerpt_flag( $excerpt ) {
1273 $this->_is_excerpt = true;
1274 return $excerpt;
1275 }
1276
1277 /**
1278 * End excerpt flag.
1279 *
1280 * Flags when `the_excerpt` call ended.
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 end_excerpt_flag( $excerpt ) {
1290 $this->_is_excerpt = false;
1291 return $excerpt;
1292 }
1293
1294 /**
1295 * Remove content filters.
1296 *
1297 * Remove WordPress default filters that conflicted with Elementor.
1298 *
1299 * @since 1.5.0
1300 * @access public
1301 */
1302 public function remove_content_filters() {
1303 $filters = [
1304 'wpautop',
1305 'shortcode_unautop',
1306 'wptexturize',
1307 ];
1308
1309 foreach ( $filters as $filter ) {
1310 // Check if another plugin/theme do not already removed the filter.
1311 if ( has_filter( 'the_content', $filter ) ) {
1312 remove_filter( 'the_content', $filter );
1313 $this->content_removed_filters[] = $filter;
1314 }
1315 }
1316 }
1317
1318 /**
1319 * Has Elementor In Page
1320 *
1321 * Determine whether the current page is using Elementor.
1322 *
1323 * @since 2.0.9
1324 *
1325 * @access public
1326 * @return bool
1327 */
1328 public function has_elementor_in_page() {
1329 return $this->_has_elementor_in_page;
1330 }
1331
1332 public function create_action_hash( $action, array $settings = [] ) {
1333 return '#' . rawurlencode( sprintf( 'elementor-action:action=%1$s&settings=%2$s', $action, base64_encode( wp_json_encode( $settings ) ) ) );
1334 }
1335
1336 /**
1337 * Is the current render mode is static.
1338 *
1339 * @return bool
1340 */
1341 public function is_static_render_mode() {
1342 // The render mode manager is exists only in frontend,
1343 // so by default if it is not exist the method will return false.
1344 if ( ! $this->render_mode_manager ) {
1345 return false;
1346 }
1347
1348 return $this->render_mode_manager->get_current()->is_static();
1349 }
1350
1351 /**
1352 * Get Init Settings
1353 *
1354 * Used to define the default/initial settings of the object. Inheriting classes may implement this method to define
1355 * their own default/initial settings.
1356 *
1357 * @since 2.3.0
1358 *
1359 * @access protected
1360 * @return array
1361 */
1362 protected function get_init_settings() {
1363 $is_preview_mode = Plugin::$instance->preview->is_preview_mode( Plugin::$instance->preview->get_post_id() );
1364
1365 $active_experimental_features = Plugin::$instance->experiments->get_active_features();
1366
1367 $active_experimental_features = array_fill_keys( array_keys( $active_experimental_features ), true );
1368
1369 $assets_url = ELEMENTOR_ASSETS_URL;
1370
1371 /**
1372 * Frontend assets URL
1373 *
1374 * Filters Elementor frontend assets URL.
1375 *
1376 * @since 2.3.0
1377 *
1378 * @param string $assets_url The frontend assets URL. Default is ELEMENTOR_ASSETS_URL.
1379 */
1380 $assets_url = apply_filters( 'elementor/frontend/assets_url', $assets_url );
1381
1382 $settings = [
1383 'environmentMode' => [
1384 'edit' => $is_preview_mode,
1385 'wpPreview' => is_preview(),
1386 'isScriptDebug' => Utils::is_script_debug(),
1387 ],
1388 'i18n' => [
1389 'shareOnFacebook' => esc_html__( 'Share on Facebook', 'elementor' ),
1390 'shareOnTwitter' => esc_html__( 'Share on Twitter', 'elementor' ),
1391 'pinIt' => esc_html__( 'Pin it', 'elementor' ),
1392 'download' => esc_html__( 'Download', 'elementor' ),
1393 'downloadImage' => esc_html__( 'Download image', 'elementor' ),
1394 'fullscreen' => esc_html__( 'Fullscreen', 'elementor' ),
1395 'zoom' => esc_html__( 'Zoom', 'elementor' ),
1396 'share' => esc_html__( 'Share', 'elementor' ),
1397 'playVideo' => esc_html__( 'Play Video', 'elementor' ),
1398 'previous' => esc_html__( 'Previous', 'elementor' ),
1399 'next' => esc_html__( 'Next', 'elementor' ),
1400 'close' => esc_html__( 'Close', 'elementor' ),
1401 'a11yCarouselPrevSlideMessage' => __( 'Previous slide', 'elementor' ),
1402 'a11yCarouselNextSlideMessage' => __( 'Next slide', 'elementor' ),
1403 'a11yCarouselFirstSlideMessage' => __( 'This is the first slide', 'elementor' ),
1404 'a11yCarouselLastSlideMessage' => __( 'This is the last slide', 'elementor' ),
1405 'a11yCarouselPaginationBulletMessage' => __( 'Go to slide', 'elementor' ),
1406 ],
1407 'is_rtl' => is_rtl(),
1408 // 'breakpoints' object is kept for BC.
1409 'breakpoints' => Responsive::get_breakpoints(),
1410 // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0
1411 'responsive' => [
1412 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(),
1413 'hasCustomBreakpoints' => Plugin::$instance->breakpoints->has_custom_breakpoints(),
1414 ],
1415 'version' => ELEMENTOR_VERSION,
1416 'is_static' => $this->is_static_render_mode(),
1417 'experimentalFeatures' => $active_experimental_features,
1418 'urls' => [
1419 'assets' => $assets_url,
1420 'ajaxurl' => admin_url( 'admin-ajax.php' ),
1421 'uploadUrl' => wp_upload_dir()['baseurl'],
1422 ],
1423 'nonces' => [
1424 'floatingButtonsClickTracking' => wp_create_nonce( Module::CLICK_TRACKING_NONCE ),
1425 ],
1426 'swiperClass' => 'swiper',
1427 ];
1428
1429 $settings['settings'] = SettingsManager::get_settings_frontend_config();
1430
1431 $kit = Plugin::$instance->kits_manager->get_active_kit_for_frontend();
1432 $settings['kit'] = $kit->get_frontend_settings();
1433
1434 if ( is_singular() ) {
1435 $post = get_post();
1436
1437 $title = Utils::urlencode_html_entities( wp_get_document_title() );
1438
1439 // Try to use the 'large' WP image size because the Pinterest share API
1440 // has problems accepting shares with large images sometimes, and the WP 'large' thumbnail is
1441 // the largest default WP image size that will probably not be changed in most sites
1442 $featured_image_url = get_the_post_thumbnail_url( null, 'large' );
1443
1444 // If the large size was nullified, use the full size which cannot be nullified/deleted
1445 if ( ! $featured_image_url ) {
1446 $featured_image_url = get_the_post_thumbnail_url( null, 'full' );
1447 }
1448
1449 $settings['post'] = [
1450 'id' => $post->ID,
1451 'title' => $title,
1452 'excerpt' => $post->post_excerpt,
1453 'featuredImage' => $featured_image_url,
1454 ];
1455 } else {
1456 $settings['post'] = [
1457 'id' => 0,
1458 'title' => wp_get_document_title(),
1459 'excerpt' => get_the_archive_description(),
1460 ];
1461 }
1462
1463 $empty_object = (object) [];
1464
1465 if ( $is_preview_mode ) {
1466 $settings['elements'] = [
1467 'data' => $empty_object,
1468 'editSettings' => $empty_object,
1469 'keys' => $empty_object,
1470 ];
1471 }
1472
1473 if ( is_user_logged_in() ) {
1474 $user = wp_get_current_user();
1475
1476 if ( ! empty( $user->roles ) ) {
1477 $settings['user'] = [
1478 'roles' => $user->roles,
1479 ];
1480 }
1481 }
1482
1483 return $settings;
1484 }
1485
1486 /**
1487 * Restore content filters.
1488 *
1489 * Restore removed WordPress filters that conflicted with Elementor.
1490 *
1491 * @since 1.5.0
1492 * @access public
1493 */
1494 public function restore_content_filters() {
1495 foreach ( $this->content_removed_filters as $filter ) {
1496 add_filter( 'the_content', $filter );
1497 }
1498
1499 $this->content_removed_filters = [];
1500 }
1501
1502 /**
1503 * Process More Tag
1504 *
1505 * Respect the native WP (<!--more-->) tag
1506 *
1507 * @access private
1508 * @since 2.0.4
1509 *
1510 * @param $content
1511 *
1512 * @return string
1513 */
1514 private function process_more_tag( $content ) {
1515 $post = get_post();
1516 $content = str_replace( '&lt;!--more--&gt;', '<!--more-->', $content );
1517 $parts = get_extended( $content );
1518 if ( empty( $parts['extended'] ) ) {
1519 return $content;
1520 }
1521
1522 if ( is_singular() ) {
1523 return $parts['main'] . '<div id="more-' . $post->ID . '"></div>' . $parts['extended'];
1524 }
1525
1526 if ( empty( $parts['more_text'] ) ) {
1527 $parts['more_text'] = esc_html__( '(more&hellip;)', 'elementor' );
1528 }
1529
1530 $more_link_text = sprintf(
1531 '<span aria-label="%1$s">%2$s</span>',
1532 sprintf(
1533 /* translators: %s: Current post name. */
1534 __( 'Continue reading %s', 'elementor' ),
1535 the_title_attribute( [
1536 'echo' => false,
1537 ] )
1538 ),
1539 $parts['more_text']
1540 );
1541
1542 $more_link = sprintf( ' <a href="%s#more-%s" class="more-link elementor-more-link">%s</a>', get_permalink(), $post->ID, $more_link_text );
1543
1544 /**
1545 * The content "more" link.
1546 *
1547 * Filters the "more" link displayed after the content.
1548 *
1549 * This hook can be used either to change the link syntax or to change the
1550 * text inside the link.
1551 *
1552 * @since 2.0.4
1553 *
1554 * @param string $more_link The more link.
1555 * @param string $more_link_text The text inside the more link.
1556 */
1557 $more_link = apply_filters( 'the_content_more_link', $more_link, $more_link_text );
1558
1559 return force_balance_tags( $parts['main'] ) . $more_link;
1560 }
1561 }
1562