PluginProbe
Elementor Website Builder – more than just a page builder / 3.14.0-beta4
Elementor Website Builder – more than just a page builder v3.14.0-beta4
4.3.4 4.3.3 4.3.2 4.3.1 4.3.0 4.3.0-beta3 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 All 457 releases
elementor / core / editor / config-providers / editor-common-client-env.php

editor-common-client-env.php in Elementor Website Builder – more than just a page builder 3.14.0-beta4, at core/editor/config-providers/editor-common-client-env.php

190 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor\Core\Editor\Config_Providers;
3
4 use Elementor\Api;
5 use Elementor\Core\Debug\Loading_Inspection_Manager;
6 use Elementor\Core\Schemes\Manager as Schemes_Manager;
7 use Elementor\Core\Settings\Manager as SettingsManager;
8 use Elementor\Icons_Manager;
9 use Elementor\Plugin;
10 use Elementor\Settings;
11 use Elementor\Shapes;
12 use Elementor\Tools;
13 use Elementor\User;
14 use Elementor\Utils;
15
16 if ( ! defined( 'ABSPATH' ) ) {
17 exit; // Exit if accessed directly.
18 }
19
20 class Editor_Common_Client_Env {
21 public static function get_client_env() {
22 $settings = SettingsManager::get_settings_managers_config();
23 // Moved to document since 2.9.0.
24 unset( $settings['page'] );
25
26 $document = Plugin::$instance->documents->get_doc_or_auto_save( Plugin::$instance->editor->get_post_id() );
27 $kits_manager = Plugin::$instance->kits_manager;
28
29 $page_title_selector = $kits_manager->get_current_settings( 'page_title_selector' );
30
31 $page_title_selector .= ', .elementor-page-title .elementor-heading-title';
32
33 $client_env = [
34 'initial_document' => $document->get_config(),
35 'version' => ELEMENTOR_VERSION,
36 'home_url' => home_url(),
37 'admin_settings_url' => admin_url( 'admin.php?page=' . Settings::PAGE_ID ),
38 'admin_tools_url' => admin_url( 'admin.php?page=' . Tools::PAGE_ID ),
39 'autosave_interval' => AUTOSAVE_INTERVAL,
40 'tabs' => Plugin::$instance->controls_manager->get_tabs(),
41 'controls' => Plugin::$instance->controls_manager->get_controls_data(),
42 'elements' => Plugin::$instance->elements_manager->get_element_types_config(),
43 'schemes' => [
44 'items' => Plugin::$instance->schemes_manager->get_registered_schemes_data(),
45 'enabled_schemes' => Schemes_Manager::get_enabled_schemes(),
46 ],
47 'globals' => [
48 'defaults_enabled' => [
49 'colors' => $kits_manager->is_custom_colors_enabled(),
50 'typography' => $kits_manager->is_custom_typography_enabled(),
51 ],
52 ],
53 'icons' => [
54 'libraries' => Icons_Manager::get_icon_manager_tabs_config(),
55 'goProURL' => 'https://go.elementor.com/go-pro-icon-library/',
56 ],
57 'fa4_to_fa5_mapping_url' => ELEMENTOR_ASSETS_URL . 'lib/font-awesome/migration/mapping.js',
58 'default_schemes' => Plugin::$instance->schemes_manager->get_schemes_defaults(),
59 'settings' => $settings,
60 'system_schemes' => Plugin::$instance->schemes_manager->get_system_schemes(),
61 'wp_editor' => static::get_wp_editor_config(),
62 'settings_page_link' => Settings::get_url(),
63 'tools_page_link' => Tools::get_url(),
64 'tools_page_nonce' => wp_create_nonce( 'tools-page-from-editor' ),
65 'elementor_site' => 'https://go.elementor.com/about-elementor/',
66 'docs_elementor_site' => 'https://go.elementor.com/docs/',
67 'help_the_content_url' => 'https://go.elementor.com/the-content-missing/',
68 'help_flexbox_bc_url' => 'https://go.elementor.com/flexbox-layout-bc/',
69 'elementPromotionURL' => 'https://go.elementor.com/go-pro-%s',
70 'dynamicPromotionURL' => 'https://go.elementor.com/go-pro-dynamic-tag',
71 'additional_shapes' => Shapes::get_additional_shapes_for_config(),
72 'user' => [
73 'restrictions' => Plugin::$instance->role_manager->get_user_restrictions_array(),
74 'is_administrator' => current_user_can( 'manage_options' ),
75 'introduction' => User::get_introduction_meta(),
76 'locale' => get_user_locale(),
77 ],
78 'preview' => [
79 'help_preview_error_url' => 'https://go.elementor.com/preview-not-loaded/',
80 'help_preview_http_error_url' => 'https://go.elementor.com/preview-not-loaded/#permissions',
81 'help_preview_http_error_500_url' => 'https://go.elementor.com/500-error/',
82 'debug_data' => Loading_Inspection_Manager::instance()->run_inspections(),
83 ],
84 'locale' => get_locale(),
85 'rich_editing_enabled' => filter_var( get_user_meta( get_current_user_id(), 'rich_editing', true ), FILTER_VALIDATE_BOOLEAN ),
86 'page_title_selector' => $page_title_selector,
87 'tinymceHasCustomConfig' => class_exists( 'Tinymce_Advanced' ) || class_exists( 'Advanced_Editor_Tools' ),
88 'inlineEditing' => Plugin::$instance->widgets_manager->get_inline_editing_config(),
89 'dynamicTags' => Plugin::$instance->dynamic_tags->get_config(),
90 'ui' => [
91 'defaultGenericFonts' => $kits_manager->get_current_settings( 'default_generic_fonts' ),
92 ],
93 // Empty array for BC to avoid errors.
94 'i18n' => [],
95 // 'responsive' contains the custom breakpoints config introduced in Elementor v3.2.0
96 'responsive' => [
97 'breakpoints' => Plugin::$instance->breakpoints->get_breakpoints_config(),
98 'icons_map' => Plugin::$instance->breakpoints->get_responsive_icons_classes_map(),
99 ],
100 'promotion' => [
101 'elements' => Plugin::$instance->editor->promotion->get_elements_promotion(),
102 ],
103 ];
104
105 if ( ! Utils::has_pro() && current_user_can( 'manage_options' ) ) {
106 $client_env['promotionWidgets'] = Api::get_promotion_widgets();
107 }
108
109 static::bc_move_document_filters();
110
111 /**
112 * Localize editor settings.
113 *
114 * Filters the editor localized settings.
115 *
116 * @since 1.0.0
117 *
118 * @param array $client_env Editor configuration.
119 * @param int $post_id The ID of the current post being edited.
120 */
121 return apply_filters( 'elementor/editor/localize_settings', $client_env );
122 }
123
124 private static function bc_move_document_filters() {
125 global $wp_filter;
126
127 $old_tag = 'elementor/editor/localize_settings';
128 $new_tag = 'elementor/document/config';
129
130 if ( ! has_filter( $old_tag ) ) {
131 return;
132 }
133
134 foreach ( $wp_filter[ $old_tag ] as $priority => $filters ) {
135 foreach ( $filters as $filter_id => $filter_args ) {
136 if ( 2 === $filter_args['accepted_args'] ) {
137 remove_filter( $old_tag, $filter_id, $priority );
138
139 add_filter( $new_tag, $filter_args['function'], $priority, 2 );
140 }
141 }
142 }
143 }
144
145 /**
146 * Get WordPress editor config.
147 *
148 * Config the default WordPress editor with custom settings for Elementor use.
149 *
150 * @since 1.9.0
151 * @access private
152 */
153 private static function get_wp_editor_config() {
154 // Remove all TinyMCE plugins.
155 remove_all_filters( 'mce_buttons', 10 );
156 remove_all_filters( 'mce_external_plugins', 10 );
157
158 if ( ! class_exists( '\_WP_Editors', false ) ) {
159 require ABSPATH . WPINC . '/class-wp-editor.php';
160 }
161
162 // WordPress 4.8 and higher
163 if ( method_exists( '\_WP_Editors', 'print_tinymce_scripts' ) ) {
164 \_WP_Editors::print_default_editor_scripts();
165 \_WP_Editors::print_tinymce_scripts();
166 }
167 ob_start();
168
169 wp_editor(
170 '%%EDITORCONTENT%%',
171 'elementorwpeditor',
172 [
173 'editor_class' => 'elementor-wp-editor',
174 'editor_height' => 250,
175 'drag_drop_upload' => true,
176 ]
177 );
178
179 $config = ob_get_clean();
180
181 // Don't call \_WP_Editors methods again
182 remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'editor_js' ], 50 );
183 remove_action( 'admin_print_footer_scripts', [ '_WP_Editors', 'print_default_editor_scripts' ], 45 );
184
185 \_WP_Editors::editor_js();
186
187 return $config;
188 }
189 }
190