PluginProbe
Elementor Website Builder – more than just a page builder / 3.20.2
Elementor Website Builder – more than just a page builder v3.20.2
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 +129 -130 4.2.03.20.2 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 *
@@ -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',
@@ -265,9 +343,8 @@
265 343 '1' => esc_html__( 'Enable', 'elementor' ),
266 344 '0' => esc_html__( 'Disable', 'elementor' ),
267 345 ],
268 346 'desc' => sprintf(
269 - /* translators: 1: Link opening tag, 2: Link closing tag */
270 347 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 348 '<a href="' . admin_url( 'admin.php?page=elementor_custom_fonts' ) . '">',
272 349 '</a>'
273 350 ),
@@ -284,9 +361,9 @@
284 361 'swap' => esc_html__( 'Swap', 'elementor' ),
285 362 'fallback' => esc_html__( 'Fallback', 'elementor' ),
286 363 'optional' => esc_html__( 'Optional', 'elementor' ),
287 364 ],
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' ),
365 + '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 366 ],
290 367 ],
291 368 ],
292 369 ],
@@ -291,94 +368,8 @@
291 368 ],
292 369 ],
293 370 ],
294 371 ],
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 372 ];
382 373 }
383 374
384 375 /**
@@ -391,8 +382,12 @@
391 382 *
392 383 * @return string Settings page title.
393 384 */
394 385 protected function get_page_title() {
386 + if ( Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
387 + return esc_html__( 'Settings', 'elementor' );
388 + }
389 +
395 390 return esc_html__( 'Elementor', 'elementor' );
396 391 }
397 392
398 393 /**
@@ -400,8 +395,9 @@
400 395 * @access private
401 396 */
402 397 private function maybe_remove_all_admin_notices() {
403 398 $elementor_pages = [
399 + 'elementor-getting-started',
404 400 'elementor-system-info',
405 401 'e-form-submissions',
406 402 'elementor_custom_fonts',
407 403 'elementor_custom_icons',
@@ -444,15 +440,21 @@
444 440
445 441 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
446 442 add_filter( 'elementor/generator_tag/settings', [ $this, 'add_generator_tag_settings' ] );
447 443
448 - add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
444 + if ( ! Plugin::$instance->experiments->is_feature_active( 'admin_menu_rearrangement' ) ) {
445 + add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
449 446
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 - } );
447 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
448 + $this->register_knowledge_base_menu( $admin_menu );
449 + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 );
454 450
451 + add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
452 +
453 + add_filter( 'custom_menu_order', '__return_true' );
454 + add_filter( 'menu_order', [ $this, 'menu_order' ] );
455 + }
456 +
455 457 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
456 458
457 459 // Clear CSS Meta after change css related methods.
458 460 $css_settings = [
@@ -458,9 +460,8 @@
458 460 $css_settings = [
459 461 'elementor_disable_color_schemes',
460 462 'elementor_disable_typography_schemes',
461 463 'elementor_css_print_method',
462 - 'elementor_local_google_fonts',
463 464 ];
464 465
465 466 foreach ( $css_settings as $option_name ) {
466 467 add_action( "add_option_{$option_name}", $clear_cache_callback );
@@ -465,8 +466,6 @@
465 466 foreach ( $css_settings as $option_name ) {
466 467 add_action( "add_option_{$option_name}", $clear_cache_callback );
467 468 add_action( "update_option_{$option_name}", $clear_cache_callback );
468 469 }
469 -
470 - add_action( 'update_option_elementor_font_display', [ Google_Font::class, 'clear_cache' ] );
471 470 }
472 471 }