PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.3
Elementor Website Builder – more than just a page builder v3.0.3
4.3.0-beta2 4.3.0-beta1 4.2.4 4.2.3 4.2.2 4.2.1 4.2.0 4.1.5 4.2.0-beta2 4.2.0-dev2 4.2.0-beta1 4.1.4 4.1.3 4.1.2 4.1.1 4.1.0 4.1.0-beta3 4.1.0-dev3 4.0.9 4.1.0-beta2 4.1.0-dev2 4.0.8 4.1.0-beta1 4.1.0-dev1 4.0.7 All 451 releases
← All changes | core/editor/editor.php +751 -186 4.2.43.0.3 View file →
@@ -1,15 +1,22 @@
1 1 <?php
2 2 namespace Elementor\Core\Editor;
3 3
4 -use Elementor\Core\Breakpoints\Manager as Breakpoints_Manager;
4 +use Elementor\Api;
5 5 use Elementor\Core\Common\Modules\Ajax\Module;
6 +use Elementor\Core\Common\Modules\Ajax\Module as Ajax;
6 7 use Elementor\Core\Debug\Loading_Inspection_Manager;
7 -use Elementor\Core\Editor\Loader\Editor_Loader_Factory;
8 -use Elementor\Core\Editor\Loader\Editor_Loader_Interface;
8 +use Elementor\Core\Files\Assets\Files_Upload_Handler;
9 +use Elementor\Core\Responsive\Responsive;
10 +use Elementor\Core\Schemes\Manager as Schemes_Manager;
9 11 use Elementor\Core\Settings\Manager as SettingsManager;
12 +use Elementor\Icons_Manager;
10 13 use Elementor\Plugin;
14 +use Elementor\Settings;
15 +use Elementor\Shapes;
11 16 use Elementor\TemplateLibrary\Source_Local;
17 +use Elementor\Tools;
18 +use Elementor\User;
12 19 use Elementor\Utils;
13 20 use Elementor\Core\Editor\Data;
14 21
15 22 if ( ! defined( 'ABSPATH' ) ) {
@@ -26,8 +33,14 @@
26 33 */
27 34 class Editor {
28 35
29 36 /**
37 + * The nonce key for Elementor editor.
38 + * @deprecated 2.3.0
39 + */
40 + const EDITING_NONCE_KEY = 'elementor-editing';
41 +
42 + /**
30 43 * User capability required to access Elementor editor.
31 44 */
32 45 const EDITING_CAPABILITY = 'edit_posts';
33 46
@@ -60,18 +73,8 @@
60 73 */
61 74 public $notice_bar;
62 75
63 76 /**
64 - * @var Promotion
65 - */
66 - public $promotion;
67 -
68 - /**
69 - * @var Editor_Loader_Interface
70 - */
71 - private $loader;
72 -
73 - /**
74 77 * Init.
75 78 *
76 79 * Initialize Elementor editor. Registers all needed actions to run Elementor,
77 80 * removes conflicting actions etc.
@@ -80,11 +83,11 @@
80 83 *
81 84 * @since 1.0.0
82 85 * @access public
83 86 *
84 - * @param bool $to_die Optional. Whether to die at the end. Default is `true`.
87 + * @param bool $die Optional. Whether to die at the end. Default is `true`.
85 88 */
86 - public function init( $to_die = true ) {
89 + public function init( $die = true ) {
87 90 if ( empty( $_REQUEST['post'] ) ) {
88 91 return;
89 92 }
90 93
@@ -107,9 +110,9 @@
107 110
108 111 Plugin::$instance->documents->switch_to_document( $document );
109 112
110 113 // Change mode to Builder
111 - $document->set_is_built_with_elementor( true );
114 + Plugin::$instance->db->set_is_elementor_page( $this->post_id );
112 115
113 116 // End BC.
114 117
115 118 Loading_Inspection_Manager::instance()->register_inspections();
@@ -116,9 +119,10 @@
116 119
117 120 // Send MIME Type header like WP admin-header.
118 121 @header( 'Content-Type: ' . get_option( 'html_type' ) . '; charset=' . get_option( 'blog_charset' ) );
119 122
120 - self::send_document_isolation_policy_header();
123 + // Temp: Allow plugins to know that the editor route is ready. TODO: Remove on 2.7.3.
124 + define( 'ELEMENTOR_EDITOR_USE_ROUTER', true );
121 125
122 126 add_filter( 'show_admin_bar', '__return_false' );
123 127
124 128 // Remove all WordPress actions
@@ -158,12 +162,12 @@
158 162 Utils::do_not_cache();
159 163
160 164 do_action( 'elementor/editor/init' );
161 165
162 - $this->get_loader()->print_root_template();
166 + $this->print_editor_template();
163 167
164 168 // From the action it's an empty string, from tests its `false`
165 - if ( false !== $to_die ) {
169 + if ( false !== $die ) {
166 170 die;
167 171 }
168 172 }
169 173
@@ -199,9 +203,9 @@
199 203
200 204 $document = Plugin::$instance->documents->get( get_the_ID() );
201 205
202 206 if ( ! $document ) {
203 - wp_die( esc_html__( 'Document not found.', 'elementor' ) );
207 + wp_die( __( 'Document not found.', 'elementor' ) );
204 208 }
205 209
206 210 if ( ! $document->is_editable_by_current_user() || ! $document->is_built_with_elementor() ) {
207 211 return;
@@ -309,10 +313,8 @@
309 313 return get_user_by( 'id', $locked_user );
310 314 }
311 315
312 316 /**
313 - * NOTICE: This method not in use, it's here for backward compatibility.
314 - *
315 317 * Print Editor Template.
316 318 *
317 319 * Include the wrapper template of the editor.
318 320 *
@@ -335,14 +337,173 @@
335 337 remove_action( 'wp_enqueue_scripts', [ $this, __FUNCTION__ ], 999999 );
336 338
337 339 global $wp_styles, $wp_scripts;
338 340
341 + $plugin = Plugin::$instance;
342 +
339 343 // Reset global variable
340 344 $wp_styles = new \WP_Styles(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
341 345 $wp_scripts = new \WP_Scripts(); // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
342 346
343 - $this->get_loader()->register_scripts();
347 + $suffix = ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG || defined( 'ELEMENTOR_TESTS' ) && ELEMENTOR_TESTS ) ? '' : '.min';
344 348
349 + wp_register_script(
350 + 'elementor-editor-modules',
351 + ELEMENTOR_ASSETS_URL . 'js/editor-modules' . $suffix . '.js',
352 + [
353 + 'elementor-common-modules',
354 + ],
355 + ELEMENTOR_VERSION,
356 + true
357 + );
358 +
359 + wp_register_script(
360 + 'elementor-editor-document',
361 + ELEMENTOR_ASSETS_URL . 'js/editor-document' . $suffix . '.js',
362 + [
363 + 'elementor-common-modules',
364 + ],
365 + ELEMENTOR_VERSION,
366 + true
367 + );
368 + // Hack for waypoint with editor mode.
369 + wp_register_script(
370 + 'elementor-waypoints',
371 + ELEMENTOR_ASSETS_URL . 'lib/waypoints/waypoints-for-editor.js',
372 + [
373 + 'jquery',
374 + ],
375 + '4.0.2',
376 + true
377 + );
378 +
379 + wp_register_script(
380 + 'perfect-scrollbar',
381 + ELEMENTOR_ASSETS_URL . 'lib/perfect-scrollbar/js/perfect-scrollbar' . $suffix . '.js',
382 + [],
383 + '1.4.0',
384 + true
385 + );
386 +
387 + wp_register_script(
388 + 'jquery-easing',
389 + ELEMENTOR_ASSETS_URL . 'lib/jquery-easing/jquery-easing' . $suffix . '.js',
390 + [
391 + 'jquery',
392 + ],
393 + '1.3.2',
394 + true
395 + );
396 +
397 + wp_register_script(
398 + 'nprogress',
399 + ELEMENTOR_ASSETS_URL . 'lib/nprogress/nprogress' . $suffix . '.js',
400 + [],
401 + '0.2.0',
402 + true
403 + );
404 +
405 + wp_register_script(
406 + 'tipsy',
407 + ELEMENTOR_ASSETS_URL . 'lib/tipsy/tipsy' . $suffix . '.js',
408 + [
409 + 'jquery',
410 + ],
411 + '1.0.0',
412 + true
413 + );
414 +
415 + wp_register_script(
416 + 'jquery-elementor-select2',
417 + ELEMENTOR_ASSETS_URL . 'lib/e-select2/js/e-select2.full' . $suffix . '.js',
418 + [
419 + 'jquery',
420 + ],
421 + '4.0.6-rc.1',
422 + true
423 + );
424 +
425 + wp_register_script(
426 + 'flatpickr',
427 + ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.js',
428 + [
429 + 'jquery',
430 + ],
431 + '1.12.0',
432 + true
433 + );
434 +
435 + wp_register_script(
436 + 'ace',
437 + 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ace.js',
438 + [],
439 + '1.2.5',
440 + true
441 + );
442 +
443 + wp_register_script(
444 + 'ace-language-tools',
445 + 'https://cdnjs.cloudflare.com/ajax/libs/ace/1.2.5/ext-language_tools.js',
446 + [
447 + 'ace',
448 + ],
449 + '1.2.5',
450 + true
451 + );
452 +
453 + wp_register_script(
454 + 'jquery-hover-intent',
455 + ELEMENTOR_ASSETS_URL . 'lib/jquery-hover-intent/jquery-hover-intent' . $suffix . '.js',
456 + [],
457 + '1.0.0',
458 + true
459 + );
460 +
461 + wp_register_script(
462 + 'nouislider',
463 + ELEMENTOR_ASSETS_URL . 'lib/nouislider/nouislider' . $suffix . '.js',
464 + [],
465 + '13.0.0',
466 + true
467 + );
468 +
469 + wp_register_script(
470 + 'pickr',
471 + ELEMENTOR_ASSETS_URL . 'lib/pickr/pickr.min.js',
472 + [],
473 + '1.5.0',
474 + true
475 + );
476 +
477 + wp_register_script(
478 + 'elementor-editor',
479 + ELEMENTOR_ASSETS_URL . 'js/editor' . $suffix . '.js',
480 + [
481 + 'elementor-common',
482 + 'elementor-editor-modules',
483 + 'elementor-editor-document',
484 + 'wp-auth-check',
485 + 'jquery-ui-sortable',
486 + 'jquery-ui-resizable',
487 + 'perfect-scrollbar',
488 + 'nprogress',
489 + 'tipsy',
490 + 'imagesloaded',
491 + 'heartbeat',
492 + 'jquery-elementor-select2',
493 + 'flatpickr',
494 + 'ace',
495 + 'ace-language-tools',
496 + 'jquery-hover-intent',
497 + 'nouislider',
498 + 'pickr',
499 + 'react',
500 + 'react-dom',
501 + ],
502 + ELEMENTOR_VERSION,
503 + true
504 + );
505 +
345 506 /**
346 507 * Before editor enqueue scripts.
347 508 *
348 509 * Fires before Elementor editor scripts are enqueued.
@@ -353,13 +514,323 @@
353 514
354 515 // Tweak for WP Admin menu icons
355 516 wp_print_styles( 'editor-buttons' );
356 517
357 - $this->get_loader()->enqueue_scripts();
518 + $page_title_selector = Plugin::$instance->kits_manager->get_current_settings( 'page_title_selector' );
358 519
359 - Plugin::$instance->controls_manager->enqueue_control_scripts();
520 + $page_title_selector .= ', .elementor-page-title';
360 521
522 + $settings = SettingsManager::get_settings_managers_config();
523 + // Moved to document since 2.9.0.
524 + unset( $settings['page'] );
525 +
526 + $document = Plugin::$instance->documents->get_doc_or_auto_save( $this->post_id );
527 + $kits_manager = Plugin::$instance->kits_manager;
528 +
529 + $config = [
530 + 'initial_document' => $document->get_config(),
531 + 'version' => ELEMENTOR_VERSION,
532 + 'home_url' => home_url(),
533 + 'admin_settings_url' => admin_url( 'admin.php?page=' . Settings::PAGE_ID ),
534 + 'autosave_interval' => AUTOSAVE_INTERVAL,
535 + 'tabs' => $plugin->controls_manager->get_tabs(),
536 + 'controls' => $plugin->controls_manager->get_controls_data(),
537 + 'elements' => $plugin->elements_manager->get_element_types_config(),
538 + 'schemes' => [
539 + 'items' => $plugin->schemes_manager->get_registered_schemes_data(),
540 + 'enabled_schemes' => Schemes_Manager::get_enabled_schemes(),
541 + ],
542 + 'globals' => [
543 + 'defaults_enabled' => [
544 + 'colors' => $kits_manager->is_custom_colors_enabled(),
545 + 'typography' => $kits_manager->is_custom_typography_enabled(),
546 + ],
547 + ],
548 + 'icons' => [
549 + 'libraries' => Icons_Manager::get_icon_manager_tabs_config(),
550 + 'goProURL' => Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=icon-library&utm_campaign=gopro&utm_medium=wp-dash' ),
551 + ],
552 + 'filesUpload' => [
553 + 'unfilteredFiles' => Files_Upload_Handler::is_enabled(),
554 + ],
555 + 'fa4_to_fa5_mapping_url' => ELEMENTOR_ASSETS_URL . 'lib/font-awesome/migration/mapping.js',
556 + 'default_schemes' => $plugin->schemes_manager->get_schemes_defaults(),
557 + 'settings' => $settings,
558 + 'system_schemes' => $plugin->schemes_manager->get_system_schemes(),
559 + 'wp_editor' => $this->get_wp_editor_config(),
560 + 'settings_page_link' => Settings::get_url(),
561 + 'tools_page_link' => Tools::get_url(),
562 + 'elementor_site' => 'https://go.elementor.com/about-elementor/',
563 + 'docs_elementor_site' => 'https://go.elementor.com/docs/',
564 + 'help_the_content_url' => 'https://go.elementor.com/the-content-missing/',
565 + 'help_right_click_url' => 'https://go.elementor.com/meet-right-click/',
566 + 'help_flexbox_bc_url' => 'https://go.elementor.com/flexbox-layout-bc/',
567 + 'elementPromotionURL' => 'https://go.elementor.com/go-pro-%s',
568 + 'dynamicPromotionURL' => 'https://go.elementor.com/go-pro-dynamic-tag',
569 + 'additional_shapes' => Shapes::get_additional_shapes_for_config(),
570 + 'user' => [
571 + 'restrictions' => $plugin->role_manager->get_user_restrictions_array(),
572 + 'is_administrator' => current_user_can( 'manage_options' ),
573 + 'introduction' => User::get_introduction_meta(),
574 + ],
575 + 'preview' => [
576 + 'help_preview_error_url' => 'https://go.elementor.com/preview-not-loaded/',
577 + 'help_preview_http_error_url' => 'https://go.elementor.com/preview-not-loaded/#permissions',
578 + 'help_preview_http_error_500_url' => 'https://go.elementor.com/500-error/',
579 + 'debug_data' => Loading_Inspection_Manager::instance()->run_inspections(),
580 + ],
581 + 'locale' => get_locale(),
582 + 'rich_editing_enabled' => filter_var( get_user_meta( get_current_user_id(), 'rich_editing', true ), FILTER_VALIDATE_BOOLEAN ),
583 + 'page_title_selector' => $page_title_selector,
584 + 'tinymceHasCustomConfig' => class_exists( 'Tinymce_Advanced' ),
585 + 'inlineEditing' => Plugin::$instance->widgets_manager->get_inline_editing_config(),
586 + 'dynamicTags' => Plugin::$instance->dynamic_tags->get_config(),
587 + 'ui' => [
588 + 'darkModeStylesheetURL' => ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css',
589 + ],
590 + // Legacy Mode - for backwards compatibility of older HTML markup.
591 + 'legacyMode' => [
592 + 'elementWrappers' => Plugin::instance()->get_legacy_mode( 'elementWrappers' ),
593 + ],
594 + 'i18n' => [
595 + 'elementor' => __( 'Elementor', 'elementor' ),
596 + 'edit' => __( 'Edit', 'elementor' ),
597 + 'delete' => __( 'Delete', 'elementor' ),
598 + 'cancel' => __( 'Cancel', 'elementor' ),
599 + 'clear' => __( 'Clear', 'elementor' ),
600 + 'done' => __( 'Done', 'elementor' ),
601 + 'got_it' => __( 'Got It', 'elementor' ),
602 + /* translators: %s: Element type. */
603 + 'add_element' => __( 'Add %s', 'elementor' ),
604 + /* translators: %s: Element name. */
605 + 'edit_element' => __( 'Edit %s', 'elementor' ),
606 + /* translators: %s: Element type. */
607 + 'duplicate_element' => __( 'Duplicate %s', 'elementor' ),
608 + /* translators: %s: Element type. */
609 + 'delete_element' => __( 'Delete %s', 'elementor' ),
610 + 'flexbox_attention_header' => __( 'Note: Flexbox Changes', 'elementor' ),
611 + 'flexbox_attention_message' => __( 'Elementor 2.5 introduces key changes to the layout using CSS Flexbox. Your existing pages might have been affected, please review your page before publishing.', 'elementor' ),
612 + 'saved_colors' => __( 'Saved Colors', 'elementor' ),
613 + 'drag_to_delete' => __( 'Drag To Delete', 'elementor' ),
614 + 'color_picker' => __( 'Color Picker', 'elementor' ),
615 +
616 + // Global Styles
617 + 'add_picked_color' => __( 'Add Picked Color', 'elementor' ),
618 + 'new_global_color' => __( 'New Global Color', 'elementor' ),
619 + 'global_colors_title' => __( 'Global Colors', 'elementor' ),
620 + 'manage_global_colors' => __( 'Manage Global Colors', 'elementor' ),
621 + 'create_global_color' => __( 'Create New Global Color', 'elementor' ),
622 + 'delete_global_color' => __( 'Delete Global Color', 'elementor' ),
623 + 'delete_global_color_info' => __( 'You\'re about to delete a Global Color. Note that if it\'s being used anywhere on your site, it will inherit a default color.', 'elementor' ),
624 + 'global_colors_info' => __( 'Global Colors help you work smarter. Save a color, and use it anywhere throughout your site. Access and edit your global colors by clicking the Manage button.', 'elementor' ),
625 + 'typography' => __( 'Typography', 'elementor' ),
626 + 'new_typography_setting' => __( 'New Typography Setting', 'elementor' ),
627 + 'global_fonts_title' => __( 'Global Fonts', 'elementor' ),
628 + 'manage_global_fonts' => __( 'Manage Global Fonts', 'elementor' ),
629 + 'create_global_font' => __( 'Create New Global Font', 'elementor' ),
630 + 'delete_global_font' => __( 'Delete Global Font', 'elementor' ),
631 + 'delete_global_font_info' => __( 'You\'re about to delete a Global Font. Note that if it\'s being used anywhere on your site, it will inherit a default typography.', 'elementor' ),
632 + 'global_fonts_info' => __( 'Global Fonts help you work smarter. Save a Typography, and use it anywhere throughout your site. Access and edit your Global Fonts by clicking the Manage button.', 'elementor' ),
633 + 'default' => __( 'Default', 'elementor' ),
634 + 'create' => __( 'Create', 'elementor' ),
635 + 'global_color_confirm_text' => __( 'Are you sure you want to create a new Global Color?', 'elementor' ),
636 + 'global_color_already_exists' => __( 'Please note that the same exact color already exists in your Global Colors list. Are you sure you want to create it?', 'elementor' ),
637 + 'global_color_name_already_exists' => __( 'Please note that a color with the same exact name already exists in your Global Colors list. Are you sure you want to create it?', 'elementor' ),
638 + 'global_fonts_confirm_text' => __( 'Are you sure you want to create a new Global Font setting?', 'elementor' ),
639 + 'custom' => __( 'Custom', 'elementor' ),
640 +
641 + // Menu.
642 + 'about_elementor' => __( 'About Elementor', 'elementor' ),
643 + 'elementor_settings' => __( 'Dashboard Settings', 'elementor' ),
644 + 'site_settings' => __( 'Site Settings', 'elementor' ),
645 + 'theme_builder' => __( 'Theme Builder', 'elementor' ),
646 + 'user_preferences' => __( 'User Preferences', 'elementor' ),
647 + 'settings' => __( 'Settings', 'elementor' ),
648 + 'more' => __( 'More', 'elementor' ),
649 + 'navigate_from_page' => __( 'Navigate From Page', 'elementor' ),
650 + 'view_page' => __( 'View Page', 'elementor' ),
651 + 'exit_to_dashboard' => __( 'Exit To Dashboard', 'elementor' ),
652 +
653 + // Elements.
654 + 'inner_section' => __( 'Inner Section', 'elementor' ),
655 +
656 + // Control Order.
657 + 'asc' => __( 'Ascending order', 'elementor' ),
658 + 'desc' => __( 'Descending order', 'elementor' ),
659 +
660 + // Clear Page.
661 + 'clear_page' => __( 'Delete All Content', 'elementor' ),
662 + 'dialog_confirm_clear_page' => __( 'Attention: We are going to DELETE ALL CONTENT from this page. Are you sure you want to do that?', 'elementor' ),
663 +
664 + // Enable unfiltered file uploads.
665 + 'enable_unfiltered_files_upload' => __( 'Enable Unfiltered File Uploads', 'elementor' ),
666 + 'dialog_confirm_enable_unfiltered_files_upload' => __( 'Before you enable unfiltered files upload, note that this kind of files include a security risk. Elementor does run a process to remove possible malicious code, but there is still risk involved when using such files.', 'elementor' ),
667 +
668 + // Enable fontawesome 5 if needed.
669 + 'enable_fa5' => __( 'Elementor\'s New Icon Library', 'elementor' ),
670 + 'dialog_confirm_enable_fa5' => __( 'Elementor v2.6 includes an upgrade from Font Awesome 4 to 5. In order to continue using icons, be sure to click "Upgrade".', 'elementor' ) . ' <a href="https://go.elementor.com/fontawesome-migration/" target="_blank">' . __( 'Learn More', 'elementor' ) . '</a>',
671 +
672 + // Panel Preview Mode.
673 + 'back_to_editor' => __( 'Show Panel', 'elementor' ),
674 + 'preview' => __( 'Hide Panel', 'elementor' ),
675 +
676 + // Inline Editing.
677 + 'type_here' => __( 'Type Here', 'elementor' ),
678 +
679 + // Library.
680 + 'an_error_occurred' => __( 'An error occurred', 'elementor' ),
681 + 'category' => __( 'Category', 'elementor' ),
682 + 'delete_template' => __( 'Delete Template', 'elementor' ),
683 + 'delete_template_confirm' => __( 'Are you sure you want to delete this template?', 'elementor' ),
684 + 'import_template_dialog_header' => __( 'Import Document Settings', 'elementor' ),
685 + 'import_template_dialog_message' => __( 'Do you want to also import the document settings of the template?', 'elementor' ),
686 + 'import_template_dialog_message_attention' => __( 'Attention: Importing may override previous settings.', 'elementor' ),
687 + 'library' => __( 'Library', 'elementor' ),
688 + 'no' => __( 'No', 'elementor' ),
689 + 'page' => __( 'Page', 'elementor' ),
690 + /* translators: %s: Template type. */
691 + 'save_your_template' => __( 'Save Your %s to Library', 'elementor' ),
692 + 'save_your_template_description' => __( 'Your designs will be available for export and reuse on any page or website', 'elementor' ),
693 + 'section' => __( 'Section', 'elementor' ),
694 + 'templates_empty_message' => __( 'This is where your templates should be. Design it. Save it. Reuse it.', 'elementor' ),
695 + 'templates_empty_title' => __( 'Haven’t Saved Templates Yet?', 'elementor' ),
696 + 'templates_no_favorites_message' => __( 'You can mark any pre-designed template as a favorite.', 'elementor' ),
697 + 'templates_no_favorites_title' => __( 'No Favorite Templates', 'elementor' ),
698 + 'templates_no_results_message' => __( 'Please make sure your search is spelled correctly or try a different words.', 'elementor' ),
699 + 'templates_no_results_title' => __( 'No Results Found', 'elementor' ),
700 + 'templates_request_error' => __( 'The following error(s) occurred while processing the request:', 'elementor' ),
701 + 'yes' => __( 'Yes', 'elementor' ),
702 + 'blocks' => __( 'Blocks', 'elementor' ),
703 + 'pages' => __( 'Pages', 'elementor' ),
704 + 'my_templates' => __( 'My Templates', 'elementor' ),
705 +
706 + // Incompatible Device.
707 + 'device_incompatible_header' => __( 'Your browser isn\'t compatible', 'elementor' ),
708 + 'device_incompatible_message' => __( 'Your browser isn\'t compatible with all of Elementor\'s editing features. We recommend you switch to another browser like Chrome or Firefox.', 'elementor' ),
709 + 'proceed_anyway' => __( 'Proceed Anyway', 'elementor' ),
710 +
711 + // Preview not loaded.
712 + 'learn_more' => __( 'Learn More', 'elementor' ),
713 + 'preview_el_not_found_header' => __( 'Sorry, the content area was not found in your page.', 'elementor' ),
714 + 'preview_el_not_found_message' => __( 'You must call \'the_content\' function in the current template, in order for Elementor to work on this page.', 'elementor' ),
715 +
716 + // Gallery.
717 + 'delete_gallery' => __( 'Reset Gallery', 'elementor' ),
718 + 'dialog_confirm_gallery_delete' => __( 'Are you sure you want to reset this gallery?', 'elementor' ),
719 + /* translators: %s: The number of images. */
720 + 'gallery_images_selected' => __( '%s Images Selected', 'elementor' ),
721 + 'gallery_no_images_selected' => __( 'No Images Selected', 'elementor' ),
722 + 'insert_media' => __( 'Insert Media', 'elementor' ),
723 +
724 + // Take Over.
725 + /* translators: %s: User name. */
726 + 'dialog_user_taken_over' => __( '%s has taken over and is currently editing. Do you want to take over this page editing?', 'elementor' ),
727 + 'go_back' => __( 'Go Back', 'elementor' ),
728 + 'take_over' => __( 'Take Over', 'elementor' ),
729 +
730 + // Revisions.
731 + /* translators: %s: Template type. */
732 + 'dialog_confirm_delete' => __( 'Are you sure you want to remove this %s?', 'elementor' ),
733 +
734 + // Saver.
735 + 'before_unload_alert' => __( 'Please note: All unsaved changes will be lost.', 'elementor' ),
736 + 'published' => __( 'Published', 'elementor' ),
737 + 'publish' => __( 'Publish', 'elementor' ),
738 + 'save' => __( 'Save', 'elementor' ),
739 + 'saved' => __( 'Saved', 'elementor' ),
740 + 'update' => __( 'Update', 'elementor' ),
741 + 'enable' => __( 'Enable', 'elementor' ),
742 + 'submit' => __( 'Submit', 'elementor' ),
743 + 'working_on_draft_notification' => __( 'This is just a draft. Play around and when you\'re done - click update.', 'elementor' ),
744 + 'keep_editing' => __( 'Keep Editing', 'elementor' ),
745 + 'have_a_look' => __( 'Have a look', 'elementor' ),
746 + 'view_all_revisions' => __( 'View All Revisions', 'elementor' ),
747 + 'dismiss' => __( 'Dismiss', 'elementor' ),
748 + 'saving_disabled' => __( 'Saving has been disabled until you’re reconnected.', 'elementor' ),
749 +
750 + // Ajax
751 + 'server_error' => __( 'Server Error', 'elementor' ),
752 + 'server_connection_lost' => __( 'Connection Lost', 'elementor' ),
753 + 'unknown_error' => __( 'Unknown Error', 'elementor' ),
754 +
755 + // Context Menu
756 + 'duplicate' => __( 'Duplicate', 'elementor' ),
757 + 'copy' => __( 'Copy', 'elementor' ),
758 + 'paste' => __( 'Paste', 'elementor' ),
759 + 'copy_style' => __( 'Copy Style', 'elementor' ),
760 + 'paste_style' => __( 'Paste Style', 'elementor' ),
761 + 'reset_style' => __( 'Reset Style', 'elementor' ),
762 + 'save_as_global' => __( 'Save as a Global', 'elementor' ),
763 + 'save_as_block' => __( 'Save as Template', 'elementor' ),
764 + 'new_column' => __( 'Add New Column', 'elementor' ),
765 + 'copy_all_content' => __( 'Copy All Content', 'elementor' ),
766 + 'delete_all_content' => __( 'Delete All Content', 'elementor' ),
767 + 'navigator' => __( 'Navigator', 'elementor' ),
768 +
769 + // Right Click Introduction
770 + 'meet_right_click_header' => __( 'Meet Right Click', 'elementor' ),
771 + 'meet_right_click_message' => __( 'Now you can access all editing actions using right click.', 'elementor' ),
772 +
773 + // Hotkeys screen
774 + 'keyboard_shortcuts' => __( 'Keyboard Shortcuts', 'elementor' ),
775 +
776 + // Deprecated Control
777 + 'deprecated_notice' => __( 'The <strong>%1$s</strong> widget has been deprecated since %2$s %3$s.', 'elementor' ),
778 + 'deprecated_notice_replacement' => __( 'It has been replaced by <strong>%1$s</strong>.', 'elementor' ),
779 + 'deprecated_notice_last' => __( 'Note that %1$s will be completely removed once %2$s %3$s is released.', 'elementor' ),
780 +
781 + //Preview Debug
782 + 'preview_debug_link_text' => __( 'Click here for preview debug', 'elementor' ),
783 +
784 + 'icon_library' => __( 'Icon Library', 'elementor' ),
785 + 'my_libraries' => __( 'My Libraries', 'elementor' ),
786 + 'upload' => __( 'Upload', 'elementor' ),
787 + 'icons_promotion' => __( 'Become a Pro user to upload unlimited font icon folders to your website.', 'elementor' ),
788 + 'go_pro' => __( 'Go Pro', 'elementor' ),
789 + 'custom_positioning' => __( 'Custom Positioning', 'elementor' ),
790 +
791 + 'element_promotion_dialog_header' => __( '%s Widget', 'elementor' ),
792 + 'element_promotion_dialog_message' => __( 'Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', 'elementor' ),
793 + 'see_it_in_action' => __( 'See it in Action', 'elementor' ),
794 + 'dynamic_content' => __( 'Dynamic Content', 'elementor' ),
795 + 'dynamic_promotion_message' => __( 'Create more personalized and dynamic sites by populating data from various sources with dozens of dynamic tags to choose from.', 'elementor' ),
796 +
797 + // TODO: Remove.
798 + 'autosave' => __( 'Autosave', 'elementor' ),
799 + 'elementor_docs' => __( 'Documentation', 'elementor' ),
800 + 'reload_page' => __( 'Reload Page', 'elementor' ),
801 + 'session_expired_header' => __( 'Timeout', 'elementor' ),
802 + 'session_expired_message' => __( 'Your session has expired. Please reload the page to continue editing.', 'elementor' ),
803 + 'soon' => __( 'Soon', 'elementor' ),
804 + 'unknown_value' => __( 'Unknown Value', 'elementor' ),
805 + ],
806 + ];
807 +
808 + if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) {
809 + $config['promotionWidgets'] = Api::get_promotion_widgets();
810 + }
811 +
812 + $this->bc_move_document_filters();
813 +
361 814 /**
815 + * Localize editor settings.
816 + *
817 + * Filters the editor localized settings.
818 + *
819 + * @since 1.0.0
820 + *
821 + * @param array $config Editor configuration.
822 + * @param int $post_id The ID of the current post being edited.
823 + */
824 + $config = apply_filters( 'elementor/editor/localize_settings', $config );
825 +
826 + Utils::print_js_config( 'elementor-editor', 'ElementorConfig', $config );
827 +
828 + wp_enqueue_script( 'elementor-editor' );
829 +
830 + $plugin->controls_manager->enqueue_control_scripts();
831 +
832 + /**
362 833 * After editor enqueue scripts.
363 834 *
364 835 * Fires after Elementor editor scripts are enqueued.
365 836 *
@@ -385,23 +856,90 @@
385 856 * @since 1.0.0
386 857 */
387 858 do_action( 'elementor/editor/before_enqueue_styles' );
388 859
389 - $this->get_loader()->register_styles();
390 - $this->get_loader()->enqueue_styles();
860 + $suffix = Utils::is_script_debug() ? '' : '.min';
391 861
392 - $this->enqueue_theme_ui_styles();
862 + $direction_suffix = is_rtl() ? '-rtl' : '';
393 863
394 - $breakpoints = Plugin::$instance->breakpoints->get_breakpoints();
864 + wp_register_style(
865 + 'font-awesome',
866 + ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/font-awesome' . $suffix . '.css',
867 + [],
868 + '4.7.0'
869 + );
395 870
396 - // The two breakpoints under 'tablet' need to be checked for values.
397 - if ( $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE ]->is_custom() || $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE_EXTRA ]->is_enabled() ) {
398 - wp_add_inline_style(
399 - 'elementor-editor',
400 - '.elementor-device-tablet #elementor-preview-responsive-wrapper { width: ' . Plugin::$instance->breakpoints->get_device_min_breakpoint( Breakpoints_Manager::BREAKPOINT_KEY_TABLET ) . 'px; }'
871 + wp_register_style(
872 + 'elementor-select2',
873 + ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css',
874 + [],
875 + '4.0.6-rc.1'
876 + );
877 +
878 + wp_register_style(
879 + 'google-font-roboto',
880 + 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
881 + [],
882 + ELEMENTOR_VERSION
883 + );
884 +
885 + wp_register_style(
886 + 'flatpickr',
887 + ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.css',
888 + [],
889 + '1.12.0'
890 + );
891 +
892 + wp_register_style(
893 + 'pickr',
894 + ELEMENTOR_ASSETS_URL . 'lib/pickr/themes/monolith.min.css',
895 + [],
896 + '1.5.0'
897 + );
898 +
899 + wp_register_style(
900 + 'elementor-editor',
901 + ELEMENTOR_ASSETS_URL . 'css/editor' . $direction_suffix . $suffix . '.css',
902 + [
903 + 'elementor-common',
904 + 'elementor-select2',
905 + 'elementor-icons',
906 + 'wp-auth-check',
907 + 'google-font-roboto',
908 + 'flatpickr',
909 + 'pickr',
910 + ],
911 + ELEMENTOR_VERSION
912 + );
913 +
914 + wp_enqueue_style( 'elementor-editor' );
915 +
916 + $ui_theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
917 +
918 + if ( 'light' !== $ui_theme ) {
919 + $ui_theme_media_queries = 'all';
920 +
921 + if ( 'auto' === $ui_theme ) {
922 + $ui_theme_media_queries = '(prefers-color-scheme: dark)';
923 + }
924 +
925 + wp_enqueue_style(
926 + 'elementor-editor-dark-mode',
927 + ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css',
928 + [
929 + 'elementor-editor',
930 + ],
931 + ELEMENTOR_VERSION,
932 + $ui_theme_media_queries
401 933 );
402 934 }
403 935
936 + if ( Responsive::has_custom_breakpoints() ) {
937 + $breakpoints = Responsive::get_breakpoints();
938 +
939 + wp_add_inline_style( 'elementor-editor', '.elementor-device-tablet #elementor-preview-responsive-wrapper { width: ' . $breakpoints['md'] . 'px; }' );
940 + }
941 +
404 942 /**
405 943 * After editor enqueue styles.
406 944 *
407 945 * Fires after Elementor editor styles are enqueued.
@@ -410,44 +948,51 @@
410 948 */
411 949 do_action( 'elementor/editor/after_enqueue_styles' );
412 950 }
413 951
414 - private function enqueue_theme_ui_styles() {
415 - $ui_theme_selected = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
952 + /**
953 + * Get WordPress editor config.
954 + *
955 + * Config the default WordPress editor with custom settings for Elementor use.
956 + *
957 + * @since 1.9.0
958 + * @access private
959 + */
960 + private function get_wp_editor_config() {
961 + // Remove all TinyMCE plugins.
962 + remove_all_filters( 'mce_buttons', 10 );
963 + remove_all_filters( 'mce_external_plugins', 10 );
416 964
417 - $ui_themes = [
418 - 'light',
419 - 'dark',
420 - ];
965 + if ( ! class_exists( '\_WP_Editors', false ) ) {
966 + require ABSPATH . WPINC . '/class-wp-editor.php';
967 + }
421 968
422 - if ( 'auto' === $ui_theme_selected || ! in_array( $ui_theme_selected, $ui_themes, true ) ) {
423 - $ui_light_theme_media_queries = '(prefers-color-scheme: light)';
424 - $ui_dark_theme_media_queries = '(prefers-color-scheme: dark)';
425 - } else {
426 - $ui_light_theme_media_queries = 'none';
427 - $ui_dark_theme_media_queries = 'none';
969 + // WordPress 4.8 and higher
970 + if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) {
971 + \_WP_Editors::print_default_editor_scripts();
972 + \_WP_Editors::print_tinymce_scripts();
973 + }
974 + ob_start();
428 975
429 - if ( 'light' === $ui_theme_selected ) {
430 - $ui_light_theme_media_queries = 'all';
431 - } elseif ( 'dark' === $ui_theme_selected ) {
432 - $ui_dark_theme_media_queries = 'all';
433 - }
434 - }
976 + wp_editor(
977 + '%%EDITORCONTENT%%',
978 + 'elementorwpeditor',
979 + [
980 + 'editor_class' => 'elementor-wp-editor',
981 + 'editor_height' => 250,
982 + 'drag_drop_upload' => true,
983 + ]
984 + );
435 985
436 - $this->enqueue_theme_ui( 'light', $ui_light_theme_media_queries );
437 - $this->enqueue_theme_ui( 'dark', $ui_dark_theme_media_queries );
438 - }
986 + $config = ob_get_clean();
439 987
440 - private function enqueue_theme_ui( $ui_theme, $ui_theme_media_queries = 'all' ) {
441 - $suffix = Utils::is_script_debug() ? '' : '.min';
988 + // Don't call \_WP_Editors methods again
989 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 );
990 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 );
442 991
443 - wp_enqueue_style(
444 - 'e-theme-ui-' . $ui_theme,
445 - ELEMENTOR_ASSETS_URL . 'css/theme-' . $ui_theme . $suffix . '.css',
446 - [],
447 - ELEMENTOR_VERSION,
448 - $ui_theme_media_queries
449 - );
992 + \_WP_Editors::editor_js();
993 +
994 + return $config;
450 995 }
451 996
452 997 /**
453 998 * Editor head trigger.
@@ -471,8 +1016,32 @@
471 1016 do_action( 'elementor/editor/wp_head' );
472 1017 }
473 1018
474 1019 /**
1020 + * Add editor template.
1021 + *
1022 + * Registers new editor templates.
1023 + *
1024 + * @since 1.0.0
1025 + * @deprecated 2.3.0 Use `Plugin::$instance->common->add_template()`
1026 + * @access public
1027 + *
1028 + * @param string $template Can be either a link to template file or template
1029 + * HTML content.
1030 + * @param string $type Optional. Whether to handle the template as path
1031 + * or text. Default is `path`.
1032 + */
1033 + public function add_editor_template( $template, $type = 'path' ) {
1034 + _deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->add_template()' );
1035 +
1036 + $common = Plugin::$instance->common;
1037 +
1038 + if ( $common ) {
1039 + Plugin::$instance->common->add_template( $template, $type );
1040 + }
1041 + }
1042 +
1043 + /**
475 1044 * WP footer.
476 1045 *
477 1046 * Prints Elementor editor with all the editor templates, and render controls,
478 1047 * widgets and content elements.
@@ -488,11 +1057,13 @@
488 1057 $plugin->controls_manager->render_controls();
489 1058 $plugin->widgets_manager->render_widgets_content();
490 1059 $plugin->elements_manager->render_elements_content();
491 1060
1061 + $plugin->schemes_manager->print_schemes_templates();
1062 +
492 1063 $plugin->dynamic_tags->print_templates();
493 1064
494 - $this->get_loader()->register_additional_templates();
1065 + $this->init_editor_templates();
495 1066
496 1067 /**
497 1068 * Elementor editor footer.
498 1069 *
@@ -528,12 +1099,11 @@
528 1099 * @since 1.0.0
529 1100 * @access public
530 1101 */
531 1102 public function __construct() {
532 - Plugin::$instance->data_manager_v2->register_controller( new Data\Globals\Controller() );
1103 + Plugin::$instance->data_manager->register_controller( Data\Globals\Controller::class );
533 1104
534 1105 $this->notice_bar = new Notice_Bar();
535 - $this->promotion = new Promotion();
536 1106
537 1107 add_action( 'admin_action_elementor', [ $this, 'init' ] );
538 1108 add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] );
539 1109
@@ -539,89 +1109,11 @@
539 1109
540 1110 // Handle autocomplete feature for URL control.
541 1111 add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] );
542 1112 add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] );
543 -
544 - add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 );
545 1113 }
546 1114
547 1115 /**
548 - * Whether the Document-Isolation-Policy header should be sent on the
549 - * Elementor editor screen and the editor preview iframe.
550 - *
551 - * DIP places the document in its own agent cluster, which is the prerequisite
552 - * for cross-origin isolation features such as SharedArrayBuffer (required by
553 - * WordPress core's client-side media processing introduced in WP 7.1).
554 - *
555 - * Both the editor parent document and the preview iframe must send the same
556 - * DIP header so they join the same agent cluster and synchronous DOM access
557 - * between them (e.g. `iframe.contentWindow.elementorFrontend`) keeps working.
558 - *
559 - * The header is only honored by browsers on a secure context (HTTPS or
560 - * localhost) so the helper short-circuits on insecure origins to avoid
561 - * sending a header that the browser will ignore.
562 - *
563 - * @since 4.1.0
564 - *
565 - * @return bool
566 - */
567 - public static function should_use_document_isolation_policy() {
568 - if ( ! is_ssl() ) {
569 - $raw_host = isset( $_SERVER['HTTP_HOST'] ) ? sanitize_text_field( wp_unslash( $_SERVER['HTTP_HOST'] ) ) : '';
570 - $host = strtolower( (string) strtok( $raw_host, ':' ) );
571 -
572 - if ( 'localhost' !== $host && ! str_ends_with( $host, '.localhost' ) ) {
573 - return false;
574 - }
575 - }
576 -
577 - /**
578 - * Filters whether Elementor sends the Document-Isolation-Policy header
579 - * on the editor screen and preview iframe.
580 - *
581 - * @since 4.1.0
582 - *
583 - * @param bool $enabled Whether DIP is enabled. Defaults to true on a secure context.
584 - */
585 - return (bool) apply_filters( 'elementor/editor/use_document_isolation_policy', true );
586 - }
587 -
588 - /**
589 - * Send the Document-Isolation-Policy header for the current response.
590 - *
591 - * Safe to call from both the Elementor editor screen handler and the
592 - * preview iframe handler. No-op when {@see self::should_use_document_isolation_policy()}
593 - * returns false.
594 - *
595 - * @since 4.1.0
596 - */
597 - public static function send_document_isolation_policy_header() {
598 - if ( ! self::should_use_document_isolation_policy() || headers_sent() ) {
599 - return;
600 - }
601 -
602 - header( 'Document-Isolation-Policy: isolate-and-credentialless' );
603 - }
604 -
605 - /**
606 - * Signals to WordPress that Elementor is replacing the block editor on its own editor page,
607 - * so that block-editor-specific behaviour (e.g. WP 7.0 COOP/COEP isolation headers) is not
608 - * applied when the Elementor editor is active.
609 - *
610 - * @param bool $replace Whether the editor is being replaced.
611 - * @param \WP_Post $post The post being edited.
612 - *
613 - * @return bool
614 - */
615 - public function filter_replace_editor( $replace, $post ) {
616 - if ( isset( $_REQUEST['action'] ) && 'elementor' === $_REQUEST['action'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
617 - return true;
618 - }
619 -
620 - return $replace;
621 - }
622 -
623 - /**
624 1116 * @since 2.2.0
625 1117 * @access public
626 1118 */
627 1119 public function filter_wp_link_query_args( $query ) {
@@ -637,11 +1129,9 @@
637 1129 * @since 2.2.0
638 1130 * @access public
639 1131 */
640 1132 public function filter_wp_link_query( $results ) {
641 -
642 - // PHPCS - The user data is not used.
643 - if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing
1133 + if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) {
644 1134 $post_type_object = get_post_type_object( 'post' );
645 1135 $post_label = $post_type_object->labels->singular_name;
646 1136
647 1137 foreach ( $results as & $result ) {
@@ -653,71 +1143,146 @@
653 1143
654 1144 return $results;
655 1145 }
656 1146
657 - public function set_post_id( $post_id ) {
658 - $this->post_id = $post_id;
1147 + /**
1148 + * Create nonce.
1149 + *
1150 + * If the user has edit capabilities, it creates a cryptographic token to
1151 + * give him access to Elementor editor.
1152 + *
1153 + * @since 1.8.1
1154 + * @since 1.8.7 The `$post_type` parameter was introduces.
1155 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )->create_nonce()` instead
1156 + * @access public
1157 + *
1158 + * @param string $post_type The post type to check capabilities.
1159 + *
1160 + * @return null|string The nonce token, or `null` if the user has no edit
1161 + * capabilities.
1162 + */
1163 + public function create_nonce( $post_type ) {
1164 + _deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->get_component( \'ajax\' )->create_nonce()' );
1165 +
1166 + /** @var Ajax $ajax */
1167 + $ajax = Plugin::$instance->common->get_component( 'ajax' );
1168 +
1169 + return $ajax->create_nonce();
659 1170 }
660 1171
661 1172 /**
662 - * Get loader.
1173 + * Verify nonce.
663 1174 *
664 - * @return Editor_Loader_Interface
1175 + * The user is given an amount of time to use the token, so therefore, since
1176 + * the user ID and `$action` remain the same, the independent variable is
1177 + * the time.
1178 + *
1179 + * @since 1.8.1
1180 + * @deprecated 2.3.0
1181 + * @access public
1182 + *
1183 + * @param string $nonce Nonce to verify.
1184 + *
1185 + * @return false|int If the nonce is invalid it returns `false`. If the
1186 + * nonce is valid and generated between 0-12 hours ago it
1187 + * returns `1`. If the nonce is valid and generated
1188 + * between 12-24 hours ago it returns `2`.
665 1189 */
666 - private function get_loader() {
667 - if ( ! $this->loader ) {
668 - $this->loader = Editor_Loader_Factory::create();
1190 + public function verify_nonce( $nonce ) {
1191 + _deprecated_function( __METHOD__, '2.3.0', 'wp_verify_nonce()' );
669 1192
670 - $this->loader->init();
671 - }
672 -
673 - return $this->loader;
1193 + return wp_verify_nonce( $nonce );
674 1194 }
675 1195
676 1196 /**
677 - * Get elements presets.
1197 + * Verify request nonce.
678 1198 *
679 - * @return array
1199 + * Whether the request nonce verified or not.
1200 + *
1201 + * @since 1.8.1
1202 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )->verify_request_nonce()` instead
1203 + * @access public
1204 + *
1205 + * @return bool True if request nonce verified, False otherwise.
680 1206 */
681 - public function get_elements_presets() {
682 - $element_types = Plugin::$instance->elements_manager->get_element_types();
683 - $presets = [];
1207 + public function verify_request_nonce() {
1208 + _deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->get_component( \'ajax\' )->verify_request_nonce()' );
684 1209
685 - foreach ( $element_types as $el_type => $element ) {
686 - $this->check_element_for_presets( $element, $el_type, $presets );
687 - }
1210 + /** @var Ajax $ajax */
1211 + $ajax = Plugin::$instance->common->get_component( 'ajax' );
688 1212
689 - return $presets;
1213 + return $ajax->verify_request_nonce();
690 1214 }
691 1215
692 1216 /**
693 - * @return void
1217 + * Verify ajax nonce.
1218 + *
1219 + * Verify request nonce and send a JSON request, if not verified returns an
1220 + * error.
1221 + *
1222 + * @since 1.9.0
1223 + * @deprecated 2.3.0
1224 + * @access public
694 1225 */
695 - private function check_element_for_presets( $element, $el_type, &$presets ) {
696 - $element_presets = $element->get_panel_presets();
1226 + public function verify_ajax_nonce() {
1227 + _deprecated_function( __METHOD__, '2.3.0' );
697 1228
698 - if ( empty( $element_presets ) ) {
699 - return;
700 - }
1229 + /** @var Ajax $ajax */
1230 + $ajax = Plugin::$instance->common->get_component( 'ajax' );
701 1231
702 - foreach ( $element_presets as $key => $preset ) {
703 - $this->maybe_add_preset( $el_type, $preset, $key, $presets );
1232 + if ( ! $ajax->verify_request_nonce() ) {
1233 + wp_send_json_error( new \WP_Error( 'token_expired', 'Nonce token expired.' ) );
704 1234 }
705 1235 }
706 1236
707 1237 /**
708 - * @return void
1238 + * Init editor templates.
1239 + *
1240 + * Initialize default elementor templates used in the editor panel.
1241 + *
1242 + * @since 1.7.0
1243 + * @access private
709 1244 */
710 - private function maybe_add_preset( $el_type, $preset, $key, &$presets ) {
711 - if ( $this->is_valid_preset( $el_type, $preset ) ) {
712 - $presets[ $key ] = $preset;
1245 + private function init_editor_templates() {
1246 + $template_names = [
1247 + 'global',
1248 + 'panel',
1249 + 'panel-elements',
1250 + 'repeater',
1251 + 'templates',
1252 + 'navigator',
1253 + 'hotkeys',
1254 + ];
1255 +
1256 + foreach ( $template_names as $template_name ) {
1257 + Plugin::$instance->common->add_template( ELEMENTOR_PATH . "includes/editor-templates/$template_name.php" );
713 1258 }
714 1259 }
715 1260
716 - /**
717 - * @return boolean
718 - */
719 - private function is_valid_preset( $el_type, $preset ) {
720 - return isset( $preset['replacements']['custom']['originalWidget'] )
721 - && $el_type === $preset['replacements']['custom']['originalWidget'];
1261 + private function bc_move_document_filters() {
1262 + global $wp_filter;
1263 +
1264 + $old_tag = 'elementor/editor/localize_settings';
1265 + $new_tag = 'elementor/document/config';
1266 +
1267 + if ( ! has_filter( $old_tag ) ) {
1268 + return;
1269 + }
1270 +
1271 + foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) {
1272 + foreach ( $filters as $filter_id => $filter_args ) {
1273 + if ( 2 === $filter_args['accepted_args'] ) {
1274 + remove_filter( $old_tag, $filter_id, $priority );
1275 +
1276 + add_filter( $new_tag, $filter_args['function'], $priority, 2 );
1277 +
1278 + // TODO: Hard deprecation
1279 + // _deprecated_hook( '`' . $old_tag . ` is no longer using post_id', '2.9.0', $new_tag' );
1280 + }
1281 + }
1282 + }
1283 + }
1284 +
1285 + public function set_post_id( $post_id ) {
1286 + $this->post_id = $post_id;
722 1287 }
723 1288 }