D ), 'autosave_interval' => AUTOSAVE_INTERVAL, 'tabs' => $plugin->controls_manager->get_tabs(), 'controls' => $plugin->controls_manager->get_controls_data(), 'elements' => $plugin->elements_manager->get_element_types_config(), 'schemes' => [ 'items' => $plugin->schemes_manager->get_registered_schemes_data(), 'enabled_schemes' => Schemes_Manager::get_enabled_schemes(), ], 'globals' => [ 'defaults_enabled' => [ 'colors' => $kits_manager->is_custom_colors_enabled(), 'typography' => $kits_manager->is_custom_typography_enabled(), ], ], 'icons' => [ 'libraries' => Icons_Manager::get_icon_manager_tabs_config(), 'goProURL' => 'https://go.elementor.com/go-pro-icon-library/', ], 'fa4_to_fa5_mapping_url' => ELEMENTOR_ASSETS_URL . 'lib/font-awesome/migration/mapping.js', 'default_schemes' => $plugin->schemes_manager->get_schemes_defaults(), 'settings' => $settings, 'system_schemes' => $plugin->schemes_manager->get_system_schemes(), 'wp_editor' => $this->get_wp_editor_config(), 'settings_page_link' => Settings::get_url(), 'tools_page_link' => Tools::get_url(), 'tools_page_nonce' => wp_create_nonce( 'tools-page-from-editor' ), 'elementor_site' => 'https://go.elementor.com/about-elementor/', 'docs_elementor_site' => 'https://go.elementor.com/docs/', 'help_the_content_url' => 'https://go.elementor.com/the-content-missing/', 'help_flexbox_bc_url' => 'https://go.elementor.com/flexbox-layout-bc/', 'elementPromotionURL' => 'https://go.elementor.com/go-pro-%s', 'dynamicPromotionURL' => 'https://go.elementor.com/go-pro-dynamic-tag', 'additional_shapes' => Shapes::get_additional_shapes_for_config(), 'user' => [ 'restrictions' => $plugin->role_manager->get_user_restrictions_array(), 'is_administrator' => current_user_can( 'manage_options' ), 'introduction' => User::get_introduction_meta(), 'locale' => get_user_locale(), ], 'preview' => [ 'help_preview_error_url' => 'https://go.elementor.com/preview-not-loaded/', 'help_preview_http_error_url' => 'https://go.elementor.com/preview-not-loaded/#permissions', 'help_preview_http_error_500_url' => 'https://go.elementor.com/500-error/', 'debug_data' => Loading_Inspection_Manager::instance()->run_inspections(), ], 'locale' => get_locale(), 'rich_editing_enabled' => filter_var( get_user_meta( get_current_user_id(), 'rich_editing', true ), FILTER_VALIDATE_BOOLEAN ), 'page_title_selector' => $page_title_selector, 'tinymceHasCustomConfig' => class_exists( 'Tinymce_Advanced' ) || class_exists( 'Advanced_Editor_Tools' ), 'inlineEditing' => Plugin::$instance->widgets_manager->get_inline_editing_config(), 'dynamicTags' => Plugin::$instance->dynamic_tags->get_config(), 'ui' => [ 'darkModeStylesheetURL' => ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css', 'defaultGenericFonts' => $kits_manager->get_current_settings( 'default_generic_fonts' ), ], // Empty array for BC to avoid errors. 'i18n' => [], // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0 'responsive' => [ 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(), 'icons_map' => Plugin::$instance->breakpoints->get_responsive_icons_classes_map(), ], 'promotion' => [ 'elements' => $this->promotion->get_elements_promotion(), ], ]; if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) { $config['promotionWidgets'] = Api::get_promotion_widgets(); } $this->bc_move_document_filters(); /** * Localize editor settings. * * Filters the editor localized settings. * * @since 1.0.0 * * @param array $config Editor configuration. * @param int $post_id The ID of the current post being edited. */ $config = apply_filters( 'elementor/editor/localize_settings', $config ); Utils::print_js_config( 'elementor-editor', 'ElementorConfig', $config ); wp_enqueue_script( 'elementor-editor' ); wp_set_script_translations( 'elementor-editor', 'elementor' ); $plugin->controls_manager->enqueue_control_scripts(); /** * After editor enqueue scripts. * * Fires after Elementor editor scripts are enqueued. * * @since 1.0.0 */ do_action( 'elementor/editor/after_enqueue_scripts' ); } /** * Enqueue styles. * * Registers all the editor styles and enqueues them. * * @since 1.0.0 * @access public */ public function enqueue_styles() { /** * Before editor enqueue styles. * * Fires before Elementor editor styles are enqueued. * * @since 1.0.0 */ do_action( 'elementor/editor/before_enqueue_styles' ); $suffix = Utils::is_script_debug() ? '' : '.min'; $direction_suffix = is_rtl() ? '-rtl' : ''; wp_register_style( 'font-awesome', ELEMENTOR_ASSETS_URL . 'lib/font-awesome/css/font-awesome' . $suffix . '.css', [], '4.7.0' ); wp_register_style( 'elementor-select2', ELEMENTOR_ASSETS_URL . 'lib/e-select2/css/e-select2' . $suffix . '.css', [], '4.0.6-rc.1' ); wp_register_style( 'google-font-roboto', 'https://fonts.googleapis.com/css?family=Roboto:300,400,500,700', [], ELEMENTOR_VERSION ); wp_register_style( 'flatpickr', ELEMENTOR_ASSETS_URL . 'lib/flatpickr/flatpickr' . $suffix . '.css', [], '1.12.0' ); wp_register_style( 'pickr', ELEMENTOR_ASSETS_URL . 'lib/pickr/themes/monolith.min.css', [], '1.5.0' ); wp_register_style( 'elementor-editor', ELEMENTOR_ASSETS_URL . 'css/editor' . $direction_suffix . $suffix . '.css', [ 'elementor-common', 'elementor-select2', 'elementor-icons', 'wp-auth-check', 'google-font-roboto', 'flatpickr', 'pickr', ], ELEMENTOR_VERSION ); wp_enqueue_style( 'elementor-editor' ); $ui_theme = SettingsManager::get_settings_managers( 'editorPreferences' )->get_model()->get_settings( 'ui_theme' ); if ( 'light' !== $ui_theme ) { $ui_theme_media_queries = 'all'; if ( 'auto' === $ui_theme ) { $ui_theme_media_queries = '(prefers-color-scheme: dark)'; } wp_enqueue_style( 'elementor-editor-dark-mode', ELEMENTOR_ASSETS_URL . 'css/editor-dark-mode' . $suffix . '.css', [ 'elementor-editor', ], ELEMENTOR_VERSION, $ui_theme_media_queries ); } $breakpoints = Plugin::$instance->breakpoints->get_breakpoints(); // The two breakpoints under 'tablet' need to be checked for values. if ( $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE ]->is_custom() || $breakpoints[ Breakpoints_Manager::BREAKPOINT_KEY_MOBILE_EXTRA ]->is_enabled() ) { wp_add_inline_style( 'elementor-editor', '.elementor-device-tablet #elementor-preview-responsive-wrapper { width: ' . Plugin::$instance->breakpoints->get_device_min_breakpoint( Breakpoints_Manager::BREAKPOINT_KEY_TABLET ) . 'px; }' ); } /** * After editor enqueue styles. * * Fires after Elementor editor styles are enqueued. * * @since 1.0.0 */ do_action( 'elementor/editor/after_enqueue_styles' ); } /** * Get WordPress editor config. * * Config the default WordPress editor with custom settings for Elementor use. * * @since 1.9.0 * @access private */ private function get_wp_editor_config() { // Remove all TinyMCE plugins. remove_all_filters( 'mce_buttons', 10 ); remove_all_filters( 'mce_external_plugins', 10 ); if ( ! class_exists( '\_WP_Editors', false ) ) { require ABSPATH . WPINC . '/class-wp-editor.php'; } // WordPress 4.8 and higher if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) { \_WP_Editors::print_default_editor_scripts(); \_WP_Editors::print_tinymce_scripts(); } ob_start(); wp_editor( '%%EDITORCONTENT%%', 'elementorwpeditor', [ 'editor_class' => 'elementor-wp-editor', 'editor_height' => 250, 'drag_drop_upload' => true, ] ); $config = ob_get_clean(); // Don't call \_WP_Editors methods again remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 ); remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 ); \_WP_Editors::editor_js(); return $config; } /** * Editor head trigger. * * Fires the 'elementor/editor/wp_head' action in the head tag in Elementor * editor. * * @since 1.0.0 * @access public */ public function editor_head_trigger() { /** * Elementor editor head. * * Fires on Elementor editor head tag. * * Used to prints scripts or any other data in the head tag. * * @since 1.0.0 */ do_action( 'elementor/editor/wp_head' ); } /** * WP footer. * * Prints Elementor editor with all the editor templates, and render controls, * widgets and content elements. * * Fired by `wp_footer` action. * * @since 1.0.0 * @access public */ public function wp_footer() { $plugin = Plugin::$instance; $plugin->controls_manager->render_controls(); $plugin->widgets_manager->render_widgets_content(); $plugin->elements_manager->render_elements_content(); $plugin->schemes_manager->print_schemes_templates(); $plugin->dynamic_tags->print_templates(); $this->init_editor_templates(); /** * Elementor editor footer. * * Fires on Elementor editor before closing the body tag. * * Used to prints scripts or any other HTML before closing the body tag. * * @since 1.0.0 */ do_action( 'elementor/editor/footer' ); } /** * Set edit mode. * * Used to update the edit mode. * * @since 1.0.0 * @access public * * @param bool $edit_mode Whether the edit mode is active. */ public function set_edit_mode( $edit_mode ) { $this->is_edit_mode = $edit_mode; } /** * Editor constructor. * * Initializing Elementor editor and redirect from old URL structure of * Elementor editor. * * @since 1.0.0 * @access public */ public function __construct() { Plugin::$instance->data_manager_v2->register_controller( new Data\Globals\Controller() ); $this->notice_bar = new Notice_Bar(); $this->promotion = new Promotion(); add_action( 'admin_action_elementor', [ $this, 'init' ] ); add_action( 'template_redirect', [ $this, 'redirect_to_new_url' ] ); // Handle autocomplete feature for URL control. add_filter( 'wp_link_query_args', [ $this, 'filter_wp_link_query_args' ] ); add_filter( 'wp_link_query', [ $this, 'filter_wp_link_query' ] ); } /** * @since 2.2.0 * @access public */ public function filter_wp_link_query_args( $query ) { $library_cpt_key = array_search( Source_Local::CPT, $query['post_type'], true ); if ( false !== $library_cpt_key ) { unset( $query['post_type'][ $library_cpt_key ] ); } return $query; } /** * @since 2.2.0 * @access public */ public function filter_wp_link_query( $results ) { // PHPCS - The user data is not used. if ( isset( $_POST['editor'] ) && 'elementor' === $_POST['editor'] ) { // phpcs:ignore WordPress.Security.NonceVerification.Missing $post_type_object = get_post_type_object( 'post' ); $post_label = $post_type_object->labels->singular_name; foreach ( $results as & $result ) { if ( 'post' === get_post_type( $result['ID'] ) ) { $result['info'] = $post_label; } } } return $results; } /** * Init editor templates. * * Initialize default elementor templates used in the editor panel. * * @since 1.7.0 * @access private */ private function init_editor_templates() { $template_names = [ 'global', 'panel', 'panel-elements', 'repeater', 'templates', 'navigator', 'hotkeys', 'responsive-bar', ]; foreach ( $template_names as $template_name ) { Plugin::$instance->common->add_template( ELEMENTOR_PATH . "includes/editor-templates/$template_name.php" ); } } private function bc_move_document_filters() { global $wp_filter; $old_tag = 'elementor/editor/localize_settings'; $new_tag = 'elementor/document/config'; if ( ! has_filter( $old_tag ) ) { return; } foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) { foreach ( $filters as $filter_id => $filter_args ) { if ( 2 === $filter_args['accepted_args'] ) { remove_filter( $old_tag, $filter_id, $priority ); add_filter( $new_tag, $filter_args['function'], $priority, 2 ); // TODO: Hard deprecation // _deprecated_hook( '`' . $old_tag . ` is no longer using post_id', '2.9.0', $new_tag' ); } } } } public function set_post_id( $post_id ) { $this->post_id = $post_id; } }