PluginProbe
Elementor Website Builder – more than just a page builder / 3.3.1
Elementor Website Builder – more than just a page builder v3.3.1
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.3.1, at includes/settings/settings.php

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