PluginProbe
Elementor Website Builder – more than just a page builder / 3.21.4
Elementor Website Builder – more than just a page builder v3.21.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 | includes/settings/settings.php +156 -105 4.2.23.21.4 View file →
@@ -1,13 +1,15 @@
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\Core\Settings\Manager as SettingsManager;
6 +use Elementor\Includes\Settings\AdminMenuItems\Admin_Menu_Item;
7 +use Elementor\Includes\Settings\AdminMenuItems\Get_Help_Menu_Item;
8 +use Elementor\Includes\Settings\AdminMenuItems\Getting_Started_Menu_Item;
5 9 use Elementor\Modules\Promotions\Module as Promotions_Module;
6 10 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;
11 +use Elementor\Modules\Home\Module as Home_Module;
10 12
11 13 if ( ! defined( 'ABSPATH' ) ) {
12 14 exit; // Exit if accessed directly.
13 15 }
@@ -42,8 +44,13 @@
42 44 */
43 45 const TAB_GENERAL = 'general';
44 46
45 47 /**
48 + * Settings page style tab slug.
49 + */
50 + const TAB_STYLE = 'style';
51 +
52 + /**
46 53 * Settings page integrations tab slug.
47 54 */
48 55 const TAB_INTEGRATIONS = 'integrations';
49 56
@@ -51,16 +58,11 @@
51 58 * Settings page advanced tab slug.
52 59 */
53 60 const TAB_ADVANCED = 'advanced';
54 61
55 - /**
56 - * Settings page performance tab slug.
57 - */
58 - const TAB_PERFORMANCE = 'performance';
59 -
60 62 const ADMIN_MENU_PRIORITY = 10;
61 63
62 - const MENU_CAPABILITY_EDIT_POSTS = 'edit_posts';
64 + public Home_Module $home_module;
63 65
64 66 /**
65 67 * Register admin menu.
66 68 *
@@ -71,9 +73,13 @@
71 73 * @since 1.0.0
72 74 * @access public
73 75 */
74 76 public function register_admin_menu() {
75 - if ( ! current_user_can( self::MENU_CAPABILITY_EDIT_POSTS ) ) {
77 + global $menu;
78 +
79 + $menu[] = [ '', 'read', 'separator-elementor', '', 'wp-menu-separator elementor' ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
80 +
81 + if ( ! current_user_can( 'manage_options' ) ) {
76 82 return;
77 83 }
78 84
79 85 add_menu_page(
@@ -78,14 +84,23 @@
78 84
79 85 add_menu_page(
80 86 esc_html__( 'Elementor', 'elementor' ),
81 87 esc_html__( 'Elementor', 'elementor' ),
82 - self::MENU_CAPABILITY_EDIT_POSTS,
88 + 'manage_options',
83 89 self::PAGE_ID,
84 - [ $this, 'display_home_screen' ],
90 + [
91 + $this,
92 + $this->home_module->is_experiment_active() ? 'display_home_screen' : 'display_settings_page',
93 + ],
85 94 '',
86 95 '58.5'
87 96 );
97 +
98 + if ( $this->home_module->is_experiment_active() ) {
99 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
100 + $admin_menu->register( 'elementor-settings', new Admin_Menu_Item( $this ) );
101 + }, 0 );
102 + }
88 103 }
89 104
90 105 public function display_home_screen() {
91 106 echo '<div id="e-home-screen"></div>';
@@ -90,17 +105,82 @@
90 105 public function display_home_screen() {
91 106 echo '<div id="e-home-screen"></div>';
92 107 }
93 108
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() );
109 + /**
110 + * Reorder the Elementor menu items in admin.
111 + * Based on WC.
112 + *
113 + * @since 2.4.0
114 + *
115 + * @param array $menu_order Menu order.
116 + * @return array
117 + */
118 + public function menu_order( $menu_order ) {
119 + // Initialize our custom order array.
120 + $elementor_menu_order = [];
121 +
122 + // Get the index of our custom separator.
123 + $elementor_separator = array_search( 'separator-elementor', $menu_order, true );
124 +
125 + // Get index of library menu.
126 + $elementor_library = array_search( Source_Local::ADMIN_MENU_SLUG, $menu_order, true );
127 +
128 + // Loop through menu order and do some rearranging.
129 + foreach ( $menu_order as $index => $item ) {
130 + if ( 'elementor' === $item ) {
131 + $elementor_menu_order[] = 'separator-elementor';
132 + $elementor_menu_order[] = $item;
133 + $elementor_menu_order[] = Source_Local::ADMIN_MENU_SLUG;
134 +
135 + unset( $menu_order[ $elementor_separator ] );
136 + unset( $menu_order[ $elementor_library ] );
137 + } elseif ( ! in_array( $item, [ 'separator-elementor' ], true ) ) {
138 + $elementor_menu_order[] = $item;
139 + }
140 + }
141 +
142 + // Return order.
143 + return $elementor_menu_order;
96 144 }
97 145
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() );
146 + /**
147 + * Register Elementor knowledge base sub-menu.
148 + *
149 + * Add new Elementor knowledge base sub-menu under the main Elementor menu.
150 + *
151 + * Fired by `admin_menu` action.
152 + *
153 + * @since 2.0.3
154 + * @access private
155 + */
156 + private function register_knowledge_base_menu( Admin_Menu_Manager $admin_menu ) {
157 + $admin_menu->register( 'elementor-getting-started', new Getting_Started_Menu_Item() );
158 + $admin_menu->register( 'go_knowledge_base_site', new Get_Help_Menu_Item() );
100 159 }
101 160
102 161 /**
162 + * Go Elementor Pro.
163 + *
164 + * Redirect the Elementor Pro page the clicking the Elementor Pro menu link.
165 + *
166 + * Fired by `admin_init` action.
167 + *
168 + * @since 2.0.3
169 + * @access public
170 + */
171 + public function handle_external_redirects() {
172 + if ( empty( $_GET['page'] ) ) {
173 + return;
174 + }
175 +
176 + if ( 'go_knowledge_base_site' === $_GET['page'] ) {
177 + wp_redirect( Get_Help_Menu_Item::URL );
178 + die;
179 + }
180 + }
181 +
182 + /**
103 183 * On admin init.
104 184 *
105 185 * Preform actions on WordPress admin initialization.
106 186 *
@@ -109,12 +189,32 @@
109 189 * @since 2.0.0
110 190 * @access public
111 191 */
112 192 public function on_admin_init() {
193 + $this->handle_external_redirects();
194 +
113 195 $this->maybe_remove_all_admin_notices();
114 196 }
115 197
116 198 /**
199 + * Change "Settings" menu name.
200 + *
201 + * Update the name of the Settings admin menu from "Elementor" to "Settings".
202 + *
203 + * Fired by `admin_menu` action.
204 + *
205 + * @since 1.0.0
206 + * @access public
207 + */
208 + public function admin_menu_change_name() {
209 + $menu_name = $this->home_module->is_experiment_active()
210 + ? esc_html__( 'Home', 'elementor' )
211 + : esc_html__( 'Settings', 'elementor' );
212 +
213 + Utils::change_submenu_first_item_label( 'elementor', $menu_name );
214 + }
215 +
216 + /**
117 217 * Update CSS print method.
118 218 *
119 219 * Clear post CSS cache.
120 220 *
@@ -146,15 +246,8 @@
146 246 self::TAB_GENERAL => [
147 247 'label' => esc_html__( 'General', 'elementor' ),
148 248 'sections' => [
149 249 '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 250 'fields' => [
158 251 self::UPDATE_TIME_FIELD => [
159 252 'full_field_id' => self::UPDATE_TIME_FIELD,
160 253 'field_args' => [
@@ -223,16 +316,22 @@
223 316 self::TAB_ADVANCED => [
224 317 'label' => esc_html__( 'Advanced', 'elementor' ),
225 318 'sections' => [
226 319 '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 320 'fields' => [
321 + 'css_print_method' => [
322 + 'label' => esc_html__( 'CSS Print Method', 'elementor' ),
323 + 'field_args' => [
324 + 'class' => 'elementor_css_print_method',
325 + 'type' => 'select',
326 + 'std' => 'external',
327 + 'options' => [
328 + 'external' => esc_html__( 'External File', 'elementor' ),
329 + 'internal' => esc_html__( 'Internal Embedding', 'elementor' ),
330 + ],
331 + '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>',
332 + ],
333 + ],
235 334 'editor_break_lines' => [
236 335 'label' => esc_html__( 'Switch Editor Loader Method', 'elementor' ),
237 336 'field_args' => [
238 337 'type' => 'select',
@@ -265,9 +364,8 @@
265 364 '1' => esc_html__( 'Enable', 'elementor' ),
266 365 '0' => esc_html__( 'Disable', 'elementor' ),
267 366 ],
268 367 'desc' => sprintf(
269 - /* translators: 1: Link opening tag, 2: Link closing tag */
270 368 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 369 '<a href="' . admin_url( 'admin.php?page=elementor_custom_fonts' ) . '">',
272 370 '</a>'
273 371 ),
@@ -284,42 +382,21 @@
284 382 'swap' => esc_html__( 'Swap', 'elementor' ),
285 383 'fallback' => esc_html__( 'Fallback', 'elementor' ),
286 384 'optional' => esc_html__( 'Optional', 'elementor' ),
287 385 ],
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' ),
386 + '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 387 ],
290 388 ],
291 - ],
292 - ],
293 - ],
294 - ],
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' ),
389 + 'optimized_gutenberg_loading' => [
390 + 'label' => esc_html__( 'Optimized Gutenberg Loading', 'elementor' ),
309 391 'field_args' => [
310 - 'class' => 'elementor_css_print_method',
311 392 'type' => 'select',
312 - 'std' => 'external',
393 + 'std' => '1',
313 394 'options' => [
314 - 'external' => esc_html__( 'External File', 'elementor' ),
315 - 'internal' => esc_html__( 'Internal Embedding', 'elementor' ),
395 + '1' => esc_html__( 'Enable', 'elementor' ),
396 + '0' => esc_html__( 'Disable', 'elementor' ),
316 397 ],
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 - ),
398 + 'desc' => esc_html__( 'Use this experiment to reduce unnecessary render-blocking loads, enhancing site performance by dequeuing unused Gutenberg block editor files (styles and scripts).', 'elementor' ),
322 399 ],
323 400 ],
324 401 'optimized_image_loading' => [
325 402 'label' => esc_html__( 'Optimized Image Loading', 'elementor' ),
@@ -331,50 +408,14 @@
331 408 '0' => esc_html__( 'Disable', 'elementor' ),
332 409 ],
333 410 'desc' => sprintf(
334 411 /* 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' ),
412 + esc_html__( 'Applying %1$s on LCP image and %2$s on images below the fold to improve performance scores.', 'elementor' ),
336 413 '<code>fetchpriority="high"</code>',
337 414 '<code>loading="lazy"</code>'
338 415 ),
339 416 ],
340 417 ],
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 418 ],
378 419 ],
379 420 ],
380 421 ],
@@ -391,8 +432,12 @@
391 432 *
392 433 * @return string Settings page title.
393 434 */
394 435 protected function get_page_title() {
436 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
437 + return esc_html__( 'Settings', 'elementor' );
438 + }
439 +
395 440 return esc_html__( 'Elementor', 'elementor' );
396 441 }
397 442
398 443 /**
@@ -400,8 +445,9 @@
400 445 * @access private
401 446 */
402 447 private function maybe_remove_all_admin_notices() {
403 448 $elementor_pages = [
449 + 'elementor-getting-started',
404 450 'elementor-system-info',
405 451 'e-form-submissions',
406 452 'elementor_custom_fonts',
407 453 'elementor_custom_icons',
@@ -441,18 +487,26 @@
441 487 */
442 488 public function __construct() {
443 489 parent::__construct();
444 490
491 + $this->home_module = new Home_Module();
492 +
445 493 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
446 494 add_filter( 'elementor/generator_tag/settings', [ $this, 'add_generator_tag_settings' ] );
447 495
448 - add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
496 + if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
497 + add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
449 498
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 - } );
499 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
500 + $this->register_knowledge_base_menu( $admin_menu );
501 + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 );
454 502
503 + add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
504 +
505 + add_filter( 'custom_menu_order', '__return_true' );
506 + add_filter( 'menu_order', [ $this, 'menu_order' ] );
507 + }
508 +
455 509 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
456 510
457 511 // Clear CSS Meta after change css related methods.
458 512 $css_settings = [
@@ -458,9 +512,8 @@
458 512 $css_settings = [
459 513 'elementor_disable_color_schemes',
460 514 'elementor_disable_typography_schemes',
461 515 'elementor_css_print_method',
462 - 'elementor_local_google_fonts',
463 516 ];
464 517
465 518 foreach ( $css_settings as $option_name ) {
466 519 add_action( "add_option_{$option_name}", $clear_cache_callback );
@@ -465,8 +518,6 @@
465 518 foreach ( $css_settings as $option_name ) {
466 519 add_action( "add_option_{$option_name}", $clear_cache_callback );
467 520 add_action( "update_option_{$option_name}", $clear_cache_callback );
468 521 }
469 -
470 - add_action( 'update_option_elementor_font_display', [ Google_Font::class, 'clear_cache' ] );
471 522 }
472 523 }