PluginProbe
Elementor Website Builder – more than just a page builder / 3.21.0-beta2
Elementor Website Builder – more than just a page builder v3.21.0-beta2
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 4.1.0-beta2 All 456 releases
← All changes | includes/settings/settings.php +150 -116 4.2.4 → 3.21.0-beta2 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( '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,61 +382,11 @@
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' ),
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 389 'optimized_gutenberg_loading' => [
342 390 'label' => esc_html__( 'Optimized Gutenberg Loading', 'elementor' ),
343 391 'field_args' => [
344 392 'type' => 'select',
@@ -346,35 +394,11 @@
346 394 'options' => [
347 395 '1' => esc_html__( 'Enable', 'elementor' ),
348 396 '0' => esc_html__( 'Disable', 'elementor' ),
349 397 ],
350 - 'desc' => esc_html__( 'Reduce unnecessary render-blocking loads by dequeuing unused Gutenberg block editor scripts and styles.', 'elementor' ),
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' ),
351 399 ],
352 400 ],
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 401 ],
378 402 ],
379 403 ],
380 404 ],
@@ -391,8 +415,12 @@
391 415 *
392 416 * @return string Settings page title.
393 417 */
394 418 protected function get_page_title() {
419 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
420 + return esc_html__( 'Settings', 'elementor' );
421 + }
422 +
395 423 return esc_html__( 'Elementor', 'elementor' );
396 424 }
397 425
398 426 /**
@@ -400,8 +428,9 @@
400 428 * @access private
401 429 */
402 430 private function maybe_remove_all_admin_notices() {
403 431 $elementor_pages = [
432 + 'elementor-getting-started',
404 433 'elementor-system-info',
405 434 'e-form-submissions',
406 435 'elementor_custom_fonts',
407 436 'elementor_custom_icons',
@@ -441,18 +470,26 @@
441 470 */
442 471 public function __construct() {
443 472 parent::__construct();
444 473
474 + $this->home_module = new Home_Module();
475 +
445 476 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
446 477 add_filter( 'elementor/generator_tag/settings', [ $this, 'add_generator_tag_settings' ] );
447 478
448 - add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
479 + if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
480 + add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
449 481
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 - } );
482 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
483 + $this->register_knowledge_base_menu( $admin_menu );
484 + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 );
454 485
486 + add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
487 +
488 + add_filter( 'custom_menu_order', '__return_true' );
489 + add_filter( 'menu_order', [ $this, 'menu_order' ] );
490 + }
491 +
455 492 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
456 493
457 494 // Clear CSS Meta after change css related methods.
458 495 $css_settings = [
@@ -458,9 +495,8 @@
458 495 $css_settings = [
459 496 'elementor_disable_color_schemes',
460 497 'elementor_disable_typography_schemes',
461 498 'elementor_css_print_method',
462 - 'elementor_local_google_fonts',
463 499 ];
464 500
465 501 foreach ( $css_settings as $option_name ) {
466 502 add_action( "add_option_{$option_name}", $clear_cache_callback );
@@ -465,8 +501,6 @@
465 501 foreach ( $css_settings as $option_name ) {
466 502 add_action( "add_option_{$option_name}", $clear_cache_callback );
467 503 add_action( "update_option_{$option_name}", $clear_cache_callback );
468 504 }
469 -
470 - add_action( 'update_option_elementor_font_display', [ Google_Font::class, 'clear_cache' ] );
471 505 }
472 506 }