PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0.3.2
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0.3.2
6.2.2 6.2.1 6.2 6.1.8 6.1.7 6.1.6 6.1.5 6.1.4 6.1.3 6.1.2 6.1.1 6.1 6.0.12 6.0.11 4.6.0.1 5.0 5.0.1 5.0.2 5.0.3 5.0.3.1 5.0.3.2 5.1 5.1.1 5.2 5.2.1 All 155 releases
mainwp / pages / page-mainwp-settings.php

page-mainwp-settings.php in MainWP Dashboard: Self-hosted WordPress Management for Agencies 5.0.3.2, at pages/page-mainwp-settings.php

1,832 lines 93.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Settings page
4 *
5 * This Class handles building/Managing the
6 * Settings MainWP DashboardPage & all SubPages.
7 *
8 * @package MainWP/Settings
9 */
10
11 namespace MainWP\Dashboard;
12
13 /**
14 * Class MainWP_Settings
15 *
16 * @package MainWP\Dashboard
17 */
18 class MainWP_Settings {
19
20 // phpcs:disable Generic.Metrics.CyclomaticComplexity -- complexity.
21
22 /**
23 * Protected static variable to hold the single instance of the class.
24 *
25 * @var mixed Default null
26 */
27 protected static $instance = null;
28
29 /**
30 * Public static varable to hold Subpages information.
31 *
32 * @var array $subPages
33 */
34 public static $subPages;
35
36 /**
37 * Get Class Name
38 *
39 * @return __CLASS__
40 */
41 public static function get_class_name() {
42 return __CLASS__;
43 }
44
45 /**
46 * Return the single instance of the class.
47 *
48 * @return mixed $instance The single instance of the class.
49 */
50 public static function get_instance() {
51 if ( is_null( self::$instance ) ) {
52 self::$instance = new self();
53 }
54 return self::$instance;
55 }
56
57 /** Instantiate Hooks for the Settings Page. */
58 public static function init() {
59 /**
60 * This hook allows you to render the Settings page header via the 'mainwp_pageheader_settings' action.
61 *
62 * This hook is normally used in the same context of 'mainwp_getsubpages_settings'
63 *
64 * @see \MainWP_Settings::render_header
65 */
66 add_action( 'mainwp-pageheader-settings', array( self::get_class_name(), 'render_header' ) ); // deprecated, use mainwp_pageheader_settings.
67
68 add_action( 'mainwp_pageheader_settings', array( self::get_class_name(), 'render_header' ) );
69
70 /**
71 * This hook allows you to render the Settings page footer via the 'mainwp-pagefooter-settings' action.
72 *
73 * This hook is normally used in the same context of 'mainwp-getsubpages-settings'
74 *
75 * @see \MainWP_Settings::render_footer
76 */
77 add_action( 'mainwp-pagefooter-settings', array( self::get_class_name(), 'render_footer' ) ); // deprecated, use mainwp_pagefooter_settings.
78
79 add_action( 'mainwp_pagefooter_settings', array( self::get_class_name(), 'render_footer' ) );
80
81 add_action( 'admin_init', array( self::get_class_name(), 'admin_init' ) );
82
83 add_action( 'mainwp_help_sidebar_content', array( self::get_class_name(), 'mainwp_help_content' ) );
84 }
85
86 /** Run the export_sites method that exports the Child Sites .csv file */
87 public static function admin_init() {
88 self::export_sites();
89 if ( isset( $_GET['clearActivationData'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'clear_activation_data' ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
90 delete_option( 'mainwp_extensions_api_username' );
91 delete_option( 'mainwp_extensions_api_password' );
92 delete_option( 'mainwp_extensions_api_save_login' );
93 delete_option( 'mainwp_extensions_plan_info' );
94 MainWP_Keys_Manager::instance()->update_key_value( 'mainwp_extensions_master_api_key', false );
95
96 $new_extensions = array();
97 $extensions = get_option( 'mainwp_extensions', array() );
98
99 if ( is_array( $extensions ) ) {
100 foreach ( $extensions as $ext ) {
101 if ( isset( $ext['api'] ) && isset( $ext['apiManager'] ) && ! empty( $ext['apiManager'] ) ) {
102 if ( isset( $ext['api_key'] ) ) {
103 $ext['api_key'] = '';
104 }
105 if ( isset( $ext['activation_email'] ) ) {
106 $ext['activation_email'] = '';
107 }
108 if ( isset( $ext['activated_key'] ) ) {
109 $ext['activated_key'] = 'Deactivated';
110 }
111
112 $act_info = MainWP_Api_Manager::instance()->get_activation_info( $ext['api'] );
113 if ( isset( $act_info['api_key'] ) ) {
114 $act_info['api_key'] = '';
115 }
116 if ( isset( $act_info['activation_email'] ) ) {
117 $act_info['activation_email'] = '';
118 }
119 if ( isset( $act_info['activated_key'] ) ) {
120 $act_info['activated_key'] = 'Deactivated';
121 }
122 MainWP_Api_Manager::instance()->set_activation_info( $ext['api'], $act_info );
123 }
124 $new_extensions[] = $ext;
125 }
126 }
127
128 MainWP_Utility::update_option( 'mainwp_extensions', $new_extensions );
129 update_option( 'mainwp_extensions_all_activation_cached', '' );
130 wp_safe_redirect( esc_url( admin_url( 'admin.php?page=MainWPTools' ) ) );
131 die();
132 }
133 }
134
135 /**
136 * Instantiate the Settings Menu.
137 *
138 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
139 */
140 public static function init_menu() {
141 add_submenu_page(
142 'mainwp_tab',
143 __( 'Settings Global options', 'mainwp' ),
144 ' <span id="mainwp-Settings">' . esc_html__( 'Settings', 'mainwp' ) . '</span>',
145 'read',
146 'Settings',
147 array(
148 self::get_class_name(),
149 'render',
150 )
151 );
152
153 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'MainWPTools' ) ) {
154 add_submenu_page(
155 'mainwp_tab',
156 __( 'Tools', 'mainwp' ),
157 ' <div class="mainwp-hidden">' . esc_html__( 'Tools', 'mainwp' ) . '</div>',
158 'read',
159 'MainWPTools',
160 array(
161 self::get_class_name(),
162 'render_mainwp_tools',
163 )
164 );
165 }
166
167 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsAdvanced' ) ) {
168 add_submenu_page(
169 'mainwp_tab',
170 __( 'Advanced Options', 'mainwp' ),
171 ' <div class="mainwp-hidden">' . esc_html__( 'Advanced Options', 'mainwp' ) . '</div>',
172 'read',
173 'SettingsAdvanced',
174 array(
175 self::get_class_name(),
176 'render_advanced',
177 )
178 );
179 }
180
181 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsEmail' ) ) {
182 add_submenu_page(
183 'mainwp_tab',
184 __( 'Email Settings', 'mainwp' ),
185 ' <div class="mainwp-hidden">' . esc_html__( 'Email Settings', 'mainwp' ) . '</div>',
186 'read',
187 'SettingsEmail',
188 array(
189 self::get_class_name(),
190 'render_email_settings',
191 )
192 );
193 }
194
195 /**
196 * Settings Subpages
197 *
198 * Filters subpages for the Settings page.
199 *
200 * @since Unknown
201 */
202 $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-settings', array( array() ), '4.0.7.2', 'mainwp_getsubpages_settings' ); // @deprecated Use 'mainwp_getsubpages_settings' instead.
203 self::$subPages = apply_filters( 'mainwp_getsubpages_settings', $sub_pages );
204
205 if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
206 foreach ( self::$subPages as $subPage ) {
207 if ( MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) {
208 continue;
209 }
210 add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Settings' . $subPage['slug'], $subPage['callback'] );
211 }
212 }
213 }
214
215 /**
216 * Instantiate Settings SubPages Menu.
217 *
218 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
219 */
220 public static function init_subpages_menu() {
221 ?>
222 <div id="menu-mainwp-Settings" class="mainwp-submenu-wrapper">
223 <div class="wp-submenu sub-open" style="">
224 <div class="mainwp_boxout">
225 <div class="mainwp_boxoutin"></div>
226 <a href="<?php echo esc_url( admin_url( 'admin.php?page=Settings' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'General Settings', 'mainwp' ); ?></a>
227 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsAdvanced' ) ) { ?>
228 <a href="<?php echo esc_url( admin_url( 'admin.php?page=SettingsAdvanced' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Advanced Settings', 'mainwp' ); ?></a>
229 <?php } ?>
230 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsEmail' ) ) { ?>
231 <a href="<?php echo esc_url( admin_url( 'admin.php?page=SettingsEmail' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Email Settings', 'mainwp' ); ?></a>
232 <?php } ?>
233 <?php if ( ! MainWP_Menu::is_disable_menu_item( 3, 'MainWPTools' ) ) { ?>
234 <a href="<?php echo esc_url( admin_url( 'admin.php?page=MainWPTools' ) ); ?>" class="mainwp-submenu"><?php esc_html_e( 'Tools', 'mainwp' ); ?></a>
235 <?php } ?>
236 <?php
237 if ( isset( self::$subPages ) && is_array( self::$subPages ) && ( count( self::$subPages ) > 0 ) ) {
238 foreach ( self::$subPages as $subPage ) {
239 if ( MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) {
240 continue;
241 }
242 ?>
243 <a href="<?php echo esc_url( admin_url( 'admin.php?page=Settings' . $subPage['slug'] ) ); ?>" class="mainwp-submenu"><?php echo isset( $subPage['before_title'] ) ? $subPage['before_title'] : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?> <?php echo esc_html( $subPage['title'] ); ?></a>
244 <?php
245 }
246 }
247 ?>
248 </div>
249 </div>
250 </div>
251 <?php
252 }
253
254 /**
255 * Instantiate left menu
256 *
257 * Settings Page & SubPage link data.
258 *
259 * @param array $subPages SubPages Array.
260 *
261 * @uses \MainWP\Dashboard\MainWP_Menu::add_left_menu()
262 * @uses \MainWP\Dashboard\MainWP_Menu::init_subpages_left_menu()
263 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
264 */
265 public static function init_left_menu( $subPages = array() ) {
266 MainWP_Menu::add_left_menu(
267 array(
268 'title' => esc_html__( 'Settings', 'mainwp' ),
269 'parent_key' => 'mainwp_tab',
270 'slug' => 'Settings',
271 'href' => 'admin.php?page=Settings',
272 'icon' => '<i class="cog icon"></i>',
273 ),
274 0
275 );
276
277 $init_sub_subleftmenu = array(
278 array(
279 'title' => esc_html__( 'General Settings', 'mainwp' ),
280 'parent_key' => 'Settings',
281 'href' => 'admin.php?page=Settings',
282 'slug' => 'Settings',
283 'right' => '',
284 ),
285 array(
286 'title' => esc_html__( 'Advanced Settings', 'mainwp' ),
287 'parent_key' => 'Settings',
288 'href' => 'admin.php?page=SettingsAdvanced',
289 'slug' => 'SettingsAdvanced',
290 'right' => '',
291 ),
292 array(
293 'title' => esc_html__( 'Email Settings', 'mainwp' ),
294 'parent_key' => 'Settings',
295 'href' => 'admin.php?page=SettingsEmail',
296 'slug' => 'SettingsEmail',
297 'right' => '',
298 ),
299 array(
300 'title' => esc_html__( 'Tools', 'mainwp' ),
301 'parent_key' => 'Settings',
302 'href' => 'admin.php?page=MainWPTools',
303 'slug' => 'MainWPTools',
304 'right' => '',
305 ),
306 );
307
308 MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'Settings', 'Settings' );
309 foreach ( $init_sub_subleftmenu as $item ) {
310 if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
311 continue;
312 }
313
314 MainWP_Menu::add_left_menu( $item, 2 );
315 }
316 }
317
318 /**
319 * Render Page Header.
320 *
321 * @param string $shownPage The page slug shown at this moment.
322 *
323 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
324 * @uses \MainWP\Dashboard\MainWP_UI::render_top_header()
325 * @uses \MainWP\Dashboard\MainWP_UI::render_page_navigation()
326 */
327 public static function render_header( $shownPage = '' ) {
328
329 $params = array(
330 'title' => esc_html__( 'MainWP Settings', 'mainwp' ),
331 );
332
333 MainWP_UI::render_top_header( $params );
334
335 $renderItems = array();
336
337 $renderItems[] = array(
338 'title' => esc_html__( 'General Settings', 'mainwp' ),
339 'href' => 'admin.php?page=Settings',
340 'active' => ( '' === $shownPage ) ? true : false,
341 );
342
343 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsAdvanced' ) ) {
344 $renderItems[] = array(
345 'title' => esc_html__( 'Advanced Settings', 'mainwp' ),
346 'href' => 'admin.php?page=SettingsAdvanced',
347 'active' => ( 'Advanced' === $shownPage ) ? true : false,
348 );
349 }
350
351 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsEmail' ) ) {
352 $renderItems[] = array(
353 'title' => esc_html__( 'Email Settings', 'mainwp' ),
354 'href' => 'admin.php?page=SettingsEmail',
355 'active' => ( 'Emails' === $shownPage ) ? true : false,
356 );
357 }
358
359 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'MainWPTools' ) ) {
360 $renderItems[] = array(
361 'title' => esc_html__( 'Tools', 'mainwp' ),
362 'href' => 'admin.php?page=MainWPTools',
363 'active' => ( 'MainWPTools' === $shownPage ) ? true : false,
364 );
365 }
366
367 if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
368 foreach ( self::$subPages as $subPage ) {
369 if ( MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) {
370 continue;
371 }
372 $item = array();
373 $item['title'] = $subPage['title'];
374 $item['href'] = 'admin.php?page=Settings' . $subPage['slug'];
375 $item['active'] = ( $subPage['slug'] === $shownPage ) ? true : false;
376 if ( ! empty( $subPage['before_title'] ) ) {
377 $item['before_title'] = $subPage['before_title'];
378 }
379
380 if ( isset( $subPage['class'] ) ) {
381 $item['class'] = $subPage['class'];
382 }
383 $renderItems[] = $item;
384 }
385 }
386
387 MainWP_UI::render_page_navigation( $renderItems );
388
389 $saved_status = MainWP_Settings_Indicator::get_instance()->get_saved_indicator_status();
390
391 ?>
392
393 <script type="text/javascript">
394 var mainwp_settings_saved_menu_indicator_status = '<?php echo !empty($saved_status) ? wp_json_encode( $saved_status ) : ''; //phpcs:ignore -- ok. ?>';
395 </script>
396 <?php
397 }
398
399 /**
400 * Close the HTML container.
401 */
402 public static function render_footer() {
403 echo '</div>';
404 }
405
406 /**
407 * Method handle_settings_post().
408 *
409 * This class handles the $_POST of Settings Options.
410 *
411 * @uses MainWP_DB::instance()
412 * @uses MainWP_Utility::update_option()
413 *
414 * @return boolean True|False Posts On True.
415 *
416 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
417 * @uses \MainWP\Dashboard\MainWP_DB_Common::update_user_extension()
418 * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
419 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
420 */
421 public static function handle_settings_post() {
422 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'Settings' ) ) {
423 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
424 $userExtension->pluginDir = '';
425
426 MainWP_DB_Common::instance()->update_user_extension( $userExtension );
427 if ( MainWP_System_Utility::is_admin() ) {
428
429 /**
430 * Action: mainwp_before_save_general_settings
431 *
432 * Fires before general settings save.
433 *
434 * @since 4.1
435 */
436 do_action( 'mainwp_before_save_general_settings', $_POST );
437
438 $val = ( ! isset( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) );
439 MainWP_Utility::update_option( 'mainwp_pluginAutomaticDailyUpdate', $val );
440 $val = ( ! isset( $_POST['mainwp_themeAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_themeAutomaticDailyUpdate'] ) );
441 MainWP_Utility::update_option( 'mainwp_themeAutomaticDailyUpdate', $val );
442 $val = ( ! isset( $_POST['mainwp_automaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_automaticDailyUpdate'] ) );
443 MainWP_Utility::update_option( 'mainwp_automaticDailyUpdate', $val );
444 $val = ( ! isset( $_POST['mainwp_show_language_updates'] ) ? 0 : 1 );
445 MainWP_Utility::update_option( 'mainwp_show_language_updates', $val );
446 $val = ( ! isset( $_POST['mainwp_disable_update_confirmations'] ) ? 0 : intval( $_POST['mainwp_disable_update_confirmations'] ) );
447 MainWP_Utility::update_option( 'mainwp_disable_update_confirmations', $val );
448 $val = ( ! isset( $_POST['mainwp_backup_before_upgrade'] ) ? 0 : 1 );
449 MainWP_Utility::update_option( 'mainwp_backup_before_upgrade', $val );
450 $val = ( ! isset( $_POST['mainwp_backup_before_upgrade_days'] ) ? 7 : intval( $_POST['mainwp_backup_before_upgrade_days'] ) );
451 MainWP_Utility::update_option( 'mainwp_backup_before_upgrade_days', $val );
452
453 if ( is_plugin_active( 'mainwp-comments-extension/mainwp-comments-extension.php' ) ) {
454 MainWP_Utility::update_option( 'mainwp_maximumComments', isset( $_POST['mainwp_maximumComments'] ) ? intval( $_POST['mainwp_maximumComments'] ) : 50 );
455 }
456
457 $current_timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' );
458 $new_timeDailyUpdate = isset( $_POST['mainwp_timeDailyUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_timeDailyUpdate'] ) ) : '';
459
460 if ( $current_timeDailyUpdate !== $new_timeDailyUpdate ) {
461 MainWP_Utility::update_option( 'mainwp_timeDailyUpdate', $new_timeDailyUpdate );
462 }
463
464 $new_freq = ( isset( $_POST['mainwp_frequencyDailyUpdate'] ) ? intval( $_POST['mainwp_frequencyDailyUpdate'] ) : 2 );
465 MainWP_Utility::update_option( 'mainwp_frequencyDailyUpdate', $new_freq );
466
467 $new_delay = ( isset( $_POST['mainwp_delay_autoupdate'] ) ? intval( $_POST['mainwp_delay_autoupdate'] ) : 1 );
468 MainWP_Utility::update_option( 'mainwp_delay_autoupdate', $new_delay );
469
470 $val = ( isset( $_POST['mainwp_sidebarPosition'] ) ? intval( $_POST['mainwp_sidebarPosition'] ) : 1 );
471 $user = wp_get_current_user();
472 if ( $user ) {
473 update_user_option( $user->ID, 'mainwp_sidebarPosition', $val, true );
474 }
475
476 MainWP_Utility::update_option( 'mainwp_numberdays_Outdate_Plugin_Theme', ! empty( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) ? intval( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) : 365 );
477 $ignore_http = isset( $_POST['mainwp_ignore_http_response_status'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_ignore_http_response_status'] ) ) : '';
478 MainWP_Utility::update_option( 'mainwp_ignore_HTTP_response_status', $ignore_http );
479
480 $check_http_response = ( isset( $_POST['mainwp_check_http_response'] ) ? 1 : 0 );
481 MainWP_Utility::update_option( 'mainwp_check_http_response', $check_http_response );
482
483 $actions_notification_enable = ( isset( $_POST['mainwp_site_actions_notification_enable'] ) ? 1 : 0 );
484 MainWP_Utility::update_option( 'mainwp_site_actions_notification_enable', $actions_notification_enable );
485
486 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
487 // Handle custom date/time formats.
488 if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] )
489 && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] )
490 ) {
491 $_POST['date_format'] = wp_unslash( $_POST['date_format_custom'] );
492 }
493
494 if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] )
495 && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] )
496 ) {
497 $_POST['time_format'] = wp_unslash( $_POST['time_format_custom'] );
498 }
499
500 if ( isset( $_POST['timezone_string'] ) ) {
501 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
502 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', wp_unslash( $_POST['timezone_string'] ) ) ) {
503 $_POST['gmt_offset'] = wp_unslash( $_POST['timezone_string'] );
504 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', wp_unslash( $_POST['gmt_offset'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
505 $_POST['timezone_string'] = '';
506 }
507
508 $options = array(
509 'gmt_offset',
510 'date_format',
511 'time_format',
512 'timezone_string',
513 );
514
515 foreach ( $options as $option ) {
516 $value = null;
517 if ( isset( $_POST[ $option ] ) ) {
518 $value = wp_unslash( $_POST[ $option ] );
519 if ( ! is_array( $value ) ) {
520 $value = trim( $value );
521 }
522 }
523 update_option( $option, $value );
524 }
525 }
526 //phpcs:enable
527
528 MainWP_Utility::update_option( 'mainwp_use_favicon', 1 );
529
530 /**
531 * Action: mainwp_after_save_general_settings
532 *
533 * Fires after save general settings.
534 *
535 * @since 4.1
536 */
537 do_action( 'mainwp_after_save_general_settings', $_POST );
538 }
539
540 return true;
541 }
542
543 return false;
544 }
545
546 /**
547 * Render the MainWP Settings Page.
548 *
549 * @uses \MainWP\Dashboard\MainWP_Monitoring_View
550 * @uses \MainWP\Dashboard\MainWP_Manage_Backups::render_settings()
551 * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes()
552 */
553 public static function render() { //phpcs:ignore -- complex method.
554 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
555 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
556 return;
557 }
558
559 self::render_header( '' );
560 ?>
561 <div id="mainwp-general-settings" class="ui segment">
562 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-general-settings-info-message' ) ) : ?>
563 <div class="ui info message">
564 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-general-settings-info-message"></i>
565 <?php printf( esc_html__( 'Manage MainWP general settings. For additional help, review this %1$shelp document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
566 </div>
567 <?php endif; ?>
568 <?php if ( isset( $_GET['message'] ) && 'saved' === $_GET['message'] ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
569 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
570 <?php endif; ?>
571 <div class="ui form">
572 <form method="POST" action="admin.php?page=Settings" id="mainwp-settings-page-form">
573 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
574 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'Settings' ) ); ?>" />
575 <?php
576 /**
577 * Action: mainwp_settings_form_top
578 *
579 * Fires at the top of settings form.
580 *
581 * @since 4.1
582 */
583 do_action( 'mainwp_settings_form_top' );
584 ?>
585 <h3 class="ui dividing header">
586 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-general', 'general-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
587 <?php esc_html_e( 'General Settings', 'mainwp' ); ?></h3>
588 <?php
589 $timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' );
590 $frequencyDailyUpdate = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 );
591 $run_timestamp = MainWP_System_Cron_Jobs::get_timestamp_from_hh_mm( $timeDailyUpdate );
592 $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
593
594 ?>
595 <div class="ui grid field settings-field-indicator-general">
596 <label class="six wide column middle aligned">
597 <?php
598 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_timeDailyUpdate', $timeDailyUpdate );
599 esc_html_e( 'Daily sync & update time', 'mainwp' );
600 ?>
601 </label>
602 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Choose a specific time to initiate the first daily synchronization and update process.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
603 <div class="time-selector">
604 <div class="ui input left icon">
605 <i class="clock icon"></i>
606 <input type="text" current-utc-datetime="<?php echo date( 'Y-m-d H:i:s' ); ?>" sync-time-local-datetime="<?php echo date( 'Y-m-d H:i:s', $run_timestamp ); ?>" local-datetime="<?php echo date( 'Y-m-d H:i:s', MainWP_Utility::get_timestamp() ); // phpcs:ignore -- to get local time. ?>" name="mainwp_timeDailyUpdate" id="mainwp_timeDailyUpdate" value="<?php echo esc_attr( $timeDailyUpdate ); ?>" />
607 </div>
608 </div>
609 <script type="text/javascript">
610 jQuery( document ).ready( function() {
611 jQuery( '.time-selector' ).calendar( {
612 type: 'time',
613 ampm: false,
614 formatter: {
615 time: 'H:mm',
616 cellTime: 'H:mm'
617 }
618 } );
619 } );
620 </script>
621 </div>
622 </div>
623 <div class="ui grid field settings-field-indicator-general">
624 <label class="six wide column middle aligned">
625 <?php
626 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_frequencyDailyUpdate', $frequencyDailyUpdate );
627 esc_html_e( 'Frequency of auto sync & updates', 'mainwp' );
628 ?>
629 </label>
630 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set the frequency for automatic synchronization and updates throughout the day.', 'mainwp' ); ?>" data-inverted="" data-position="top left" >
631 <select name="mainwp_frequencyDailyUpdate" id="mainwp_frequencyDailyUpdate" class="ui dropdown">
632 <option value="1" <?php echo ( 1 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Once per day', 'mainwp' ); ?></option>
633 <option value="2" <?php echo ( 2 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Twice per day', 'mainwp' ); ?></option>
634 <option value="3" <?php echo ( 3 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Three times per day', 'mainwp' ); ?></option>
635 <option value="4" <?php echo ( 4 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Four times per day', 'mainwp' ); ?></option>
636 <option value="5" <?php echo ( 5 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Five times per day', 'mainwp' ); ?></option>
637 <option value="6" <?php echo ( 6 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Six times per day', 'mainwp' ); ?></option>
638 <option value="7" <?php echo ( 7 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Seven times per day', 'mainwp' ); ?></option>
639 <option value="8" <?php echo ( 8 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Eight times per day', 'mainwp' ); ?></option>
640 <option value="9" <?php echo ( 9 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Nine times per day', 'mainwp' ); ?></option>
641 <option value="10" <?php echo ( 10 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Ten times per day', 'mainwp' ); ?></option>
642 <option value="11" <?php echo ( 11 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Eleven times per day', 'mainwp' ); ?></option>
643 <option value="12" <?php echo ( 12 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Twelve times per day', 'mainwp' ); ?></option>
644 </select>
645 </div>
646 </div>
647
648 <?php
649 self::render_timezone_settings();
650 self::render_datetime_settings();
651
652 $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
653 if ( false === $sidebarPosition ) {
654 $sidebarPosition = 1;
655 }
656
657 ?>
658 <div class="ui grid field settings-field-indicator-general">
659 <label class="six wide column middle aligned">
660 <?php
661 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sidebarPosition', (int) $sidebarPosition );
662 esc_html_e( 'Sidebar position', 'mainwp' );
663 ?>
664 </label>
665 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Select if you want to show sidebar with option on left or right.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
666 <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
667 <option value="1" <?php echo ( 1 === (int) $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Right (default)', 'mainwp' ); ?></option>
668 <option value="0" <?php echo ( 0 === (int) $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
669 </select>
670 </div>
671 </div>
672 <?php MainWP_UI::render_screen_options(); ?>
673
674 <h3 class="ui dividing header">
675 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-updates', 'general-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
676 <?php esc_html_e( 'Updates Settings', 'mainwp' ); ?></h3>
677 <?php
678 $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate', 0 );
679 $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate', 0 );
680 $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate', 0 );
681 $backup_before_upgrade = get_option( 'mainwp_backup_before_upgrade' );
682 $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
683 if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
684 $mainwp_backup_before_upgrade_days = 7;
685 }
686
687 $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
688
689 $update_time = self::get_websites_automatic_update_time();
690 $lastAutomaticUpdate = $update_time['last'];
691 $nextAutomaticUpdate = $update_time['next'];
692
693 $enableLegacyBackupFeature = get_option( 'mainwp_enableLegacyBackupFeature' );
694 $primaryBackup = get_option( 'mainwp_primaryBackup' );
695 $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
696
697 $http_error_codes = MainWP_Utility::get_http_codes();
698 ?>
699 <div class="ui grid field settings-field-indicator-updates">
700 <label class="six wide column middle aligned">
701 <?php
702 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_pluginAutomaticDailyUpdate', $snPluginAutomaticDailyUpdate );
703 esc_html_e( 'Plugin advanced automatic updates', 'mainwp' );
704 ?>
705 </label>
706 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugins updates. If enabled, MainWP will update only plugins that you have marked as Trusted.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
707 <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown">
708 <option value="1" <?php echo ( 1 === $snPluginAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
709 <option value="0" <?php echo ( ( 0 === $snPluginAutomaticDailyUpdate ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
710 </select>
711 </div>
712 </div>
713 <div class="ui grid field settings-field-indicator-updates">
714 <label class="six wide column middle aligned">
715 <?php
716 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_themeAutomaticDailyUpdate', $snThemeAutomaticDailyUpdate );
717 esc_html_e( 'Theme advanced automatic updates', 'mainwp' );
718 ?>
719 </label>
720 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic themes updates. If enabled, MainWP will update only themes that you have marked as Trusted.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
721 <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown">
722 <option value="1" <?php echo ( 1 === $snThemeAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
723 <option value="0" <?php echo ( 0 === $snThemeAutomaticDailyUpdate || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
724 </select>
725 </div>
726 </div>
727 <div class="ui grid field settings-field-indicator-updates">
728 <label class="six wide column middle aligned">
729 <?php
730 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_automaticDailyUpdate', $snAutomaticDailyUpdate );
731 esc_html_e( 'WP Core advanced automatic updates', 'mainwp' );
732 ?>
733 </label>
734 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic WordPress core updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
735 <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown">
736 <option value="1" <?php echo ( 1 === $snAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
737 <option value="0" <?php echo ( 0 === $snAutomaticDailyUpdate || 2 === (int) $snAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
738 </select>
739 </div>
740 </div>
741 <div class="ui grid field settings-field-indicator-updates">
742 <label class="six wide column middle aligned">
743 <?php
744 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_delay_autoupdate', $delay_autoupdate );
745 esc_html_e( 'Advanced automatic updates delay', 'mainwp' );
746 ?>
747 </label>
748 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'Set the number of days to delay automatic updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
749 <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown">
750 <option value="0" <?php echo ( 0 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
751 <option value="1" <?php echo ( 1 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
752 <option value="2" <?php echo ( 2 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
753 <option value="3" <?php echo ( 3 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
754 <option value="4" <?php echo ( 4 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
755 <option value="5" <?php echo ( 5 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
756 <option value="6" <?php echo ( 6 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
757 <option value="7" <?php echo ( 7 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
758 <option value="14" <?php echo ( 14 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
759 <option value="30" <?php echo ( 30 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
760 </select>
761 </div>
762 </div>
763 <div class="ui grid field settings-field-indicator-updates">
764 <label class="six wide column middle aligned">
765 <?php
766 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_show_language_updates', $mainwp_show_language_updates );
767 esc_html_e( 'Show WordPress language updates', 'mainwp' );
768 ?>
769 </label>
770 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to manage Translation updates', 'mainwp' ); ?>" data-inverted="" data-position="top left">
771 <input type="checkbox" name="mainwp_show_language_updates" id="mainwp_show_language_updates" <?php echo ( 1 === (int) $mainwp_show_language_updates ? 'checked="true"' : '' ); ?>/>
772 </div>
773 </div>
774 <div class="ui grid field settings-field-indicator-updates">
775 <label class="six wide column middle aligned">
776 <?php
777 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disable_update_confirmations', $disableUpdateConfirmations );
778 esc_html_e( 'Update confirmations', 'mainwp' );
779 ?>
780 </label>
781 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Choose if you want to disable the popup confirmations when performing updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
782 <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown">
783 <option value="0" <?php echo ( 0 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
784 <option value="2" <?php echo ( 2 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
785 <option value="1" <?php echo ( 1 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
786 </select>
787 </div>
788 </div>
789 <div class="ui grid field settings-field-indicator-updates">
790 <label class="six wide column middle aligned">
791 <?php
792 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_check_http_response', get_option( 'mainwp_check_http_response', '' ) );
793 esc_html_e( 'Check site HTTP response after update', 'mainwp' );
794 ?>
795 </label>
796 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want your MainWP Dashboard to check child site header response after updates.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
797 <input type="checkbox" name="mainwp_check_http_response" id="mainwp_check_http_response" <?php echo ( ( 1 === (int) get_option( 'mainwp_check_http_response', 0 ) ) ? 'checked="true"' : '' ); ?>/>
798 </div>
799 </div>
800 <div class="ui grid field settings-field-indicator-updates">
801 <label class="six wide column middle aligned">
802 <?php
803 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_ignore_HTTP_response_status', (int) get_option( 'mainwp_ignore_HTTP_response_status', 0 ) );
804 esc_html_e( 'Ignored HTTP response statuses', 'mainwp' );
805 ?>
806 </label>
807 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Select response codes that you want your MainWP Dashboard to ignore.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
808 <div class="ui multiple selection dropdown" init-value="<?php echo esc_attr( ( get_option( 'mainwp_ignore_HTTP_response_status', '' ) ) ); ?>">
809 <input name="mainwp_ignore_http_response_status" type="hidden">
810 <i class="dropdown icon"></i>
811 <div class="default text"></div>
812 <div class="menu">
813 <?php
814 foreach ( $http_error_codes as $error_code => $label ) {
815 ?>
816 <div class="item" data-value="<?php echo esc_attr( $error_code ); ?>"><?php echo esc_html( $error_code . ' (' . $label . ')' ); ?></div>
817 <?php
818 }
819 ?>
820 </div>
821 </div>
822 </div>
823 </div>
824 <?php if ( ( ( $enableLegacyBackupFeature && empty( $primaryBackup ) ) || ( empty( $enableLegacyBackupFeature ) && ! empty( $primaryBackup ) ) ) ) { ?>
825 <div class="ui grid field mainwp-parent-toggle settings-field-indicator-updates">
826 <label class="six wide column middle aligned">
827 <?php
828 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backup_before_upgrade', (int) $backup_before_upgrade );
829 esc_html_e( 'Require a backup before an update', 'mainwp' );
830 ?>
831 </label>
832 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, your MainWP Dashboard will check if full backups exists before updating.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
833 <input type="checkbox" name="mainwp_backup_before_upgrade" id="mainwp_backup_before_upgrade" <?php echo ( 1 === (int) $backup_before_upgrade ? 'checked="true"' : '' ); ?>/>
834 </div>
835 </div>
836 <div class="ui grid field mainwp-child-field settings-field-indicator-updates" <?php echo ( 1 === (int) $backup_before_upgrade ? '' : 'style="display:none"' ); ?> >
837 <label class="six wide column middle aligned">
838 <?php
839 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backup_before_upgrade_days', (int) $mainwp_backup_before_upgrade_days );
840 esc_html_e( 'Days without of a full backup tolerance', 'mainwp' );
841 ?>
842 </label>
843 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set the number of days without of backup tolerance.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
844 <input type="text" name="mainwp_backup_before_upgrade_days" id="mainwp_backup_before_upgrade_days" value="<?php echo esc_attr( $mainwp_backup_before_upgrade_days ); ?>" />
845 </div>
846 </div>
847 <?php } ?>
848
849 <div class="ui grid field settings-field-indicator-updates">
850 <label class="six wide column middle aligned">
851 <?php
852 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_numberdays_Outdate_Plugin_Theme', (int) get_option( 'mainwp_numberdays_Outdate_Plugin_Theme', 365 ) );
853
854 esc_html_e( 'Abandoned plugins/themes tolerance', 'mainwp' );
855 ?>
856 </label>
857 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set how many days without an update before plugin or theme will be considered as abandoned.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
858 <input type="text" name="mainwp_numberdays_Outdate_Plugin_Theme" id="mainwp_numberdays_Outdate_Plugin_Theme" value="<?php echo ( ( false === get_option( 'mainwp_numberdays_Outdate_Plugin_Theme' ) ) ? 365 : intval( get_option( 'mainwp_numberdays_Outdate_Plugin_Theme' ) ) ); ?>"/>
859 </div>
860 </div>
861 <?php MainWP_Monitoring_View::render_settings(); ?>
862 <?php MainWP_Manage_Backups::render_settings(); ?>
863 <?php
864 /**
865 * Action: mainwp_settings_form_bottom
866 *
867 * Fires at the bottom of settings form.
868 *
869 * @since 4.1
870 */
871 do_action( 'mainwp_settings_form_bottom' );
872 ?>
873 <div class="ui divider"></div>
874 <input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
875 <div style="clear:both"></div>
876 </form>
877 </div>
878 </div>
879 <?php
880 self::render_footer( '' );
881 }
882
883 /**
884 * Render Timezone settings.
885 */
886 public static function render_timezone_settings() {
887
888 $current_offset = get_option( 'gmt_offset' );
889 $tzstring = get_option( 'timezone_string' );
890 $check_zone_info = true;
891
892 // Remove old Etc mappings. Fallback to gmt_offset.
893 if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
894 $tzstring = '';
895 }
896
897 if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists.
898 $check_zone_info = false;
899 if ( empty( $current_offset ) ) {
900 $tzstring = 'UTC+0';
901 } elseif ( $current_offset < 0 ) {
902 $tzstring = 'UTC' . $current_offset;
903 } else {
904 $tzstring = 'UTC+' . $current_offset;
905 }
906 }
907
908 $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
909
910 ?>
911 <div class="ui grid field settings-field-indicator-general">
912 <label class="six wide column middle aligned"><?php esc_html_e( 'Timezone', 'mainwp' ); ?></label>
913 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Choose either a city in the same timezone as you or a %s (Coordinated Universal Time) time offset.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
914 <select id="timezone_string" class="ui dropdown" name="timezone_string" aria-describedby="timezone-description">
915 <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
916 </select>
917 <div class="ui hidden fitted divider"></div>
918 <div class="ui secondary segment">
919 <?php printf( esc_html__( 'Universal time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format, false, true ) ) . '</code>' ); ?>
920 <div class="ui hidden fitted divider"></div>
921 <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
922 <?php printf( esc_html__( 'Local time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format ) ) . '</code>' ); ?>
923 <div class="ui hidden fitted divider"></div>
924 <?php endif; ?>
925 <?php if ( $check_zone_info && $tzstring ) : ?>
926 <?php
927 $now = new \DateTime( 'now', new \DateTimeZone( $tzstring ) );
928 $dst = (bool) $now->format( 'I' );
929
930 if ( $dst ) {
931 esc_html_e( 'This timezone is currently in daylight saving time.', 'mainwp' );
932 } else {
933 esc_html_e( 'This timezone is currently in standard time.', 'mainwp' );
934 }
935 ?>
936 <div class="ui hidden fitted divider"></div>
937 <?php
938 if ( in_array( $tzstring, timezone_identifiers_list(), true ) ) {
939 $transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
940
941 if ( ! empty( $transitions[1] ) ) {
942 echo ' ';
943 $message = $transitions[1]['isdst'] ? esc_html__( 'Daylight saving time begins on: %s.', 'mainwp' ) : esc_html__( 'Standard time begins on: %s.', 'mainwp' );
944 printf( $message, '<code>' . wp_date( esc_html__( 'F j, Y' ) . ' ' . esc_html__( 'g:i a' ), esc_html( $transitions[1]['ts'] ) ) . '</code>' ); // phpcs:ignore WordPress.Security.EscapeOutput
945 } else {
946 esc_html_e( 'This timezone does not observe daylight saving time.', 'mainwp' );
947 }
948 }
949 ?>
950 <?php endif; ?>
951 </div>
952 </div>
953 </div>
954 <?php
955 }
956
957 /**
958 * Render Date/Time settings.
959 */
960 public static function render_datetime_settings() {
961 ?>
962 <div class="ui grid field settings-field-indicator-general">
963 <label class="six wide column middle aligned">
964 <?php
965 MainWP_Settings_Indicator::render_not_default_indicator( 'date_formats', get_option( 'date_format' ) );
966 esc_html_e( 'Date format', 'mainwp' );
967 ?>
968 </label>
969 <div class="ten wide column fieldset-wrapper" data-tooltip="<?php esc_attr_e( 'Choose the display format for date.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
970 <?php
971 /**
972 * Filters the default date formats.
973 *
974 * @since 2.7.0
975 * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
976 *
977 * @param string[] $default_date_formats Array of default date formats.
978 */
979 $date_formats = array_unique( apply_filters( 'date_formats', array( esc_html__( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
980
981 $custom = true;
982
983 foreach ( $date_formats as $format ) {
984 echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
985 if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
986 echo " checked='checked'";
987 $custom = false;
988 }
989 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
990 }
991
992 echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
993 checked( $custom );
994 echo '/> <span class="date-time-text date-time-custom-text">' . esc_html__( 'Custom:' ) . '<span class="screen-reader-text"> ' . esc_html__( 'enter a custom date format in the following field' ) . '</span></span></label>' .
995 '<label for="date_format_custom" class="screen-reader-text">' . esc_html__( 'Custom date format:' ) . '</label>' .
996 '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" />' .
997 '<br />' .
998 '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'date_format' ) ) ) . '</span>' .
999 "<span class='spinner'></span>\n" . '</em>';
1000 ?>
1001 </div>
1002 </div>
1003
1004 <div class="ui grid field">
1005 <label class="six wide column middle aligned">
1006 <?php
1007 MainWP_Settings_Indicator::render_not_default_indicator( 'time_format', get_option( 'time_format' ) );
1008 esc_html_e( 'Time format', 'mainwp' );
1009 ?>
1010 </label>
1011 <div class="ten wide column fieldset-wrapper" data-tooltip="<?php esc_attr_e( 'Choose the display format for time.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1012 <?php
1013 /**
1014 * Filters the default time formats.
1015 *
1016 * @since 2.7.0
1017 *
1018 * @param string[] $default_time_formats Array of default time formats.
1019 */
1020 $time_formats = array_unique( apply_filters( 'time_formats', array( esc_html__( 'g:i a' ), 'g:i A', 'H:i' ) ) );
1021
1022 $custom = true;
1023
1024 foreach ( $time_formats as $format ) {
1025 echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
1026 if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===".
1027 echo " checked='checked'";
1028 $custom = false;
1029 }
1030 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
1031 }
1032 echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
1033 checked( $custom );
1034 echo '/> <span class="date-time-text date-time-custom-text">' . esc_html__( 'Custom:' ) . '<span class="screen-reader-text"> ' . esc_html__( 'enter a custom time format in the following field' ) . '</span></span></label>' .
1035 '<label for="time_format_custom" class="screen-reader-text">' . esc_html__( 'Custom time format:' ) . '</label>' .
1036 '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" />' .
1037 '<br />' .
1038 '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'time_format' ) ) ) . '</span>' .
1039 "<span class='spinner'></span>\n" . '</em>';
1040 ?>
1041 </div>
1042 </div>
1043 <script type="text/javascript">
1044 jQuery(document).ready( function($) {
1045 $( 'input[name="date_format"]' ).on( 'click', function() {
1046 if ( 'date_format_custom_radio' !== $( this ).attr( 'id' ) )
1047 $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( '.fieldset-wrapper' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
1048 } );
1049
1050 $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
1051 $( '#date_format_custom_radio' ).prop( 'checked', true );
1052 } );
1053
1054 $( 'input[name="time_format"]' ).on( 'click', function() {
1055 if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) )
1056 $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( '.fieldset-wrapper' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
1057 } );
1058
1059 $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
1060 $( '#time_format_custom_radio' ).prop( 'checked', true );
1061 } );
1062
1063 $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
1064 var format = $( this ),
1065 fieldset = format.closest( '.fieldset-wrapper' ),
1066 example = fieldset.find( '.example' ),
1067 spinner = fieldset.find( '.spinner' );
1068
1069 // Debounce the event callback while users are typing.
1070 clearTimeout( $.data( this, 'timer' ) );
1071 $( this ).data( 'timer', setTimeout( function() {
1072 // If custom date is not empty.
1073 if ( format.val() ) {
1074 spinner.addClass( 'is-active' );
1075
1076 $.post( ajaxurl, {
1077 action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format',
1078 date : format.val()
1079 }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
1080 }
1081 }, 500 ) );
1082 } );
1083 });
1084 </script>
1085 <?php
1086 }
1087
1088 /**
1089 * Method get_websites_automatic_update_time()
1090 *
1091 * Get websites automatic update time.
1092 *
1093 * @return mixed array
1094 *
1095 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_last_automatic_sync()
1096 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count_where_dts_automatic_sync_smaller_then_start()
1097 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
1098 */
1099 public static function get_websites_automatic_update_time() {
1100 $lastAutomaticUpdate = MainWP_DB::instance()->get_websites_last_automatic_sync();
1101 $lasttimeAutomatic = get_option( 'mainwp_updatescheck_last_timestamp' );
1102 $lasttimeStartAutomatic = get_option( 'mainwp_updatescheck_start_last_timestamp' );
1103 $local_timestamp = MainWP_Utility::get_timestamp();
1104 $running = get_option( 'mainwp_cron_checksites_running' );
1105
1106 if ( empty( $lasttimeStartAutomatic ) && ! empty( $lasttimeAutomatic ) ) {
1107 $lasttimeStartAutomatic = $lasttimeAutomatic;
1108 }
1109
1110 if ( empty( $lastAutomaticUpdate ) ) {
1111 $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' );
1112 } elseif ( 'yes' === $running && ( 0 < MainWP_DB::instance()->get_websites_count_where_dts_automatic_sync_smaller_then_start( $lasttimeStartAutomatic ) || 0 < MainWP_DB::instance()->get_websites_check_updates_count( $lasttimeStartAutomatic ) ) ) {
1113 $nextAutomaticUpdate = esc_html__( 'Processing your websites.', 'mainwp' );
1114 } else {
1115 $next_time = MainWP_System_Cron_Jobs::get_next_time_automatic_update_to_show();
1116 if ( $next_time < $local_timestamp + 5 * MINUTE_IN_SECONDS ) {
1117 $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' );
1118 } else {
1119 $nextAutomaticUpdate = MainWP_Utility::format_timestamp( $next_time );
1120 }
1121 }
1122
1123 if ( empty( $lastAutomaticUpdate ) ) {
1124 $lastAutomaticUpdate = esc_html__( 'Never', 'mainwp' );
1125 } else {
1126 $lastAutomaticUpdate = MainWP_Utility::format_timestamp( $lastAutomaticUpdate );
1127 }
1128
1129 return array(
1130 'last' => $lastAutomaticUpdate,
1131 'next' => $nextAutomaticUpdate,
1132 );
1133 }
1134
1135 /**
1136 * Returns false or the location of the OpenSSL Lib File.
1137 *
1138 * @return mixed false|opensslLibLocation
1139 *
1140 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning()
1141 */
1142 public static function show_openssl_lib_config() {
1143 if ( MainWP_Server_Information_Handler::is_openssl_config_warning() ) {
1144 return true;
1145 } else {
1146 return false;
1147 }
1148 }
1149
1150 /**
1151 * Render Advanced Options Subpage.
1152 *
1153 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1154 */
1155 public static function render_advanced() { //phpcs:ignore -- complex method.
1156 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
1157 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1158 return;
1159 }
1160
1161 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) {
1162
1163 /**
1164 * Action: mainwp_before_save_advanced_settings
1165 *
1166 * Fires before save advanced settings.
1167 *
1168 * @since 4.1
1169 */
1170 do_action( 'mainwp_before_save_advanced_settings', $_POST );
1171
1172 MainWP_Utility::update_option( 'mainwp_maximumRequests', ! empty( $_POST['mainwp_maximumRequests'] ) ? intval( $_POST['mainwp_maximumRequests'] ) : 4 );
1173 MainWP_Utility::update_option( 'mainwp_minimumDelay', ! empty( $_POST['mainwp_minimumDelay'] ) ? intval( $_POST['mainwp_minimumDelay'] ) : 200 );
1174 MainWP_Utility::update_option( 'mainwp_maximumIPRequests', ! empty( $_POST['mainwp_maximumIPRequests'] ) ? intval( $_POST['mainwp_maximumIPRequests'] ) : 1 );
1175 MainWP_Utility::update_option( 'mainwp_minimumIPDelay', ! empty( $_POST['mainwp_minimumIPDelay'] ) ? intval( $_POST['mainwp_minimumIPDelay'] ) : 1000 );
1176 MainWP_Utility::update_option( 'mainwp_maximumSyncRequests', ! empty( $_POST['mainwp_maximumSyncRequests'] ) ? intval( $_POST['mainwp_maximumSyncRequests'] ) : 8 );
1177 MainWP_Utility::update_option( 'mainwp_maximumInstallUpdateRequests', ! empty( $_POST['mainwp_maximumInstallUpdateRequests'] ) ? intval( $_POST['mainwp_maximumInstallUpdateRequests'] ) : 3 );
1178 MainWP_Utility::update_option( 'mainwp_sslVerifyCertificate', isset( $_POST['mainwp_sslVerifyCertificate'] ) ? 1 : 0 );
1179 MainWP_Utility::update_option( 'mainwp_connect_signature_algo', isset( $_POST['mainwp_settings_openssl_alg'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_settings_openssl_alg'] ) ) : 0 );
1180 MainWP_Utility::update_option( 'mainwp_verify_connection_method', isset( $_POST['mainwp_settings_verify_connection_method'] ) ? intval( $_POST['mainwp_settings_verify_connection_method'] ) : 0 );
1181 MainWP_Utility::update_option( 'mainwp_forceUseIPv4', isset( $_POST['mainwp_forceUseIPv4'] ) ? 1 : 0 );
1182 MainWP_Utility::update_option( 'mainwp_wp_cron', ( ! isset( $_POST['mainwp_options_wp_cron'] ) ? 0 : 1 ) );
1183 MainWP_Utility::update_option( 'mainwp_optimize', ( ! isset( $_POST['mainwp_optimize'] ) ? 0 : 1 ) );
1184
1185 if ( isset( $_POST['mainwp_openssl_lib_location'] ) ) {
1186 $openssl_loc = ! empty( $_POST['mainwp_openssl_lib_location'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_openssl_lib_location'] ) ) : '';
1187 MainWP_Utility::update_option( 'mainwp_opensslLibLocation', $openssl_loc );
1188 }
1189
1190 /**
1191 * Action: mainwp_after_save_advanced_settings
1192 *
1193 * Fires after advanced settings save.
1194 *
1195 * @since 4.1
1196 */
1197 do_action( 'mainwp_after_save_advanced_settings', $_POST );
1198 }
1199 self::render_header( 'Advanced' );
1200 ?>
1201
1202 <div id="mainwp-advanced-settings" class="ui segment">
1203 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-advanced-settings-info-notice' ) ) : ?>
1204 <div class="ui info message">
1205 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-advanced-settings-info-notice"></i>
1206 <?php echo esc_html__( 'Set how many requests are performed at once and delay between requests in order to optimize your MainWP Dashboard performance. Both Cross IP and IP Settings handle the majority of work connecting to your Child sites, while the sync, update, and installation request have specialized options under the Frontend Requests Settings section.', 'mainwp' ); ?>
1207 </div>
1208 <?php endif; ?>
1209 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) : ?>
1210 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1211 <?php endif; ?>
1212 <div class="ui form">
1213 <form method="POST" action="">
1214 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1215 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SettingsAdvanced' ) ); ?>" />
1216 <?php
1217
1218 /**
1219 * Action: mainwp_advanced_settings_form_top
1220 *
1221 * Fires at the top of advanced settings form.
1222 *
1223 * @since 4.1
1224 */
1225 do_action( 'mainwp_advanced_settings_form_top' );
1226
1227 if ( self::show_openssl_lib_config() ) {
1228 $openssl_loc = MainWP_System_Utility::get_openssl_conf();
1229 ?>
1230 <h3 class="ui dividing header">
1231 <?php esc_html_e( 'OpenSSL Settings', 'mainwp' ); ?>
1232 <div class="sub header"><?php esc_html_e( 'Due to bug with PHP on some servers it is required to set the OpenSSL Library location so MainWP Dashboard can connect to your child sites.', 'mainwp' ); ?></div>
1233 </h3>
1234 <div class="ui grid field">
1235 <label class="six wide column middle aligned"><?php esc_html_e( 'OpenSSL.cnf location', 'mainwp' ); ?></label>
1236 <div class="ten wide column ui field">
1237 <input type="text" name="mainwp_openssl_lib_location" value="<?php echo esc_html( $openssl_loc ); ?>">
1238 <em><?php esc_html_e( 'If your openssl.cnf file is saved to a different path from what is entered please enter your exact path.', 'mainwp' ); ?> <?php printf( esc_html__( 'If you are not sure how to find the openssl.cnf location, please %1$scheck this help document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/how-to-find-the-openssl-cnf-file/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?></em>
1239 <em><?php esc_html_e( 'If you have confirmed the placement of your openssl.cnf and are still receiving an error banner, click the "Error Fixed" button to dismiss it.', 'mainwp' ); ?></em>
1240 </div>
1241 </div>
1242 <?php } ?>
1243
1244 <h3 class="ui dividing header">
1245 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-cross-ip', 'advanced-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1246 <?php esc_html_e( 'Cross IP Settings', 'mainwp' ); ?></h3>
1247
1248 <div class="ui grid field settings-field-indicator-cross-ip">
1249 <label class="six wide column middle aligned">
1250 <?php
1251 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumRequests', (int) get_option( 'mainwp_maximumRequests', 4 ) );
1252 esc_html_e( 'Maximum simultaneous requests (Default: 4)', 'mainwp' );
1253 ?>
1254 </label>
1255 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'If too many requests are sent out, they will begin to time out. This causes your sites to be shown as offline while they are up and running.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1256 <input type="text" name="mainwp_maximumRequests" id="mainwp_maximumRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumRequests' ) ) ? 4 : esc_attr( get_option( 'mainwp_maximumRequests' ) ) ); ?>"/>
1257 </div>
1258 </div>
1259
1260 <div class="ui grid field settings-field-indicator-cross-ip">
1261 <label class="six wide column middle aligned">
1262 <?php
1263 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_minimumDelay', (int) get_option( 'mainwp_minimumDelay', 200 ) );
1264 esc_html_e( 'Minimum delay between requests (Default: 200)', 'mainwp' );
1265 ?>
1266 </label>
1267 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'This option allows you to control minimum time delay between two requests.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1268 <input type="text" name="mainwp_minimumDelay" id="mainwp_minimumDelay" value="<?php echo ( ( false === get_option( 'mainwp_minimumDelay' ) ) ? 200 : esc_attr( get_option( 'mainwp_minimumDelay' ) ) ); ?>"/>
1269 </div>
1270 </div>
1271
1272 <h3 class="ui dividing header">
1273 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-per-ip', 'advanced-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1274 <?php esc_html_e( 'Per IP Settings', 'mainwp' ); ?></h3>
1275
1276 <div class="ui grid field settings-field-indicator-per-ip">
1277 <label class="six wide column middle aligned">
1278 <?php
1279 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumIPRequests', (int) get_option( 'mainwp_maximumIPRequests', 1 ) );
1280 esc_html_e( 'Maximum simultaneous requests per IP (Default: 1)', 'mainwp' );
1281 ?>
1282 </label>
1283 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'If too many requests are sent out, they will begin to time out. This causes your sites to be shown as offline while they are up and running.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1284 <input type="text" name="mainwp_maximumIPRequests" id="mainwp_maximumIPRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumIPRequests' ) ) ? 1 : esc_attr( get_option( 'mainwp_maximumIPRequests' ) ) ); ?>"/>
1285 </div>
1286 </div>
1287
1288 <div class="ui grid field settings-field-indicator-per-ip">
1289 <label class="six wide column middle aligned">
1290 <?php
1291 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_minimumIPDelay', (int) get_option( 'mainwp_minimumIPDelay', 1000 ) );
1292 esc_html_e( 'Minimum delay between requests to the same IP (Default: 1000)', 'mainwp' );
1293 ?>
1294 </label>
1295 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'This option allows you to control minimum time delay between two requests.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1296 <input type="text" name="mainwp_minimumIPDelay" id="mainwp_minimumIPDelay" value="<?php echo ( ( false === get_option( 'mainwp_minimumIPDelay' ) ) ? 1000 : esc_attr( get_option( 'mainwp_minimumIPDelay' ) ) ); ?>"/>
1297 </div>
1298 </div>
1299
1300 <h3 class="ui dividing header">
1301 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-frontend-request', 'advanced-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1302 <?php esc_html_e( 'Frontend Request Settings', 'mainwp' ); ?></h3>
1303
1304 <div class="ui grid field settings-field-indicator-frontend-request">
1305 <label class="six wide column middle aligned">
1306 <?php
1307 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumSyncRequests', (int) get_option( 'mainwp_maximumSyncRequests', 8 ) );
1308 esc_html_e( 'Maximum simultaneous sync requests (Default: 8)', 'mainwp' );
1309 ?>
1310 </label>
1311 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'This option allows you to control how many sites your MainWP Dashboard should sync at once.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1312 <input type="text" name="mainwp_maximumSyncRequests" id="mainwp_maximumSyncRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumSyncRequests' ) ) ? 8 : esc_attr( get_option( 'mainwp_maximumSyncRequests' ) ) ); ?>"/>
1313 </div>
1314 </div>
1315
1316 <div class="ui grid field settings-field-indicator-frontend-request">
1317 <label class="six wide column middle aligned">
1318 <?php
1319 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumInstallUpdateRequests', (int) get_option( 'mainwp_maximumInstallUpdateRequests', 3 ) );
1320 esc_html_e( 'Maximum simultaneous install and update requests (Default: 3)', 'mainwp' );
1321 ?>
1322 </label>
1323 <div class="ten wide column ui input" data-tooltip="<?php esc_attr_e( 'This option allows you to control how many update and install requests your MainWP Dashboard should process at once.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1324 <input type="text" name="mainwp_maximumInstallUpdateRequests" id="mainwp_maximumInstallUpdateRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumInstallUpdateRequests' ) ) ? 3 : esc_attr( get_option( 'mainwp_maximumInstallUpdateRequests' ) ) ); ?>"/>
1325 </div>
1326 </div>
1327
1328 <h3 class="ui dividing header">
1329 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-miscellaneous', 'advanced-settings' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1330 <?php esc_html_e( 'Miscellaneous Settings', 'mainwp' ); ?></h3>
1331 <div class="ui grid field settings-field-indicator-miscellaneous">
1332 <label class="six wide column middle aligned">
1333 <?php
1334 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_optimize', (int) get_option( 'mainwp_optimize', 1 ) );
1335 esc_html_e( 'Optimize data loading', 'mainwp' );
1336 ?>
1337 </label>
1338 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, your MainWP Dashboard will cache updates for faster loading.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1339 <input type="checkbox" name="mainwp_optimize" id="mainwp_optimize" <?php echo ( ( 1 === (int) get_option( 'mainwp_optimize', 1 ) ) ? 'checked="true"' : '' ); ?> /><label><?php esc_html_e( 'Default: Off', 'mainwp' ); ?></label>
1340 </div>
1341 </div>
1342 <div class="ui grid field settings-field-indicator-miscellaneous">
1343 <label class="six wide column middle aligned">
1344 <?php
1345 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_wp_cron', (int) get_option( 'mainwp_wp_cron', 1 ) );
1346 esc_html_e( 'Use WP Cron', 'mainwp' );
1347 ?>
1348 </label>
1349 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Disabling this option will disable the WP Cron so all scheduled events will stop working.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1350 <input type="checkbox" name="mainwp_options_wp_cron" id="mainwp_options_wp_cron" <?php echo ( ( 1 === (int) get_option( 'mainwp_wp_cron' ) ) || ( false === get_option( 'mainwp_wp_cron' ) ) ? 'checked="true"' : '' ); ?>/><label><?php esc_html_e( 'Default: On', 'mainwp' ); ?></label>
1351 </div>
1352 </div>
1353 <div class="ui grid field settings-field-indicator-miscellaneous" >
1354 <label class="six wide column middle aligned"><?php esc_html_e( 'Verify SSL certificate', 'mainwp' ); ?></label>
1355 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, your MainWP Dashboard will verify the SSL Certificate on your Child Site (if exists) while connecting the Child Site.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1356 <input type="checkbox" name="mainwp_sslVerifyCertificate" id="mainwp_sslVerifyCertificate" value="checked" <?php echo ( ( false === get_option( 'mainwp_sslVerifyCertificate' ) ) || ( 1 === (int) get_option( 'mainwp_sslVerifyCertificate' ) ) ) ? 'checked="checked"' : ''; ?>/><label><?php esc_html_e( 'Default: On', 'mainwp' ); ?></label>
1357 </div>
1358 </div>
1359 <?php
1360 $general_verify_con = (int) get_option( 'mainwp_verify_connection_method', 1 );
1361 ?>
1362 <div class="ui grid field settings-field-indicator-miscellaneous">
1363 <label class="six wide column middle aligned">
1364 <?php
1365 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_verify_connection_method', (int) $general_verify_con );
1366 esc_html_e( 'Verify connection method', 'mainwp' );
1367 ?>
1368 </label>
1369 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Select Verify connection method. If you are not sure, select "Default".', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1370 <select class="ui dropdown" id="mainwp_settings_verify_connection_method" name="mainwp_settings_verify_connection_method">
1371 <option <?php echo ( empty( $general_verify_con ) || 1 === $general_verify_con ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'OpenSSL (default)', 'mainwp' ); ?></option>
1372 <option <?php echo ( 2 === $general_verify_con ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'PHPSECLIB (fallback)', 'mainwp' ); ?></option>
1373 </select>
1374 </div>
1375 </div>
1376 <?php
1377 $sign_note = MainWP_Connect_Lib::get_connection_algo_settings_note();
1378 $sign_algs = MainWP_System_Utility::get_open_ssl_sign_algos();
1379 $general_sign_alg = get_option( 'mainwp_connect_signature_algo', false );
1380 if ( false === $general_sign_alg ) {
1381 $general_sign_alg = defined( 'OPENSSL_ALGO_SHA256' ) ? OPENSSL_ALGO_SHA256 : 1;
1382 MainWP_Utility::update_option( 'mainwp_connect_signature_algo', $general_sign_alg );
1383 } else {
1384 $general_sign_alg = intval( $general_sign_alg );
1385 }
1386 ?>
1387 <div class="ui grid field mainwp-hide-elemenent-sign-algo settings-field-indicator-miscellaneous" <?php echo ( 2 === $general_verify_con ) ? 'style="display:none;"' : ''; ?> >
1388 <label class="six wide column middle aligned">
1389 <?php
1390 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_connect_signature_algo', (int) $general_sign_alg );
1391 esc_html_e( 'OpenSSL signature algorithm', 'mainwp' );
1392 ?>
1393 </label>
1394 <div class="ui six wide column" data-tooltip="<?php esc_attr_e( 'Select OpenSSL signature algorithm. If you are not sure, select "Default".', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1395 <select class="ui dropdown" id="mainwp_settings_openssl_alg" name="mainwp_settings_openssl_alg">
1396 <?php
1397 foreach ( $sign_algs as $val => $text ) {
1398 ?>
1399 <option <?php echo ( $val === $general_sign_alg ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $val ); ?>"><?php echo esc_html( $text ); ?></option>
1400 <?php
1401 }
1402 ?>
1403 </select>
1404 <div class="ui yellow message mainwp-hide-elemenent-sign-algo-note" <?php echo ( 1 === $general_sign_alg ) ? '' : 'style="display:none;"'; ?>><?php echo esc_html( $sign_note ); ?></div>
1405 </div>
1406 </div>
1407 <div class="ui grid field settings-field-indicator-miscellaneous">
1408 <label class="six wide column middle aligned">
1409 <?php
1410 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_forceUseIPv4', (int) get_option( 'mainwp_forceUseIPv4' ) );
1411 esc_html_e( 'Force IPv4', 'mainwp' );
1412 ?>
1413 </label>
1414 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'Enable if you want to force your MainWP Dashboard to use IPv4 while tryig to connect child sites.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1415 <input type="checkbox" name="mainwp_forceUseIPv4" id="mainwp_forceUseIPv4" value="checked" <?php echo ( 1 === (int) get_option( 'mainwp_forceUseIPv4' ) ) ? 'checked="checked"' : ''; ?>/><label><?php esc_html_e( 'Default: Off', 'mainwp' ); ?></label>
1416 </div>
1417 </div>
1418 <?php
1419
1420 /**
1421 * Action: mainwp_advanced_settings_form_bottom
1422 *
1423 * Fires at the bottom of advanced settings form.
1424 *
1425 * @since 4.1
1426 */
1427 do_action( 'mainwp_advanced_settings_form_bottom' );
1428
1429 ?>
1430 <div class="ui divider"></div>
1431 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1432 </form>
1433 </div>
1434 </div>
1435 <?php
1436 self::render_footer( 'Advanced' );
1437 }
1438
1439 /**
1440 * Render MainWP Tools SubPage.
1441 *
1442 * @uses \MainWP\Dashboard\MainWP_UI::render_screen_options()
1443 */
1444 public static function render_mainwp_tools() {
1445 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
1446 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1447
1448 return;
1449 }
1450 self::render_header( 'MainWPTools' );
1451 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1452 ?>
1453 <div id="mainwp-tools-settings" class="ui segment">
1454 <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
1455 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-message' ) ) : ?>
1456 <div class="ui info message">
1457 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-message"></i>
1458 <?php printf( esc_html__( 'Use MainWP tools to adjust your MainWP Dashboard to your needs and perform specific actions when needed. For additional help, review this %1$shelp document%2$s.', 'mainwp' ), '<a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/" target="_blank">', '</a> <i class="external alternate icon"></i>' ); ?>
1459 </div>
1460 <?php endif; ?>
1461 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-custom-theme' ) ) : ?>
1462 <div class="ui info message">
1463 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-custom-theme"></i>
1464 <div><?php esc_html_e( 'Here you can select a theme for your MainWP Dashboard.', 'mainwp' ); ?></div>
1465 <div><?php esc_html_e( 'To create a custom theme, copy the `mainwp-dark-theme.css` file from the MainWP Custom Dashboard Extension located in the `css` directory, make your edits and upload the file to the `../wp-content/uploads/mainwp/custom-dashboard/` directory.', 'mainwp' ); ?></div>
1466 </div>
1467 <?php endif; ?>
1468 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1469 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1470 <?php endif; ?>
1471 <?php if ( isset( $_POST['mainwp_restore_info_messages'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1472 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Info messages have been restored successfully!', 'mainwp' ); ?></div>
1473 <?php endif; ?>
1474 <div class="ui form">
1475 <form method="POST" action="">
1476 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1477 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPTools' ) ); ?>" />
1478 <h3 class="ui dividing header">
1479 <?php echo MainWP_Settings_Indicator::get_indicator( 'header', 'settings-field-indicator-tools', 'mainwp-tools' ); //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
1480 <?php esc_html_e( 'MainWP Dashboard Tools', 'mainwp' ); ?></h3>
1481 <?php
1482 /**
1483 * Action: mainwp_tools_form_top
1484 *
1485 * Fires at the top of MainWP tools form.
1486 *
1487 * @since 4.1
1488 */
1489 do_action( 'mainwp_tools_form_top' );
1490
1491 $show_qsw = apply_filters( 'mainwp_show_qsw', true );
1492
1493 self::get_instance()->render_select_custom_themes();
1494
1495 ?>
1496 <div class="ui grid field settings-field-indicator-tools">
1497 <label class="six wide column middle aligned">
1498 <?php
1499 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_enable_guided_tours', (int) get_option( 'mainwp_enable_guided_tours', 0 ) );
1500 esc_html_e( 'Enable MainWP guided tours', 'mainwp' );
1501 ?>
1502 <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></label>
1503 <div class="ten wide column " data-tooltip="<?php esc_attr_e( 'Check this option to enable, or uncheck to disable MainWP guided tours.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1504 <div class="ui info message" style="display:block!important;">
1505 <?php printf( esc_html__( 'This feature is implemented using Javascript provided by Usetiful and is subject to the %1$sUsetiful Privacy Policy%2$s.', 'mainwp' ), '<a href="https://www.usetiful.com/privacy-policy" target="_blank">', '</a>' ); ?>
1506 </div>
1507 <div class="ui toggle checkbox">
1508 <input type="checkbox" name="mainwp-guided-tours-option" id="mainwp-guided-tours-option" <?php echo ( ( 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ) ? 'checked="true"' : '' ); ?> />
1509 </div>
1510 </div>
1511 </div>
1512 <div class="ui grid field">
1513 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashboard to establish a new connection', 'mainwp' ); ?></label>
1514 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Force your MainWP Dashboard to reconnect with your child sites. Only needed if suggested by MainWP Support.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1515 <?php
1516 if ( $is_demo ) {
1517 MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<input type="button" disabled="disabled" class="ui green basic button disabled" value="' . esc_attr__( 'Re-establish Connections', 'mainwp' ) . '" />' );
1518 } else {
1519 ?>
1520 <input type="button" name="" id="force-destroy-sessions-button" data-inverted="" data-position="top right" data-tooltip="<?php esc_attr_e( 'Forces your dashboard to reconnect with your child sites. This feature will log out any currently logged in users on the Child sites and require them to re-log in. Only needed if suggested by MainWP Support.', 'mainwp' ); ?>" class="ui green basic button" value="<?php esc_attr_e( 'Re-establish Connections', 'mainwp' ); ?>" />
1521 <?php } ?>
1522 </div>
1523 </div>
1524 <div class="ui grid field">
1525 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashbaord to set new pair of OpenSSL Keys', 'mainwp' ); ?></label>
1526 <div class="ten wide column" id="mainwp-renew-connections-tool" data-content="<?php esc_attr_e( 'This will function renew connection and reconnect site right away.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left">
1527 <?php
1528 if ( $is_demo ) {
1529 MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="javascript:void(0)" disabled="disabled" class="ui button green basic disabled">' . esc_html__( 'Reset OpenSSL Key Pair', 'mainwp' ) . '</a>' );
1530 } else {
1531 ?>
1532 <a href="javascript:void(0)" onclick="mainwp_tool_renew_connections_show(); return false;" class="ui button green basic"><?php esc_html_e( 'Reset OpenSSL Key Pair', 'mainwp' ); ?></a>
1533 <?php } ?>
1534 </div>
1535 </div>
1536 <?php if ( $show_qsw ) { ?>
1537 <div class="ui grid field">
1538 <label class="six wide column middle aligned"><?php esc_html_e( 'Start the MainWP Quick Setup Wizard', 'mainwp' ); ?></label>
1539 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Click this button to start the Quick Setup Wizard', 'mainwp' ); ?>" data-inverted="" data-position="top left"><a href="admin.php?page=mainwp-setup" class="ui green button basic" ><?php esc_html_e( 'Start Quick Setup Wizard', 'mainwp' ); ?></a></div>
1540 </div>
1541 <?php } ?>
1542 <div class="ui grid field">
1543 <label class="six wide column middle aligned"><?php esc_html_e( 'Export child sites to CSV file', 'mainwp' ); ?></label>
1544 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Click this button to export all connected sites to a CSV file.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><a href="admin.php?page=MainWPTools&doExportSites=yes&_wpnonce=<?php echo esc_attr( wp_create_nonce( 'export_sites' ) ); ?>" class="ui button green basic"><?php esc_html_e( 'Export Child Sites', 'mainwp' ); ?></a></div>
1545 </div>
1546 <div class="ui grid field">
1547 <label class="six wide column middle aligned"><?php esc_html_e( 'Import child sites', 'mainwp' ); ?></label>
1548 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Click this button to import websites to your MainWP Dashboard.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><a href="admin.php?page=managesites&do=bulknew" class="ui button green basic"><?php esc_html_e( 'Import Child Sites', 'mainwp' ); ?></a></div>
1549 </div>
1550 <div class="ui grid field">
1551 <label class="six wide column middle aligned"><?php esc_html_e( 'Disconnect all child sites', 'mainwp' ); ?></label>
1552 <div class="ten wide column" id="mainwp-disconnect-sites-tool" data-content="<?php esc_attr_e( 'This will function will break the connection and leave the MainWP Child plugin active and which makes your sites vulnerable. Use only if you attend to reconnect site to the same or a different dashboard right away.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left">
1553 <?php
1554 if ( $is_demo ) {
1555 MainWP_Demo_Handle::get_instance()->render_demo_disable_button( '<a href="#" class="ui button green basic disabled" disabled="disabled">' . esc_html__( 'Disconnect Sites', 'mainwp' ) . '</a>' );
1556 } else {
1557 ?>
1558 <a href="admin.php?page=MainWPTools&disconnectSites=yes&_wpnonce=<?php echo esc_attr( wp_create_nonce( 'disconnect_sites' ) ); ?>" onclick="mainwp_tool_disconnect_sites(); return false;" class="ui button green basic"><?php esc_html_e( 'Disconnect Sites', 'mainwp' ); ?></a>
1559 <?php } ?>
1560 </div>
1561 </div>
1562 <div class="ui grid field">
1563 <label class="six wide column middle aligned"><?php esc_html_e( 'Delete extensions API Activation data', 'mainwp' ); ?></label>
1564 <div class="ten wide column" id="mainwp-clear-activation-data" data-content="<?php esc_attr_e( 'Delete extensions API activation data. This will not affect extensions settings, it just removes API activation data.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left">
1565 <a href="admin.php?page=MainWPTools&clearActivationData=yes&_wpnonce=<?php echo esc_attr( wp_create_nonce( 'clear_activation_data' ) ); ?>" onclick="mainwp_tool_clear_activation_data(this); return false;" class="ui button green basic"><?php esc_html_e( 'Delete Extensions API Activation Data', 'mainwp' ); ?></a>
1566 </div>
1567 </div>
1568 <div class="ui grid field">
1569 <label class="six wide column middle aligned"><?php esc_html_e( 'Restore all info messages', 'mainwp' ); ?></label>
1570 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Click this button to restore all info messages in your MainWP Dashboard and Extensions.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1571 <input type="submit" name="mainwp_restore_info_messages" id="mainwp_restore_info_messages" class="ui button" value="<?php esc_attr_e( 'Restore Info Messages', 'mainwp' ); ?>"/>
1572 </div>
1573 </div>
1574 <?php
1575 $enabled_demo = MainWP_Demo_Handle::is_demo_mode();
1576 $is_new = MainWP_Demo_Handle::get_instance()->is_new_instance();
1577 if ( ! MainWP_Demo_Handle::is_instawp_site() ) {
1578 ?>
1579 <div class="ui grid field">
1580 <label class="six wide column middle aligned"><?php echo esc_html__( 'Demo mode', 'mainwp' ); ?></label>
1581 <div class="ten wide column">
1582 <?php if ( ! $enabled_demo ) { ?>
1583 <span data-tooltip="<?php esc_attr_e( 'Demo Mode can not be enabled on MainWP Dashboards that already have sites connected, clients created or extensions installed.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><button page-import="settings" class="ui green button mainwp-import-demo-data-button" <?php echo ( ! $is_new ? 'disabled="disabled"' : '' ); ?>><?php esc_html_e( 'Import Demo Content', 'mainwp' ); ?></button></span>
1584 <?php } else { ?>
1585 <span data-tooltip="<?php esc_attr_e( 'Click this button to delete the Demo content from your MainWP Dashboard and disable the Demo mode.', 'mainwp' ); ?>" data-inverted="" data-position="top left"><button class="ui green button mainwp-remove-demo-data-button"><?php esc_html_e( 'Delete Demo Content', 'mainwp' ); ?></button></span>
1586 <?php } ?>
1587 </div>
1588 </div>
1589 <?php
1590 }
1591 /**
1592 * Action: mainwp_tools_form_bottom
1593 *
1594 * Fires at the bottom of mainwp tools form.
1595 *
1596 * @since 4.1
1597 */
1598 do_action( 'mainwp_tools_form_bottom' );
1599 ?>
1600 <div class="ui divider"></div>
1601 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1602 </form>
1603 </div>
1604 </div>
1605 <script type="text/javascript">
1606 jQuery( '#mainwp-disconnect-sites-tool' ).popup();
1607 jQuery( '#mainwp-clear-activation-data' ).popup();
1608 </script>
1609 <?php
1610 self::render_footer( 'MainWPTools' );
1611 MainWP_Connect_Helper::render_renew_connections_modal();
1612 }
1613
1614 /**
1615 * Render MainWP themes selection.
1616 */
1617 public function render_select_custom_themes() {
1618 $custom_theme = $this->get_current_user_theme();
1619 if ( false === $custom_theme ) {
1620 // to compatible with Custom Dashboard extension settings.
1621 $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1622 if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1623 $compat_theme = $compat_settings['theme'];
1624 }
1625 if ( null !== $compat_theme ) {
1626 $custom_theme = $compat_theme;
1627 }
1628 }
1629 $themes_files = self::get_instance()->get_custom_themes_files();
1630 if ( empty( $themes_files ) ) {
1631 $themes_files = array();
1632 }
1633 ?>
1634 <div class="ui grid field settings-field-indicator-tools">
1635 <label class="six wide column middle aligned">
1636 <?php
1637 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_selected_theme', $custom_theme );
1638 esc_html_e( 'Select MainWP Theme', 'mainwp' );
1639 ?>
1640 </label>
1641 <div class="ten wide column" tabindex="0" data-tooltip="<?php esc_attr_e( 'Select your MainWP Dashboard theme.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1642 <select name="mainwp_settings_custom_theme" id="mainwp_settings_custom_theme" class="ui dropdown selection">
1643 <option value="default" <?php echo ( 'default' === $custom_theme || empty( $custom_theme ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Default', 'mainwp' ); ?></option>
1644 <option value="classic" <?php echo ( 'classic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Classic', 'mainwp' ); ?></option>
1645 <option value="dark" <?php echo ( 'dark' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Dark', 'mainwp' ); ?></option>
1646 <option value="wpadmin" <?php echo ( 'wpadmin' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'WP Admin', 'mainwp' ); ?></option>
1647 <option value="minimalistic" <?php echo ( 'minimalistic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Minimalistic', 'mainwp' ); ?></option>
1648 <?php
1649 foreach ( $themes_files as $file_name => $theme ) {
1650 $theme = ucfirst( $theme );
1651 $_select = '';
1652 if ( $custom_theme === $file_name ) {
1653 $_select = 'selected';
1654 }
1655 echo '<option value="' . esc_attr( $file_name ) . '" ' . esc_attr( $_select ) . '>' . esc_html( $theme ) . '</option>';
1656 }
1657 ?>
1658 </select>
1659 </div>
1660 </div>
1661 <?php
1662 }
1663
1664 /**
1665 * Get custom themes files.
1666 */
1667 public function get_custom_themes_files() {
1668 // get themes files.
1669 $dirs = $this->get_custom_theme_folder();
1670 $scan_dir = $dirs[0];
1671 $handle = opendir( $scan_dir );
1672 $themes = array();
1673 $scan_files = array();
1674 if ( $handle ) {
1675 $filename = readdir( $handle );
1676 while ( false !== $filename ) {
1677 $correct_file = true;
1678 if ( '.' === substr( $filename, 0, 1 ) || 'index.php' === $filename ) {
1679 $correct_file = false;
1680 } elseif ( '.css' !== substr( $filename, - 4 ) ) {
1681 $correct_file = false;
1682 }
1683 if ( $correct_file ) {
1684 $theme = basename( $filename, '.css' );
1685 $theme = str_replace( '-theme', '', $theme );
1686 $themes[ $filename ] = trim( $theme );
1687 }
1688 $filename = readdir( $handle ); // to while loop.
1689 }
1690 closedir( $handle );
1691 }
1692 return $themes;
1693 }
1694
1695 /**
1696 * Get selected MainWP theme name.
1697 */
1698 public function get_selected_theme() {
1699 $selected_theme = false;
1700
1701 $custom_theme = $this->get_current_user_theme();
1702
1703 if ( false === $custom_theme ) {
1704 // to compatible with Custom Dashboard extension settings.
1705 $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1706 if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1707 $compat_theme = $compat_settings['theme'];
1708 }
1709
1710 if ( null !== $compat_theme ) {
1711 $custom_theme = $compat_theme;
1712 }
1713 }
1714
1715 if ( ! empty( $custom_theme ) ) {
1716 if ( 'default' === $custom_theme || 'dark' === $custom_theme || 'wpadmin' === $custom_theme || 'minimalistic' === $custom_theme ) {
1717 return $custom_theme;
1718 }
1719 $dirs = $this->get_custom_theme_folder();
1720 $theme_dir = $dirs[0];
1721 $file = $theme_dir . $custom_theme;
1722 if ( file_exists( $file ) && '.css' === substr( $file, - 4 ) ) {
1723 $selected_theme = $custom_theme;
1724 }
1725 }
1726 return $selected_theme;
1727 }
1728
1729
1730 /**
1731 * Get custom MainWP theme folder.
1732 */
1733 public function get_custom_theme_folder() {
1734 $dirs = MainWP_System_Utility::get_mainwp_dir();
1735 global $wp_filesystem;
1736 if ( is_array( $dirs ) && ! $wp_filesystem->exists( $dirs[0] . 'themes' ) && $wp_filesystem->exists( $dirs[0] . 'custom-dashboard' ) ) {
1737 // re-name the custom-dashboard folder to compatible.
1738 $wp_filesystem->move( $dirs[0] . 'custom-dashboard', $dirs[0] . 'themes' );
1739 }
1740 $dirs = MainWP_System_Utility::get_mainwp_dir_allow_access( 'themes' );
1741 return $dirs;
1742 }
1743
1744
1745 /**
1746 * Get current user's selected theme.
1747 */
1748 public function get_current_user_theme() {
1749 $custom_theme = get_user_option( 'mainwp_selected_theme' );
1750 if ( empty( $custom_theme ) ) {
1751 $custom_theme = get_option( 'mainwp_selected_theme', 'default' );
1752 }
1753 return $custom_theme;
1754 }
1755
1756 /**
1757 * Export Child Sites and save as .csv file.
1758 *
1759 * @uses \MainWP\Dashboard\MainWP_DB::query()
1760 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1761 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1762 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1763 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
1764 */
1765 public static function export_sites() {
1766 if ( isset( $_GET['doExportSites'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'export_sites' ) ) {
1767
1768 $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( true );
1769 $websites = MainWP_DB::instance()->query( $sql );
1770
1771 if ( ! $websites ) {
1772 die( 'Not found sites' );
1773 }
1774
1775 $keys = array( 'name', 'url', 'adminname', 'wpgroups', 'uniqueId', 'http_user', 'http_pass', 'verify_certificate', 'ssl_version' );
1776 $allowedHeaders = array( 'site name', 'url', 'admin name', 'group', 'security id', 'http username', 'http password', 'verify certificate', 'ssl version' );
1777
1778 $csv = implode( ',', $allowedHeaders ) . "\r";
1779 MainWP_DB::data_seek( $websites, 0 );
1780 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1781 if ( empty( $website ) ) {
1782 continue;
1783 }
1784 $row = MainWP_Utility::map_site( $website, $keys, false );
1785 $csv .= '"' . implode( '","', $row ) . '"' . "\r";
1786 }
1787
1788 header( 'Content-Type: text/csv; charset=utf-8' );
1789 header( 'Content-Disposition: attachment; filename=export-sites.csv' );
1790 echo $csv; // phpcs:ignore WordPress.Security.EscapeOutput
1791 exit();
1792 }
1793 }
1794
1795 /**
1796 * Render MainWP Email Settings SubPage.
1797 *
1798 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::get_notification_types()
1799 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_edit_settings()
1800 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::emails_general_settings_handle()
1801 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_all_settings()
1802 * @uses \MainWP\Dashboard\MainWP_Notification_Template::handle_template_file_action()
1803 */
1804 public static function render_email_settings() {
1805 $notification_emails = MainWP_Notification_Settings::get_notification_types();
1806 self::render_header( 'Emails' );
1807 $edit_email = isset( $_GET['edit-email'] ) ? sanitize_text_field( wp_unslash( $_GET['edit-email'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1808 if ( ! empty( $edit_email ) && isset( $notification_emails[ $edit_email ] ) ) {
1809 $updated_templ = MainWP_Notification_Template::instance()->handle_template_file_action();
1810 MainWP_Notification_Settings::instance()->render_edit_settings( $edit_email, $updated_templ );
1811 } else {
1812 $updated = MainWP_Notification_Settings::emails_general_settings_handle();
1813 MainWP_Notification_Settings::instance()->render_all_settings( $updated );
1814 }
1815 self::render_footer( 'Emails' );
1816 }
1817
1818 /**
1819 * Hook the section help content to the Help Sidebar element
1820 */
1821 public static function mainwp_help_content() {
1822 if ( isset( $_GET['page'] ) && ( 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'MainWPTools' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1823 ?>
1824 <p><?php esc_html_e( 'If you need help with your MainWP Dashboard settings, please review following help documents', 'mainwp' ); ?></p>
1825 <div class="ui relaxed bulleted list">
1826 <div class="item"><a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/" target="_blank">MainWP Dashboard Settings</a> <i class="external alternate icon"></i></div>
1827 </div>
1828 <?php
1829 }
1830 }
1831 }
1832