PluginProbe
Elementor Website Builder – more than just a page builder / 3.22.2
Elementor Website Builder – more than just a page builder v3.22.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 +135 -65 4.1.0-dev13.22.2 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
@@ -58,9 +65,9 @@
58 65 const TAB_PERFORMANCE = 'performance';
59 66
60 67 const ADMIN_MENU_PRIORITY = 10;
61 68
62 - const MENU_CAPABILITY_EDIT_POSTS = 'edit_posts';
69 + public Home_Module $home_module;
63 70
64 71 /**
65 72 * Register admin menu.
66 73 *
@@ -71,9 +78,13 @@
71 78 * @since 1.0.0
72 79 * @access public
73 80 */
74 81 public function register_admin_menu() {
75 - if ( ! current_user_can( self::MENU_CAPABILITY_EDIT_POSTS ) ) {
82 + global $menu;
83 +
84 + $menu[] = [ '', 'read', 'separator-elementor', '', 'wp-menu-separator elementor' ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
85 +
86 + if ( ! current_user_can( 'manage_options' ) ) {
76 87 return;
77 88 }
78 89
79 90 add_menu_page(
@@ -78,14 +89,23 @@
78 89
79 90 add_menu_page(
80 91 esc_html__( 'Elementor', 'elementor' ),
81 92 esc_html__( 'Elementor', 'elementor' ),
82 - self::MENU_CAPABILITY_EDIT_POSTS,
93 + 'manage_options',
83 94 self::PAGE_ID,
84 - [ $this, 'display_home_screen' ],
95 + [
96 + $this,
97 + $this->home_module->is_experiment_active() ? 'display_home_screen' : 'display_settings_page',
98 + ],
85 99 '',
86 100 '58.5'
87 101 );
102 +
103 + if ( $this->home_module->is_experiment_active() ) {
104 + add_action( 'elementor/admin/menu/register', function( Admin_Menu_Manager $admin_menu ) {
105 + $admin_menu->register( 'elementor-settings', new Admin_Menu_Item( $this ) );
106 + }, 0 );
107 + }
88 108 }
89 109
90 110 public function display_home_screen() {
91 111 echo '<div id="e-home-screen"></div>';
@@ -90,17 +110,82 @@
90 110 public function display_home_screen() {
91 111 echo '<div id="e-home-screen"></div>';
92 112 }
93 113
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() );
114 + /**
115 + * Reorder the Elementor menu items in admin.
116 + * Based on WC.
117 + *
118 + * @since 2.4.0
119 + *
120 + * @param array $menu_order Menu order.
121 + * @return array
122 + */
123 + public function menu_order( $menu_order ) {
124 + // Initialize our custom order array.
125 + $elementor_menu_order = [];
126 +
127 + // Get the index of our custom separator.
128 + $elementor_separator = array_search( 'separator-elementor', $menu_order, true );
129 +
130 + // Get index of library menu.
131 + $elementor_library = array_search( Source_Local::ADMIN_MENU_SLUG, $menu_order, true );
132 +
133 + // Loop through menu order and do some rearranging.
134 + foreach ( $menu_order as $index => $item ) {
135 + if ( 'elementor' === $item ) {
136 + $elementor_menu_order[] = 'separator-elementor';
137 + $elementor_menu_order[] = $item;
138 + $elementor_menu_order[] = Source_Local::ADMIN_MENU_SLUG;
139 +
140 + unset( $menu_order[ $elementor_separator ] );
141 + unset( $menu_order[ $elementor_library ] );
142 + } elseif ( ! in_array( $item, [ 'separator-elementor' ], true ) ) {
143 + $elementor_menu_order[] = $item;
144 + }
145 + }
146 +
147 + // Return order.
148 + return $elementor_menu_order;
96 149 }
97 150
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() );
151 + /**
152 + * Register Elementor knowledge base sub-menu.
153 + *
154 + * Add new Elementor knowledge base sub-menu under the main Elementor menu.
155 + *
156 + * Fired by `admin_menu` action.
157 + *
158 + * @since 2.0.3
159 + * @access private
160 + */
161 + private function register_knowledge_base_menu( Admin_Menu_Manager $admin_menu ) {
162 + $admin_menu->register( 'elementor-getting-started', new Getting_Started_Menu_Item() );
163 + $admin_menu->register( 'go_knowledge_base_site', new Get_Help_Menu_Item() );
100 164 }
101 165
102 166 /**
167 + * Go Elementor Pro.
168 + *
169 + * Redirect the Elementor Pro page the clicking the Elementor Pro menu link.
170 + *
171 + * Fired by `admin_init` action.
172 + *
173 + * @since 2.0.3
174 + * @access public
175 + */
176 + public function handle_external_redirects() {
177 + if ( empty( $_GET['page'] ) ) {
178 + return;
179 + }
180 +
181 + if ( 'go_knowledge_base_site' === $_GET['page'] ) {
182 + wp_redirect( Get_Help_Menu_Item::URL );
183 + die;
184 + }
185 + }
186 +
187 + /**
103 188 * On admin init.
104 189 *
105 190 * Preform actions on WordPress admin initialization.
106 191 *
@@ -109,12 +194,32 @@
109 194 * @since 2.0.0
110 195 * @access public
111 196 */
112 197 public function on_admin_init() {
198 + $this->handle_external_redirects();
199 +
113 200 $this->maybe_remove_all_admin_notices();
114 201 }
115 202
116 203 /**
204 + * Change "Settings" menu name.
205 + *
206 + * Update the name of the Settings admin menu from "Elementor" to "Settings".
207 + *
208 + * Fired by `admin_menu` action.
209 + *
210 + * @since 1.0.0
211 + * @access public
212 + */
213 + public function admin_menu_change_name() {
214 + $menu_name = $this->home_module->is_experiment_active()
215 + ? esc_html__( 'Home', 'elementor' )
216 + : esc_html__( 'Settings', 'elementor' );
217 +
218 + Utils::change_submenu_first_item_label( 'elementor', $menu_name );
219 + }
220 +
221 + /**
117 222 * Update CSS print method.
118 223 *
119 224 * Clear post CSS cache.
120 225 *
@@ -146,15 +251,8 @@
146 251 self::TAB_GENERAL => [
147 252 'label' => esc_html__( 'General', 'elementor' ),
148 253 'sections' => [
149 254 '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 255 'fields' => [
158 256 self::UPDATE_TIME_FIELD => [
159 257 'full_field_id' => self::UPDATE_TIME_FIELD,
160 258 'field_args' => [
@@ -223,15 +321,8 @@
223 321 self::TAB_ADVANCED => [
224 322 'label' => esc_html__( 'Advanced', 'elementor' ),
225 323 'sections' => [
226 324 '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 325 'fields' => [
235 326 'editor_break_lines' => [
236 327 'label' => esc_html__( 'Switch Editor Loader Method', 'elementor' ),
237 328 'field_args' => [
@@ -265,9 +356,8 @@
265 356 '1' => esc_html__( 'Enable', 'elementor' ),
266 357 '0' => esc_html__( 'Disable', 'elementor' ),
267 358 ],
268 359 'desc' => sprintf(
269 - /* translators: 1: Link opening tag, 2: Link closing tag */
270 360 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 361 '<a href="' . admin_url( 'admin.php?page=elementor_custom_fonts' ) . '">',
272 362 '</a>'
273 363 ),
@@ -284,9 +374,9 @@
284 374 'swap' => esc_html__( 'Swap', 'elementor' ),
285 375 'fallback' => esc_html__( 'Fallback', 'elementor' ),
286 376 'optional' => esc_html__( 'Optional', 'elementor' ),
287 377 ],
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' ),
378 + '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 379 ],
290 380 ],
291 381 ],
292 382 ],
@@ -299,9 +389,9 @@
299 389 'label' => esc_html__( 'Performance', 'elementor' ),
300 390 'callback' => function() {
301 391 printf(
302 392 '<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' )
393 + esc_html__( 'Improve loading times on your site by selecting the optimization tools that best fit your requirements. ', 'elementor' )
304 394 );
305 395 },
306 396 'fields' => [
307 397 'css_print_method' => [
@@ -313,13 +403,13 @@
313 403 'options' => [
314 404 'external' => esc_html__( 'External File', 'elementor' ),
315 405 'internal' => esc_html__( 'Internal Embedding', 'elementor' ),
316 406 ],
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 - ),
407 + 'desc' => '<div class="description elementor-css-print-method-description" data-value="external" style="display: none">'
408 + . esc_html__( 'Use external CSS files for all generated stylesheets. Choose this setting for better performance (recommended).', 'elementor' )
409 + . '</div><div class="description elementor-css-print-method-description" data-value="internal" style="display: none">'
410 + . esc_html__( 'Use internal CSS that is embedded in the head of the page. For troubleshooting server configuration conflicts and managing development environments.', 'elementor' )
411 + . '</div>',
322 412 ],
323 413 ],
324 414 'optimized_image_loading' => [
325 415 'label' => esc_html__( 'Optimized Image Loading', 'elementor' ),
@@ -349,32 +439,8 @@
349 439 ],
350 440 'desc' => esc_html__( 'Reduce unnecessary render-blocking loads by dequeuing unused Gutenberg block editor scripts and styles.', 'elementor' ),
351 441 ],
352 442 ],
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 443 ],
378 444 ],
379 445 ],
380 446 ],
@@ -400,8 +466,9 @@
400 466 * @access private
401 467 */
402 468 private function maybe_remove_all_admin_notices() {
403 469 $elementor_pages = [
470 + 'elementor-getting-started',
404 471 'elementor-system-info',
405 472 'e-form-submissions',
406 473 'elementor_custom_fonts',
407 474 'elementor_custom_icons',
@@ -441,18 +508,24 @@
441 508 */
442 509 public function __construct() {
443 510 parent::__construct();
444 511
512 + $this->home_module = new Home_Module();
513 +
445 514 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
446 515 add_filter( 'elementor/generator_tag/settings', [ $this, 'add_generator_tag_settings' ] );
447 516
448 517 add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
449 518
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 - } );
519 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
520 + $this->register_knowledge_base_menu( $admin_menu );
521 + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 );
454 522
523 + add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
524 +
525 + add_filter( 'custom_menu_order', '__return_true' );
526 + add_filter( 'menu_order', [ $this, 'menu_order' ] );
527 +
455 528 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
456 529
457 530 // Clear CSS Meta after change css related methods.
458 531 $css_settings = [
@@ -458,9 +531,8 @@
458 531 $css_settings = [
459 532 'elementor_disable_color_schemes',
460 533 'elementor_disable_typography_schemes',
461 534 'elementor_css_print_method',
462 - 'elementor_local_google_fonts',
463 535 ];
464 536
465 537 foreach ( $css_settings as $option_name ) {
466 538 add_action( "add_option_{$option_name}", $clear_cache_callback );
@@ -465,8 +537,6 @@
465 537 foreach ( $css_settings as $option_name ) {
466 538 add_action( "add_option_{$option_name}", $clear_cache_callback );
467 539 add_action( "update_option_{$option_name}", $clear_cache_callback );
468 540 }
469 -
470 - add_action( 'update_option_elementor_font_display', [ Google_Font::class, 'clear_cache' ] );
471 541 }
472 542 }