PluginProbe
Elementor Website Builder – more than just a page builder / 3.9.0
Elementor Website Builder – more than just a page builder v3.9.0
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 | includes/settings/settings.php +132 -165 4.2.03.9.0 View file →
@@ -1,13 +1,13 @@
1 1 <?php
2 2 namespace Elementor;
3 3
4 -use Elementor\Core\Files\Fonts\Google_Font;
4 +use Elementor\Core\Admin\Menu\Admin_Menu_Manager;
5 +use Elementor\Includes\Settings\AdminMenuItems\Admin_Menu_Item;
6 +use Elementor\Includes\Settings\AdminMenuItems\Get_Help_Menu_Item;
7 +use Elementor\Includes\Settings\AdminMenuItems\Getting_Started_Menu_Item;
5 8 use Elementor\Modules\Promotions\Module as Promotions_Module;
6 9 use Elementor\TemplateLibrary\Source_Local;
7 -use Elementor\Modules\EditorOne\Classes\Menu_Data_Provider;
8 -use Elementor\Includes\Settings\AdminMenuItems\Editor_One_Home_Menu;
9 -use Elementor\Includes\Settings\AdminMenuItems\Editor_One_Settings_Menu;
10 10
11 11 if ( ! defined( 'ABSPATH' ) ) {
12 12 exit; // Exit if accessed directly.
13 13 }
@@ -42,8 +42,13 @@
42 42 */
43 43 const TAB_GENERAL = 'general';
44 44
45 45 /**
46 + * Settings page style tab slug.
47 + */
48 + const TAB_STYLE = 'style';
49 +
50 + /**
46 51 * Settings page integrations tab slug.
47 52 */
48 53 const TAB_INTEGRATIONS = 'integrations';
49 54
@@ -51,17 +56,10 @@
51 56 * Settings page advanced tab slug.
52 57 */
53 58 const TAB_ADVANCED = 'advanced';
54 59
55 - /**
56 - * Settings page performance tab slug.
57 - */
58 - const TAB_PERFORMANCE = 'performance';
59 -
60 60 const ADMIN_MENU_PRIORITY = 10;
61 61
62 - const MENU_CAPABILITY_EDIT_POSTS = 'edit_posts';
63 -
64 62 /**
65 63 * Register admin menu.
66 64 *
67 65 * Add new Elementor Settings admin menu.
@@ -71,9 +69,13 @@
71 69 * @since 1.0.0
72 70 * @access public
73 71 */
74 72 public function register_admin_menu() {
75 - if ( ! current_user_can( self::MENU_CAPABILITY_EDIT_POSTS ) ) {
73 + global $menu;
74 +
75 + $menu[] = [ '', 'read', 'separator-elementor', '', 'wp-menu-separator elementor' ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
76 +
77 + if ( ! current_user_can( 'manage_options' ) ) {
76 78 return;
77 79 }
78 80
79 81 add_menu_page(
@@ -78,26 +80,87 @@
78 80
79 81 add_menu_page(
80 82 esc_html__( 'Elementor', 'elementor' ),
81 83 esc_html__( 'Elementor', 'elementor' ),
82 - self::MENU_CAPABILITY_EDIT_POSTS,
84 + 'manage_options',
83 85 self::PAGE_ID,
84 - [ $this, 'display_home_screen' ],
86 + [ $this, 'display_settings_page' ],
85 87 '',
86 88 '58.5'
87 89 );
88 90 }
89 91
90 - public function display_home_screen() {
91 - echo '<div id="e-home-screen"></div>';
92 + /**
93 + * Reorder the Elementor menu items in admin.
94 + * Based on WC.
95 + *
96 + * @since 2.4.0
97 + *
98 + * @param array $menu_order Menu order.
99 + * @return array
100 + */
101 + public function menu_order( $menu_order ) {
102 + // Initialize our custom order array.
103 + $elementor_menu_order = [];
104 +
105 + // Get the index of our custom separator.
106 + $elementor_separator = array_search( 'separator-elementor', $menu_order, true );
107 +
108 + // Get index of library menu.
109 + $elementor_library = array_search( Source_Local::ADMIN_MENU_SLUG, $menu_order, true );
110 +
111 + // Loop through menu order and do some rearranging.
112 + foreach ( $menu_order as $index => $item ) {
113 + if ( 'elementor' === $item ) {
114 + $elementor_menu_order[] = 'separator-elementor';
115 + $elementor_menu_order[] = $item;
116 + $elementor_menu_order[] = Source_Local::ADMIN_MENU_SLUG;
117 +
118 + unset( $menu_order[ $elementor_separator ] );
119 + unset( $menu_order[ $elementor_library ] );
120 + } elseif ( ! in_array( $item, [ 'separator-elementor' ], true ) ) {
121 + $elementor_menu_order[] = $item;
122 + }
123 + }
124 +
125 + // Return order.
126 + return $elementor_menu_order;
92 127 }
93 128
94 - private function register_editor_one_settings_menu( Menu_Data_Provider $menu_data_provider ) {
95 - $menu_data_provider->register_menu( new Editor_One_Settings_Menu() );
129 + /**
130 + * Register Elementor knowledge base sub-menu.
131 + *
132 + * Add new Elementor knowledge base sub-menu under the main Elementor menu.
133 + *
134 + * Fired by `admin_menu` action.
135 + *
136 + * @since 2.0.3
137 + * @access private
138 + */
139 + private function register_knowledge_base_menu( Admin_Menu_Manager $admin_menu ) {
140 + $admin_menu->register( 'elementor-getting-started', new Getting_Started_Menu_Item() );
141 + $admin_menu->register( 'go_knowledge_base_site', new Get_Help_Menu_Item() );
96 142 }
97 143
98 - private function register_editor_one_home_menu( Menu_Data_Provider $menu_data_provider ) {
99 - $menu_data_provider->register_menu( new Editor_One_Home_Menu() );
144 + /**
145 + * Go Elementor Pro.
146 + *
147 + * Redirect the Elementor Pro page the clicking the Elementor Pro menu link.
148 + *
149 + * Fired by `admin_init` action.
150 + *
151 + * @since 2.0.3
152 + * @access public
153 + */
154 + public function handle_external_redirects() {
155 + if ( empty( $_GET['page'] ) ) {
156 + return;
157 + }
158 +
159 + if ( 'go_knowledge_base_site' === $_GET['page'] ) {
160 + wp_redirect( Get_Help_Menu_Item::URL );
161 + die;
162 + }
100 163 }
101 164
102 165 /**
103 166 * On admin init.
@@ -109,12 +172,28 @@
109 172 * @since 2.0.0
110 173 * @access public
111 174 */
112 175 public function on_admin_init() {
176 + $this->handle_external_redirects();
177 +
113 178 $this->maybe_remove_all_admin_notices();
114 179 }
115 180
116 181 /**
182 + * Change "Settings" menu name.
183 + *
184 + * Update the name of the Settings admin menu from "Elementor" to "Settings".
185 + *
186 + * Fired by `admin_menu` action.
187 + *
188 + * @since 1.0.0
189 + * @access public
190 + */
191 + public function admin_menu_change_name() {
192 + Utils::change_submenu_first_item_label( 'elementor', esc_html__( 'Settings', 'elementor' ) );
193 + }
194 +
195 + /**
117 196 * Update CSS print method.
118 197 *
119 198 * Clear post CSS cache.
120 199 *
@@ -122,9 +201,9 @@
122 201 * `update_option_elementor_css_print_method` actions.
123 202 *
124 203 * @since 1.7.5
125 204 * @access public
126 - * @deprecated 3.0.0 Use `Plugin::$instance->files_manager->clear_cache()` method instead.
205 + * @deprecated 3.0.0
127 206 */
128 207 public function update_css_print_method() {
129 208 Plugin::$instance->files_manager->clear_cache();
130 209 }
@@ -146,15 +225,8 @@
146 225 self::TAB_GENERAL => [
147 226 'label' => esc_html__( 'General', 'elementor' ),
148 227 'sections' => [
149 228 'general' => [
150 - 'label' => esc_html__( 'General', 'elementor' ),
151 - 'callback' => function() {
152 - printf(
153 - '<p>%s</p><br><hr><br>',
154 - esc_html__( 'Tailor how Elementor enhances your site, from post types to other functions.', 'elementor' )
155 - );
156 - },
157 229 'fields' => [
158 230 self::UPDATE_TIME_FIELD => [
159 231 'full_field_id' => self::UPDATE_TIME_FIELD,
160 232 'field_args' => [
@@ -223,16 +295,22 @@
223 295 self::TAB_ADVANCED => [
224 296 'label' => esc_html__( 'Advanced', 'elementor' ),
225 297 'sections' => [
226 298 'advanced' => [
227 - 'label' => esc_html__( 'Advanced', 'elementor' ),
228 - 'callback' => function() {
229 - printf(
230 - '<p>%s</p><br><hr><br>',
231 - esc_html__( 'Personalize the way Elementor works on your website by choosing the advanced features and how they operate.', 'elementor' )
232 - );
233 - },
234 299 'fields' => [
300 + 'css_print_method' => [
301 + 'label' => esc_html__( 'CSS Print Method', 'elementor' ),
302 + 'field_args' => [
303 + 'class' => 'elementor_css_print_method',
304 + 'type' => 'select',
305 + 'std' => 'external',
306 + 'options' => [
307 + 'external' => esc_html__( 'External File', 'elementor' ),
308 + 'internal' => esc_html__( 'Internal Embedding', 'elementor' ),
309 + ],
310 + 'desc' => '<div class="elementor-css-print-method-description" data-value="external" style="display: none">' . esc_html__( 'Use external CSS files for all generated stylesheets. Choose this setting for better performance (recommended).', 'elementor' ) . '</div><div class="elementor-css-print-method-description" data-value="internal" style="display: none">' . esc_html__( 'Use internal CSS that is embedded in the head of the page. For troubleshooting server configuration conflicts and managing development environments.', 'elementor' ) . '</div>',
311 + ],
312 + ],
235 313 'editor_break_lines' => [
236 314 'label' => esc_html__( 'Switch Editor Loader Method', 'elementor' ),
237 315 'field_args' => [
238 316 'type' => 'select',
@@ -255,25 +333,8 @@
255 333 ],
256 334 'desc' => esc_html__( 'Please note! Allowing uploads of any files (SVG & JSON included) is a potential security risk.', 'elementor' ) . '<br>' . esc_html__( 'Elementor will try to sanitize the unfiltered files, removing potential malicious code and scripts.', 'elementor' ) . '<br>' . esc_html__( 'We recommend you only enable this feature if you understand the security risks involved.', 'elementor' ),
257 335 ],
258 336 ],
259 - 'google_font' => [
260 - 'label' => esc_html__( 'Google Fonts', 'elementor' ),
261 - 'field_args' => [
262 - 'type' => 'select',
263 - 'std' => '1',
264 - 'options' => [
265 - '1' => esc_html__( 'Enable', 'elementor' ),
266 - '0' => esc_html__( 'Disable', 'elementor' ),
267 - ],
268 - 'desc' => sprintf(
269 - /* translators: 1: Link opening tag, 2: Link closing tag */
270 - esc_html__( 'Disable this option if you want to prevent Google Fonts from being loaded. This setting is recommended when loading fonts from a different source (plugin, theme or %1$scustom fonts%2$s).', 'elementor' ),
271 - '<a href="' . admin_url( 'admin.php?page=elementor_custom_fonts' ) . '">',
272 - '</a>'
273 - ),
274 - ],
275 - ],
276 337 'font_display' => [
277 338 'label' => esc_html__( 'Google Fonts Load', 'elementor' ),
278 339 'field_args' => [
279 340 'type' => 'select',
@@ -284,9 +345,9 @@
284 345 'swap' => esc_html__( 'Swap', 'elementor' ),
285 346 'fallback' => esc_html__( 'Fallback', 'elementor' ),
286 347 'optional' => esc_html__( 'Optional', 'elementor' ),
287 348 ],
288 - 'desc' => esc_html__( 'Font-display property defines how font files are loaded and displayed by the browser.', 'elementor' ) . '<br>' . esc_html__( 'Set the way Google Fonts are being loaded by selecting the font-display property (Recommended: Swap).', 'elementor' ),
349 + 'desc' => esc_html__( 'Font-display property defines how font files are loaded and displayed by the browser.', 'elementor' ) . '<br>' . esc_html__( 'Set the way Google Fonts are being loaded by selecting the font-display property (Default: Auto).', 'elementor' ),
289 350 ],
290 351 ],
291 352 ],
292 353 ],
@@ -291,94 +352,8 @@
291 352 ],
292 353 ],
293 354 ],
294 355 ],
295 - self::TAB_PERFORMANCE => [
296 - 'label' => esc_html__( 'Performance', 'elementor' ),
297 - 'sections' => [
298 - 'performance' => [
299 - 'label' => esc_html__( 'Performance', 'elementor' ),
300 - 'callback' => function() {
301 - printf(
302 - '<p>%s</p><br><hr><br>',
303 - esc_html__( 'Improve loading times on your site by selecting the optimization tools that best fit your requirements.', 'elementor' )
304 - );
305 - },
306 - 'fields' => [
307 - 'css_print_method' => [
308 - 'label' => esc_html__( 'CSS Print Method', 'elementor' ),
309 - 'field_args' => [
310 - 'class' => 'elementor_css_print_method',
311 - 'type' => 'select',
312 - 'std' => 'external',
313 - 'options' => [
314 - 'external' => esc_html__( 'External File', 'elementor' ),
315 - 'internal' => esc_html__( 'Internal Embedding', 'elementor' ),
316 - ],
317 - 'desc' => sprintf(
318 - /* translators: %s: <head> tag. */
319 - esc_html__( 'Internal Embedding places all CSS in the %s which works great for troubleshooting, while External File uses external CSS file for better performance (recommended).', 'elementor' ),
320 - '<code>&lt;head&gt;</code>',
321 - ),
322 - ],
323 - ],
324 - 'optimized_image_loading' => [
325 - 'label' => esc_html__( 'Optimized Image Loading', 'elementor' ),
326 - 'field_args' => [
327 - 'type' => 'select',
328 - 'std' => '1',
329 - 'options' => [
330 - '1' => esc_html__( 'Enable', 'elementor' ),
331 - '0' => esc_html__( 'Disable', 'elementor' ),
332 - ],
333 - 'desc' => sprintf(
334 - /* translators: 1: fetchpriority attribute, 2: lazy loading attribute. */
335 - esc_html__( 'Improve performance by applying %1$s on LCP image and %2$s on images below the fold.', 'elementor' ),
336 - '<code>fetchpriority="high"</code>',
337 - '<code>loading="lazy"</code>'
338 - ),
339 - ],
340 - ],
341 - 'optimized_gutenberg_loading' => [
342 - 'label' => esc_html__( 'Optimized Gutenberg Loading', 'elementor' ),
343 - 'field_args' => [
344 - 'type' => 'select',
345 - 'std' => '1',
346 - 'options' => [
347 - '1' => esc_html__( 'Enable', 'elementor' ),
348 - '0' => esc_html__( 'Disable', 'elementor' ),
349 - ],
350 - 'desc' => esc_html__( 'Reduce unnecessary render-blocking loads by dequeuing unused Gutenberg block editor scripts and styles.', 'elementor' ),
351 - ],
352 - ],
353 - 'lazy_load_background_images' => [
354 - 'label' => esc_html__( 'Lazy Load Background Images', 'elementor' ),
355 - 'field_args' => [
356 - 'type' => 'select',
357 - 'std' => '1',
358 - 'options' => [
359 - '1' => esc_html__( 'Enable', 'elementor' ),
360 - '0' => esc_html__( 'Disable', 'elementor' ),
361 - ],
362 - 'desc' => esc_html__( 'Improve initial page load performance by lazy loading all background images except the first one.', 'elementor' ),
363 - ],
364 - ],
365 - 'local_google_fonts' => [
366 - 'label' => esc_html__( 'Load Google Fonts Locally', 'elementor' ),
367 - 'field_args' => [
368 - 'type' => 'select',
369 - 'std' => '0',
370 - 'options' => [
371 - '1' => esc_html__( 'Enable', 'elementor' ),
372 - '0' => esc_html__( 'Disable', 'elementor' ),
373 - ],
374 - 'desc' => esc_html__( 'Load Google fonts locally to benefit from faster performance and ensure GDPR compliance. Fonts will be served from your own server instead of Google’s. Only the very first load (in the editor and on the front end) may take slightly longer.', 'elementor' ),
375 - ],
376 - ],
377 - ],
378 - ],
379 - ],
380 - ],
381 356 ];
382 357 }
383 358
384 359 /**
@@ -391,8 +366,12 @@
391 366 *
392 367 * @return string Settings page title.
393 368 */
394 369 protected function get_page_title() {
370 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
371 + return esc_html__( 'Settings', 'elementor' );
372 + }
373 +
395 374 return esc_html__( 'Elementor', 'elementor' );
396 375 }
397 376
398 377 /**
@@ -400,16 +379,15 @@
400 379 * @access private
401 380 */
402 381 private function maybe_remove_all_admin_notices() {
403 382 $elementor_pages = [
404 - 'elementor-system-info',
405 - 'e-form-submissions',
383 + 'elementor-getting-started',
406 384 'elementor_custom_fonts',
407 385 'elementor_custom_icons',
408 386 'elementor-license',
409 - 'elementor_custom_code',
387 + 'e-form-submissions',
388 + 'elementor_custom_custom_code',
410 389 'popup_templates',
411 - 'elementor-apps',
412 390 ];
413 391
414 392 if ( empty( $_GET['page'] ) || ! in_array( $_GET['page'], $elementor_pages, true ) ) {
415 393 return;
@@ -417,21 +395,8 @@
417 395
418 396 remove_all_actions( 'admin_notices' );
419 397 }
420 398
421 - public function add_generator_tag_settings( $settings ) {
422 - $css_print_method = get_option( 'elementor_css_print_method', 'external' );
423 - $settings[] = 'css_print_method-' . $css_print_method;
424 -
425 - $google_font = Fonts::is_google_fonts_enabled() ? 'enabled' : 'disabled';
426 - $settings[] = 'google_font-' . $google_font;
427 -
428 - $font_display = Fonts::get_font_display_setting();
429 - $settings[] = 'font_display-' . $font_display;
430 -
431 - return $settings;
432 - }
433 -
434 399 /**
435 400 * Settings page constructor.
436 401 *
437 402 * Initializing Elementor "Settings" page.
@@ -442,17 +407,22 @@
442 407 public function __construct() {
443 408 parent::__construct();
444 409
445 410 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
446 - add_filter( 'elementor/generator_tag/settings', [ $this, 'add_generator_tag_settings' ] );
447 411
448 - add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
412 + if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
413 + add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
449 414
450 - add_action( 'elementor/editor-one/menu/register', function ( Menu_Data_Provider $menu_data_provider ) {
451 - $this->register_editor_one_settings_menu( $menu_data_provider );
452 - $this->register_editor_one_home_menu( $menu_data_provider );
453 - } );
415 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
416 + $this->register_knowledge_base_menu( $admin_menu );
417 + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 );
454 418
419 + add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
420 +
421 + add_filter( 'custom_menu_order', '__return_true' );
422 + add_filter( 'menu_order', [ $this, 'menu_order' ] );
423 + }
424 +
455 425 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
456 426
457 427 // Clear CSS Meta after change css related methods.
458 428 $css_settings = [
@@ -458,9 +428,8 @@
458 428 $css_settings = [
459 429 'elementor_disable_color_schemes',
460 430 'elementor_disable_typography_schemes',
461 431 'elementor_css_print_method',
462 - 'elementor_local_google_fonts',
463 432 ];
464 433
465 434 foreach ( $css_settings as $option_name ) {
466 435 add_action( "add_option_{$option_name}", $clear_cache_callback );
@@ -465,8 +434,6 @@
465 434 foreach ( $css_settings as $option_name ) {
466 435 add_action( "add_option_{$option_name}", $clear_cache_callback );
467 436 add_action( "update_option_{$option_name}", $clear_cache_callback );
468 437 }
469 -
470 - add_action( 'update_option_elementor_font_display', [ Google_Font::class, 'clear_cache' ] );
471 438 }
472 439 }