PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 4.6.0.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v4.6.0.1
6.2.3 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 All 156 releases
mainwp / pages / page-mainwp-settings.php

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

1,658 lines 85.9 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 foreach ( $extensions as $ext ) {
100 if ( isset( $ext['api'] ) && isset( $ext['apiManager'] ) && ! empty( $ext['apiManager'] ) ) {
101 if ( isset( $ext['api_key'] ) ) {
102 $ext['api_key'] = '';
103 }
104 if ( isset( $ext['activation_email'] ) ) {
105 $ext['activation_email'] = '';
106 }
107 if ( isset( $ext['activated_key'] ) ) {
108 $ext['activated_key'] = 'Deactivated';
109 }
110
111 $act_info = MainWP_Api_Manager::instance()->get_activation_info( $ext['api'] );
112 if ( isset( $act_info['api_key'] ) ) {
113 $act_info['api_key'] = '';
114 }
115 if ( isset( $act_info['activation_email'] ) ) {
116 $act_info['activation_email'] = '';
117 }
118 if ( isset( $act_info['activated_key'] ) ) {
119 $act_info['activated_key'] = 'Deactivated';
120 }
121 MainWP_Api_Manager::instance()->set_activation_info( $ext['api'], $act_info );
122 }
123 $new_extensions[] = $ext;
124 }
125
126 MainWP_Utility::update_option( 'mainwp_extensions', $new_extensions );
127 update_option( 'mainwp_extensions_all_activation_cached', '' );
128 wp_safe_redirect( esc_url( admin_url( 'admin.php?page=MainWPTools' ) ) );
129 die();
130 }
131 }
132
133 /**
134 * Instantiate the Settings Menu.
135 *
136 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
137 */
138 public static function init_menu() {
139 add_submenu_page(
140 'mainwp_tab',
141 __( 'Settings Global options', 'mainwp' ),
142 ' <span id="mainwp-Settings">' . esc_html__( 'Settings', 'mainwp' ) . '</span>',
143 'read',
144 'Settings',
145 array(
146 self::get_class_name(),
147 'render',
148 )
149 );
150
151 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'MainWPTools' ) ) {
152 add_submenu_page(
153 'mainwp_tab',
154 __( 'Tools', 'mainwp' ),
155 ' <div class="mainwp-hidden">' . esc_html__( 'Tools', 'mainwp' ) . '</div>',
156 'read',
157 'MainWPTools',
158 array(
159 self::get_class_name(),
160 'render_mainwp_tools',
161 )
162 );
163 }
164
165 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsAdvanced' ) ) {
166 add_submenu_page(
167 'mainwp_tab',
168 __( 'Advanced Options', 'mainwp' ),
169 ' <div class="mainwp-hidden">' . esc_html__( 'Advanced Options', 'mainwp' ) . '</div>',
170 'read',
171 'SettingsAdvanced',
172 array(
173 self::get_class_name(),
174 'render_advanced',
175 )
176 );
177 }
178
179 if ( ! MainWP_Menu::is_disable_menu_item( 3, 'SettingsEmail' ) ) {
180 add_submenu_page(
181 'mainwp_tab',
182 __( 'Email Settings', 'mainwp' ),
183 ' <div class="mainwp-hidden">' . esc_html__( 'Email Settings', 'mainwp' ) . '</div>',
184 'read',
185 'SettingsEmail',
186 array(
187 self::get_class_name(),
188 'render_email_settings',
189 )
190 );
191 }
192
193 /**
194 * Settings Subpages
195 *
196 * Filters subpages for the Settings page.
197 *
198 * @since Unknown
199 */
200 $sub_pages = apply_filters_deprecated( 'mainwp-getsubpages-settings', array( array() ), '4.0.7.2', 'mainwp_getsubpages_settings' ); // @deprecated Use 'mainwp_getsubpages_settings' instead.
201 self::$subPages = apply_filters( 'mainwp_getsubpages_settings', $sub_pages );
202
203 if ( isset( self::$subPages ) && is_array( self::$subPages ) ) {
204 foreach ( self::$subPages as $subPage ) {
205 if ( MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) {
206 continue;
207 }
208 add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Settings' . $subPage['slug'], $subPage['callback'] );
209 }
210 }
211
212 self::init_left_menu( self::$subPages );
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 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
377 if ( isset( $subPage['class'] ) ) {
378 $item['class'] = $subPage['class'];
379 }
380 $renderItems[] = $item;
381 }
382 }
383
384 MainWP_UI::render_page_navigation( $renderItems );
385 }
386
387 /**
388 * Close the HTML container.
389 */
390 public static function render_footer() {
391 echo '</div>';
392 }
393
394 /**
395 * Method handle_settings_post().
396 *
397 * This class handles the $_POST of Settings Options.
398 *
399 * @uses MainWP_DB::instance()
400 * @uses MainWP_Utility::update_option()
401 *
402 * @return boolean True|False Posts On True.
403 *
404 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
405 * @uses \MainWP\Dashboard\MainWP_DB_Common::update_user_extension()
406 * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
407 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
408 */
409 public static function handle_settings_post() {
410 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'Settings' ) ) {
411 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
412 $userExtension->pluginDir = '';
413
414 MainWP_DB_Common::instance()->update_user_extension( $userExtension );
415 if ( MainWP_System_Utility::is_admin() ) {
416
417 /**
418 * Action: mainwp_before_save_general_settings
419 *
420 * Fires before general settings save.
421 *
422 * @since 4.1
423 */
424 do_action( 'mainwp_before_save_general_settings', $_POST );
425
426 $val = ( ! isset( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) );
427 MainWP_Utility::update_option( 'mainwp_pluginAutomaticDailyUpdate', $val );
428 $val = ( ! isset( $_POST['mainwp_themeAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_themeAutomaticDailyUpdate'] ) );
429 MainWP_Utility::update_option( 'mainwp_themeAutomaticDailyUpdate', $val );
430 $val = ( ! isset( $_POST['mainwp_automaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_automaticDailyUpdate'] ) );
431 MainWP_Utility::update_option( 'mainwp_automaticDailyUpdate', $val );
432 $val = ( ! isset( $_POST['mainwp_show_language_updates'] ) ? 0 : 1 );
433 MainWP_Utility::update_option( 'mainwp_show_language_updates', $val );
434 $val = ( ! isset( $_POST['mainwp_disable_update_confirmations'] ) ? 0 : intval( $_POST['mainwp_disable_update_confirmations'] ) );
435 MainWP_Utility::update_option( 'mainwp_disable_update_confirmations', $val );
436 $val = ( ! isset( $_POST['mainwp_backup_before_upgrade'] ) ? 0 : 1 );
437 MainWP_Utility::update_option( 'mainwp_backup_before_upgrade', $val );
438 $val = ( ! isset( $_POST['mainwp_backup_before_upgrade_days'] ) ? 7 : intval( $_POST['mainwp_backup_before_upgrade_days'] ) );
439 MainWP_Utility::update_option( 'mainwp_backup_before_upgrade_days', $val );
440
441 if ( is_plugin_active( 'mainwp-comments-extension/mainwp-comments-extension.php' ) ) {
442 MainWP_Utility::update_option( 'mainwp_maximumComments', isset( $_POST['mainwp_maximumComments'] ) ? intval( $_POST['mainwp_maximumComments'] ) : 50 );
443 }
444 MainWP_Utility::update_option( 'mainwp_timeDailyUpdate', isset( $_POST['mainwp_timeDailyUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_timeDailyUpdate'] ) ) : '' );
445
446 $new_freq = ( isset( $_POST['mainwp_frequencyDailyUpdate'] ) ? intval( $_POST['mainwp_frequencyDailyUpdate'] ) : 1 );
447 MainWP_Utility::update_option( 'mainwp_frequencyDailyUpdate', $new_freq );
448
449 $new_delay = ( isset( $_POST['mainwp_delay_autoupdate'] ) ? intval( $_POST['mainwp_delay_autoupdate'] ) : 1 );
450 MainWP_Utility::update_option( 'mainwp_delay_autoupdate', $new_delay );
451
452 $val = ( isset( $_POST['mainwp_sidebarPosition'] ) ? intval( $_POST['mainwp_sidebarPosition'] ) : 1 );
453 $user = wp_get_current_user();
454 if ( $user ) {
455 update_user_option( $user->ID, 'mainwp_sidebarPosition', $val, true );
456 }
457
458 MainWP_Utility::update_option( 'mainwp_numberdays_Outdate_Plugin_Theme', ! empty( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) ? intval( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) : 365 );
459 $ignore_http = isset( $_POST['mainwp_ignore_http_response_status'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_ignore_http_response_status'] ) ) : '';
460 MainWP_Utility::update_option( 'mainwp_ignore_HTTP_response_status', $ignore_http );
461
462 $check_http_response = ( isset( $_POST['mainwp_check_http_response'] ) ? 1 : 0 );
463 MainWP_Utility::update_option( 'mainwp_check_http_response', $check_http_response );
464
465 $actions_notification_enable = ( isset( $_POST['mainwp_site_actions_notification_enable'] ) ? 1 : 0 );
466 MainWP_Utility::update_option( 'mainwp_site_actions_notification_enable', $actions_notification_enable );
467
468 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
469 // Handle custom date/time formats.
470 if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] )
471 && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] )
472 ) {
473 $_POST['date_format'] = wp_unslash( $_POST['date_format_custom'] );
474 }
475
476 if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] )
477 && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] )
478 ) {
479 $_POST['time_format'] = wp_unslash( $_POST['time_format_custom'] );
480 }
481
482 if ( isset( $_POST['timezone_string'] ) ) {
483 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
484 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', wp_unslash( $_POST['timezone_string'] ) ) ) {
485 $_POST['gmt_offset'] = wp_unslash( $_POST['timezone_string'] );
486 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', wp_unslash( $_POST['gmt_offset'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
487 $_POST['timezone_string'] = '';
488 }
489
490 $options = array(
491 'gmt_offset',
492 'date_format',
493 'time_format',
494 'timezone_string',
495 );
496
497 foreach ( $options as $option ) {
498 $value = null;
499 if ( isset( $_POST[ $option ] ) ) {
500 $value = wp_unslash( $_POST[ $option ] );
501 if ( ! is_array( $value ) ) {
502 $value = trim( $value );
503 }
504 }
505 update_option( $option, $value );
506 }
507 }
508 //phpcs:enable
509
510 MainWP_Utility::update_option( 'mainwp_use_favicon', ( ! isset( $_POST['mainwp_use_favicon'] ) ? 0 : 1 ) );
511
512 /**
513 * Action: mainwp_after_save_general_settings
514 *
515 * Fires after save general settings.
516 *
517 * @since 4.1
518 */
519 do_action( 'mainwp_after_save_general_settings', $_POST );
520 }
521
522 return true;
523 }
524
525 return false;
526 }
527
528 /**
529 * Render the MainWP Settings Page.
530 *
531 * @uses \MainWP\Dashboard\MainWP_Monitoring_View
532 * @uses \MainWP\Dashboard\MainWP_Manage_Backups::render_settings()
533 * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes()
534 */
535 public static function render() { //phpcs:ignore -- complex method.
536 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
537 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
538 return;
539 }
540
541 self::render_header( '' );
542 ?>
543 <div id="mainwp-general-settings" class="ui segment">
544 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-general-settings-info-message' ) ) : ?>
545 <div class="ui info message">
546 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-general-settings-info-message"></i>
547 <?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>' ); ?>
548 </div>
549 <?php endif; ?>
550 <?php if ( isset( $_GET['message'] ) && 'saved' === $_GET['message'] ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
551 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
552 <?php endif; ?>
553 <div class="ui form">
554 <form method="POST" action="admin.php?page=Settings" id="mainwp-settings-page-form">
555 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
556 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'Settings' ) ); ?>" />
557 <?php
558 /**
559 * Action: mainwp_settings_form_top
560 *
561 * Fires at the top of settings form.
562 *
563 * @since 4.1
564 */
565 do_action( 'mainwp_settings_form_top' );
566 ?>
567 <h3 class="ui dividing header"><?php esc_html_e( 'General Settings', 'mainwp' ); ?></h3>
568 <?php
569 $timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' );
570 $frequencyDailyUpdate = (int) get_option( 'mainwp_frequencyDailyUpdate' );
571 $run_timestamp = MainWP_System_Cron_Jobs::get_timestamp_from_hh_mm( $timeDailyUpdate );
572 $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
573
574 ?>
575 <div class="ui grid field">
576 <label class="six wide column middle aligned"><?php esc_html_e( 'Automatic daily sync time', 'mainwp' ); ?></label>
577 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set specific time for the automatic daily sync process.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
578 <div class="time-selector">
579 <div class="ui input left icon">
580 <i class="clock icon"></i>
581 <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 ); ?>" />
582 </div>
583 </div>
584 <script type="text/javascript">
585 jQuery( document ).ready( function() {
586 jQuery( '.time-selector' ).calendar( {
587 type: 'time',
588 ampm: false
589 } );
590 } );
591 </script>
592 </div>
593 </div>
594 <div class="ui grid field">
595 <label class="six wide column middle aligned"><?php esc_html_e( 'Daily update frequency', 'mainwp' ); ?></label>
596 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set how often you want your MainWP Dashboard to run the auto update process.', 'mainwp' ); ?>" data-inverted="" data-position="top left" >
597 <select name="mainwp_frequencyDailyUpdate" id="mainwp_frequencyDailyUpdate" class="ui dropdown">
598 <option value="1" <?php echo ( 1 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Once per day', 'mainwp' ); ?></option>
599 <option value="2" <?php echo ( 2 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Twice per day', 'mainwp' ); ?></option>
600 <option value="3" <?php echo ( 3 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Three times per day', 'mainwp' ); ?></option>
601 <option value="4" <?php echo ( 4 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Four times per day', 'mainwp' ); ?></option>
602 <option value="5" <?php echo ( 5 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Five times per day', 'mainwp' ); ?></option>
603 <option value="6" <?php echo ( 6 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Six times per day', 'mainwp' ); ?></option>
604 <option value="7" <?php echo ( 7 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Seven times per day', 'mainwp' ); ?></option>
605 <option value="8" <?php echo ( 8 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Eight times per day', 'mainwp' ); ?></option>
606 <option value="9" <?php echo ( 9 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Nine times per day', 'mainwp' ); ?></option>
607 <option value="10" <?php echo ( 10 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Ten times per day', 'mainwp' ); ?></option>
608 <option value="11" <?php echo ( 11 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Eleven times per day', 'mainwp' ); ?></option>
609 <option value="12" <?php echo ( 12 === $frequencyDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Twelve times per day', 'mainwp' ); ?></option>
610 </select>
611 </div>
612 </div>
613
614 <?php
615 self::render_timezone_settings();
616 self::render_datetime_settings();
617
618 $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
619 if ( false === $sidebarPosition ) {
620 $sidebarPosition = 1;
621 }
622
623 ?>
624 <div class="ui grid field">
625 <label class="six wide column middle aligned"><?php esc_html_e( 'Sidebar position', 'mainwp' ); ?></label>
626 <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">
627 <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown">
628 <option value="1" <?php echo ( 1 === (int) $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Right (default)', 'mainwp' ); ?></option>
629 <option value="0" <?php echo ( 0 === (int) $sidebarPosition ? 'selected' : '' ); ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
630 </select>
631 </div>
632 </div>
633 <?php MainWP_UI::render_screen_options(); ?>
634 <div class="ui grid field">
635 <label class="six wide column middle aligned"><?php esc_html_e( 'Show favicons', 'mainwp' ); ?></label>
636 <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, your MainWP Dashboard will download and show child sites favicons.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
637 <input type="checkbox" name="mainwp_use_favicon" id="mainwp_use_favicon" <?php echo ( ( 1 === (int) get_option( 'mainwp_use_favicon', 1 ) ) ? 'checked="true"' : '' ); ?> />
638 </div>
639 </div>
640 <h3 class="ui dividing header"><?php esc_html_e( 'Updates Settings', 'mainwp' ); ?></h3>
641 <?php
642 $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate', 0 );
643 $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate', 0 );
644 $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate', 0 );
645 $backup_before_upgrade = get_option( 'mainwp_backup_before_upgrade' );
646 $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
647 if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
648 $mainwp_backup_before_upgrade_days = 7;
649 }
650
651 $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
652
653 $update_time = self::get_websites_automatic_update_time();
654 $lastAutomaticUpdate = $update_time['last'];
655 $nextAutomaticUpdate = $update_time['next'];
656
657 $enableLegacyBackupFeature = get_option( 'mainwp_enableLegacyBackupFeature' );
658 $primaryBackup = get_option( 'mainwp_primaryBackup' );
659 $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
660
661 $http_error_codes = MainWP_Utility::get_http_codes();
662 ?>
663 <div class="ui grid field">
664 <label class="six wide column middle aligned"><?php esc_html_e( 'Plugin advanced automatic updates', 'mainwp' ); ?></label>
665 <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">
666 <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown">
667 <option value="1" <?php echo ( 1 === $snPluginAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
668 <option value="0" <?php echo ( ( 0 === $snPluginAutomaticDailyUpdate ) || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
669 </select>
670 </div>
671 </div>
672 <div class="ui grid field">
673 <label class="six wide column middle aligned"><?php esc_html_e( 'Theme advanced automatic updates', 'mainwp' ); ?></label>
674 <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">
675 <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown">
676 <option value="1" <?php echo ( 1 === $snThemeAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
677 <option value="0" <?php echo ( 0 === $snThemeAutomaticDailyUpdate || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
678 </select>
679 </div>
680 </div>
681 <div class="ui grid field">
682 <label class="six wide column middle aligned"><?php esc_html_e( 'WP Core advanced automatic updates', 'mainwp' ); ?></label>
683 <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">
684 <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown">
685 <option value="1" <?php echo ( 1 === $snAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
686 <option value="0" <?php echo ( 0 === $snAutomaticDailyUpdate || 2 === (int) $snAutomaticDailyUpdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
687 </select>
688 <div class="ui hidden divider"></div>
689 <div class="ui label"><?php esc_html_e( 'Last run: ', 'mainwp' ); ?><?php echo esc_html( $lastAutomaticUpdate ); ?></div>
690 <div class="ui label"><?php esc_html_e( 'Next run: ', 'mainwp' ); ?><?php echo esc_html( $nextAutomaticUpdate ); ?></div>
691 </div>
692 </div>
693 <div class="ui grid field">
694 <label class="six wide column middle aligned"><?php esc_html_e( 'Advanced automatic updates delay', 'mainwp' ); ?></label>
695 <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">
696 <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown">
697 <option value="0" <?php echo ( 0 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
698 <option value="1" <?php echo ( 1 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
699 <option value="2" <?php echo ( 2 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
700 <option value="3" <?php echo ( 3 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
701 <option value="4" <?php echo ( 4 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
702 <option value="5" <?php echo ( 5 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
703 <option value="6" <?php echo ( 6 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
704 <option value="7" <?php echo ( 7 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
705 <option value="14" <?php echo ( 14 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
706 <option value="30" <?php echo ( 30 === $delay_autoupdate ? 'selected' : '' ); ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
707 </select>
708 </div>
709 </div>
710 <div class="ui grid field">
711 <label class="six wide column middle aligned"><?php esc_html_e( 'Show WordPress language updates', 'mainwp' ); ?></label>
712 <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">
713 <input type="checkbox" name="mainwp_show_language_updates" id="mainwp_show_language_updates" <?php echo ( 1 === (int) $mainwp_show_language_updates ? 'checked="true"' : '' ); ?>/>
714 </div>
715 </div>
716 <div class="ui grid field">
717 <label class="six wide column middle aligned"><?php esc_html_e( 'Update confirmations', 'mainwp' ); ?></label>
718 <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">
719 <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown">
720 <option value="0" <?php echo ( 0 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
721 <option value="2" <?php echo ( 2 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
722 <option value="1" <?php echo ( 1 === $disableUpdateConfirmations ? 'selected' : '' ); ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
723 </select>
724 </div>
725 </div>
726 <div class="ui grid field">
727 <label class="six wide column middle aligned"><?php esc_html_e( 'Check site HTTP response after update', 'mainwp' ); ?></label>
728 <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">
729 <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"' : '' ); ?>/>
730 </div>
731 </div>
732 <div class="ui grid field">
733 <label class="six wide column middle aligned"><?php esc_html_e( 'Ignored HTTP response statuses', 'mainwp' ); ?></label>
734 <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">
735 <div class="ui multiple selection dropdown" init-value="<?php echo esc_attr( ( get_option( 'mainwp_ignore_HTTP_response_status', '' ) ) ); ?>">
736 <input name="mainwp_ignore_http_response_status" type="hidden">
737 <i class="dropdown icon"></i>
738 <div class="default text"></div>
739 <div class="menu">
740 <?php
741 foreach ( $http_error_codes as $error_code => $label ) {
742 ?>
743 <div class="item" data-value="<?php echo esc_attr( $error_code ); ?>"><?php echo esc_html( $error_code . ' (' . $label . ')' ); ?></div>
744 <?php
745 }
746 ?>
747 </div>
748 </div>
749 </div>
750 </div>
751 <?php if ( ( ( $enableLegacyBackupFeature && empty( $primaryBackup ) ) || ( empty( $enableLegacyBackupFeature ) && ! empty( $primaryBackup ) ) ) ) { ?>
752 <div class="ui grid field mainwp-parent-toggle">
753 <label class="six wide column middle aligned"><?php esc_html_e( 'Require a backup before an update', 'mainwp' ); ?></label>
754 <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">
755 <input type="checkbox" name="mainwp_backup_before_upgrade" id="mainwp_backup_before_upgrade" <?php echo ( 1 === (int) $backup_before_upgrade ? 'checked="true"' : '' ); ?>/>
756 </div>
757 </div>
758 <div class="ui grid field mainwp-child-field" <?php echo ( 1 === (int) $backup_before_upgrade ? '' : 'style="display:none"' ); ?> >
759 <label class="six wide column middle aligned"><?php esc_html_e( 'Days without of a full backup tolerance', 'mainwp' ); ?></label>
760 <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">
761 <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 ); ?>" />
762 </div>
763 </div>
764 <?php } ?>
765
766 <div class="ui grid field">
767 <label class="six wide column middle aligned"><?php esc_html_e( 'Abandoned plugins/themes tolerance', 'mainwp' ); ?></label>
768 <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">
769 <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' ) ) ); ?>"/>
770 </div>
771 </div>
772 <?php MainWP_Monitoring_View::render_settings(); ?>
773 <?php MainWP_Manage_Backups::render_settings(); ?>
774 <?php
775 /**
776 * Action: mainwp_settings_form_bottom
777 *
778 * Fires at the bottom of settings form.
779 *
780 * @since 4.1
781 */
782 do_action( 'mainwp_settings_form_bottom' );
783 ?>
784 <div class="ui divider"></div>
785 <input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
786 <div style="clear:both"></div>
787 </form>
788 </div>
789 </div>
790 <?php
791 self::render_footer( '' );
792 }
793
794 /**
795 * Render Timezone settings.
796 */
797 public static function render_timezone_settings() {
798
799 $current_offset = get_option( 'gmt_offset' );
800 $tzstring = get_option( 'timezone_string' );
801 $check_zone_info = true;
802
803 // Remove old Etc mappings. Fallback to gmt_offset.
804 if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
805 $tzstring = '';
806 }
807
808 if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists.
809 $check_zone_info = false;
810 if ( empty( $current_offset ) ) {
811 $tzstring = 'UTC+0';
812 } elseif ( $current_offset < 0 ) {
813 $tzstring = 'UTC' . $current_offset;
814 } else {
815 $tzstring = 'UTC+' . $current_offset;
816 }
817 }
818
819 $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
820
821 ?>
822 <div class="ui grid field">
823 <label class="six wide column middle aligned"><?php esc_html_e( 'Timezone', 'mainwp' ); ?></label>
824 <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">
825 <select id="timezone_string" class="ui dropdown" name="timezone_string" aria-describedby="timezone-description">
826 <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
827 </select>
828 <div class="ui hidden fitted divider"></div>
829 <div class="ui secondary segment">
830 <?php printf( esc_html__( 'Universal time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format, false, true ) ) . '</code>' ); ?>
831 <div class="ui hidden fitted divider"></div>
832 <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
833 <?php printf( esc_html__( 'Local time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format ) ) . '</code>' ); ?>
834 <div class="ui hidden fitted divider"></div>
835 <?php endif; ?>
836 <?php if ( $check_zone_info && $tzstring ) : ?>
837 <?php
838 $now = new \DateTime( 'now', new \DateTimeZone( $tzstring ) );
839 $dst = (bool) $now->format( 'I' );
840
841 if ( $dst ) {
842 esc_html_e( 'This timezone is currently in daylight saving time.', 'mainwp' );
843 } else {
844 esc_html_e( 'This timezone is currently in standard time.', 'mainwp' );
845 }
846 ?>
847 <div class="ui hidden fitted divider"></div>
848 <?php
849 if ( in_array( $tzstring, timezone_identifiers_list(), true ) ) {
850 $transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
851
852 if ( ! empty( $transitions[1] ) ) {
853 echo ' ';
854 $message = $transitions[1]['isdst'] ? esc_html__( 'Daylight saving time begins on: %s.', 'mainwp' ) : esc_html__( 'Standard time begins on: %s.', 'mainwp' );
855 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
856 } else {
857 esc_html_e( 'This timezone does not observe daylight saving time.', 'mainwp' );
858 }
859 }
860 ?>
861 <?php endif; ?>
862 </div>
863 </div>
864 </div>
865 <?php
866 }
867
868 /**
869 * Render Date/Time settings.
870 */
871 public static function render_datetime_settings() {
872 ?>
873 <div class="ui grid field">
874 <label class="six wide column middle aligned"><?php esc_html_e( 'Date Format', 'mainwp' ); ?></label>
875 <div class="ten wide column fieldset-wrapper" data-tooltip="<?php esc_attr_e( 'Date Format.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
876 <?php
877 /**
878 * Filters the default date formats.
879 *
880 * @since 2.7.0
881 * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
882 *
883 * @param string[] $default_date_formats Array of default date formats.
884 */
885 $date_formats = array_unique( apply_filters( 'date_formats', array( esc_html__( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
886
887 $custom = true;
888
889 foreach ( $date_formats as $format ) {
890 echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
891 if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
892 echo " checked='checked'";
893 $custom = false;
894 }
895 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
896 }
897
898 echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
899 checked( $custom );
900 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>' .
901 '<label for="date_format_custom" class="screen-reader-text">' . esc_html__( 'Custom date format:' ) . '</label>' .
902 '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text" />' .
903 '<br />' .
904 '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'date_format' ) ) ) . '</span>' .
905 "<span class='spinner'></span>\n" . '</em>';
906 ?>
907 </div>
908 </div>
909
910 <div class="ui grid field">
911 <label class="six wide column middle aligned"><?php esc_html_e( 'Time format', 'mainwp' ); ?></label>
912 <div class="ten wide column fieldset-wrapper" data-tooltip="<?php esc_attr_e( 'Select preferred time format.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
913 <?php
914 /**
915 * Filters the default time formats.
916 *
917 * @since 2.7.0
918 *
919 * @param string[] $default_time_formats Array of default time formats.
920 */
921 $time_formats = array_unique( apply_filters( 'time_formats', array( esc_html__( 'g:i a' ), 'g:i A', 'H:i' ) ) );
922
923 $custom = true;
924
925 foreach ( $time_formats as $format ) {
926 echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
927 if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===".
928 echo " checked='checked'";
929 $custom = false;
930 }
931 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
932 }
933 echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
934 checked( $custom );
935 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>' .
936 '<label for="time_format_custom" class="screen-reader-text">' . esc_html__( 'Custom time format:' ) . '</label>' .
937 '<input type="text" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" class="small-text" />' .
938 '<br />' .
939 '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'time_format' ) ) ) . '</span>' .
940 "<span class='spinner'></span>\n" . '</em>';
941 ?>
942 </div>
943 </div>
944 <script type="text/javascript">
945 jQuery(document).ready( function($) {
946 $( 'input[name="date_format"]' ).on( 'click', function() {
947 if ( 'date_format_custom_radio' !== $( this ).attr( 'id' ) )
948 $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( '.fieldset-wrapper' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
949 } );
950
951 $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
952 $( '#date_format_custom_radio' ).prop( 'checked', true );
953 } );
954
955 $( 'input[name="time_format"]' ).on( 'click', function() {
956 if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) )
957 $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( '.fieldset-wrapper' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
958 } );
959
960 $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
961 $( '#time_format_custom_radio' ).prop( 'checked', true );
962 } );
963
964 $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
965 var format = $( this ),
966 fieldset = format.closest( '.fieldset-wrapper' ),
967 example = fieldset.find( '.example' ),
968 spinner = fieldset.find( '.spinner' );
969
970 // Debounce the event callback while users are typing.
971 clearTimeout( $.data( this, 'timer' ) );
972 $( this ).data( 'timer', setTimeout( function() {
973 // If custom date is not empty.
974 if ( format.val() ) {
975 spinner.addClass( 'is-active' );
976
977 $.post( ajaxurl, {
978 action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format',
979 date : format.val()
980 }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
981 }
982 }, 500 ) );
983 } );
984 });
985 </script>
986 <?php
987 }
988
989 /**
990 * Method get_websites_automatic_update_time()
991 *
992 * Get websites automatic update time.
993 *
994 * @return mixed array
995 *
996 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_last_automatic_sync()
997 * @uses \MainWP\Dashboard\MainWP_DB::get_websites_count_where_dts_automatic_sync_smaller_then_start()
998 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
999 */
1000 public static function get_websites_automatic_update_time() {
1001 $lastAutomaticUpdate = MainWP_DB::instance()->get_websites_last_automatic_sync();
1002 $lasttimeAutomatic = get_option( 'mainwp_updatescheck_last_timestamp' );
1003 $lasttimeStartAutomatic = get_option( 'mainwp_updatescheck_start_last_timestamp' );
1004 $local_timestamp = MainWP_Utility::get_timestamp();
1005 $running = get_option( 'mainwp_cron_checksites_running' );
1006
1007 if ( empty( $lasttimeStartAutomatic ) && ! empty( $lasttimeAutomatic ) ) {
1008 $lasttimeStartAutomatic = $lasttimeAutomatic;
1009 }
1010
1011 if ( empty( $lastAutomaticUpdate ) ) {
1012 $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' );
1013 } 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 ) ) ) {
1014 $nextAutomaticUpdate = esc_html__( 'Processing your websites.', 'mainwp' );
1015 } else {
1016 $next_time = MainWP_System_Cron_Jobs::get_next_time_automatic_update_to_show();
1017 if ( $next_time < $local_timestamp + 5 * MINUTE_IN_SECONDS ) {
1018 $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' );
1019 } else {
1020 $nextAutomaticUpdate = MainWP_Utility::format_timestamp( $next_time );
1021 }
1022 }
1023
1024 if ( empty( $lastAutomaticUpdate ) ) {
1025 $lastAutomaticUpdate = esc_html__( 'Never', 'mainwp' );
1026 } else {
1027 $lastAutomaticUpdate = MainWP_Utility::format_timestamp( $lastAutomaticUpdate );
1028 }
1029
1030 return array(
1031 'last' => $lastAutomaticUpdate,
1032 'next' => $nextAutomaticUpdate,
1033 );
1034 }
1035
1036 /**
1037 * Returns false or the location of the OpenSSL Lib File.
1038 *
1039 * @return mixed false|opensslLibLocation
1040 *
1041 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning()
1042 */
1043 public static function show_openssl_lib_config() {
1044 if ( MainWP_Server_Information_Handler::is_openssl_config_warning() ) {
1045 return true;
1046 } else {
1047 return false;
1048 }
1049 }
1050
1051 /**
1052 * Render Advanced Options Subpage.
1053 *
1054 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1055 */
1056 public static function render_advanced() { //phpcs:ignore -- complex method.
1057 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
1058 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1059 return;
1060 }
1061
1062 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) {
1063
1064 /**
1065 * Action: mainwp_before_save_advanced_settings
1066 *
1067 * Fires before save advanced settings.
1068 *
1069 * @since 4.1
1070 */
1071 do_action( 'mainwp_before_save_advanced_settings', $_POST );
1072
1073 MainWP_Utility::update_option( 'mainwp_maximumRequests', ! empty( $_POST['mainwp_maximumRequests'] ) ? intval( $_POST['mainwp_maximumRequests'] ) : 4 );
1074 MainWP_Utility::update_option( 'mainwp_minimumDelay', ! empty( $_POST['mainwp_minimumDelay'] ) ? intval( $_POST['mainwp_minimumDelay'] ) : 200 );
1075 MainWP_Utility::update_option( 'mainwp_maximumIPRequests', ! empty( $_POST['mainwp_maximumIPRequests'] ) ? intval( $_POST['mainwp_maximumIPRequests'] ) : 1 );
1076 MainWP_Utility::update_option( 'mainwp_minimumIPDelay', ! empty( $_POST['mainwp_minimumIPDelay'] ) ? intval( $_POST['mainwp_minimumIPDelay'] ) : 1000 );
1077 MainWP_Utility::update_option( 'mainwp_maximumSyncRequests', ! empty( $_POST['mainwp_maximumSyncRequests'] ) ? intval( $_POST['mainwp_maximumSyncRequests'] ) : 8 );
1078 MainWP_Utility::update_option( 'mainwp_maximumInstallUpdateRequests', ! empty( $_POST['mainwp_maximumInstallUpdateRequests'] ) ? intval( $_POST['mainwp_maximumInstallUpdateRequests'] ) : 3 );
1079 MainWP_Utility::update_option( 'mainwp_sslVerifyCertificate', isset( $_POST['mainwp_sslVerifyCertificate'] ) ? 1 : 0 );
1080 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 );
1081 MainWP_Utility::update_option( 'mainwp_verify_connection_method', isset( $_POST['mainwp_settings_verify_connection_method'] ) ? intval( $_POST['mainwp_settings_verify_connection_method'] ) : 0 );
1082 MainWP_Utility::update_option( 'mainwp_forceUseIPv4', isset( $_POST['mainwp_forceUseIPv4'] ) ? 1 : 0 );
1083 MainWP_Utility::update_option( 'mainwp_wp_cron', ( ! isset( $_POST['mainwp_options_wp_cron'] ) ? 0 : 1 ) );
1084 MainWP_Utility::update_option( 'mainwp_optimize', ( ! isset( $_POST['mainwp_optimize'] ) ? 0 : 1 ) );
1085
1086 if ( isset( $_POST['mainwp_openssl_lib_location'] ) ) {
1087 $openssl_loc = ! empty( $_POST['mainwp_openssl_lib_location'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_openssl_lib_location'] ) ) : '';
1088 MainWP_Utility::update_option( 'mainwp_opensslLibLocation', $openssl_loc );
1089 }
1090
1091 /**
1092 * Action: mainwp_after_save_advanced_settings
1093 *
1094 * Fires after advanced settings save.
1095 *
1096 * @since 4.1
1097 */
1098 do_action( 'mainwp_after_save_advanced_settings', $_POST );
1099 }
1100 self::render_header( 'Advanced' );
1101 ?>
1102
1103 <div id="mainwp-advanced-settings" class="ui segment">
1104 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-advanced-settings-info-notice' ) ) : ?>
1105 <div class="ui info message">
1106 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-advanced-settings-info-notice"></i>
1107 <?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' ); ?>
1108 </div>
1109 <?php endif; ?>
1110 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) : ?>
1111 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1112 <?php endif; ?>
1113 <div class="ui form">
1114 <form method="POST" action="">
1115 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1116 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SettingsAdvanced' ) ); ?>" />
1117 <?php
1118
1119 /**
1120 * Action: mainwp_advanced_settings_form_top
1121 *
1122 * Fires at the top of advanced settings form.
1123 *
1124 * @since 4.1
1125 */
1126 do_action( 'mainwp_advanced_settings_form_top' );
1127
1128 if ( self::show_openssl_lib_config() ) {
1129 $openssl_loc = MainWP_System_Utility::get_openssl_conf();
1130 ?>
1131 <h3 class="ui dividing header">
1132 <?php esc_html_e( 'OpenSSL Settings', 'mainwp' ); ?>
1133 <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>
1134 </h3>
1135 <div class="ui grid field">
1136 <label class="six wide column middle aligned"><?php esc_html_e( 'OpenSSL.cnf location', 'mainwp' ); ?></label>
1137 <div class="ten wide column ui field">
1138 <input type="text" name="mainwp_openssl_lib_location" value="<?php echo esc_html( $openssl_loc ); ?>">
1139 <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>' ); ?></em>
1140 <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>
1141 </div>
1142 </div>
1143 <?php } ?>
1144
1145 <h3 class="ui dividing header"><?php esc_html_e( 'Cross IP Settings', 'mainwp' ); ?></h3>
1146
1147 <div class="ui grid field">
1148 <label class="six wide column middle aligned"><?php esc_html_e( 'Maximum simultaneous requests (Default: 4)', 'mainwp' ); ?></label>
1149 <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">
1150 <input type="text" name="mainwp_maximumRequests" id="mainwp_maximumRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumRequests' ) ) ? 4 : esc_attr( get_option( 'mainwp_maximumRequests' ) ) ); ?>"/>
1151 </div>
1152 </div>
1153
1154 <div class="ui grid field">
1155 <label class="six wide column middle aligned"><?php esc_html_e( 'Minimum delay between requests (Default: 200)', 'mainwp' ); ?></label>
1156 <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">
1157 <input type="text" name="mainwp_minimumDelay" id="mainwp_minimumDelay" value="<?php echo ( ( false === get_option( 'mainwp_minimumDelay' ) ) ? 200 : esc_attr( get_option( 'mainwp_minimumDelay' ) ) ); ?>"/>
1158 </div>
1159 </div>
1160
1161 <h3 class="ui dividing header"><?php esc_html_e( 'Per IP Settings', 'mainwp' ); ?></h3>
1162
1163 <div class="ui grid field">
1164 <label class="six wide column middle aligned"><?php esc_html_e( 'Maximum simultaneous requests per IP (Default: 1)', 'mainwp' ); ?></label>
1165 <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">
1166 <input type="text" name="mainwp_maximumIPRequests" id="mainwp_maximumIPRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumIPRequests' ) ) ? 1 : esc_attr( get_option( 'mainwp_maximumIPRequests' ) ) ); ?>"/>
1167 </div>
1168 </div>
1169
1170 <div class="ui grid field">
1171 <label class="six wide column middle aligned"><?php esc_html_e( 'Minimum delay between requests to the same IP (Default: 1000)', 'mainwp' ); ?></label>
1172 <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">
1173 <input type="text" name="mainwp_minimumIPDelay" id="mainwp_minimumIPDelay" value="<?php echo ( ( false === get_option( 'mainwp_minimumIPDelay' ) ) ? 1000 : esc_attr( get_option( 'mainwp_minimumIPDelay' ) ) ); ?>"/>
1174 </div>
1175 </div>
1176
1177 <h3 class="ui dividing header"><?php esc_html_e( 'Frontend Request Settings', 'mainwp' ); ?></h3>
1178
1179 <div class="ui grid field">
1180 <label class="six wide column middle aligned"><?php esc_html_e( 'Maximum simultaneous sync requests (Default: 8)', 'mainwp' ); ?></label>
1181 <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">
1182 <input type="text" name="mainwp_maximumSyncRequests" id="mainwp_maximumSyncRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumSyncRequests' ) ) ? 8 : esc_attr( get_option( 'mainwp_maximumSyncRequests' ) ) ); ?>"/>
1183 </div>
1184 </div>
1185
1186 <div class="ui grid field">
1187 <label class="six wide column middle aligned"><?php esc_html_e( 'Maximum simultaneous install and update requests (Default: 3)', 'mainwp' ); ?></label>
1188 <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">
1189 <input type="text" name="mainwp_maximumInstallUpdateRequests" id="mainwp_maximumInstallUpdateRequests" value="<?php echo ( ( false === get_option( 'mainwp_maximumInstallUpdateRequests' ) ) ? 3 : esc_attr( get_option( 'mainwp_maximumInstallUpdateRequests' ) ) ); ?>"/>
1190 </div>
1191 </div>
1192
1193 <h3 class="ui dividing header"><?php esc_html_e( 'Miscellaneous Settings', 'mainwp' ); ?></h3>
1194 <div class="ui grid field">
1195 <label class="six wide column middle aligned"><?php esc_html_e( 'Optimize for shared hosting or big networks', 'mainwp' ); ?></label>
1196 <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">
1197 <input type="checkbox" name="mainwp_optimize" id="mainwp_optimize" <?php echo ( ( 1 === (int) get_option( 'mainwp_optimize', 0 ) ) ? 'checked="true"' : '' ); ?> /><label><?php esc_html_e( 'Default: Off', 'mainwp' ); ?></label>
1198 </div>
1199 </div>
1200 <div class="ui grid field">
1201 <label class="six wide column middle aligned"><?php esc_html_e( 'Use WP Cron', 'mainwp' ); ?></label>
1202 <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">
1203 <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>
1204 </div>
1205 </div>
1206 <div class="ui grid field" >
1207 <label class="six wide column middle aligned"><?php esc_html_e( 'Verify SSL certificate', 'mainwp' ); ?></label>
1208 <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">
1209 <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>
1210 </div>
1211 </div>
1212 <?php
1213 $general_verify_con = (int) get_option( 'mainwp_verify_connection_method', 0 );
1214 ?>
1215 <div class="ui grid field">
1216 <label class="six wide column middle aligned"><?php esc_html_e( 'Verify connection method', 'mainwp' ); ?></label>
1217 <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">
1218 <select class="ui dropdown" id="mainwp_settings_verify_connection_method" name="mainwp_settings_verify_connection_method">
1219 <option <?php echo ( empty( $general_verify_con ) || 1 === $general_verify_con ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'OpenSSL (default)', 'mainwp' ); ?></option>
1220 <option <?php echo ( 2 === $general_verify_con ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'PHPSECLIB (fallback)', 'mainwp' ); ?></option>
1221 </select>
1222 </div>
1223 </div>
1224 <?php
1225 $sign_note = MainWP_Connect_Lib::get_connection_algo_settings_note();
1226 $sign_algs = MainWP_System_Utility::get_open_ssl_sign_algos();
1227 $general_sign_alg = get_option( 'mainwp_connect_signature_algo', false );
1228 if ( false === $general_sign_alg ) {
1229 $general_sign_alg = defined( 'OPENSSL_ALGO_SHA256' ) ? OPENSSL_ALGO_SHA256 : 1;
1230 MainWP_Utility::update_option( 'mainwp_connect_signature_algo', $general_sign_alg );
1231 } else {
1232 $general_sign_alg = intval( $general_sign_alg );
1233 }
1234 ?>
1235 <div class="ui grid field mainwp-hide-elemenent-sign-algo" <?php echo ( 2 === $general_verify_con ) ? 'style="display:none;"' : ''; ?> >
1236 <label class="six wide column middle aligned"><?php esc_html_e( 'OpenSSL signature algorithm', 'mainwp' ); ?></label>
1237 <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">
1238 <select class="ui dropdown" id="mainwp_settings_openssl_alg" name="mainwp_settings_openssl_alg">
1239 <?php
1240 foreach ( $sign_algs as $val => $text ) {
1241 ?>
1242 <option <?php echo ( $val === $general_sign_alg ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $val ); ?>"><?php echo esc_html( $text ); ?></option>
1243 <?php
1244 }
1245 ?>
1246 </select>
1247 <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>
1248 </div>
1249 </div>
1250 <div class="ui grid field">
1251 <label class="six wide column middle aligned"><?php esc_html_e( 'Force IPv4', 'mainwp' ); ?></label>
1252 <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">
1253 <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>
1254 </div>
1255 </div>
1256 <?php
1257
1258 /**
1259 * Action: mainwp_advanced_settings_form_bottom
1260 *
1261 * Fires at the bottom of advanced settings form.
1262 *
1263 * @since 4.1
1264 */
1265 do_action( 'mainwp_advanced_settings_form_bottom' );
1266
1267 ?>
1268 <div class="ui divider"></div>
1269 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1270 </form>
1271 </div>
1272 </div>
1273 <?php
1274 self::render_footer( 'Advanced' );
1275 }
1276
1277 /**
1278 * Render MainWP Tools SubPage.
1279 *
1280 * @uses \MainWP\Dashboard\MainWP_UI::render_screen_options()
1281 */
1282 public static function render_mainwp_tools() {
1283 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
1284 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1285
1286 return;
1287 }
1288 self::render_header( 'MainWPTools' );
1289 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1290 ?>
1291 <div id="mainwp-tools-settings" class="ui segment">
1292 <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
1293 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-message' ) ) : ?>
1294 <div class="ui info message">
1295 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-message"></i>
1296 <?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>' ); ?>
1297 </div>
1298 <?php endif; ?>
1299 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-custom-theme' ) ) : ?>
1300 <div class="ui info message">
1301 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-custom-theme"></i>
1302 <div><?php esc_html_e( 'Here you can select a theme for your MainWP Dashboard.', 'mainwp' ); ?></div>
1303 <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>
1304 </div>
1305 <?php endif; ?>
1306 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1307 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1308 <?php endif; ?>
1309 <?php if ( isset( $_POST['mainwp_restore_info_messages'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1310 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Info messages have been restored successfully!', 'mainwp' ); ?></div>
1311 <?php endif; ?>
1312 <div class="ui form">
1313 <form method="POST" action="">
1314 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1315 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPTools' ) ); ?>" />
1316 <h3 class="ui dividing header"><?php esc_html_e( 'MainWP Dashboard Tools', 'mainwp' ); ?></h3>
1317 <?php
1318 /**
1319 * Action: mainwp_tools_form_top
1320 *
1321 * Fires at the top of MainWP tools form.
1322 *
1323 * @since 4.1
1324 */
1325 do_action( 'mainwp_tools_form_top' );
1326
1327 $show_qsw = apply_filters( 'mainwp_show_qsw', true );
1328
1329 self::get_instance()->render_select_custom_themes();
1330
1331 ?>
1332 <div class="ui grid field">
1333 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable MainWP guided tours', 'mainwp' ); ?> <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></label>
1334 <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">
1335 <div class="ui info message" style="display:block!important;">
1336 <?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>' ); ?>
1337 </div>
1338 <div class="ui toggle checkbox">
1339 <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"' : '' ); ?> />
1340 </div>
1341 </div>
1342 </div>
1343 <div class="ui grid field">
1344 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashboard to establish a new connection', 'mainwp' ); ?></label>
1345 <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">
1346 <?php
1347 if ( $is_demo ) {
1348 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' ) . '" />' );
1349 } else {
1350 ?>
1351 <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' ); ?>" />
1352 <?php } ?>
1353 </div>
1354 </div>
1355 <div class="ui grid field">
1356 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashbaord to set new pair of OpenSSL Keys', 'mainwp' ); ?></label>
1357 <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">
1358 <?php
1359 if ( $is_demo ) {
1360 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>' );
1361 } else {
1362 ?>
1363 <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>
1364 <?php } ?>
1365 </div>
1366 </div>
1367 <?php if ( $show_qsw ) { ?>
1368 <div class="ui grid field">
1369 <label class="six wide column middle aligned"><?php esc_html_e( 'Start the MainWP Quick Setup Wizard', 'mainwp' ); ?></label>
1370 <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>
1371 </div>
1372 <?php } ?>
1373 <div class="ui grid field">
1374 <label class="six wide column middle aligned"><?php esc_html_e( 'Export child sites to CSV file', 'mainwp' ); ?></label>
1375 <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>
1376 </div>
1377 <div class="ui grid field">
1378 <label class="six wide column middle aligned"><?php esc_html_e( 'Import child sites', 'mainwp' ); ?></label>
1379 <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>
1380 </div>
1381 <div class="ui grid field">
1382 <label class="six wide column middle aligned"><?php esc_html_e( 'Disconnect all child sites', 'mainwp' ); ?></label>
1383 <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">
1384 <?php
1385 if ( $is_demo ) {
1386 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>' );
1387 } else {
1388 ?>
1389 <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>
1390 <?php } ?>
1391 </div>
1392 </div>
1393 <div class="ui grid field">
1394 <label class="six wide column middle aligned"><?php esc_html_e( 'Delete extensions API Activation data', 'mainwp' ); ?></label>
1395 <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">
1396 <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>
1397 </div>
1398 </div>
1399 <div class="ui grid field">
1400 <label class="six wide column middle aligned"><?php esc_html_e( 'Restore all info messages', 'mainwp' ); ?></label>
1401 <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">
1402 <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' ); ?>"/>
1403 </div>
1404 </div>
1405 <?php
1406 $enabled_demo = MainWP_Demo_Handle::is_demo_mode();
1407 $is_new = MainWP_Demo_Handle::get_instance()->is_new_instance();
1408 if ( ! MainWP_Demo_Handle::is_instawp_site() ) {
1409 ?>
1410 <div class="ui grid field">
1411 <label class="six wide column middle aligned"><?php echo esc_html__( 'Demo mode', 'mainwp' ); ?></label>
1412 <div class="ten wide column">
1413 <?php if ( ! $enabled_demo ) { ?>
1414 <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>
1415 <?php } else { ?>
1416 <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>
1417 <?php } ?>
1418 </div>
1419 </div>
1420 <?php
1421 }
1422 /**
1423 * Action: mainwp_tools_form_bottom
1424 *
1425 * Fires at the bottom of mainwp tools form.
1426 *
1427 * @since 4.1
1428 */
1429 do_action( 'mainwp_tools_form_bottom' );
1430 ?>
1431 <div class="ui divider"></div>
1432 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1433 </form>
1434 </div>
1435 </div>
1436 <script type="text/javascript">
1437 jQuery( '#mainwp-disconnect-sites-tool' ).popup();
1438 jQuery( '#mainwp-clear-activation-data' ).popup();
1439 </script>
1440 <?php
1441 self::render_footer( 'MainWPTools' );
1442 MainWP_Connect_Helper::render_renew_connections_modal();
1443 }
1444
1445 /**
1446 * Render MainWP themes selection.
1447 */
1448 public function render_select_custom_themes() {
1449 $custom_theme = $this->get_current_user_theme();
1450 if ( false === $custom_theme ) {
1451 // to compatible with Custom Dashboard extension settings.
1452 $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1453 if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1454 $compat_theme = $compat_settings['theme'];
1455 }
1456 if ( null !== $compat_theme ) {
1457 $custom_theme = $compat_theme;
1458 }
1459 }
1460 $themes_files = self::get_instance()->get_custom_themes_files();
1461 if ( empty( $themes_files ) ) {
1462 $themes_files = array();
1463 }
1464 ?>
1465 <div class="ui grid field">
1466 <label class="six wide column middle aligned"><?php esc_html_e( 'Select MainWP Theme', 'mainwp' ); ?></label>
1467 <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">
1468 <select name="mainwp_settings_custom_theme" id="mainwp_settings_custom_theme" class="ui dropdown selection">
1469 <option value="default" <?php echo ( 'default' === $custom_theme || empty( $custom_theme ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Default', 'mainwp' ); ?></option>
1470 <option value="classic" <?php echo ( 'classic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Classic', 'mainwp' ); ?></option>
1471 <option value="dark" <?php echo ( 'dark' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Dark', 'mainwp' ); ?></option>
1472 <option value="wpadmin" <?php echo ( 'wpadmin' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'WP Admin', 'mainwp' ); ?></option>
1473 <option value="minimalistic" <?php echo ( 'minimalistic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Minimalistic', 'mainwp' ); ?></option>
1474 <?php
1475 foreach ( $themes_files as $file_name => $theme ) {
1476 $theme = ucfirst( $theme );
1477 $_select = '';
1478 if ( $custom_theme === $file_name ) {
1479 $_select = 'selected';
1480 }
1481 echo '<option value="' . esc_attr( $file_name ) . '" ' . esc_attr( $_select ) . '>' . esc_html( $theme ) . '</option>';
1482 }
1483 ?>
1484 </select>
1485 </div>
1486 </div>
1487 <?php
1488 }
1489
1490 /**
1491 * Get custom themes files.
1492 */
1493 public function get_custom_themes_files() {
1494 // get themes files.
1495 $dirs = $this->get_custom_theme_folder();
1496 $scan_dir = $dirs[0];
1497 $handle = opendir( $scan_dir );
1498 $themes = array();
1499 $scan_files = array();
1500 if ( $handle ) {
1501 $filename = readdir( $handle );
1502 while ( false !== $filename ) {
1503 $correct_file = true;
1504 if ( '.' === substr( $filename, 0, 1 ) || 'index.php' === $filename ) {
1505 $correct_file = false;
1506 } elseif ( '.css' !== substr( $filename, - 4 ) ) {
1507 $correct_file = false;
1508 }
1509 if ( $correct_file ) {
1510 $theme = basename( $filename, '.css' );
1511 $theme = str_replace( '-theme', '', $theme );
1512 $themes[ $filename ] = trim( $theme );
1513 }
1514 $filename = readdir( $handle ); // to while loop.
1515 }
1516 closedir( $handle );
1517 }
1518 return $themes;
1519 }
1520
1521 /**
1522 * Get selected MainWP theme name.
1523 */
1524 public function get_selected_theme() {
1525 $selected_theme = false;
1526
1527 $custom_theme = $this->get_current_user_theme();
1528
1529 if ( false === $custom_theme ) {
1530 // to compatible with Custom Dashboard extension settings.
1531 $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1532 if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1533 $compat_theme = $compat_settings['theme'];
1534 }
1535
1536 if ( null !== $compat_theme ) {
1537 $custom_theme = $compat_theme;
1538 }
1539 }
1540
1541 if ( ! empty( $custom_theme ) ) {
1542 if ( 'default' === $custom_theme || 'dark' === $custom_theme || 'wpadmin' === $custom_theme || 'minimalistic' === $custom_theme ) {
1543 return $custom_theme;
1544 }
1545 $dirs = $this->get_custom_theme_folder();
1546 $theme_dir = $dirs[0];
1547 $file = $theme_dir . $custom_theme;
1548 if ( file_exists( $file ) && '.css' === substr( $file, - 4 ) ) {
1549 $selected_theme = $custom_theme;
1550 }
1551 }
1552 return $selected_theme;
1553 }
1554
1555
1556 /**
1557 * Get custom MainWP theme folder.
1558 */
1559 public function get_custom_theme_folder() {
1560 $dirs = MainWP_System_Utility::get_mainwp_dir();
1561 global $wp_filesystem;
1562 if ( is_array( $dirs ) && ! $wp_filesystem->exists( $dirs[0] . 'themes' ) && $wp_filesystem->exists( $dirs[0] . 'custom-dashboard' ) ) {
1563 // re-name the custom-dashboard folder to compatible.
1564 $wp_filesystem->move( $dirs[0] . 'custom-dashboard', $dirs[0] . 'themes' );
1565 }
1566 $dirs = MainWP_System_Utility::get_mainwp_dir_allow_access( 'themes' );
1567 return $dirs;
1568 }
1569
1570
1571 /**
1572 * Get current user's selected theme.
1573 */
1574 public function get_current_user_theme() {
1575 $custom_theme = get_user_option( 'mainwp_selected_theme' );
1576 if ( empty( $custom_theme ) ) {
1577 $custom_theme = get_option( 'mainwp_selected_theme', 'default' );
1578 }
1579 return $custom_theme;
1580 }
1581
1582 /**
1583 * Export Child Sites and save as .csv file.
1584 *
1585 * @uses \MainWP\Dashboard\MainWP_DB::query()
1586 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1587 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1588 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1589 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
1590 */
1591 public static function export_sites() {
1592 if ( isset( $_GET['doExportSites'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'export_sites' ) ) {
1593
1594 $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( true );
1595 $websites = MainWP_DB::instance()->query( $sql );
1596
1597 if ( ! $websites ) {
1598 die( 'Not found sites' );
1599 }
1600
1601 $keys = array( 'name', 'url', 'adminname', 'wpgroups', 'uniqueId', 'http_user', 'http_pass', 'verify_certificate', 'ssl_version' );
1602 $allowedHeaders = array( 'site name', 'url', 'admin name', 'group', 'security id', 'http username', 'http password', 'verify certificate', 'ssl version' );
1603
1604 $csv = implode( ',', $allowedHeaders ) . "\r";
1605 MainWP_DB::data_seek( $websites, 0 );
1606 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1607 if ( empty( $website ) ) {
1608 continue;
1609 }
1610 $row = MainWP_Utility::map_site( $website, $keys, false );
1611 $csv .= '"' . implode( '","', $row ) . '"' . "\r";
1612 }
1613
1614 header( 'Content-Type: text/csv; charset=utf-8' );
1615 header( 'Content-Disposition: attachment; filename=export-sites.csv' );
1616 echo $csv; // phpcs:ignore WordPress.Security.EscapeOutput
1617 exit();
1618 }
1619 }
1620
1621 /**
1622 * Render MainWP Email Settings SubPage.
1623 *
1624 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::get_notification_types()
1625 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_edit_settings()
1626 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::emails_general_settings_handle()
1627 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_all_settings()
1628 * @uses \MainWP\Dashboard\MainWP_Notification_Template::handle_template_file_action()
1629 */
1630 public static function render_email_settings() {
1631 $notification_emails = MainWP_Notification_Settings::get_notification_types();
1632 self::render_header( 'Emails' );
1633 $edit_email = isset( $_GET['edit-email'] ) ? sanitize_text_field( wp_unslash( $_GET['edit-email'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1634 if ( ! empty( $edit_email ) && isset( $notification_emails[ $edit_email ] ) ) {
1635 $updated_templ = MainWP_Notification_Template::instance()->handle_template_file_action();
1636 MainWP_Notification_Settings::instance()->render_edit_settings( $edit_email, $updated_templ );
1637 } else {
1638 $updated = MainWP_Notification_Settings::emails_general_settings_handle();
1639 MainWP_Notification_Settings::instance()->render_all_settings( $updated );
1640 }
1641 self::render_footer( 'Emails' );
1642 }
1643
1644 /**
1645 * Hook the section help content to the Help Sidebar element
1646 */
1647 public static function mainwp_help_content() {
1648 if ( isset( $_GET['page'] ) && ( 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'MainWPTools' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1649 ?>
1650 <p><?php esc_html_e( 'If you need help with your MainWP Dashboard settings, please review following help documents', 'mainwp' ); ?></p>
1651 <div class="ui relaxed bulleted list">
1652 <div class="item"><a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/" target="_blank">MainWP Dashboard Settings</a></div>
1653 </div>
1654 <?php
1655 }
1656 }
1657 }
1658