PluginProbe
Elementor Website Builder – more than just a page builder / 3.0.4
Elementor Website Builder – more than just a page builder v3.0.4
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 +745 -186 4.2.43.0.4 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,317 @@
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 +
613 + // Global Styles
614 + 'new_global_color' => __( 'New Global Color', 'elementor' ),
615 + 'global_colors_title' => __( 'Global Colors', 'elementor' ),
616 + 'manage_global_colors' => __( 'Manage Global Colors', 'elementor' ),
617 + 'create_global_color' => __( 'Create New Global Color', 'elementor' ),
618 + 'delete_global_color' => __( 'Delete Global Color', 'elementor' ),
619 + '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' ),
620 + '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' ),
621 + 'typography' => __( 'Typography', 'elementor' ),
622 + 'new_typography_setting' => __( 'New Typography Setting', 'elementor' ),
623 + 'global_fonts_title' => __( 'Global Fonts', 'elementor' ),
624 + 'manage_global_fonts' => __( 'Manage Global Fonts', 'elementor' ),
625 + 'create_global_font' => __( 'Create New Global Font', 'elementor' ),
626 + 'delete_global_font' => __( 'Delete Global Font', 'elementor' ),
627 + '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' ),
628 + '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' ),
629 + 'default' => __( 'Default', 'elementor' ),
630 + 'create' => __( 'Create', 'elementor' ),
631 + 'global_color_confirm_text' => __( 'Are you sure you want to create a new Global Color?', 'elementor' ),
632 + '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' ),
633 + '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' ),
634 + 'global_fonts_confirm_text' => __( 'Are you sure you want to create a new Global Font setting?', 'elementor' ),
635 + 'custom' => __( 'Custom', 'elementor' ),
636 +
637 + // Menu.
638 + 'site_settings' => __( 'Site Settings', 'elementor' ),
639 + 'theme_builder' => __( 'Theme Builder', 'elementor' ),
640 + 'user_preferences' => __( 'User Preferences', 'elementor' ),
641 + 'settings' => __( 'Settings', 'elementor' ),
642 + 'more' => __( 'More', 'elementor' ),
643 + 'navigate_from_page' => __( 'Navigate From Page', 'elementor' ),
644 + 'view_page' => __( 'View Page', 'elementor' ),
645 + 'exit_to_dashboard' => __( 'Exit To Dashboard', 'elementor' ),
646 +
647 + // Elements.
648 + 'inner_section' => __( 'Inner Section', 'elementor' ),
649 +
650 + // Control Order.
651 + 'asc' => __( 'Ascending order', 'elementor' ),
652 + 'desc' => __( 'Descending order', 'elementor' ),
653 +
654 + // Clear Page.
655 + 'clear_page' => __( 'Delete All Content', 'elementor' ),
656 + 'dialog_confirm_clear_page' => __( 'Attention: We are going to DELETE ALL CONTENT from this page. Are you sure you want to do that?', 'elementor' ),
657 +
658 + // Enable unfiltered file uploads.
659 + 'enable_unfiltered_files_upload' => __( 'Enable Unfiltered File Uploads', 'elementor' ),
660 + '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' ),
661 +
662 + // Enable fontawesome 5 if needed.
663 + 'enable_fa5' => __( 'Elementor\'s New Icon Library', 'elementor' ),
664 + '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>',
665 +
666 + // Panel Preview Mode.
667 + 'back_to_editor' => __( 'Show Panel', 'elementor' ),
668 + 'preview' => __( 'Hide Panel', 'elementor' ),
669 +
670 + // Inline Editing.
671 + 'type_here' => __( 'Type Here', 'elementor' ),
672 +
673 + // Library.
674 + 'an_error_occurred' => __( 'An error occurred', 'elementor' ),
675 + 'category' => __( 'Category', 'elementor' ),
676 + 'delete_template' => __( 'Delete Template', 'elementor' ),
677 + 'delete_template_confirm' => __( 'Are you sure you want to delete this template?', 'elementor' ),
678 + 'import_template_dialog_header' => __( 'Import Document Settings', 'elementor' ),
679 + 'import_template_dialog_message' => __( 'Do you want to also import the document settings of the template?', 'elementor' ),
680 + 'import_template_dialog_message_attention' => __( 'Attention: Importing may override previous settings.', 'elementor' ),
681 + 'library' => __( 'Library', 'elementor' ),
682 + 'no' => __( 'No', 'elementor' ),
683 + 'page' => __( 'Page', 'elementor' ),
684 + /* translators: %s: Template type. */
685 + 'save_your_template' => __( 'Save Your %s to Library', 'elementor' ),
686 + 'save_your_template_description' => __( 'Your designs will be available for export and reuse on any page or website', 'elementor' ),
687 + 'section' => __( 'Section', 'elementor' ),
688 + 'templates_empty_message' => __( 'This is where your templates should be. Design it. Save it. Reuse it.', 'elementor' ),
689 + 'templates_empty_title' => __( 'Haven’t Saved Templates Yet?', 'elementor' ),
690 + 'templates_no_favorites_message' => __( 'You can mark any pre-designed template as a favorite.', 'elementor' ),
691 + 'templates_no_favorites_title' => __( 'No Favorite Templates', 'elementor' ),
692 + 'templates_no_results_message' => __( 'Please make sure your search is spelled correctly or try a different words.', 'elementor' ),
693 + 'templates_no_results_title' => __( 'No Results Found', 'elementor' ),
694 + 'templates_request_error' => __( 'The following error(s) occurred while processing the request:', 'elementor' ),
695 + 'yes' => __( 'Yes', 'elementor' ),
696 + 'blocks' => __( 'Blocks', 'elementor' ),
697 + 'pages' => __( 'Pages', 'elementor' ),
698 + 'my_templates' => __( 'My Templates', 'elementor' ),
699 +
700 + // Incompatible Device.
701 + 'device_incompatible_header' => __( 'Your browser isn\'t compatible', 'elementor' ),
702 + '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' ),
703 + 'proceed_anyway' => __( 'Proceed Anyway', 'elementor' ),
704 +
705 + // Preview not loaded.
706 + 'learn_more' => __( 'Learn More', 'elementor' ),
707 + 'preview_el_not_found_header' => __( 'Sorry, the content area was not found in your page.', 'elementor' ),
708 + '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' ),
709 +
710 + // Gallery.
711 + 'delete_gallery' => __( 'Reset Gallery', 'elementor' ),
712 + 'dialog_confirm_gallery_delete' => __( 'Are you sure you want to reset this gallery?', 'elementor' ),
713 + /* translators: %s: The number of images. */
714 + 'gallery_images_selected' => __( '%s Images Selected', 'elementor' ),
715 + 'gallery_no_images_selected' => __( 'No Images Selected', 'elementor' ),
716 + 'insert_media' => __( 'Insert Media', 'elementor' ),
717 +
718 + // Take Over.
719 + /* translators: %s: User name. */
720 + 'dialog_user_taken_over' => __( '%s has taken over and is currently editing. Do you want to take over this page editing?', 'elementor' ),
721 + 'go_back' => __( 'Go Back', 'elementor' ),
722 + 'take_over' => __( 'Take Over', 'elementor' ),
723 +
724 + // Revisions.
725 + /* translators: %s: Template type. */
726 + 'dialog_confirm_delete' => __( 'Are you sure you want to remove this %s?', 'elementor' ),
727 +
728 + // Saver.
729 + 'before_unload_alert' => __( 'Please note: All unsaved changes will be lost.', 'elementor' ),
730 + 'published' => __( 'Published', 'elementor' ),
731 + 'publish' => __( 'Publish', 'elementor' ),
732 + 'save' => __( 'Save', 'elementor' ),
733 + 'saved' => __( 'Saved', 'elementor' ),
734 + 'update' => __( 'Update', 'elementor' ),
735 + 'enable' => __( 'Enable', 'elementor' ),
736 + 'submit' => __( 'Submit', 'elementor' ),
737 + 'working_on_draft_notification' => __( 'This is just a draft. Play around and when you\'re done - click update.', 'elementor' ),
738 + 'keep_editing' => __( 'Keep Editing', 'elementor' ),
739 + 'have_a_look' => __( 'Have a look', 'elementor' ),
740 + 'view_all_revisions' => __( 'View All Revisions', 'elementor' ),
741 + 'dismiss' => __( 'Dismiss', 'elementor' ),
742 + 'saving_disabled' => __( 'Saving has been disabled until you’re reconnected.', 'elementor' ),
743 +
744 + // Ajax
745 + 'server_error' => __( 'Server Error', 'elementor' ),
746 + 'server_connection_lost' => __( 'Connection Lost', 'elementor' ),
747 + 'unknown_error' => __( 'Unknown Error', 'elementor' ),
748 +
749 + // Context Menu
750 + 'duplicate' => __( 'Duplicate', 'elementor' ),
751 + 'copy' => __( 'Copy', 'elementor' ),
752 + 'paste' => __( 'Paste', 'elementor' ),
753 + 'copy_style' => __( 'Copy Style', 'elementor' ),
754 + 'paste_style' => __( 'Paste Style', 'elementor' ),
755 + 'reset_style' => __( 'Reset Style', 'elementor' ),
756 + 'save_as_global' => __( 'Save as a Global', 'elementor' ),
757 + 'save_as_block' => __( 'Save as Template', 'elementor' ),
758 + 'new_column' => __( 'Add New Column', 'elementor' ),
759 + 'copy_all_content' => __( 'Copy All Content', 'elementor' ),
760 + 'delete_all_content' => __( 'Delete All Content', 'elementor' ),
761 + 'navigator' => __( 'Navigator', 'elementor' ),
762 +
763 + // Right Click Introduction
764 + 'meet_right_click_header' => __( 'Meet Right Click', 'elementor' ),
765 + 'meet_right_click_message' => __( 'Now you can access all editing actions using right click.', 'elementor' ),
766 +
767 + // Hotkeys screen
768 + 'keyboard_shortcuts' => __( 'Keyboard Shortcuts', 'elementor' ),
769 +
770 + // Deprecated Control
771 + 'deprecated_notice' => __( 'The <strong>%1$s</strong> widget has been deprecated since %2$s %3$s.', 'elementor' ),
772 + 'deprecated_notice_replacement' => __( 'It has been replaced by <strong>%1$s</strong>.', 'elementor' ),
773 + 'deprecated_notice_last' => __( 'Note that %1$s will be completely removed once %2$s %3$s is released.', 'elementor' ),
774 +
775 + //Preview Debug
776 + 'preview_debug_link_text' => __( 'Click here for preview debug', 'elementor' ),
777 +
778 + 'icon_library' => __( 'Icon Library', 'elementor' ),
779 + 'my_libraries' => __( 'My Libraries', 'elementor' ),
780 + 'upload' => __( 'Upload', 'elementor' ),
781 + 'icons_promotion' => __( 'Become a Pro user to upload unlimited font icon folders to your website.', 'elementor' ),
782 + 'go_pro' => __( 'Go Pro', 'elementor' ),
783 + 'custom_positioning' => __( 'Custom Positioning', 'elementor' ),
784 +
785 + 'element_promotion_dialog_header' => __( '%s Widget', 'elementor' ),
786 + 'element_promotion_dialog_message' => __( 'Use %s widget and dozens more pro features to extend your toolbox and build sites faster and better.', 'elementor' ),
787 + 'see_it_in_action' => __( 'See it in Action', 'elementor' ),
788 + 'dynamic_content' => __( 'Dynamic Content', 'elementor' ),
789 + 'dynamic_promotion_message' => __( 'Create more personalized and dynamic sites by populating data from various sources with dozens of dynamic tags to choose from.', 'elementor' ),
790 +
791 + // TODO: Remove.
792 + 'autosave' => __( 'Autosave', 'elementor' ),
793 + 'elementor_docs' => __( 'Documentation', 'elementor' ),
794 + 'reload_page' => __( 'Reload Page', 'elementor' ),
795 + 'session_expired_header' => __( 'Timeout', 'elementor' ),
796 + 'session_expired_message' => __( 'Your session has expired. Please reload the page to continue editing.', 'elementor' ),
797 + 'soon' => __( 'Soon', 'elementor' ),
798 + 'unknown_value' => __( 'Unknown Value', 'elementor' ),
799 + ],
800 + ];
801 +
802 + if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) {
803 + $config['promotionWidgets'] = Api::get_promotion_widgets();
804 + }
805 +
806 + $this->bc_move_document_filters();
807 +
361 808 /**
809 + * Localize editor settings.
810 + *
811 + * Filters the editor localized settings.
812 + *
813 + * @since 1.0.0
814 + *
815 + * @param array $config Editor configuration.
816 + * @param int $post_id The ID of the current post being edited.
817 + */
818 + $config = apply_filters( 'elementor/editor/localize_settings', $config );
819 +
820 + Utils::print_js_config( 'elementor-editor', 'ElementorConfig', $config );
821 +
822 + wp_enqueue_script( 'elementor-editor' );
823 +
824 + $plugin->controls_manager->enqueue_control_scripts();
825 +
826 + /**
362 827 * After editor enqueue scripts.
363 828 *
364 829 * Fires after Elementor editor scripts are enqueued.
365 830 *
@@ -385,23 +850,90 @@
385 850 * @since 1.0.0
386 851 */
387 852 do_action( 'elementor/editor/before_enqueue_styles' );
388 853
389 - $this->get_loader()->register_styles();
390 - $this->get_loader()->enqueue_styles();
854 + $suffix = Utils::is_script_debug() ? '' : '.min';
391 855
392 - $this->enqueue_theme_ui_styles();
856 + $direction_suffix = is_rtl() ? '-rtl' : '';
393 857
394 - $breakpoints = Plugin::$instance->breakpoints->get_breakpoints();
858 + wp_register_style(
859 + 'font-awesome',
860 + ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/font-awesome' . $suffix . '.css',
861 + [],
862 + '4.7.0'
863 + );
395 864
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; }'
865 + wp_register_style(
866 + 'elementor-select2',
867 + ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css',
868 + [],
869 + '4.0.6-rc.1'
870 + );
871 +
872 + wp_register_style(
873 + 'google-font-roboto',
874 + 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700',
875 + [],
876 + ELEMENTOR_VERSION
877 + );
878 +
879 + wp_register_style(
880 + 'flatpickr',
881 + ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.css',
882 + [],
883 + '1.12.0'
884 + );
885 +
886 + wp_register_style(
887 + 'pickr',
888 + ELEMENTOR_ASSETS_URL . 'lib/pickr/themes/monolith.min.css',
889 + [],
890 + '1.5.0'
891 + );
892 +
893 + wp_register_style(
894 + 'elementor-editor',
895 + ELEMENTOR_ASSETS_URL . 'css/editor' . $direction_suffix . $suffix . '.css',
896 + [
897 + 'elementor-common',
898 + 'elementor-select2',
899 + 'elementor-icons',
900 + 'wp-auth-check',
901 + 'google-font-roboto',
902 + 'flatpickr',
903 + 'pickr',
904 + ],
905 + ELEMENTOR_VERSION
906 + );
907 +
908 + wp_enqueue_style( 'elementor-editor' );
909 +
910 + $ui_theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
911 +
912 + if ( 'light' !== $ui_theme ) {
913 + $ui_theme_media_queries = 'all';
914 +
915 + if ( 'auto' === $ui_theme ) {
916 + $ui_theme_media_queries = '(prefers-color-scheme: dark)';
917 + }
918 +
919 + wp_enqueue_style(
920 + 'elementor-editor-dark-mode',
921 + ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css',
922 + [
923 + 'elementor-editor',
924 + ],
925 + ELEMENTOR_VERSION,
926 + $ui_theme_media_queries
401 927 );
402 928 }
403 929
930 + if ( Responsive::has_custom_breakpoints() ) {
931 + $breakpoints = Responsive::get_breakpoints();
932 +
933 + wp_add_inline_style( 'elementor-editor', '.elementor-device-tablet #elementor-preview-responsive-wrapper { width: ' . $breakpoints['md'] . 'px; }' );
934 + }
935 +
404 936 /**
405 937 * After editor enqueue styles.
406 938 *
407 939 * Fires after Elementor editor styles are enqueued.
@@ -410,44 +942,51 @@
410 942 */
411 943 do_action( 'elementor/editor/after_enqueue_styles' );
412 944 }
413 945
414 - private function enqueue_theme_ui_styles() {
415 - $ui_theme_selected = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' );
946 + /**
947 + * Get WordPress editor config.
948 + *
949 + * Config the default WordPress editor with custom settings for Elementor use.
950 + *
951 + * @since 1.9.0
952 + * @access private
953 + */
954 + private function get_wp_editor_config() {
955 + // Remove all TinyMCE plugins.
956 + remove_all_filters( 'mce_buttons', 10 );
957 + remove_all_filters( 'mce_external_plugins', 10 );
416 958
417 - $ui_themes = [
418 - 'light',
419 - 'dark',
420 - ];
959 + if ( ! class_exists( '\_WP_Editors', false ) ) {
960 + require ABSPATH . WPINC . '/class-wp-editor.php';
961 + }
421 962
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';
963 + // WordPress 4.8 and higher
964 + if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) {
965 + \_WP_Editors::print_default_editor_scripts();
966 + \_WP_Editors::print_tinymce_scripts();
967 + }
968 + ob_start();
428 969
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 - }
970 + wp_editor(
971 + '%%EDITORCONTENT%%',
972 + 'elementorwpeditor',
973 + [
974 + 'editor_class' => 'elementor-wp-editor',
975 + 'editor_height' => 250,
976 + 'drag_drop_upload' => true,
977 + ]
978 + );
435 979
436 - $this->enqueue_theme_ui( 'light', $ui_light_theme_media_queries );
437 - $this->enqueue_theme_ui( 'dark', $ui_dark_theme_media_queries );
438 - }
980 + $config = ob_get_clean();
439 981
440 - private function enqueue_theme_ui( $ui_theme, $ui_theme_media_queries = 'all' ) {
441 - $suffix = Utils::is_script_debug() ? '' : '.min';
982 + // Don't call \_WP_Editors methods again
983 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 );
984 + remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 );
442 985
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 - );
986 + \_WP_Editors::editor_js();
987 +
988 + return $config;
450 989 }
451 990
452 991 /**
453 992 * Editor head trigger.
@@ -471,8 +1010,32 @@
471 1010 do_action( 'elementor/editor/wp_head' );
472 1011 }
473 1012
474 1013 /**
1014 + * Add editor template.
1015 + *
1016 + * Registers new editor templates.
1017 + *
1018 + * @since 1.0.0
1019 + * @deprecated 2.3.0 Use `Plugin::$instance->common->add_template()`
1020 + * @access public
1021 + *
1022 + * @param string $template Can be either a link to template file or template
1023 + * HTML content.
1024 + * @param string $type Optional. Whether to handle the template as path
1025 + * or text. Default is `path`.
1026 + */
1027 + public function add_editor_template( $template, $type = 'path' ) {
1028 + _deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->add_template()' );
1029 +
1030 + $common = Plugin::$instance->common;
1031 +
1032 + if ( $common ) {
1033 + Plugin::$instance->common->add_template( $template, $type );
1034 + }
1035 + }
1036 +
1037 + /**
475 1038 * WP footer.
476 1039 *
477 1040 * Prints Elementor editor with all the editor templates, and render controls,
478 1041 * widgets and content elements.
@@ -488,11 +1051,13 @@
488 1051 $plugin->controls_manager->render_controls();
489 1052 $plugin->widgets_manager->render_widgets_content();
490 1053 $plugin->elements_manager->render_elements_content();
491 1054
1055 + $plugin->schemes_manager->print_schemes_templates();
1056 +
492 1057 $plugin->dynamic_tags->print_templates();
493 1058
494 - $this->get_loader()->register_additional_templates();
1059 + $this->init_editor_templates();
495 1060
496 1061 /**
497 1062 * Elementor editor footer.
498 1063 *
@@ -528,12 +1093,11 @@
528 1093 * @since 1.0.0
529 1094 * @access public
530 1095 */
531 1096 public function __construct() {
532 - Plugin::$instance->data_manager_v2->register_controller( new Data\Globals\Controller() );
1097 + Plugin::$instance->data_manager->register_controller( Data\Globals\Controller::class );
533 1098
534 1099 $this->notice_bar = new Notice_Bar();
535 - $this->promotion = new Promotion();
536 1100
537 1101 add_action( 'admin_action_elementor', [ $this, 'init' ] );
538 1102 add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] );
539 1103
@@ -539,89 +1103,11 @@
539 1103
540 1104 // Handle autocomplete feature for URL control.
541 1105 add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] );
542 1106 add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] );
543 -
544 - add_filter( 'replace_editor', [ $this, 'filter_replace_editor' ], 10, 2 );
545 1107 }
546 1108
547 1109 /**
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 1110 * @since 2.2.0
625 1111 * @access public
626 1112 */
627 1113 public function filter_wp_link_query_args( $query ) {
@@ -637,11 +1123,9 @@
637 1123 * @since 2.2.0
638 1124 * @access public
639 1125 */
640 1126 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
1127 + if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) {
644 1128 $post_type_object = get_post_type_object( 'post' );
645 1129 $post_label = $post_type_object->labels->singular_name;
646 1130
647 1131 foreach ( $results as & $result ) {
@@ -653,71 +1137,146 @@
653 1137
654 1138 return $results;
655 1139 }
656 1140
657 - public function set_post_id( $post_id ) {
658 - $this->post_id = $post_id;
1141 + /**
1142 + * Create nonce.
1143 + *
1144 + * If the user has edit capabilities, it creates a cryptographic token to
1145 + * give him access to Elementor editor.
1146 + *
1147 + * @since 1.8.1
1148 + * @since 1.8.7 The `$post_type` parameter was introduces.
1149 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )->create_nonce()` instead
1150 + * @access public
1151 + *
1152 + * @param string $post_type The post type to check capabilities.
1153 + *
1154 + * @return null|string The nonce token, or `null` if the user has no edit
1155 + * capabilities.
1156 + */
1157 + public function create_nonce( $post_type ) {
1158 + _deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->get_component( \'ajax\' )->create_nonce()' );
1159 +
1160 + /** @var Ajax $ajax */
1161 + $ajax = Plugin::$instance->common->get_component( 'ajax' );
1162 +
1163 + return $ajax->create_nonce();
659 1164 }
660 1165
661 1166 /**
662 - * Get loader.
1167 + * Verify nonce.
663 1168 *
664 - * @return Editor_Loader_Interface
1169 + * The user is given an amount of time to use the token, so therefore, since
1170 + * the user ID and `$action` remain the same, the independent variable is
1171 + * the time.
1172 + *
1173 + * @since 1.8.1
1174 + * @deprecated 2.3.0
1175 + * @access public
1176 + *
1177 + * @param string $nonce Nonce to verify.
1178 + *
1179 + * @return false|int If the nonce is invalid it returns `false`. If the
1180 + * nonce is valid and generated between 0-12 hours ago it
1181 + * returns `1`. If the nonce is valid and generated
1182 + * between 12-24 hours ago it returns `2`.
665 1183 */
666 - private function get_loader() {
667 - if ( ! $this->loader ) {
668 - $this->loader = Editor_Loader_Factory::create();
1184 + public function verify_nonce( $nonce ) {
1185 + _deprecated_function( __METHOD__, '2.3.0', 'wp_verify_nonce()' );
669 1186
670 - $this->loader->init();
671 - }
672 -
673 - return $this->loader;
1187 + return wp_verify_nonce( $nonce );
674 1188 }
675 1189
676 1190 /**
677 - * Get elements presets.
1191 + * Verify request nonce.
678 1192 *
679 - * @return array
1193 + * Whether the request nonce verified or not.
1194 + *
1195 + * @since 1.8.1
1196 + * @deprecated 2.3.0 Use `Plugin::$instance->common->get_component( 'ajax' )->verify_request_nonce()` instead
1197 + * @access public
1198 + *
1199 + * @return bool True if request nonce verified, False otherwise.
680 1200 */
681 - public function get_elements_presets() {
682 - $element_types = Plugin::$instance->elements_manager->get_element_types();
683 - $presets = [];
1201 + public function verify_request_nonce() {
1202 + _deprecated_function( __METHOD__, '2.3.0', 'Plugin::$instance->common->get_component( \'ajax\' )->verify_request_nonce()' );
684 1203
685 - foreach ( $element_types as $el_type => $element ) {
686 - $this->check_element_for_presets( $element, $el_type, $presets );
687 - }
1204 + /** @var Ajax $ajax */
1205 + $ajax = Plugin::$instance->common->get_component( 'ajax' );
688 1206
689 - return $presets;
1207 + return $ajax->verify_request_nonce();
690 1208 }
691 1209
692 1210 /**
693 - * @return void
1211 + * Verify ajax nonce.
1212 + *
1213 + * Verify request nonce and send a JSON request, if not verified returns an
1214 + * error.
1215 + *
1216 + * @since 1.9.0
1217 + * @deprecated 2.3.0
1218 + * @access public
694 1219 */
695 - private function check_element_for_presets( $element, $el_type, &$presets ) {
696 - $element_presets = $element->get_panel_presets();
1220 + public function verify_ajax_nonce() {
1221 + _deprecated_function( __METHOD__, '2.3.0' );
697 1222
698 - if ( empty( $element_presets ) ) {
699 - return;
700 - }
1223 + /** @var Ajax $ajax */
1224 + $ajax = Plugin::$instance->common->get_component( 'ajax' );
701 1225
702 - foreach ( $element_presets as $key => $preset ) {
703 - $this->maybe_add_preset( $el_type, $preset, $key, $presets );
1226 + if ( ! $ajax->verify_request_nonce() ) {
1227 + wp_send_json_error( new \WP_Error( 'token_expired', 'Nonce token expired.' ) );
704 1228 }
705 1229 }
706 1230
707 1231 /**
708 - * @return void
1232 + * Init editor templates.
1233 + *
1234 + * Initialize default elementor templates used in the editor panel.
1235 + *
1236 + * @since 1.7.0
1237 + * @access private
709 1238 */
710 - private function maybe_add_preset( $el_type, $preset, $key, &$presets ) {
711 - if ( $this->is_valid_preset( $el_type, $preset ) ) {
712 - $presets[ $key ] = $preset;
1239 + private function init_editor_templates() {
1240 + $template_names = [
1241 + 'global',
1242 + 'panel',
1243 + 'panel-elements',
1244 + 'repeater',
1245 + 'templates',
1246 + 'navigator',
1247 + 'hotkeys',
1248 + ];
1249 +
1250 + foreach ( $template_names as $template_name ) {
1251 + Plugin::$instance->common->add_template( ELEMENTOR_PATH . "includes/editor-templates/$template_name.php" );
713 1252 }
714 1253 }
715 1254
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'];
1255 + private function bc_move_document_filters() {
1256 + global $wp_filter;
1257 +
1258 + $old_tag = 'elementor/editor/localize_settings';
1259 + $new_tag = 'elementor/document/config';
1260 +
1261 + if ( ! has_filter( $old_tag ) ) {
1262 + return;
1263 + }
1264 +
1265 + foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) {
1266 + foreach ( $filters as $filter_id => $filter_args ) {
1267 + if ( 2 === $filter_args['accepted_args'] ) {
1268 + remove_filter( $old_tag, $filter_id, $priority );
1269 +
1270 + add_filter( $new_tag, $filter_args['function'], $priority, 2 );
1271 +
1272 + // TODO: Hard deprecation
1273 + // _deprecated_hook( '`' . $old_tag . ` is no longer using post_id', '2.9.0', $new_tag' );
1274 + }
1275 + }
1276 + }
1277 + }
1278 +
1279 + public function set_post_id( $post_id ) {
1280 + $this->post_id = $post_id;
722 1281 }
723 1282 }