PluginProbe
Elementor Website Builder – more than just a page builder / 3.13.0-beta1
Elementor Website Builder – more than just a page builder v3.13.0-beta1
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-settings.php

editor-common-client-settings.php in Elementor Website Builder – more than just a page builder 3.13.0-beta1, at core/editor/config-providers/editor-common-client-settings.php

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