PluginProbe
Elementor Website Builder – more than just a page builder / 3.24.8
Elementor Website Builder – more than just a page builder v3.24.8
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 -33 4.1.33.24.8 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 *
@@ -265,9 +370,8 @@
265 370 '1' => esc_html__( 'Enable', 'elementor' ),
266 371 '0' => esc_html__( 'Disable', 'elementor' ),
267 372 ],
268 373 'desc' => sprintf(
269 - /* translators: 1: Link opening tag, 2: Link closing tag */
270 374 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 375 '<a href="' . admin_url( 'admin.php?page=elementor_custom_fonts' ) . '">',
272 376 '</a>'
273 377 ),
@@ -284,9 +388,9 @@
284 388 'swap' => esc_html__( 'Swap', 'elementor' ),
285 389 'fallback' => esc_html__( 'Fallback', 'elementor' ),
286 390 'optional' => esc_html__( 'Optional', 'elementor' ),
287 391 ],
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' ),
392 + '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 393 ],
290 394 ],
291 395 ],
292 396 ],
@@ -361,20 +465,8 @@
361 465 ],
362 466 'desc' => esc_html__( 'Improve initial page load performance by lazy loading all background images except the first one.', 'elementor' ),
363 467 ],
364 468 ],
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 469 ],
378 470 ],
379 471 ],
380 472 ],
@@ -400,8 +492,9 @@
400 492 * @access private
401 493 */
402 494 private function maybe_remove_all_admin_notices() {
403 495 $elementor_pages = [
496 + 'elementor-getting-started',
404 497 'elementor-system-info',
405 498 'e-form-submissions',
406 499 'elementor_custom_fonts',
407 500 'elementor_custom_icons',
@@ -441,18 +534,24 @@
441 534 */
442 535 public function __construct() {
443 536 parent::__construct();
444 537
538 + $this->home_module = new Home_Module();
539 +
445 540 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
446 541 add_filter( 'elementor/generator_tag/settings', [ $this, 'add_generator_tag_settings' ] );
447 542
448 543 add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
449 544
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 - } );
545 + add_action( 'elementor/admin/menu/register', function ( Admin_Menu_Manager $admin_menu ) {
546 + $this->register_knowledge_base_menu( $admin_menu );
547 + }, Promotions_Module::ADMIN_MENU_PRIORITY - 1 );
454 548
549 + add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
550 +
551 + add_filter( 'custom_menu_order', '__return_true' );
552 + add_filter( 'menu_order', [ $this, 'menu_order' ] );
553 +
455 554 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
456 555
457 556 // Clear CSS Meta after change css related methods.
458 557 $css_settings = [
@@ -458,9 +557,8 @@
458 557 $css_settings = [
459 558 'elementor_disable_color_schemes',
460 559 'elementor_disable_typography_schemes',
461 560 'elementor_css_print_method',
462 - 'elementor_local_google_fonts',
463 561 ];
464 562
465 563 foreach ( $css_settings as $option_name ) {
466 564 add_action( "add_option_{$option_name}", $clear_cache_callback );
@@ -465,8 +563,6 @@
465 563 foreach ( $css_settings as $option_name ) {
466 564 add_action( "add_option_{$option_name}", $clear_cache_callback );
467 565 add_action( "update_option_{$option_name}", $clear_cache_callback );
468 566 }
469 -
470 - add_action( 'update_option_elementor_font_display', [ Google_Font::class, 'clear_cache' ] );
471 567 }
472 568 }