PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.2.1
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.2.1, at pages/page-mainwp-settings.php

1,989 lines 129.7 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 { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR.
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( static::$instance ) ) {
52 static::$instance = new self();
53 }
54 return static::$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( static::get_class_name(), 'render_header' ) ); // deprecated, use mainwp_pageheader_settings.
67
68 add_action( 'mainwp_pageheader_settings', array( static::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( static::get_class_name(), 'render_footer' ) ); // deprecated, use mainwp_pagefooter_settings.
78
79 add_action( 'mainwp_pagefooter_settings', array( static::get_class_name(), 'render_footer' ) );
80
81 add_action( 'admin_init', array( static::get_class_name(), 'admin_init' ) );
82
83 add_action( 'mainwp_help_sidebar_content', array( static::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() { // phpcs:ignore -- NOSONAR - complex.
88 static::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 static::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 static::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 static::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 static::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. NOSONAR - not IP.
203 static::$subPages = apply_filters( 'mainwp_getsubpages_settings', $sub_pages );
204
205 if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
206 foreach ( static::$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( static::$subPages ) && is_array( static::$subPages ) && ! empty( static::$subPages ) ) {
238 foreach ( static::$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 = '' ) { // phpcs:ignore -- NOSONAR - complex.
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( static::$subPages ) && is_array( static::$subPages ) ) {
368 foreach ( static::$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
390 /**
391 * Close the HTML container.
392 */
393 public static function render_footer() {
394 echo '</div>';
395 }
396
397 /**
398 * Method handle_settings_post().
399 *
400 * This class handles the $_POST of Settings Options.
401 *
402 * @uses MainWP_DB::instance()
403 * @uses MainWP_Utility::update_option()
404 *
405 * @return boolean True|False Posts On True.
406 *
407 * @uses \MainWP\Dashboard\MainWP_DB_Common::get_user_extension()
408 * @uses \MainWP\Dashboard\MainWP_DB_Common::update_user_extension()
409 * @uses \MainWP\Dashboard\MainWP_System_Utility::is_admin()
410 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
411 */
412 public static function handle_settings_post() { // phpcs:ignore -- NOSONAR - complex.
413 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'Settings' ) ) {
414 $userExtension = MainWP_DB_Common::instance()->get_user_extension();
415 $userExtension->pluginDir = '';
416
417 MainWP_DB_Common::instance()->update_user_extension( $userExtension );
418 if ( MainWP_System_Utility::is_admin() ) {
419
420 /**
421 * Action: mainwp_before_save_general_settings
422 *
423 * Fires before general settings save.
424 *
425 * @since 4.1
426 */
427 do_action( 'mainwp_before_save_general_settings', $_POST );
428
429 $val = ( ! isset( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) );
430 MainWP_Utility::update_option( 'mainwp_pluginAutomaticDailyUpdate', $val );
431 $val = ( ! isset( $_POST['mainwp_themeAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_themeAutomaticDailyUpdate'] ) );
432 MainWP_Utility::update_option( 'mainwp_themeAutomaticDailyUpdate', $val );
433 $val = ( ! isset( $_POST['mainwp_automaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_automaticDailyUpdate'] ) );
434 MainWP_Utility::update_option( 'mainwp_automaticDailyUpdate', $val );
435 $val = ( ! isset( $_POST['mainwp_show_language_updates'] ) ? 0 : 1 );
436 MainWP_Utility::update_option( 'mainwp_show_language_updates', $val );
437 $val = ( ! isset( $_POST['mainwp_disable_update_confirmations'] ) ? 0 : intval( $_POST['mainwp_disable_update_confirmations'] ) );
438 MainWP_Utility::update_option( 'mainwp_disable_update_confirmations', $val );
439 $val = ( ! isset( $_POST['mainwp_backup_before_upgrade'] ) ? 0 : 1 );
440 MainWP_Utility::update_option( 'mainwp_backup_before_upgrade', $val );
441 $val = ( ! isset( $_POST['mainwp_backup_before_upgrade_days'] ) ? 7 : intval( $_POST['mainwp_backup_before_upgrade_days'] ) );
442 MainWP_Utility::update_option( 'mainwp_backup_before_upgrade_days', $val );
443
444 if ( is_plugin_active( 'mainwp-comments-extension/mainwp-comments-extension.php' ) ) {
445 MainWP_Utility::update_option( 'mainwp_maximumComments', isset( $_POST['mainwp_maximumComments'] ) ? intval( $_POST['mainwp_maximumComments'] ) : 50 );
446 }
447
448 $current_timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' );
449 $new_timeDailyUpdate = isset( $_POST['mainwp_timeDailyUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_timeDailyUpdate'] ) ) : '';
450
451 if ( $current_timeDailyUpdate !== $new_timeDailyUpdate ) {
452 MainWP_Utility::update_option( 'mainwp_timeDailyUpdate', $new_timeDailyUpdate );
453 }
454
455 $old_freq = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 );
456 $new_freq = ( isset( $_POST['mainwp_frequencyDailyUpdate'] ) ? intval( $_POST['mainwp_frequencyDailyUpdate'] ) : 2 );
457 if ( $old_freq !== $new_freq ) {
458 MainWP_Utility::update_option( 'mainwp_frequencyDailyUpdate', $new_freq );
459 MainWP_Logger::instance()->log_update_check( 'New frequency daily :: ' . $new_freq );
460 }
461
462 $curr_frequency_updates = get_option( 'mainwp_frequency_AutoUpdate', 'daily' );
463 $new_frequency_updates = isset( $_POST['mainwp_frequency_AutoUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_frequency_AutoUpdate'] ) ) : 'daily';
464 if ( $new_frequency_updates !== $curr_frequency_updates ) {
465 MainWP_Utility::update_option( 'mainwp_frequency_AutoUpdate', $new_frequency_updates );
466 }
467
468 $curr_day_updates = (int) get_option( 'mainwp_dayinweek_AutoUpdate', 0 );
469 $new_day_updates = isset( $_POST['mainwp_dayinweek_AutoUpdate'] ) ? intval( wp_unslash( $_POST['mainwp_dayinweek_AutoUpdate'] ) ) : 0;
470 if ( $new_day_updates !== $curr_day_updates ) {
471 MainWP_Utility::update_option( 'mainwp_dayinweek_AutoUpdate', $new_day_updates );
472 }
473
474 $curr_dayinmonth_updates = (int) get_option( 'mainwp_dayinmonth_AutoUpdate', 1 );
475 $new_dayinmonth_updates = isset( $_POST['mainwp_dayinmonth_AutoUpdate'] ) ? intval( wp_unslash( $_POST['mainwp_dayinmonth_AutoUpdate'] ) ) : 1;
476 if ( $new_dayinmonth_updates !== $curr_dayinmonth_updates ) {
477 MainWP_Utility::update_option( 'mainwp_dayinmonth_AutoUpdate', $new_dayinmonth_updates );
478 }
479
480 $curr_time_updates = get_option( 'mainwp_time_AutoUpdate', '00:00' );
481 $new_time_updates = isset( $_POST['mainwp_time_AutoUpdate'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_time_AutoUpdate'] ) ) : '00:00';
482 if ( $new_time_updates !== $curr_time_updates ) {
483 MainWP_Utility::update_option( 'mainwp_time_AutoUpdate', $new_time_updates );
484 }
485
486 MainWP_Cron_Jobs_Auto_Updates::set_next_auto_updates_time();
487
488 $new_delay = ( isset( $_POST['mainwp_delay_autoupdate'] ) ? intval( $_POST['mainwp_delay_autoupdate'] ) : 1 );
489 MainWP_Utility::update_option( 'mainwp_delay_autoupdate', $new_delay );
490
491 $val = ( isset( $_POST['mainwp_sidebarPosition'] ) ? intval( $_POST['mainwp_sidebarPosition'] ) : 1 );
492 $user = wp_get_current_user();
493 if ( $user ) {
494 update_user_option( $user->ID, 'mainwp_sidebarPosition', $val, true );
495 }
496
497 MainWP_Utility::update_option( 'mainwp_numberdays_Outdate_Plugin_Theme', ! empty( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) ? intval( $_POST['mainwp_numberdays_Outdate_Plugin_Theme'] ) : 365 );
498 $ignore_http = isset( $_POST['mainwp_ignore_http_response_status'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_ignore_http_response_status'] ) ) : '';
499 MainWP_Utility::update_option( 'mainwp_ignore_HTTP_response_status', $ignore_http );
500
501 $check_http_response = ( isset( $_POST['mainwp_check_http_response'] ) ? 1 : 0 );
502 MainWP_Utility::update_option( 'mainwp_check_http_response', $check_http_response );
503
504 $actions_notification_enable = ( isset( $_POST['mainwp_site_actions_notification_enable'] ) ? 1 : 0 );
505 MainWP_Utility::update_option( 'mainwp_site_actions_notification_enable', $actions_notification_enable );
506
507 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
508 // Handle custom date/time formats.
509 if ( ! empty( $_POST['date_format'] ) && isset( $_POST['date_format_custom'] )
510 && '\c\u\s\t\o\m' === wp_unslash( $_POST['date_format'] )
511 ) {
512 $_POST['date_format'] = wp_unslash( $_POST['date_format_custom'] );
513 }
514
515 if ( ! empty( $_POST['time_format'] ) && isset( $_POST['time_format_custom'] )
516 && '\c\u\s\t\o\m' === wp_unslash( $_POST['time_format'] )
517 ) {
518 $_POST['time_format'] = wp_unslash( $_POST['time_format_custom'] );
519 }
520
521 if ( isset( $_POST['timezone_string'] ) ) {
522 // Map UTC+- timezones to gmt_offsets and set timezone_string to empty.
523 if ( ! empty( $_POST['timezone_string'] ) && preg_match( '/^UTC[+-]/', wp_unslash( $_POST['timezone_string'] ) ) ) {
524 $_POST['gmt_offset'] = wp_unslash( $_POST['timezone_string'] );
525 $_POST['gmt_offset'] = preg_replace( '/UTC\+?/', '', wp_unslash( $_POST['gmt_offset'] ) ); //phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotValidated
526 $_POST['timezone_string'] = '';
527 }
528
529 $options = array(
530 'gmt_offset',
531 'date_format',
532 'time_format',
533 'timezone_string',
534 );
535
536 foreach ( $options as $option ) {
537 $value = null;
538 if ( isset( $_POST[ $option ] ) ) {
539 $value = wp_unslash( $_POST[ $option ] );
540 if ( ! is_array( $value ) ) {
541 $value = trim( $value );
542 }
543 }
544 update_option( $option, $value );
545 }
546 }
547 //phpcs:enable
548
549 MainWP_Utility::update_option( 'mainwp_use_favicon', 1 );
550
551 /**
552 * Action: mainwp_after_save_general_settings
553 *
554 * Fires after save general settings.
555 *
556 * @since 4.1
557 */
558 do_action( 'mainwp_after_save_general_settings', $_POST );
559 }
560
561 return true;
562 }
563
564 return false;
565 }
566
567 /**
568 * Render the MainWP Settings Page.
569 *
570 * @uses \MainWP\Dashboard\MainWP_Monitoring_View
571 * @uses \MainWP\Dashboard\MainWP_Manage_Backups::render_settings()
572 * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes()
573 */
574 public static function render() { //phpcs:ignore -- NOSONAR - complex method.
575 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
576 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
577 return;
578 }
579
580 static::render_header( '' );
581 ?>
582 <div id="mainwp-general-settings" class="ui segment">
583 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-general-settings-info-message' ) ) : ?>
584 <div class="ui info message">
585 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-general-settings-info-message"></i>
586 <?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>' ); ?>
587 </div>
588 <?php endif; ?>
589 <?php if ( isset( $_GET['message'] ) && 'saved' === $_GET['message'] ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
590 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
591 <?php endif; ?>
592 <div class="ui form">
593 <form method="POST" action="admin.php?page=Settings" id="mainwp-settings-page-form">
594 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
595 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'Settings' ) ); ?>" />
596 <?php
597 /**
598 * Action: mainwp_settings_form_top
599 *
600 * Fires at the top of settings form.
601 *
602 * @since 4.1
603 */
604 do_action( 'mainwp_settings_form_top' );
605 ?>
606 <h3 class="ui dividing header">
607 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-general' ); ?>
608 <?php esc_html_e( 'General Settings', 'mainwp' ); ?></h3>
609 <?php
610 $timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' );
611 $frequencyDailyUpdate = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 );
612 $run_timestamp = MainWP_System_Cron_Jobs::get_timestamp_from_hh_mm( $timeDailyUpdate );
613 $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
614
615 ?>
616 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general">
617 <label class="six wide column middle aligned">
618 <?php
619 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_timeDailyUpdate', $timeDailyUpdate );
620 esc_html_e( 'Daily sync time', 'mainwp' );
621 ?>
622 </label>
623 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Choose a specific time to initiate the first daily synchronization process.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
624 <div class="time-selector">
625 <div class="ui input left icon">
626 <i class="clock icon"></i>
627 <input type="text" class="settings-field-value-change-handler" current-utc-datetime="<?php echo esc_attr( gmdate( 'Y-m-d H:i:s' ) ); ?>" sync-time-local-datetime="<?php echo esc_attr( gmdate( 'Y-m-d H:i:s', $run_timestamp ) ); ?>" local-datetime="<?php echo esc_attr( gmdate( '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 ); ?>" />
628 </div>
629 </div>
630 </div>
631 </div>
632 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="2">
633 <label class="six wide column middle aligned">
634 <?php
635 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_frequencyDailyUpdate', $frequencyDailyUpdate );
636 esc_html_e( 'Frequency of auto sync', 'mainwp' );
637 ?>
638 </label>
639 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set the frequency for automatic synchronization throughout the day.', 'mainwp' ); ?>" data-inverted="" data-position="top left" >
640 <select name="mainwp_frequencyDailyUpdate" id="mainwp_frequencyDailyUpdate" class="ui dropdown settings-field-value-change-handler">
641 <option value="1" <?php echo 1 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Once per day', 'mainwp' ); ?></option>
642 <option value="2" <?php echo 2 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Twice per day', 'mainwp' ); ?></option>
643 <option value="3" <?php echo 3 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Three times per day', 'mainwp' ); ?></option>
644 <option value="4" <?php echo 4 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Four times per day', 'mainwp' ); ?></option>
645 <option value="5" <?php echo 5 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Five times per day', 'mainwp' ); ?></option>
646 <option value="6" <?php echo 6 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Six times per day', 'mainwp' ); ?></option>
647 <option value="7" <?php echo 7 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Seven times per day', 'mainwp' ); ?></option>
648 <option value="8" <?php echo 8 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Eight times per day', 'mainwp' ); ?></option>
649 <option value="9" <?php echo 9 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Nine times per day', 'mainwp' ); ?></option>
650 <option value="10" <?php echo 10 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Ten times per day', 'mainwp' ); ?></option>
651 <option value="11" <?php echo 11 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Eleven times per day', 'mainwp' ); ?></option>
652 <option value="12" <?php echo 12 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Twelve times per day', 'mainwp' ); ?></option>
653 </select>
654 </div>
655 </div>
656 <script type="text/javascript">
657 jQuery( document ).ready( function() {
658 jQuery( '.time-selector' ).calendar( {
659 type: 'time',
660 ampm: false,
661 formatter: {
662 time: 'H:mm',
663 cellTime: 'H:mm'
664 }
665 } );
666 } );
667 </script>
668
669 <?php
670
671 static::render_timezone_settings();
672 static::render_datetime_settings();
673
674 $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
675 if ( false === $sidebarPosition ) {
676 $sidebarPosition = 1;
677 }
678
679 ?>
680 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="1">
681 <label class="six wide column middle aligned">
682 <?php
683 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sidebarPosition', (int) $sidebarPosition );
684 esc_html_e( 'Sidebar position', 'mainwp' );
685 ?>
686 </label>
687 <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">
688 <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown settings-field-value-change-handler">
689 <option value="1" <?php echo 1 === (int) $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Right (default)', 'mainwp' ); ?></option>
690 <option value="0" <?php echo 0 === (int) $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
691 </select>
692 </div>
693 </div>
694 <?php MainWP_UI::render_screen_options(); ?>
695
696 <h3 class="ui dividing header">
697 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-updates' ); ?>
698 <?php esc_html_e( 'Updates Settings', 'mainwp' ); ?></h3>
699 <?php
700 $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate', 0 );
701 $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate', 0 );
702 $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate', 0 );
703 $backup_before_upgrade = get_option( 'mainwp_backup_before_upgrade' );
704 $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
705 if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
706 $mainwp_backup_before_upgrade_days = 7;
707 }
708 $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
709 $enableLegacyBackupFeature = get_option( 'mainwp_enableLegacyBackupFeature' );
710 $primaryBackup = get_option( 'mainwp_primaryBackup' );
711 $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
712
713 $http_error_codes = MainWP_Utility::get_http_codes();
714 ?>
715 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
716 <label class="six wide column middle aligned">
717 <?php
718 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_pluginAutomaticDailyUpdate', $snPluginAutomaticDailyUpdate );
719 esc_html_e( 'Plugin advanced automatic updates', 'mainwp' );
720 ?>
721 </label>
722 <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">
723 <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
724 <option value="1" <?php echo 1 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
725 <option value="0" <?php echo 0 === $snPluginAutomaticDailyUpdate || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
726 </select>
727 </div>
728 </div>
729 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
730 <label class="six wide column middle aligned">
731 <?php
732 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_themeAutomaticDailyUpdate', $snThemeAutomaticDailyUpdate );
733 esc_html_e( 'Theme advanced automatic updates', 'mainwp' );
734 ?>
735 </label>
736 <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">
737 <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
738 <option value="1" <?php echo 1 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
739 <option value="0" <?php echo 0 === $snThemeAutomaticDailyUpdate || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
740 </select>
741 </div>
742 </div>
743 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
744 <label class="six wide column middle aligned">
745 <?php
746 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_automaticDailyUpdate', $snAutomaticDailyUpdate );
747 esc_html_e( 'WP Core advanced automatic updates', 'mainwp' );
748 ?>
749 </label>
750 <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">
751 <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
752 <option value="1" <?php echo 1 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
753 <option value="0" <?php echo 0 === $snAutomaticDailyUpdate || 2 === (int) $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
754 </select>
755 </div>
756 </div>
757 <?php static::render_auto_updates_settings(); ?>
758 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="1">
759 <label class="six wide column middle aligned">
760 <?php
761 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_delay_autoupdate', $delay_autoupdate );
762 esc_html_e( 'Advanced automatic updates delay', 'mainwp' );
763 ?>
764 </label>
765 <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">
766 <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown settings-field-value-change-handler">
767 <option value="0" <?php echo 0 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
768 <option value="1" <?php echo 1 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
769 <option value="2" <?php echo 2 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
770 <option value="3" <?php echo 3 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
771 <option value="4" <?php echo 4 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
772 <option value="5" <?php echo 5 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
773 <option value="6" <?php echo 6 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
774 <option value="7" <?php echo 7 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
775 <option value="14" <?php echo 14 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
776 <option value="30" <?php echo 30 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
777 </select>
778 </div>
779 </div>
780 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="1">
781 <label class="six wide column middle aligned">
782 <?php
783 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_show_language_updates', $mainwp_show_language_updates );
784 esc_html_e( 'Show WordPress language updates', 'mainwp' );
785 ?>
786 </label>
787 <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">
788 <input type="checkbox" name="mainwp_show_language_updates" class="settings-field-value-change-handler" id="mainwp_show_language_updates" <?php echo 1 === (int) $mainwp_show_language_updates ? 'checked="true"' : ''; ?>/>
789 </div>
790 </div>
791 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
792 <label class="six wide column middle aligned">
793 <?php
794 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disable_update_confirmations', $disableUpdateConfirmations );
795 esc_html_e( 'Update confirmations', 'mainwp' );
796 ?>
797 </label>
798 <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">
799 <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown settings-field-value-change-handler">
800 <option value="0" <?php echo 0 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
801 <option value="2" <?php echo 2 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
802 <option value="1" <?php echo 1 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
803 </select>
804 </div>
805 </div>
806 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
807 <label class="six wide column middle aligned">
808 <?php
809 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_check_http_response', get_option( 'mainwp_check_http_response', '' ) );
810 esc_html_e( 'Check site HTTP response after update', 'mainwp' );
811 ?>
812 </label>
813 <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">
814 <input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_check_http_response" id="mainwp_check_http_response" <?php echo 1 === (int) get_option( 'mainwp_check_http_response', 0 ) ? 'checked="true"' : ''; ?>/>
815 </div>
816 </div>
817 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
818 <label class="six wide column middle aligned">
819 <?php
820 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_ignore_HTTP_response_status', (int) get_option( 'mainwp_ignore_HTTP_response_status', 0 ) );
821 esc_html_e( 'Ignored HTTP response statuses', 'mainwp' );
822 ?>
823 </label>
824 <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">
825 <div class="ui multiple selection dropdown" init-value="<?php echo esc_attr( ( get_option( 'mainwp_ignore_HTTP_response_status', '' ) ) ); ?>">
826 <input name="mainwp_ignore_http_response_status" class="settings-field-value-change-handler" type="hidden">
827 <i class="dropdown icon"></i>
828 <div class="default text"></div>
829 <div class="menu">
830 <?php
831 foreach ( $http_error_codes as $error_code => $label ) {
832 ?>
833 <div class="item" data-value="<?php echo esc_attr( $error_code ); ?>"><?php echo esc_html( $error_code . ' (' . $label . ')' ); ?></div>
834 <?php
835 }
836 ?>
837 </div>
838 </div>
839 </div>
840 </div>
841 <?php if ( ( $enableLegacyBackupFeature && empty( $primaryBackup ) ) || ( empty( $enableLegacyBackupFeature ) && ! empty( $primaryBackup ) ) ) { ?>
842 <div class="ui grid field mainwp-parent-toggle settings-field-indicator-wrapper settings-field-indicator-updates">
843 <label class="six wide column middle aligned">
844 <?php
845 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backup_before_upgrade', (int) $backup_before_upgrade );
846 esc_html_e( 'Require a backup before an update', 'mainwp' );
847 ?>
848 </label>
849 <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">
850 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_backup_before_upgrade" id="mainwp_backup_before_upgrade" <?php echo 1 === (int) $backup_before_upgrade ? 'checked="true"' : ''; ?>/>
851 </div>
852 </div>
853 <div class="ui grid field mainwp-child-field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="7" <?php echo 1 === (int) $backup_before_upgrade ? '' : 'style="display:none"'; ?> >
854 <label class="six wide column middle aligned">
855 <?php
856 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backup_before_upgrade_days', (int) $mainwp_backup_before_upgrade_days );
857 esc_html_e( 'Days without of a full backup tolerance', 'mainwp' );
858 ?>
859 </label>
860 <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">
861 <input type="text" class="settings-field-value-change-handler" name="mainwp_backup_before_upgrade_days" id="mainwp_backup_before_upgrade_days" value="<?php echo esc_attr( $mainwp_backup_before_upgrade_days ); ?>" />
862 </div>
863 </div>
864 <?php } ?>
865
866 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="365">
867 <label class="six wide column middle aligned">
868 <?php
869 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_numberdays_Outdate_Plugin_Theme', (int) get_option( 'mainwp_numberdays_Outdate_Plugin_Theme', 365 ) );
870
871 esc_html_e( 'Abandoned plugins/themes tolerance', 'mainwp' );
872 ?>
873 </label>
874 <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">
875 <input type="text" class="settings-field-value-change-handler" 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' ) ); ?>"/>
876 </div>
877 </div>
878 <?php MainWP_Monitoring_View::render_settings(); ?>
879 <?php MainWP_Manage_Backups::render_settings(); ?>
880 <?php
881 /**
882 * Action: mainwp_settings_form_bottom
883 *
884 * Fires at the bottom of settings form.
885 *
886 * @since 4.1
887 */
888 do_action( 'mainwp_settings_form_bottom' );
889 ?>
890 <div class="ui divider"></div>
891 <input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
892 <div style="clear:both"></div>
893 </form>
894 </div>
895 </div>
896 <?php
897 static::render_footer( '' );
898 }
899
900 /**
901 * Method render_auto_updates_settings().
902 */
903 public static function render_auto_updates_settings() { // phpcs:ignore -- NOSONAR - complex.
904
905 $time_AutoUpdate = get_option( 'mainwp_time_AutoUpdate' );
906 $dayinweek_AutoUpdate = (int) get_option( 'mainwp_dayinweek_AutoUpdate', 0 );
907 $dayinmonth_AutoUpdate = (int) get_option( 'mainwp_dayinmonth_AutoUpdate', 1 );
908 $frequency_AutoUpdate = get_option( 'mainwp_frequency_AutoUpdate', 'daily' );
909
910 if ( empty( $time_AutoUpdate ) ) {
911 $time_AutoUpdate = '00:00';
912 }
913
914 if ( ! in_array( $frequency_AutoUpdate, array( 'daily', 'weekly', 'monthly' ) ) ) {
915 $frequency_AutoUpdate = 'daily';
916 }
917
918 ?>
919 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="daily">
920 <label class="six wide column middle aligned">
921 <?php
922 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_frequency_AutoUpdate', $frequency_AutoUpdate );
923 esc_html_e( 'Frequency of automatic updates', 'mainwp' );
924 ?>
925 </label>
926 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set the frequency for automatic updates process.', 'mainwp' ); ?>" data-inverted="" data-position="top left" >
927 <select name="mainwp_frequency_AutoUpdate" id="mainwp_frequency_AutoUpdate" class="ui dropdown settings-field-value-change-handler">
928 <option value="daily" <?php echo 'daily' === $frequency_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Daily', 'mainwp' ); ?></option>
929 <option value="weekly" <?php echo 'weekly' === $frequency_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Weekly', 'mainwp' ); ?></option>
930 <option value="monthly" <?php echo 'monthly' === $frequency_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Monthly', 'mainwp' ); ?></option>
931 </select>
932 </div>
933 </div>
934
935 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" id="mainwp-dayinmonth-autoupdate-wrapper" <?php echo in_array( $frequency_AutoUpdate, array( 'monthly' ) ) ? '' : 'style="display:none;"'; ?>>
936 <label class="six wide column middle aligned">
937 <?php
938 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_dayinmonth_AutoUpdate', $dayinmonth_AutoUpdate );
939 esc_html_e( 'Select day', 'mainwp' );
940 ?>
941 </label>
942 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Choose a specific day in month to initiate automatic updates process.', 'mainwp' ); ?>" data-inverted="" data-position="top left" >
943 <select name="mainwp_dayinmonth_AutoUpdate" id="mainwp_dayinmonth_AutoUpdate" class="ui dropdown settings-field-value-change-handler">
944 <?php
945 $day_suffix = array(
946 1 => 'st',
947 2 => 'nd',
948 3 => 'rd',
949 );
950 for ( $x = 1; $x <= 31; $x++ ) {
951 $_select = '';
952 if ( $dayinmonth_AutoUpdate === $x ) {
953 $_select = 'selected';
954 }
955 $remain = $x % 10;
956 $day_sf = isset( $day_suffix[ $remain ] ) ? $day_suffix[ $remain ] : 'th';
957 echo '<option value="' . intval( $x ) . '" ' . esc_html( $_select ) . '>' . esc_html( $x . $day_sf ) . ' of the month</option>';
958 }
959 ?>
960 </select>
961 </div>
962 </div>
963
964 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" id="mainwp-dayinweek-autoupdate-wrapper" <?php echo in_array( $frequency_AutoUpdate, array( 'weekly' ) ) ? '' : 'style="display:none;"'; ?>>
965 <label class="six wide column middle aligned">
966 <?php
967 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_dayinweek_AutoUpdate', $dayinweek_AutoUpdate );
968 esc_html_e( 'Select day', 'mainwp' );
969 ?>
970 </label>
971 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Choose a specific day in week to initiate automatic updates process.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
972 <select name="mainwp_dayinweek_AutoUpdate" id="mainwp_dayinweek_AutoUpdate" class="ui dropdown settings-field-value-change-handler">
973 <option value="0" <?php echo 0 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Mon', 'mainwp' ); ?></option>
974 <option value="1" <?php echo 1 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Tue', 'mainwp' ); ?></option>
975 <option value="2" <?php echo 2 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Wed', 'mainwp' ); ?></option>
976 <option value="3" <?php echo 3 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Thus', 'mainwp' ); ?></option>
977 <option value="4" <?php echo 4 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Fri', 'mainwp' ); ?></option>
978 <option value="5" <?php echo 5 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Sat', 'mainwp' ); ?></option>
979 <option value="6" <?php echo 6 === $dayinweek_AutoUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Sun', 'mainwp' ); ?></option>
980 </select>
981 </div>
982 </div>
983 <div id="mainwp-time-autoupdate-wrapper" class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="00:00">
984 <label class="six wide column middle aligned">
985 <?php
986 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_time_AutoUpdate', $time_AutoUpdate );
987 esc_html_e( 'Select time', 'mainwp' );
988 $_last_start_auto_updates = get_option( 'mainwp_automatic_updates_start_lasttime', 0 );
989 $_next_auto_updates = get_option( 'mainwp_automatic_update_next_run_timestamp', 0 );
990 ?>
991 </label>
992 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Choose a specific time to initiate automatic updates process.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
993 <div class="time-selector">
994 <div class="ui input left icon">
995 <i class="clock icon"></i>
996 <input type="text" class="settings-field-value-change-handler" current-utc-datetime="<?php echo date( 'Y-m-d H:i:s' ); ?>" auto-updates-last-start-time="<?php echo date( 'Y-m-d H:i:s', $_last_start_auto_updates ); ?>" auto-updates-next-time="<?php echo date( 'Y-m-d H:i:s', $_next_auto_updates ); ?>" local-datetime="<?php echo date( 'Y-m-d H:i:s', MainWP_Utility::get_timestamp() ); // phpcs:ignore -- to get local time. ?>" name="mainwp_time_AutoUpdate" id="mainwp_time_AutoUpdate" value="<?php echo esc_attr( $time_AutoUpdate ); ?>" />
997 </div>
998 </div>
999 </div>
1000 </div>
1001 <script type="text/javascript">
1002 jQuery(document).on('change', '#mainwp_frequency_AutoUpdate', function () {
1003 if( jQuery(this).val() == 'monthly' ){
1004 jQuery('#mainwp-dayinweek-autoupdate-wrapper').hide();
1005 jQuery('#mainwp-dayinmonth-autoupdate-wrapper').show();
1006 } else if( jQuery(this).val() == 'weekly'){
1007 jQuery('#mainwp-dayinweek-autoupdate-wrapper').show();
1008 jQuery('#mainwp-dayinmonth-autoupdate-wrapper').hide();
1009 } else {
1010 jQuery('#mainwp-dayinweek-autoupdate-wrapper').hide();
1011 jQuery('#mainwp-dayinmonth-autoupdate-wrapper').hide();
1012 }
1013 });
1014 </script>
1015 <?php
1016 }
1017
1018 /**
1019 * Render Timezone settings.
1020 */
1021 public static function render_timezone_settings() { // phpcs:ignore -- NOSONAR - complex.
1022
1023 $current_offset = get_option( 'gmt_offset' );
1024 $tzstring = get_option( 'timezone_string' );
1025 $check_zone_info = true;
1026
1027 // Remove old Etc mappings. Fallback to gmt_offset.
1028 if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
1029 $tzstring = '';
1030 }
1031
1032 if ( empty( $tzstring ) ) { // Create a UTC+- zone if no timezone string exists.
1033 $check_zone_info = false;
1034 if ( empty( $current_offset ) ) {
1035 $tzstring = 'UTC+0';
1036 } elseif ( $current_offset < 0 ) {
1037 $tzstring = 'UTC' . $current_offset;
1038 } else {
1039 $tzstring = 'UTC+' . $current_offset;
1040 }
1041 }
1042
1043 $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
1044
1045 ?>
1046 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general">
1047 <label class="six wide column middle aligned"><?php esc_html_e( 'Timezone', 'mainwp' ); ?></label>
1048 <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">
1049 <select id="timezone_string" class="ui dropdown" name="timezone_string" aria-describedby="timezone-description">
1050 <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
1051 </select>
1052 <div class="ui hidden fitted divider"></div>
1053 <div class="ui secondary segment">
1054 <?php printf( esc_html__( 'Universal time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format, false, true ) ) . '</code>' ); ?>
1055 <div class="ui hidden fitted divider"></div>
1056 <?php if ( get_option( 'timezone_string' ) || ! empty( $current_offset ) ) : ?>
1057 <?php printf( esc_html__( 'Local time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format ) ) . '</code>' ); ?>
1058 <div class="ui hidden fitted divider"></div>
1059 <?php endif; ?>
1060 <?php if ( $check_zone_info && $tzstring ) : ?>
1061 <?php
1062 $now = new \DateTime( 'now', new \DateTimeZone( $tzstring ) );
1063 $dst = (bool) $now->format( 'I' );
1064
1065 if ( $dst ) {
1066 esc_html_e( 'This timezone is currently in daylight saving time.', 'mainwp' );
1067 } else {
1068 esc_html_e( 'This timezone is currently in standard time.', 'mainwp' );
1069 }
1070 ?>
1071 <div class="ui hidden fitted divider"></div>
1072 <?php
1073 if ( in_array( $tzstring, timezone_identifiers_list(), true ) ) {
1074 $transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
1075
1076 if ( ! empty( $transitions[1] ) ) {
1077 echo ' ';
1078 $message = $transitions[1]['isdst'] ? esc_html__( 'Daylight saving time begins on: %s.', 'mainwp' ) : esc_html__( 'Standard time begins on: %s.', 'mainwp' );
1079 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
1080 } else {
1081 esc_html_e( 'This timezone does not observe daylight saving time.', 'mainwp' );
1082 }
1083 }
1084 ?>
1085 <?php endif; ?>
1086 </div>
1087 </div>
1088 </div>
1089 <?php
1090 }
1091
1092 /**
1093 * Render Date/Time settings.
1094 */
1095 public static function render_datetime_settings() {
1096 ?>
1097 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="F j, Y">
1098 <label class="six wide column middle aligned">
1099 <?php
1100 MainWP_Settings_Indicator::render_not_default_indicator( 'date_format', get_option( 'date_format' ) );
1101 esc_html_e( 'Date format', 'mainwp' );
1102 ?>
1103 </label>
1104 <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">
1105 <?php
1106 /**
1107 * Filters the default date formats.
1108 *
1109 * @since 2.7.0
1110 * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
1111 *
1112 * @param string[] $default_date_formats Array of default date formats.
1113 */
1114 $date_formats = array_unique( apply_filters( 'date_formats', array( esc_html__( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
1115
1116 $custom = true;
1117
1118 foreach ( $date_formats as $format ) {
1119 echo "\t<label><input type='radio' name='date_format' value='" . esc_attr( $format ) . "'";
1120 if ( get_option( 'date_format' ) === $format ) { // checked() uses "==" rather than "===".
1121 echo " checked='checked'";
1122 $custom = false;
1123 }
1124 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
1125 }
1126 echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
1127 checked( $custom );
1128 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>' .
1129 '<label for="date_format_custom" class="screen-reader-text">' . esc_html__( 'Custom date format:' ) . '</label>' .
1130 '<input type="text" name="date_format_custom" id="date_format_custom" value="' . esc_attr( get_option( 'date_format' ) ) . '" class="small-text settings-field-value-change-handler" />' .
1131 '<br />' .
1132 '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'date_format' ) ) ) . '</span>' .
1133 "<span class='spinner'></span>\n" . '</em>';
1134 ?>
1135 </div>
1136 </div>
1137
1138 <div class="ui grid field settings-field-indicator-wrapper" default-indi-value="g:i a">
1139 <label class="six wide column middle aligned">
1140 <?php
1141 MainWP_Settings_Indicator::render_not_default_indicator( 'time_format', get_option( 'time_format' ) );
1142 esc_html_e( 'Time format', 'mainwp' );
1143 ?>
1144 </label>
1145 <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">
1146 <?php
1147 /**
1148 * Filters the default time formats.
1149 *
1150 * @since 2.7.0
1151 *
1152 * @param string[] $default_time_formats Array of default time formats.
1153 */
1154 $time_formats = array_unique( apply_filters( 'time_formats', array( esc_html__( 'g:i a' ), 'g:i A', 'H:i' ) ) );
1155
1156 $custom = true;
1157
1158 foreach ( $time_formats as $format ) {
1159 echo "\t<label><input type='radio' name='time_format' value='" . esc_attr( $format ) . "'";
1160 if ( get_option( 'time_format' ) === $format ) { // checked() uses "==" rather than "===".
1161 echo " checked='checked'";
1162 $custom = false;
1163 }
1164 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
1165 }
1166 echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
1167 checked( $custom );
1168 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>' .
1169 '<label for="time_format_custom" class="screen-reader-text">' . esc_html__( 'Custom time format:' ) . '</label>' .
1170 '<input type="text" class="small-text settings-field-value-change-handler" name="time_format_custom" id="time_format_custom" value="' . esc_attr( get_option( 'time_format' ) ) . '" />' .
1171 '<br />' .
1172 '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'time_format' ) ) ) . '</span>' .
1173 "<span class='spinner'></span>\n" . '</em>';
1174 ?>
1175 </div>
1176 </div>
1177 <script type="text/javascript">
1178 jQuery(function($) {
1179 $( 'input[name="date_format"]' ).on( 'click', function() {
1180 if ( 'date_format_custom_radio' !== $( this ).attr( 'id' ) ){
1181 $( 'input[name="date_format_custom"]' ).val( $( this ).val() ).closest( '.fieldset-wrapper' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
1182 $( 'input[name="date_format_custom"]' ).trigger("change"); // support indicator.
1183 }
1184 } );
1185
1186 $( 'input[name="date_format_custom"]' ).on( 'click input', function() {
1187 $( '#date_format_custom_radio' ).prop( 'checked', true );
1188 } );
1189
1190 $( 'input[name="time_format"]' ).on( 'click', function() {
1191 if ( 'time_format_custom_radio' !== $(this).attr( 'id' ) ){
1192 $( 'input[name="time_format_custom"]' ).val( $( this ).val() ).closest( '.fieldset-wrapper' ).find( '.example' ).text( $( this ).parent( 'label' ).children( '.format-i18n' ).text() );
1193 $( 'input[name="time_format_custom"]' ).trigger("change"); // support indicator.
1194 }
1195 } );
1196
1197 $( 'input[name="time_format_custom"]' ).on( 'click input', function() {
1198 $( '#time_format_custom_radio' ).prop( 'checked', true );
1199 } );
1200
1201 $( 'input[name="date_format_custom"], input[name="time_format_custom"]' ).on( 'input', function() {
1202 let format = $( this ),
1203 fieldset = format.closest( '.fieldset-wrapper' ),
1204 example = fieldset.find( '.example' ),
1205 spinner = fieldset.find( '.spinner' );
1206
1207 // Debounce the event callback while users are typing.
1208 clearTimeout( $.data( this, 'timer' ) );
1209 $( this ).data( 'timer', setTimeout( function() {
1210 // If custom date is not empty.
1211 if ( format.val() ) {
1212 spinner.addClass( 'is-active' );
1213
1214 $.post( ajaxurl, {
1215 action: 'date_format_custom' === format.attr( 'name' ) ? 'date_format' : 'time_format',
1216 date : format.val()
1217 }, function( d ) { spinner.removeClass( 'is-active' ); example.text( d ); } );
1218 }
1219 }, 500 ) );
1220 } );
1221 });
1222 </script>
1223 <?php
1224 }
1225
1226 /**
1227 * Method get_websites_automatic_update_time()
1228 *
1229 * Get websites automatic update time.
1230 *
1231 * @return mixed array
1232 *
1233 * @uses \MainWP\Dashboard\MainWP_Utility::format_timestamp()
1234 */
1235 public static function get_websites_automatic_update_time() {
1236 $lastAutomaticUpdate = MainWP_Auto_Updates_DB::instance()->get_websites_last_automatic_sync();
1237 $lasttimeAutomatic = get_option( 'mainwp_updatescheck_last_timestamp' );
1238 $lasttimeStartAutomatic = get_option( 'mainwp_updatescheck_start_last_timestamp' );
1239 $local_timestamp = MainWP_Utility::get_timestamp();
1240 $running = get_option( 'mainwp_cron_checksites_running' );
1241
1242 if ( empty( $lasttimeStartAutomatic ) && ! empty( $lasttimeAutomatic ) ) {
1243 $lasttimeStartAutomatic = $lasttimeAutomatic;
1244 }
1245
1246 if ( empty( $lastAutomaticUpdate ) ) {
1247 $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' );
1248 } elseif ( 'yes' === $running && ( 0 < MainWP_Auto_Updates_DB::instance()->get_websites_count_where_dts_automatic_sync_smaller_then_start( $lasttimeStartAutomatic ) || 0 < MainWP_Auto_Updates_DB::instance()->get_websites_check_updates_count( $lasttimeStartAutomatic ) ) ) {
1249 $nextAutomaticUpdate = esc_html__( 'Processing your websites.', 'mainwp' );
1250 } else {
1251 $next_time = MainWP_System_Cron_Jobs::get_next_time_automatic_update_to_show();
1252 if ( $next_time < $local_timestamp + 5 * MINUTE_IN_SECONDS ) {
1253 $nextAutomaticUpdate = esc_html__( 'Any minute', 'mainwp' );
1254 } else {
1255 $nextAutomaticUpdate = MainWP_Utility::format_timestamp( $next_time );
1256 }
1257 }
1258
1259 if ( empty( $lastAutomaticUpdate ) ) {
1260 $lastAutomaticUpdate = esc_html__( 'Never', 'mainwp' );
1261 } else {
1262 $lastAutomaticUpdate = MainWP_Utility::format_timestamp( $lastAutomaticUpdate );
1263 }
1264
1265 return array(
1266 'last' => $lastAutomaticUpdate,
1267 'next' => $nextAutomaticUpdate,
1268 );
1269 }
1270
1271 /**
1272 * Returns false or the location of the OpenSSL Lib File.
1273 *
1274 * @return mixed false|opensslLibLocation
1275 *
1276 * @uses \MainWP\Dashboard\MainWP_Server_Information_Handler::is_openssl_config_warning()
1277 */
1278 public static function show_openssl_lib_config() {
1279 return MainWP_Server_Information_Handler::is_openssl_config_warning() ? true : false;
1280 }
1281
1282 /**
1283 * Render Advanced Options Subpage.
1284 *
1285 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1286 */
1287 public static function render_advanced() { //phpcs:ignore -- NOSONAR - complex method.
1288 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
1289 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1290 return;
1291 }
1292
1293 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) {
1294
1295 /**
1296 * Action: mainwp_before_save_advanced_settings
1297 *
1298 * Fires before save advanced settings.
1299 *
1300 * @since 4.1
1301 */
1302 do_action( 'mainwp_before_save_advanced_settings', $_POST );
1303
1304 MainWP_Utility::update_option( 'mainwp_maximumRequests', ! empty( $_POST['mainwp_maximumRequests'] ) ? intval( $_POST['mainwp_maximumRequests'] ) : 4 );
1305 MainWP_Utility::update_option( 'mainwp_minimumDelay', ! empty( $_POST['mainwp_minimumDelay'] ) ? intval( $_POST['mainwp_minimumDelay'] ) : 200 );
1306 MainWP_Utility::update_option( 'mainwp_maximumIPRequests', ! empty( $_POST['mainwp_maximumIPRequests'] ) ? intval( $_POST['mainwp_maximumIPRequests'] ) : 1 );
1307 MainWP_Utility::update_option( 'mainwp_minimumIPDelay', ! empty( $_POST['mainwp_minimumIPDelay'] ) ? intval( $_POST['mainwp_minimumIPDelay'] ) : 1000 );
1308 MainWP_Utility::update_option( 'mainwp_maximumSyncRequests', ! empty( $_POST['mainwp_maximumSyncRequests'] ) ? intval( $_POST['mainwp_maximumSyncRequests'] ) : 8 );
1309 MainWP_Utility::update_option( 'mainwp_maximumInstallUpdateRequests', ! empty( $_POST['mainwp_maximumInstallUpdateRequests'] ) ? intval( $_POST['mainwp_maximumInstallUpdateRequests'] ) : 3 );
1310 MainWP_Utility::update_option( 'mainwp_sslVerifyCertificate', isset( $_POST['mainwp_sslVerifyCertificate'] ) ? 1 : 0 );
1311 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 );
1312 MainWP_Utility::update_option( 'mainwp_verify_connection_method', isset( $_POST['mainwp_settings_verify_connection_method'] ) ? intval( $_POST['mainwp_settings_verify_connection_method'] ) : 0 );
1313 MainWP_Utility::update_option( 'mainwp_forceUseIPv4', isset( $_POST['mainwp_forceUseIPv4'] ) ? 1 : 0 );
1314 MainWP_Utility::update_option( 'mainwp_wp_cron', ( ! isset( $_POST['mainwp_options_wp_cron'] ) ? 0 : 1 ) );
1315 MainWP_Utility::update_option( 'mainwp_optimize', ( ! isset( $_POST['mainwp_optimize'] ) ? 0 : 1 ) );
1316
1317 if ( isset( $_POST['mainwp_openssl_lib_location'] ) ) {
1318 $openssl_loc = ! empty( $_POST['mainwp_openssl_lib_location'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_openssl_lib_location'] ) ) : '';
1319 MainWP_Utility::update_option( 'mainwp_opensslLibLocation', $openssl_loc );
1320 }
1321
1322 /**
1323 * Action: mainwp_after_save_advanced_settings
1324 *
1325 * Fires after advanced settings save.
1326 *
1327 * @since 4.1
1328 */
1329 do_action( 'mainwp_after_save_advanced_settings', $_POST );
1330 }
1331 static::render_header( 'Advanced' );
1332 ?>
1333
1334 <div id="mainwp-advanced-settings" class="ui segment">
1335 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-advanced-settings-info-notice' ) ) : ?>
1336 <div class="ui info message">
1337 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-advanced-settings-info-notice"></i>
1338 <?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' ); ?>
1339 </div>
1340 <?php endif; ?>
1341 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) : ?>
1342 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1343 <?php endif; ?>
1344 <div class="ui form">
1345 <form method="POST" action="">
1346 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1347 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SettingsAdvanced' ) ); ?>" />
1348 <?php
1349
1350 /**
1351 * Action: mainwp_advanced_settings_form_top
1352 *
1353 * Fires at the top of advanced settings form.
1354 *
1355 * @since 4.1
1356 */
1357 do_action( 'mainwp_advanced_settings_form_top' );
1358
1359 if ( static::show_openssl_lib_config() ) {
1360 $openssl_loc = MainWP_System_Utility::get_openssl_conf();
1361 ?>
1362 <h3 class="ui dividing header">
1363 <?php esc_html_e( 'OpenSSL Settings', 'mainwp' ); ?>
1364 <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>
1365 </h3>
1366 <div class="ui grid field">
1367 <label class="six wide column middle aligned"><?php esc_html_e( 'OpenSSL.cnf location', 'mainwp' ); ?></label>
1368 <div class="ten wide column ui field">
1369 <input type="text" name="mainwp_openssl_lib_location" value="<?php echo esc_html( $openssl_loc ); ?>">
1370 <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>
1371 <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>
1372 </div>
1373 </div>
1374 <?php } ?>
1375
1376 <h3 class="ui dividing header">
1377 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cross-ip' ); ?>
1378 <?php esc_html_e( 'Cross IP Settings', 'mainwp' ); ?></h3>
1379
1380 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="4">
1381 <label class="six wide column middle aligned">
1382 <?php
1383 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumRequests', (int) get_option( 'mainwp_maximumRequests', 4 ) );
1384 esc_html_e( 'Maximum simultaneous requests (Default: 4)', 'mainwp' );
1385 ?>
1386 </label>
1387 <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">
1388 <input type="text" class="settings-field-value-change-handler" name="mainwp_maximumRequests" id="mainwp_maximumRequests" value="<?php echo false === get_option( 'mainwp_maximumRequests' ) ? 4 : esc_attr( get_option( 'mainwp_maximumRequests' ) ); ?>"/>
1389 </div>
1390 </div>
1391
1392 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="200">
1393 <label class="six wide column middle aligned">
1394 <?php
1395 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_minimumDelay', (int) get_option( 'mainwp_minimumDelay', 200 ) );
1396 esc_html_e( 'Minimum delay between requests (Default: 200)', 'mainwp' );
1397 ?>
1398 </label>
1399 <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">
1400 <input type="text" class="settings-field-value-change-handler" name="mainwp_minimumDelay" id="mainwp_minimumDelay" value="<?php echo false === get_option( 'mainwp_minimumDelay' ) ? 200 : esc_attr( get_option( 'mainwp_minimumDelay' ) ); ?>"/>
1401 </div>
1402 </div>
1403
1404 <h3 class="ui dividing header">
1405 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-per-ip' ); ?>
1406 <?php esc_html_e( 'Per IP Settings', 'mainwp' ); ?></h3>
1407
1408 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-per-ip" default-indi-value="1">
1409 <label class="six wide column middle aligned">
1410 <?php
1411 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumIPRequests', (int) get_option( 'mainwp_maximumIPRequests', 1 ) );
1412 esc_html_e( 'Maximum simultaneous requests per IP (Default: 1)', 'mainwp' );
1413 ?>
1414 </label>
1415 <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">
1416 <input type="text" class="settings-field-value-change-handler" name="mainwp_maximumIPRequests" id="mainwp_maximumIPRequests" value="<?php echo false === get_option( 'mainwp_maximumIPRequests' ) ? 1 : esc_attr( get_option( 'mainwp_maximumIPRequests' ) ); ?>"/>
1417 </div>
1418 </div>
1419
1420 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-per-ip" default-indi-value="1000">
1421 <label class="six wide column middle aligned">
1422 <?php
1423 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_minimumIPDelay', (int) get_option( 'mainwp_minimumIPDelay', 1000 ) );
1424 esc_html_e( 'Minimum delay between requests to the same IP (Default: 1000)', 'mainwp' );
1425 ?>
1426 </label>
1427 <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">
1428 <input type="text" class="settings-field-value-change-handler" name="mainwp_minimumIPDelay" id="mainwp_minimumIPDelay" value="<?php echo false === get_option( 'mainwp_minimumIPDelay' ) ? 1000 : esc_attr( get_option( 'mainwp_minimumIPDelay' ) ); ?>"/>
1429 </div>
1430 </div>
1431
1432 <h3 class="ui dividing header">
1433 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-frontend-request' ); ?>
1434 <?php esc_html_e( 'Frontend Request Settings', 'mainwp' ); ?></h3>
1435
1436 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-frontend-request" default-indi-value="8">
1437 <label class="six wide column middle aligned">
1438 <?php
1439 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumSyncRequests', (int) get_option( 'mainwp_maximumSyncRequests', 8 ) );
1440 esc_html_e( 'Maximum simultaneous sync requests (Default: 8)', 'mainwp' );
1441 ?>
1442 </label>
1443 <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">
1444 <input type="text" class="settings-field-value-change-handler" name="mainwp_maximumSyncRequests" id="mainwp_maximumSyncRequests" value="<?php echo false === get_option( 'mainwp_maximumSyncRequests' ) ? 8 : esc_attr( get_option( 'mainwp_maximumSyncRequests' ) ); ?>"/>
1445 </div>
1446 </div>
1447
1448 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-frontend-request" default-indi-value="3">
1449 <label class="six wide column middle aligned">
1450 <?php
1451 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumInstallUpdateRequests', (int) get_option( 'mainwp_maximumInstallUpdateRequests', 3 ) );
1452 esc_html_e( 'Maximum simultaneous install and update requests (Default: 3)', 'mainwp' );
1453 ?>
1454 </label>
1455 <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">
1456 <input type="text" class="settings-field-value-change-handler" name="mainwp_maximumInstallUpdateRequests" id="mainwp_maximumInstallUpdateRequests" value="<?php echo false === get_option( 'mainwp_maximumInstallUpdateRequests' ) ? 3 : esc_attr( get_option( 'mainwp_maximumInstallUpdateRequests' ) ); ?>"/>
1457 </div>
1458 </div>
1459
1460 <h3 class="ui dividing header">
1461 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-miscellaneous' ); ?>
1462 <?php esc_html_e( 'Miscellaneous Settings', 'mainwp' ); ?></h3>
1463 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1">
1464 <label class="six wide column middle aligned">
1465 <?php
1466 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_optimize', (int) get_option( 'mainwp_optimize', 1 ) );
1467 esc_html_e( 'Optimize data loading', 'mainwp' );
1468 ?>
1469 </label>
1470 <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">
1471 <input type="checkbox" class="settings-field-value-change-handler" 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>
1472 </div>
1473 </div>
1474 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1">
1475 <label class="six wide column middle aligned">
1476 <?php
1477 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_wp_cron', (int) get_option( 'mainwp_wp_cron', 1 ) );
1478 esc_html_e( 'Use WP Cron', 'mainwp' );
1479 ?>
1480 </label>
1481 <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">
1482 <input type="checkbox" class="settings-field-value-change-handler" 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>
1483 </div>
1484 </div>
1485 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1" >
1486 <label class="six wide column middle aligned">
1487 <?php
1488 $indi_val = (int) get_option( 'mainwp_sslVerifyCertificate', 1 );
1489 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sslVerifyCertificate', $indi_val );
1490 esc_html_e( 'Verify SSL certificate', 'mainwp' );
1491 ?>
1492 </label>
1493 <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">
1494 <input type="checkbox" class="settings-field-value-change-handler" 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>
1495 </div>
1496 </div>
1497 <?php
1498 $general_verify_con = (int) get_option( 'mainwp_verify_connection_method', 1 );
1499 ?>
1500 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1">
1501 <label class="six wide column middle aligned">
1502 <?php
1503 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_verify_connection_method', (int) $general_verify_con );
1504 esc_html_e( 'Verify connection method', 'mainwp' );
1505 ?>
1506 </label>
1507 <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">
1508 <select class="ui dropdown settings-field-value-change-handler" id="mainwp_settings_verify_connection_method" name="mainwp_settings_verify_connection_method">
1509 <option <?php echo ( empty( $general_verify_con ) || 1 === $general_verify_con ) ? 'selected' : ''; ?> value="1"><?php esc_html_e( 'OpenSSL (default)', 'mainwp' ); ?></option>
1510 <option <?php echo ( 2 === $general_verify_con ) ? 'selected' : ''; ?> value="2"><?php esc_html_e( 'PHPSECLIB (fallback)', 'mainwp' ); ?></option>
1511 </select>
1512 </div>
1513 </div>
1514 <?php
1515 $sign_note = MainWP_Connect_Lib::get_connection_algo_settings_note();
1516 $sign_algs = MainWP_System_Utility::get_open_ssl_sign_algos();
1517 $general_sign_alg = get_option( 'mainwp_connect_signature_algo', false );
1518 if ( false === $general_sign_alg ) {
1519 $general_sign_alg = defined( 'OPENSSL_ALGO_SHA256' ) ? OPENSSL_ALGO_SHA256 : 1;
1520 MainWP_Utility::update_option( 'mainwp_connect_signature_algo', $general_sign_alg );
1521 } else {
1522 $general_sign_alg = intval( $general_sign_alg );
1523 }
1524 $algo_def = defined( 'OPENSSL_ALGO_SHA256' ) ? (int) OPENSSL_ALGO_SHA256 : 1;
1525 ?>
1526 <div default-indi-value="<?php echo esc_attr( $algo_def ); ?>" class="ui grid field mainwp-hide-elemenent-sign-algo settings-field-indicator-wrapper settings-field-indicator-miscellaneous" <?php echo ( 2 === $general_verify_con ) ? 'style="display:none;"' : ''; ?> >
1527 <label class="six wide column middle aligned">
1528 <?php
1529 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_connect_signature_algo', (int) $general_sign_alg );
1530 esc_html_e( 'OpenSSL signature algorithm', 'mainwp' );
1531 ?>
1532 </label>
1533 <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">
1534 <select class="ui dropdown settings-field-value-change-handler" id="mainwp_settings_openssl_alg" name="mainwp_settings_openssl_alg">
1535 <?php
1536 foreach ( $sign_algs as $val => $text ) {
1537 ?>
1538 <option <?php echo ( $val === $general_sign_alg ) ? 'selected' : ''; ?> value="<?php echo esc_attr( $val ); ?>"><?php echo esc_html( $text ); ?></option>
1539 <?php
1540 }
1541 ?>
1542 </select>
1543 <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>
1544 </div>
1545 </div>
1546 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous">
1547 <label class="six wide column middle aligned">
1548 <?php
1549 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_forceUseIPv4', (int) get_option( 'mainwp_forceUseIPv4' ) );
1550 esc_html_e( 'Force IPv4', 'mainwp' );
1551 ?>
1552 </label>
1553 <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">
1554 <input type="checkbox" class="settings-field-value-change-handler" 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>
1555 </div>
1556 </div>
1557 <?php
1558
1559 /**
1560 * Action: mainwp_advanced_settings_form_bottom
1561 *
1562 * Fires at the bottom of advanced settings form.
1563 *
1564 * @since 4.1
1565 */
1566 do_action( 'mainwp_advanced_settings_form_bottom' );
1567
1568 ?>
1569 <div class="ui divider"></div>
1570 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1571 </form>
1572 </div>
1573 </div>
1574 <?php
1575 static::render_footer( 'Advanced' );
1576 }
1577
1578 /**
1579 * Render MainWP Tools SubPage.
1580 *
1581 * @uses \MainWP\Dashboard\MainWP_UI::render_screen_options()
1582 */
1583 public static function render_mainwp_tools() { // phpcs:ignore -- NOSONAR - complex.
1584 if ( ! mainwp_current_user_have_right( 'dashboard', 'manage_dashboard_settings' ) ) {
1585 mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1586
1587 return;
1588 }
1589 static::render_header( 'MainWPTools' );
1590 $is_demo = MainWP_Demo_Handle::is_demo_mode();
1591 ?>
1592 <div id="mainwp-tools-settings" class="ui segment">
1593 <div id="mainwp-message-zone" style="display:none;" class="ui message"></div>
1594 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-message' ) ) : ?>
1595 <div class="ui info message">
1596 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-message"></i>
1597 <?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>' ); ?>
1598 </div>
1599 <?php endif; ?>
1600 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-custom-theme' ) ) : ?>
1601 <div class="ui info message">
1602 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-custom-theme"></i>
1603 <div><?php esc_html_e( 'Here you can select a theme for your MainWP Dashboard.', 'mainwp' ); ?></div>
1604 <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>
1605 </div>
1606 <?php endif; ?>
1607 <?php if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1608 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1609 <?php endif; ?>
1610 <?php if ( isset( $_POST['mainwp_restore_info_messages'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1611 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Info messages have been restored successfully!', 'mainwp' ); ?></div>
1612 <?php endif; ?>
1613 <div class="ui form">
1614 <form method="POST" action="">
1615 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1616 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MainWPTools' ) ); ?>" />
1617 <h3 class="ui dividing header">
1618 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-tools' ); ?>
1619 <?php esc_html_e( 'MainWP Dashboard Tools', 'mainwp' ); ?></h3>
1620 <?php
1621 /**
1622 * Action: mainwp_tools_form_top
1623 *
1624 * Fires at the top of MainWP tools form.
1625 *
1626 * @since 4.1
1627 */
1628 do_action( 'mainwp_tools_form_top' );
1629
1630 $show_qsw = apply_filters( 'mainwp_show_qsw', true );
1631
1632 static::get_instance()->render_select_custom_themes();
1633
1634 ?>
1635 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-tools">
1636 <label class="six wide column middle aligned">
1637 <?php
1638 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_enable_guided_tours', (int) get_option( 'mainwp_enable_guided_tours', 0 ) );
1639 esc_html_e( 'Enable MainWP guided tours', 'mainwp' );
1640 ?>
1641 <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></label>
1642 <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">
1643 <div class="ui info message" style="display:block!important;">
1644 <?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>' ); ?>
1645 </div>
1646 <div class="ui toggle checkbox">
1647 <input type="checkbox" class="settings-field-value-change-handler" name="mainwp-guided-tours-option" id="mainwp-guided-tours-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_tours', 0 ) ? 'checked="true"' : ''; ?> />
1648 </div>
1649 </div>
1650 </div>
1651 <div class="ui grid field">
1652 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashboard to establish a new connection', 'mainwp' ); ?></label>
1653 <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">
1654 <?php
1655 if ( $is_demo ) {
1656 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' ) . '" />' );
1657 } else {
1658 ?>
1659 <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' ); ?>" />
1660 <?php } ?>
1661 </div>
1662 </div>
1663 <div class="ui grid field">
1664 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashboard to set new pair of OpenSSL Keys', 'mainwp' ); ?></label>
1665 <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">
1666 <?php
1667 if ( $is_demo ) {
1668 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>' );
1669 } else {
1670 ?>
1671 <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>
1672 <?php } ?>
1673 </div>
1674 </div>
1675 <?php if ( $show_qsw ) { ?>
1676 <div class="ui grid field">
1677 <label class="six wide column middle aligned"><?php esc_html_e( 'Start the MainWP Quick Setup Wizard', 'mainwp' ); ?></label>
1678 <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>
1679 </div>
1680 <?php } ?>
1681 <div class="ui grid field">
1682 <label class="six wide column middle aligned"><?php esc_html_e( 'Export child sites to CSV file', 'mainwp' ); ?></label>
1683 <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>
1684 </div>
1685 <div class="ui grid field">
1686 <label class="six wide column middle aligned"><?php esc_html_e( 'Import child sites', 'mainwp' ); ?></label>
1687 <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>
1688 </div>
1689 <div class="ui grid field">
1690 <label class="six wide column middle aligned"><?php esc_html_e( 'Disconnect all child sites', 'mainwp' ); ?></label>
1691 <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">
1692 <?php
1693 if ( $is_demo ) {
1694 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>' );
1695 } else {
1696 ?>
1697 <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>
1698 <?php } ?>
1699 </div>
1700 </div>
1701 <div class="ui grid field">
1702 <label class="six wide column middle aligned"><?php esc_html_e( 'Delete extensions API Activation data', 'mainwp' ); ?></label>
1703 <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">
1704 <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>
1705 </div>
1706 </div>
1707 <div class="ui grid field">
1708 <label class="six wide column middle aligned"><?php esc_html_e( 'Restore all info messages', 'mainwp' ); ?></label>
1709 <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">
1710 <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' ); ?>"/>
1711 </div>
1712 </div>
1713 <?php
1714 $enabled_demo = MainWP_Demo_Handle::is_demo_mode();
1715 $is_new = MainWP_Demo_Handle::get_instance()->is_new_instance();
1716 if ( ! MainWP_Demo_Handle::is_instawp_site() ) {
1717 ?>
1718 <div class="ui grid field">
1719 <label class="six wide column middle aligned"><?php echo esc_html__( 'Demo mode', 'mainwp' ); ?></label>
1720 <div class="ten wide column">
1721 <?php if ( ! $enabled_demo ) { ?>
1722 <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>
1723 <?php } else { ?>
1724 <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>
1725 <?php } ?>
1726 </div>
1727 </div>
1728 <?php
1729 }
1730 /**
1731 * Action: mainwp_tools_form_bottom
1732 *
1733 * Fires at the bottom of mainwp tools form.
1734 *
1735 * @since 4.1
1736 */
1737 do_action( 'mainwp_tools_form_bottom' );
1738 ?>
1739 <div class="ui divider"></div>
1740 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1741 </form>
1742 </div>
1743 </div>
1744 <script type="text/javascript">
1745 jQuery( '#mainwp-disconnect-sites-tool' ).popup();
1746 jQuery( '#mainwp-clear-activation-data' ).popup();
1747 </script>
1748 <?php
1749 static::render_footer( 'MainWPTools' );
1750 MainWP_Connect_Helper::render_renew_connections_modal();
1751 }
1752
1753 /**
1754 * Render MainWP themes selection.
1755 */
1756 public function render_select_custom_themes() { // phpcs:ignore -- NOSONAR - complex.
1757 $custom_theme = $this->get_current_user_theme();
1758 if ( false === $custom_theme ) {
1759 // to compatible with Custom Dashboard extension settings.
1760 $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1761 if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1762 $compat_theme = $compat_settings['theme'];
1763 }
1764 if ( null !== $compat_theme ) {
1765 $custom_theme = $compat_theme;
1766 }
1767 }
1768 $themes_files = static::get_instance()->get_custom_themes_files();
1769 if ( empty( $themes_files ) ) {
1770 $themes_files = array();
1771 }
1772 ?>
1773 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-tools" default-indi-value="default">
1774 <label class="six wide column middle aligned">
1775 <?php
1776 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_selected_theme', $custom_theme );
1777 esc_html_e( 'Select MainWP Theme', 'mainwp' );
1778 ?>
1779 </label>
1780 <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">
1781 <select name="mainwp_settings_custom_theme" id="mainwp_settings_custom_theme" class="ui dropdown selection settings-field-value-change-handler">
1782 <option value="default" <?php echo ( 'default' === $custom_theme || empty( $custom_theme ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Default', 'mainwp' ); ?></option>
1783 <option value="classic" <?php echo ( 'classic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Classic', 'mainwp' ); ?></option>
1784 <option value="dark" <?php echo ( 'dark' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Dark', 'mainwp' ); ?></option>
1785 <option value="wpadmin" <?php echo ( 'wpadmin' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'WP Admin', 'mainwp' ); ?></option>
1786 <option value="minimalistic" <?php echo ( 'minimalistic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Minimalistic', 'mainwp' ); ?></option>
1787 <?php
1788 foreach ( $themes_files as $file_name => $theme ) {
1789 $theme = ucfirst( $theme );
1790 $_select = '';
1791 if ( $custom_theme === $file_name ) {
1792 $_select = 'selected';
1793 }
1794 echo '<option value="' . esc_attr( $file_name ) . '" ' . esc_attr( $_select ) . '>' . esc_html( $theme ) . '</option>';
1795 }
1796 ?>
1797 </select>
1798 </div>
1799 </div>
1800 <?php
1801 }
1802
1803 /**
1804 * Get custom themes files.
1805 */
1806 public function get_custom_themes_files() {
1807 // get themes files.
1808 $dirs = $this->get_custom_theme_folder();
1809 $scan_dir = $dirs[0];
1810 $handle = opendir( $scan_dir );
1811 $themes = array();
1812 if ( $handle ) {
1813 $filename = readdir( $handle );
1814 while ( false !== $filename ) {
1815 $correct_file = true;
1816 if ( '.' === substr( $filename, 0, 1 ) || 'index.php' === $filename || '.css' !== substr( $filename, - 4 ) ) {
1817 $correct_file = false;
1818 }
1819 if ( $correct_file ) {
1820 $theme = basename( $filename, '.css' );
1821 $theme = str_replace( '-theme', '', $theme );
1822 $themes[ $filename ] = trim( $theme );
1823 }
1824 $filename = readdir( $handle ); // to while loop.
1825 }
1826 closedir( $handle );
1827 }
1828 return $themes;
1829 }
1830
1831 /**
1832 * Get selected MainWP theme name.
1833 */
1834 public function get_selected_theme() {
1835 $selected_theme = false;
1836
1837 $custom_theme = $this->get_current_user_theme();
1838
1839 if ( false === $custom_theme ) {
1840 // to compatible with Custom Dashboard extension settings.
1841 $compat_settings = get_option( 'mainwp_custom_dashboard_settings' );
1842 if ( is_array( $compat_settings ) && isset( $compat_settings['theme'] ) ) {
1843 $compat_theme = $compat_settings['theme'];
1844 }
1845
1846 if ( null !== $compat_theme ) {
1847 $custom_theme = $compat_theme;
1848 }
1849 }
1850
1851 if ( ! empty( $custom_theme ) ) {
1852 if ( 'default' === $custom_theme || 'dark' === $custom_theme || 'wpadmin' === $custom_theme || 'minimalistic' === $custom_theme ) {
1853 return $custom_theme;
1854 }
1855 $dirs = $this->get_custom_theme_folder();
1856 $theme_dir = $dirs[0];
1857 $file = $theme_dir . $custom_theme;
1858 if ( file_exists( $file ) && '.css' === substr( $file, - 4 ) ) {
1859 $selected_theme = $custom_theme;
1860 }
1861 }
1862 return $selected_theme;
1863 }
1864
1865
1866 /**
1867 * Get custom MainWP theme folder.
1868 */
1869 public function get_custom_theme_folder() {
1870 $dirs = MainWP_System_Utility::get_mainwp_dir();
1871 global $wp_filesystem;
1872 if ( is_array( $dirs ) && ! $wp_filesystem->exists( $dirs[0] . 'themes' ) && $wp_filesystem->exists( $dirs[0] . 'custom-dashboard' ) ) {
1873 // re-name the custom-dashboard folder to compatible.
1874 $wp_filesystem->move( $dirs[0] . 'custom-dashboard', $dirs[0] . 'themes' );
1875 }
1876 return MainWP_System_Utility::get_mainwp_dir_allow_access( 'themes' );
1877 }
1878
1879
1880 /**
1881 * Get current user's selected theme.
1882 */
1883 public function get_current_user_theme() {
1884 $custom_theme = get_user_option( 'mainwp_selected_theme' );
1885 if ( empty( $custom_theme ) ) {
1886 $custom_theme = get_option( 'mainwp_selected_theme', 'default' );
1887 }
1888 return $custom_theme;
1889 }
1890
1891 /**
1892 * Export Child Sites and save as .csv file.
1893 *
1894 * @uses \MainWP\Dashboard\MainWP_DB::query()
1895 * @uses \MainWP\Dashboard\MainWP_DB::get_sql_websites_for_current_user()
1896 * @uses \MainWP\Dashboard\MainWP_DB::data_seek()
1897 * @uses \MainWP\Dashboard\MainWP_DB::fetch_object()
1898 * @uses \MainWP\Dashboard\MainWP_Utility::map_site()
1899 */
1900 public static function export_sites() {
1901 if ( isset( $_GET['doExportSites'] ) && isset( $_GET['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_GET['_wpnonce'] ), 'export_sites' ) ) {
1902
1903 $sql = MainWP_DB::instance()->get_sql_websites_for_current_user( true );
1904 $websites = MainWP_DB::instance()->query( $sql );
1905
1906 if ( ! $websites ) {
1907 die( 'Not found sites' );
1908 }
1909
1910 $keys = array( 'name', 'url', 'adminname', 'wpgroups', 'uniqueId', 'http_user', 'http_pass', 'verify_certificate', 'ssl_version' );
1911 $allowedHeaders = array( 'site name', 'url', 'admin name', 'group', 'security id', 'http username', 'http password', 'verify certificate', 'ssl version' );
1912
1913 $csv = implode( ',', $allowedHeaders ) . "\r";
1914 MainWP_DB::data_seek( $websites, 0 );
1915 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1916 if ( empty( $website ) ) {
1917 continue;
1918 }
1919 $row = MainWP_Utility::map_site( $website, $keys, false );
1920 $csv .= '"' . implode( '","', $row ) . '"' . "\r";
1921 }
1922
1923 header( 'Content-Type: text/csv; charset=utf-8' );
1924 header( 'Content-Disposition: attachment; filename=export-sites.csv' );
1925 echo $csv; // phpcs:ignore WordPress.Security.EscapeOutput
1926 exit();
1927 }
1928 }
1929
1930 /**
1931 * Render MainWP Email Settings SubPage.
1932 *
1933 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::get_notification_types()
1934 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_edit_settings()
1935 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::emails_general_settings_handle()
1936 * @uses \MainWP\Dashboard\MainWP_Notification_Settings::render_all_settings()
1937 * @uses \MainWP\Dashboard\MainWP_Notification_Template::handle_template_file_action()
1938 */
1939 public static function render_email_settings() {
1940 $notification_emails = MainWP_Notification_Settings::get_notification_types();
1941 static::render_header( 'Emails' );
1942 $edit_email = isset( $_GET['edit-email'] ) ? sanitize_text_field( wp_unslash( $_GET['edit-email'] ) ) : ''; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1943 if ( ! empty( $edit_email ) && isset( $notification_emails[ $edit_email ] ) ) {
1944 $updated_templ = MainWP_Notification_Template::instance()->handle_template_file_action();
1945 MainWP_Notification_Settings::instance()->render_edit_settings( $edit_email, $updated_templ );
1946 } else {
1947 $updated = MainWP_Notification_Settings::emails_general_settings_handle();
1948 MainWP_Notification_Settings::instance()->render_all_settings( $updated );
1949 }
1950 static::render_footer( 'Emails' );
1951 }
1952
1953 /**
1954 * Method mainwp_help_content()
1955 *
1956 * Creates the MainWP Help Documentation List for the help component in the sidebar.
1957 */
1958 public static function mainwp_help_content() {
1959 if ( isset( $_GET['page'] ) && ( 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'MainWPTools' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1960 ?>
1961 <p><?php esc_html_e( 'If you need help with your MainWP Dashboard settings, please review following help documents', 'mainwp' ); ?></p>
1962 <div class="ui list">
1963 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/" target="_blank">MainWP Dashboard Settings</a></div>
1964 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#updates-settings" target="_blank">Updates Settings</a></div>
1965 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#basic-uptime-monitoring" target="_blank">Basic Uptime Monitoring Settings</a></div>
1966 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#site-health-monitoring" target="_blank">Site Health Settings</a></div>
1967 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#backup-options" target="_blank">Backup Settings</a></div>
1968 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#advanced-settings" target="_blank">Advanced Settings</a></div>
1969 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#email-settings" target="_blank">Email Settings</a></div>
1970 <div class="item"><i class="external alternate icon"></i> <a href="https://kb.mainwp.com/docs/mainwp-dashboard-settings/#mainwp-tools" target="_blank">Tools</a></div>
1971 </div>
1972 <?php
1973 /**
1974 * Action: mainwp_settings_help_item
1975 *
1976 * Fires at the bottom of the help articles list in the Help sidebar on the Settings page.
1977 *
1978 * Suggested HTML markup:
1979 *
1980 * <div class="item"><a href="Your custom URL">Your custom text</a></div>
1981 *
1982 * @since 5.2
1983 */
1984 do_action( 'mainwp_settings_help_item' );
1985
1986 }
1987 }
1988 }
1989