PluginProbe
Elementor Website Builder – more than just a page builder / 3.2.4
Elementor Website Builder – more than just a page builder v3.2.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
elementor / includes / settings / settings.php

settings.php in Elementor Website Builder – more than just a page builder 3.2.4, at includes/settings/settings.php

612 lines 19.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Elementor;
3
4 use Elementor\Core\Upgrade\Manager as Upgrades_Manager;
5 use Elementor\TemplateLibrary\Source_Local;
6
7 if ( ! defined( 'ABSPATH' ) ) {
8 exit; // Exit if accessed directly.
9 }
10
11 /**
12 * Elementor "Settings" page in WordPress Dashboard.
13 *
14 * Elementor settings page handler class responsible for creating and displaying
15 * Elementor "Settings" page in WordPress dashboard.
16 *
17 * @since 1.0.0
18 */
19 class Settings extends Settings_Page {
20
21 /**
22 * Settings page ID for Elementor settings.
23 */
24 const PAGE_ID = 'elementor';
25
26 /**
27 * Go Pro menu priority.
28 */
29 const MENU_PRIORITY_GO_PRO = 502;
30
31 /**
32 * Settings page field for update time.
33 */
34 const UPDATE_TIME_FIELD = '_elementor_settings_update_time';
35
36 /**
37 * Settings page general tab slug.
38 */
39 const TAB_GENERAL = 'general';
40
41 /**
42 * Settings page style tab slug.
43 */
44 const TAB_STYLE = 'style';
45
46 /**
47 * Settings page integrations tab slug.
48 */
49 const TAB_INTEGRATIONS = 'integrations';
50
51 /**
52 * Settings page advanced tab slug.
53 */
54 const TAB_ADVANCED = 'advanced';
55
56 /**
57 * Register admin menu.
58 *
59 * Add new Elementor Settings admin menu.
60 *
61 * Fired by `admin_menu` action.
62 *
63 * @since 1.0.0
64 * @access public
65 */
66 public function register_admin_menu() {
67 global $menu;
68
69 $menu[] = [ '', 'read', 'separator-elementor', '', 'wp-menu-separator elementor' ]; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
70
71 if ( ! current_user_can( 'manage_options' ) ) {
72 return;
73 }
74
75 add_menu_page(
76 __( 'Elementor', 'elementor' ),
77 __( 'Elementor', 'elementor' ),
78 'manage_options',
79 self::PAGE_ID,
80 [ $this, 'display_settings_page' ],
81 '',
82 '58.5'
83 );
84 }
85
86 /**
87 * Reorder the Elementor menu items in admin.
88 * Based on WC.
89 *
90 * @since 2.4.0
91 *
92 * @param array $menu_order Menu order.
93 * @return array
94 */
95 public function menu_order( $menu_order ) {
96 // Initialize our custom order array.
97 $elementor_menu_order = [];
98
99 // Get the index of our custom separator.
100 $elementor_separator = array_search( 'separator-elementor', $menu_order, true );
101
102 // Get index of library menu.
103 $elementor_library = array_search( Source_Local::ADMIN_MENU_SLUG, $menu_order, true );
104
105 // Loop through menu order and do some rearranging.
106 foreach ( $menu_order as $index => $item ) {
107 if ( 'elementor' === $item ) {
108 $elementor_menu_order[] = 'separator-elementor';
109 $elementor_menu_order[] = $item;
110 $elementor_menu_order[] = Source_Local::ADMIN_MENU_SLUG;
111
112 unset( $menu_order[ $elementor_separator ] );
113 unset( $menu_order[ $elementor_library ] );
114 } elseif ( ! in_array( $item, [ 'separator-elementor' ], true ) ) {
115 $elementor_menu_order[] = $item;
116 }
117 }
118
119 // Return order.
120 return $elementor_menu_order;
121 }
122
123 /**
124 * Register Elementor Pro sub-menu.
125 *
126 * Add new Elementor Pro sub-menu under the main Elementor menu.
127 *
128 * Fired by `admin_menu` action.
129 *
130 * @since 1.0.0
131 * @access public
132 */
133 public function register_pro_menu() {
134 add_submenu_page(
135 self::PAGE_ID,
136 __( 'Custom Fonts', 'elementor' ),
137 __( 'Custom Fonts', 'elementor' ),
138 'manage_options',
139 'elementor_custom_fonts',
140 [ $this, 'elementor_custom_fonts' ]
141 );
142
143 add_submenu_page(
144 self::PAGE_ID,
145 __( 'Custom Icons', 'elementor' ),
146 __( 'Custom Icons', 'elementor' ),
147 'manage_options',
148 'elementor_custom_icons',
149 [ $this, 'elementor_custom_icons' ]
150 );
151
152 add_submenu_page(
153 self::PAGE_ID,
154 '',
155 '<span class="dashicons dashicons-star-filled" style="font-size: 17px"></span> ' . __( 'Go Pro', 'elementor' ),
156 'manage_options',
157 'go_elementor_pro',
158 [ $this, 'handle_external_redirects' ]
159 );
160
161 add_submenu_page( Source_Local::ADMIN_MENU_SLUG, __( 'Popups', 'elementor' ), __( 'Popups', 'elementor' ), 'manage_options', 'popup_templates', [ $this, 'elementor_popups' ] );
162 }
163
164 /**
165 * Register Elementor knowledge base sub-menu.
166 *
167 * Add new Elementor knowledge base sub-menu under the main Elementor menu.
168 *
169 * Fired by `admin_menu` action.
170 *
171 * @since 2.0.3
172 * @access public
173 */
174 public function register_knowledge_base_menu() {
175 add_submenu_page(
176 self::PAGE_ID,
177 '',
178 __( 'Getting Started', 'elementor' ),
179 'manage_options',
180 'elementor-getting-started',
181 [ $this, 'elementor_getting_started' ]
182 );
183
184 add_submenu_page(
185 self::PAGE_ID,
186 '',
187 __( 'Get Help', 'elementor' ),
188 'manage_options',
189 'go_knowledge_base_site',
190 [ $this, 'handle_external_redirects' ]
191 );
192 }
193
194 /**
195 * Go Elementor Pro.
196 *
197 * Redirect the Elementor Pro page the clicking the Elementor Pro menu link.
198 *
199 * Fired by `admin_init` action.
200 *
201 * @since 2.0.3
202 * @access public
203 */
204 public function handle_external_redirects() {
205 if ( empty( $_GET['page'] ) ) {
206 return;
207 }
208
209 if ( 'go_elementor_pro' === $_GET['page'] ) {
210 wp_redirect( Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-menu&utm_campaign=gopro&utm_medium=wp-dash' ) );
211 die;
212 }
213
214 if ( 'go_knowledge_base_site' === $_GET['page'] ) {
215 wp_redirect( 'https://go.elementor.com/docs-admin-menu/' );
216 die;
217 }
218 }
219
220 /**
221 * Display settings page.
222 *
223 * Output the content for the getting started page.
224 *
225 * @since 2.2.0
226 * @access public
227 */
228 public function elementor_getting_started() {
229 if ( User::is_current_user_can_edit_post_type( 'page' ) ) {
230 $create_new_label = __( 'Create Your First Page', 'elementor' );
231 $create_new_cpt = 'page';
232 } elseif ( User::is_current_user_can_edit_post_type( 'post' ) ) {
233 $create_new_label = __( 'Create Your First Post', 'elementor' );
234 $create_new_cpt = 'post';
235 }
236
237 ?>
238 <div class="wrap">
239 <div class="e-getting-started">
240 <div class="e-getting-started__box postbox">
241 <div class="e-getting-started__header">
242 <div class="e-getting-started__title">
243 <div class="e-logo-wrapper">
244 <i class="eicon-elementor"></i>
245 </div>
246 <?php echo __( 'Getting Started', 'elementor' ); ?>
247 </div>
248 <a class="e-getting-started__skip" href="<?php echo esc_url( admin_url() ); ?>">
249 <i class="eicon-close" aria-hidden="true" title="<?php esc_attr_e( 'Skip', 'elementor' ); ?>"></i>
250 <span class="elementor-screen-only"><?php echo __( 'Skip', 'elementor' ); ?></span>
251 </a>
252 </div>
253 <div class="e-getting-started__content">
254 <div class="e-getting-started__content--narrow">
255 <h2><?php echo __( 'Welcome to Elementor', 'elementor' ); ?></h2>
256 <p><?php echo __( 'Get introduced to Elementor by watching our "Getting Started" video series. It will guide you through the steps needed to create your website. Then click to create your first page.', 'elementor' ); ?></p>
257 </div>
258
259 <div class="e-getting-started__video">
260 <iframe width="620" height="350" src="https://www.youtube-nocookie.com/embed/videoseries?list=PLZyp9H25CboH8b_wsNyOmstckiOE8aUBg&amp;controls=1&amp;modestbranding=1" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
261 </div>
262
263 <div class="e-getting-started__actions e-getting-started__content--narrow">
264 <?php if ( ! empty( $create_new_cpt ) ) : ?>
265 <a href="<?php echo esc_url( Utils::get_create_new_post_url( $create_new_cpt ) ); ?>" class="button button-primary button-hero"><?php echo esc_html( $create_new_label ); ?></a>
266 <?php endif; ?>
267
268 <a href="https://go.elementor.com/getting-started/" target="_blank" class="button button-secondary button-hero"><?php echo __( 'Watch the Full Guide', 'elementor' ); ?></a>
269 </div>
270 </div>
271 </div>
272 </div>
273 </div><!-- /.wrap -->
274 <?php
275 }
276
277 /**
278 * Display settings page.
279 *
280 * Output the content for the custom fonts page.
281 *
282 * @since 2.0.0
283 * @access public
284 */
285 public function elementor_custom_fonts() {
286 ?>
287 <div class="wrap">
288 <div class="elementor-blank_state">
289 <img src="<?php echo ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg'; ?>" />
290 <h2><?php echo __( 'Add Your Custom Fonts', 'elementor' ); ?></h2>
291 <p><?php echo __( 'Custom Fonts allows you to add your self-hosted fonts and use them on your Elementor projects to create a unique brand language.', 'elementor' ); ?></p>
292 <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-custom-fonts&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a>
293 </div>
294 </div><!-- /.wrap -->
295 <?php
296 }
297
298 /**
299 * Display settings page.
300 *
301 * Output the content for the custom icons page.
302 *
303 * @since 2.8.0
304 * @access public
305 */
306 public function elementor_custom_icons() {
307 ?>
308 <div class="wrap">
309 <div class="elementor-blank_state">
310 <img src="<?php echo ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg'; ?>" />
311 <h2><?php echo __( 'Add Your Custom Icons', 'elementor' ); ?></h2>
312 <p><?php echo __( 'Don\'t rely solely on the FontAwesome icons everyone else is using! Differentiate your website and your style with custom icons you can upload from your favorite icons source.', 'elementor' ); ?></p>
313 <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/pro/?utm_source=wp-custom-icons&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a>
314 </div>
315 </div><!-- /.wrap -->
316 <?php
317 }
318
319 /**
320 * Display settings page.
321 *
322 * Output the content for the Popups page.
323 *
324 * @since 2.4.0
325 * @access public
326 */
327 public function elementor_popups() {
328 ?>
329 <div class="wrap">
330 <div class="elementor-blank_state">
331 <img src="<?php echo ELEMENTOR_ASSETS_URL . 'images/go-pro-wp-dashboard.svg'; ?>" />
332 <h2><?php echo __( 'Get Popup Builder', 'elementor' ); ?></h2>
333 <p><?php echo __( 'Popup Builder lets you take advantage of all the amazing features in Elementor, so you can build beautiful & highly converting popups. Go pro and start designing your popups today.', 'elementor' ); ?></p>
334 <a class="elementor-button elementor-button-default elementor-button-go-pro" target="_blank" href="<?php echo Utils::get_pro_link( 'https://elementor.com/popup-builder/?utm_source=popup-templates&utm_campaign=gopro&utm_medium=wp-dash' ); ?>"><?php echo __( 'Go Pro', 'elementor' ); ?></a>
335 </div>
336 </div><!-- /.wrap -->
337 <?php
338 }
339
340 /**
341 * On admin init.
342 *
343 * Preform actions on WordPress admin initialization.
344 *
345 * Fired by `admin_init` action.
346 *
347 * @since 2.0.0
348 * @access public
349 */
350 public function on_admin_init() {
351 $this->handle_external_redirects();
352
353 $this->maybe_remove_all_admin_notices();
354 }
355
356 /**
357 * Change "Settings" menu name.
358 *
359 * Update the name of the Settings admin menu from "Elementor" to "Settings".
360 *
361 * Fired by `admin_menu` action.
362 *
363 * @since 1.0.0
364 * @access public
365 */
366 public function admin_menu_change_name() {
367 Utils::change_submenu_first_item_label( 'elementor', __( 'Settings', 'elementor' ) );
368 }
369
370 /**
371 * Update CSS print method.
372 *
373 * Clear post CSS cache.
374 *
375 * Fired by `add_option_elementor_css_print_method` and
376 * `update_option_elementor_css_print_method` actions.
377 *
378 * @since 1.7.5
379 * @access public
380 * @deprecated 3.0.0
381 */
382 public function update_css_print_method() {
383 Plugin::$instance->files_manager->clear_cache();
384 }
385
386 /**
387 * Create tabs.
388 *
389 * Return the settings page tabs, sections and fields.
390 *
391 * @since 1.5.0
392 * @access protected
393 *
394 * @return array An array with the settings page tabs, sections and fields.
395 */
396 protected function create_tabs() {
397 $validations_class_name = __NAMESPACE__ . '\Settings_Validations';
398
399 return [
400 self::TAB_GENERAL => [
401 'label' => __( 'General', 'elementor' ),
402 'sections' => [
403 'general' => [
404 'fields' => [
405 self::UPDATE_TIME_FIELD => [
406 'full_field_id' => self::UPDATE_TIME_FIELD,
407 'field_args' => [
408 'type' => 'hidden',
409 ],
410 'setting_args' => [ $validations_class_name, 'current_time' ],
411 ],
412 'cpt_support' => [
413 'label' => __( 'Post Types', 'elementor' ),
414 'field_args' => [
415 'type' => 'checkbox_list_cpt',
416 'std' => [ 'page', 'post' ],
417 'exclude' => [ 'attachment', 'elementor_library' ],
418 ],
419 'setting_args' => [ $validations_class_name, 'checkbox_list' ],
420 ],
421 'disable_color_schemes' => [
422 'label' => __( 'Disable Default Colors', 'elementor' ),
423 'field_args' => [
424 'type' => 'checkbox',
425 'value' => 'yes',
426 'sub_desc' => __( 'Checking this box will disable Elementor\'s Default Colors, and make Elementor inherit the colors from your theme.', 'elementor' ),
427 ],
428 ],
429 'disable_typography_schemes' => [
430 'label' => __( 'Disable Default Fonts', 'elementor' ),
431 'field_args' => [
432 'type' => 'checkbox',
433 'value' => 'yes',
434 'sub_desc' => __( 'Checking this box will disable Elementor\'s Default Fonts, and make Elementor inherit the fonts from your theme.', 'elementor' ),
435 ],
436 ],
437 ],
438 ],
439 'usage' => [
440 'label' => __( 'Improve Elementor', 'elementor' ),
441 'fields' => $this->get_usage_fields(),
442 ],
443 ],
444 ],
445 self::TAB_STYLE => [
446 'label' => __( 'Style', 'elementor' ),
447 'sections' => [
448 'style' => [
449 'fields' => [
450 'notice' => [
451 'label' => __( 'Looking for the Style settings?', 'elementor' ),
452 'field_args' => [
453 'type' => 'raw_html',
454 'html' => __( 'The Style settings changed its location and can now be found within Elementor Editor\'s <b>Panel > Hamburger Menu > Site Settings</b>.<br>You can use the Site Settings to make changes and see them live!', 'elementor' ) . sprintf( ' <a target="_blank" href="http://go.elementor.com/panel-layout-settings">%s</a>', __( 'Learn More', 'elementor' ) ),
455 ],
456 ],
457 ],
458 ],
459 ],
460 ],
461 self::TAB_INTEGRATIONS => [
462 'label' => __( 'Integrations', 'elementor' ),
463 'sections' => [
464 'google_maps' => [
465 'label' => __( 'Google Maps Embed API', 'elementor' ),
466 'callback' => function() {
467 printf( __( 'Google Maps Embed API is a free service by Google that allows embedding Google Maps in your site. For more details, visit Google Maps\' <a href="%s" target="_blank">Using API Keys</a> page.', 'elementor' ), esc_url( 'https://developers.google.com/maps/documentation/embed/get-api-key' ) );
468 },
469 'fields' => [
470 'google_maps_api_key' => [
471 'label' => __( 'API Key', 'elementor' ),
472 'field_args' => [
473 'class' => 'elementor_google_maps_api_key',
474 'type' => 'text',
475 ],
476 ],
477 ],
478 ],
479 ],
480 ],
481 self::TAB_ADVANCED => [
482 'label' => __( 'Advanced', 'elementor' ),
483 'sections' => [
484 'advanced' => [
485 'fields' => [
486 'css_print_method' => [
487 'label' => __( 'CSS Print Method', 'elementor' ),
488 'field_args' => [
489 'class' => 'elementor_css_print_method',
490 'type' => 'select',
491 'options' => [
492 'external' => __( 'External File', 'elementor' ),
493 'internal' => __( 'Internal Embedding', 'elementor' ),
494 ],
495 'desc' => '<div class="elementor-css-print-method-description" data-value="external" style="display: none">' . __( '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">' . __( 'Use internal CSS that is embedded in the head of the page. For troubleshooting server configuration conflicts and managing development environments.', 'elementor' ) . '</div>',
496 ],
497 ],
498 'editor_break_lines' => [
499 'label' => __( 'Switch Editor Loader Method', 'elementor' ),
500 'field_args' => [
501 'type' => 'select',
502 'options' => [
503 '' => __( 'Disable', 'elementor' ),
504 1 => __( 'Enable', 'elementor' ),
505 ],
506 'desc' => __( 'For troubleshooting server configuration conflicts.', 'elementor' ),
507 ],
508 ],
509 'unfiltered_files_upload' => [
510 'label' => __( 'Enable Unfiltered File Uploads', 'elementor' ),
511 'field_args' => [
512 'type' => 'select',
513 'std' => '',
514 'options' => [
515 '' => __( 'Disable', 'elementor' ),
516 1 => __( 'Enable', 'elementor' ),
517 ],
518 'desc' => __( 'Please note! Allowing uploads of any files (SVG & JSON included) is a potential security risk.', 'elementor' ) . '<br>' . __( 'Elementor will try to sanitize the unfiltered files, removing potential malicious code and scripts.', 'elementor' ) . '<br>' . __( 'We recommend you only enable this feature if you understand the security risks involved.', 'elementor' ),
519 ],
520 ],
521 'font_display' => [
522 'label' => __( 'Google Fonts Load', 'elementor' ),
523 'field_args' => [
524 'type' => 'select',
525 'std' => 'auto',
526 'options' => [
527 'auto' => __( 'Default', 'elementor' ),
528 'block' => __( 'Blocking', 'elementor' ),
529 'swap' => __( 'Swap', 'elementor' ),
530 'fallback' => __( 'Fallback', 'elementor' ),
531 'optional' => __( 'Optional', 'elementor' ),
532 ],
533 'desc' => __( 'Font-display property defines how font files are loaded and displayed by the browser.', 'elementor' ) . '<br>' . __( 'Set the way Google Fonts are being loaded by selecting the font-display property (Default: Auto).', 'elementor' ),
534 ],
535 ],
536 ],
537 ],
538 ],
539 ],
540 ];
541 }
542
543 /**
544 * Get settings page title.
545 *
546 * Retrieve the title for the settings page.
547 *
548 * @since 1.5.0
549 * @access protected
550 *
551 * @return string Settings page title.
552 */
553 protected function get_page_title() {
554 return __( 'Elementor', 'elementor' );
555 }
556
557 /**
558 * @since 2.2.0
559 * @access private
560 */
561 private function maybe_remove_all_admin_notices() {
562 $elementor_pages = [
563 'elementor-getting-started',
564 'elementor_custom_fonts',
565 'elementor_custom_icons',
566 'elementor-license',
567 'popup_templates',
568 ];
569
570 if ( empty( $_GET['page'] ) || ! in_array( $_GET['page'], $elementor_pages, true ) ) {
571 return;
572 }
573
574 remove_all_actions( 'admin_notices' );
575 }
576
577 /**
578 * Settings page constructor.
579 *
580 * Initializing Elementor "Settings" page.
581 *
582 * @since 1.0.0
583 * @access public
584 */
585 public function __construct() {
586 parent::__construct();
587
588 add_action( 'admin_init', [ $this, 'on_admin_init' ] );
589 add_action( 'admin_menu', [ $this, 'register_admin_menu' ], 20 );
590 add_action( 'admin_menu', [ $this, 'admin_menu_change_name' ], 200 );
591 add_action( 'admin_menu', [ $this, 'register_pro_menu' ], self::MENU_PRIORITY_GO_PRO );
592 add_action( 'admin_menu', [ $this, 'register_knowledge_base_menu' ], 501 );
593
594 $clear_cache_callback = [ Plugin::$instance->files_manager, 'clear_cache' ];
595
596 // Clear CSS Meta after change css related methods.
597 $css_settings = [
598 'elementor_disable_color_schemes',
599 'elementor_disable_typography_schemes',
600 'elementor_css_print_method',
601 ];
602
603 foreach ( $css_settings as $option_name ) {
604 add_action( "add_option_{$option_name}", $clear_cache_callback );
605 add_action( "update_option_{$option_name}", $clear_cache_callback );
606 }
607
608 add_filter( 'custom_menu_order', '__return_true' );
609 add_filter( 'menu_order', [ $this, 'menu_order' ] );
610 }
611 }
612