PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 6.2.1
MainWP Dashboard: Self-hosted WordPress Management for Agencies v6.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
← All changes | pages/page-mainwp-settings.php +1468 -616 5.2 → 6.2.1 View file →
@@ -9,8 +9,15 @@
9 9 */
10 10
11 11 namespace MainWP\Dashboard;
12 12
13 +use MainWP\Dashboard\Module\CostTracker\Cost_Tracker_Settings;
14 +
15 +// Exit if accessed directly.
16 +if ( ! defined( 'ABSPATH' ) ) {
17 + exit;
18 +}
19 +
13 20 /**
14 21 * Class MainWP_Settings
15 22 *
16 23 * @package MainWP\Dashboard
@@ -82,8 +89,308 @@
82 89
83 90 add_action( 'mainwp_help_sidebar_content', array( static::get_class_name(), 'mainwp_help_content' ) );
84 91 }
85 92
93 + /**
94 + * Get the registered Settings subpages.
95 + *
96 + * @return array<int, array<string, mixed>> Settings subpages.
97 + */
98 + private static function get_subpages() {
99 + if ( isset( static::$subPages ) && is_array( static::$subPages ) ) {
100 + return static::$subPages;
101 + }
102 +
103 + /**
104 + * Settings Subpages
105 + *
106 + * Filters subpages for the Settings page.
107 + *
108 + * @since Unknown
109 + */
110 + $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.
111 + static::$subPages = apply_filters( 'mainwp_getsubpages_settings', $sub_pages );
112 +
113 + return is_array( static::$subPages ) ? static::$subPages : array();
114 + }
115 +
116 + /**
117 + * Get the built-in Settings pages used across menu registration and navigation rendering.
118 + *
119 + * @return array<int, array<string, mixed>> Settings page definitions.
120 + */
121 + private static function get_core_pages() {
122 + $pages = array(
123 + array(
124 + 'slug' => 'Settings',
125 + 'page_title' => __( 'Settings Global options', 'mainwp' ),
126 + 'menu_title' => ' <span id="mainwp-Settings">' . esc_html__( 'Settings', 'mainwp' ) . '</span>',
127 + 'nav_title' => esc_html__( 'General Settings', 'mainwp' ),
128 + 'callback' => array( static::get_class_name(), 'render' ),
129 + 'active_keys' => array( '', 'Settings' ),
130 + ),
131 + array(
132 + 'slug' => 'MainWPTools',
133 + 'page_title' => __( 'Tools', 'mainwp' ),
134 + 'menu_title' => ' <div class="mainwp-hidden">' . esc_html__( 'Tools', 'mainwp' ) . '</div>',
135 + 'nav_title' => esc_html__( 'Tools', 'mainwp' ),
136 + 'callback' => array( static::get_class_name(), 'render_mainwp_tools' ),
137 + 'active_keys' => array( 'MainWPTools' ),
138 + ),
139 + array(
140 + 'slug' => 'CostTrackerSettings',
141 + 'page_title' => esc_html__( 'Cost Tracker Settings', 'mainwp' ),
142 + 'menu_title' => '<div class="mainwp-hidden">' . esc_html__( 'Cost Tracker', 'mainwp' ) . '</div>',
143 + 'nav_title' => esc_html__( 'Cost Tracker Settings', 'mainwp' ),
144 + 'callback' => array( Cost_Tracker_Settings::get_instance(), 'render_settings_page' ),
145 + 'active_keys' => array( 'CostTrackerSettings' ),
146 + ),
147 + array(
148 + 'slug' => 'SettingsAdvanced',
149 + 'page_title' => __( 'Advanced Options', 'mainwp' ),
150 + 'menu_title' => ' <div class="mainwp-hidden">' . esc_html__( 'Advanced Options', 'mainwp' ) . '</div>',
151 + 'nav_title' => esc_html__( 'Advanced Settings', 'mainwp' ),
152 + 'callback' => array( static::get_class_name(), 'render_advanced' ),
153 + 'active_keys' => array( 'Advanced', 'SettingsAdvanced' ),
154 + ),
155 + array(
156 + 'slug' => 'MonitoringSettings',
157 + 'page_title' => __( 'Monitoring Options', 'mainwp' ),
158 + 'menu_title' => ' <div class="mainwp-hidden">' . esc_html__( 'Monitoring Options', 'mainwp' ) . '</div>',
159 + 'nav_title' => esc_html__( 'Monitoring Settings', 'mainwp' ),
160 + 'callback' => array( static::get_class_name(), 'render_monitoring' ),
161 + 'active_keys' => array( 'Monitoring', 'MonitoringSettings' ),
162 + ),
163 + array(
164 + 'slug' => 'SettingsEmail',
165 + 'page_title' => __( 'Email Settings', 'mainwp' ),
166 + 'menu_title' => ' <div class="mainwp-hidden">' . esc_html__( 'Email Settings', 'mainwp' ) . '</div>',
167 + 'nav_title' => esc_html__( 'Email Settings', 'mainwp' ),
168 + 'callback' => array( static::get_class_name(), 'render_email_settings' ),
169 + 'active_keys' => array( 'Emails', 'SettingsEmail' ),
170 + ),
171 + array(
172 + 'slug' => 'PremiumUpdates',
173 + 'page_title' => __( 'Premium Updates', 'mainwp' ),
174 + 'menu_title' => ' <div class="mainwp-hidden">' . esc_html__( 'Premium Updates', 'mainwp' ) . '</div>',
175 + 'nav_title' => esc_html__( 'Premium Updates', 'mainwp' ),
176 + 'callback' => array( MainWP_Settings_Premium_Updates::get_class_name(), 'render' ),
177 + 'active_keys' => array( 'Premium', 'PremiumUpdates' ),
178 + ),
179 + );
180 +
181 + $visible_pages = array();
182 +
183 + foreach ( $pages as $page ) {
184 + if ( 'Settings' !== $page['slug'] && MainWP_Menu::is_disable_menu_item( 3, $page['slug'] ) ) {
185 + continue;
186 + }
187 +
188 + $visible_pages[] = $page;
189 + }
190 +
191 + return $visible_pages;
192 + }
193 +
194 + /**
195 + * Convert a navigation href into a usable URL.
196 + *
197 + * @param string $href Navigation href.
198 + *
199 + * @return string Navigation URL.
200 + */
201 + private static function get_navigation_item_url( $href ) {
202 + $href = trim( wp_specialchars_decode( (string) $href, ENT_QUOTES ) );
203 +
204 + if ( empty( $href ) ) {
205 + return '';
206 + }
207 +
208 + if ( preg_match( '/^https?:\/\//i', $href ) ) {
209 + return $href;
210 + }
211 +
212 + return admin_url( ltrim( $href, '/' ) );
213 + }
214 +
215 + /**
216 + * Get dynamic Settings subpage items using the legacy left-menu normalization path.
217 + *
218 + * @return array<int, array<string, mixed>> Settings navigation items.
219 + */
220 + private static function get_filtered_subpage_navigation_items() {
221 + $menu_items = array();
222 + $core_slugs = array();
223 +
224 + foreach ( static::get_navigation_items( 'left_menu_core' ) as $item ) {
225 + $core_slugs[ $item['slug'] ] = true;
226 + $menu_items[] = array(
227 + 'title' => $item['title'],
228 + 'parent_key' => 'Settings',
229 + 'href' => $item['href'],
230 + 'slug' => $item['slug'],
231 + 'right' => '',
232 + 'before_title' => isset( $item['before_title'] ) ? $item['before_title'] : '',
233 + );
234 + }
235 +
236 + MainWP_Menu::init_subpages_left_menu( static::get_subpages(), $menu_items, 'Settings', 'Settings' );
237 +
238 + $items = array();
239 +
240 + foreach ( $menu_items as $menu_item ) {
241 + if ( empty( $menu_item['slug'] ) || empty( $menu_item['title'] ) || empty( $menu_item['href'] ) ) {
242 + continue;
243 + }
244 +
245 + if ( isset( $core_slugs[ $menu_item['slug'] ] ) ) {
246 + continue;
247 + }
248 +
249 + if ( isset( $menu_item['item_slug'] ) ) {
250 + if ( MainWP_Menu::is_disable_menu_item( 3, $menu_item['item_slug'] ) ) {
251 + continue;
252 + }
253 + } elseif ( MainWP_Menu::is_disable_menu_item( 3, $menu_item['slug'] ) ) {
254 + continue;
255 + }
256 +
257 + $active_slug = 0 === strpos( $menu_item['slug'], 'Settings' ) ? substr( $menu_item['slug'], strlen( 'Settings' ) ) : $menu_item['slug'];
258 + $item = array(
259 + 'slug' => $menu_item['slug'],
260 + 'title' => $menu_item['title'],
261 + 'href' => $menu_item['href'],
262 + 'active_keys' => array( $active_slug, $menu_item['slug'] ),
263 + 'menu_hidden' => false,
264 + );
265 +
266 + if ( ! empty( $menu_item['before_title'] ) ) {
267 + $item['before_title'] = $menu_item['before_title'];
268 + }
269 +
270 + if ( isset( $menu_item['item_slug'] ) ) {
271 + $item['item_slug'] = $menu_item['item_slug'];
272 + }
273 +
274 + $items[] = $item;
275 + }
276 +
277 + return $items;
278 + }
279 +
280 + /**
281 + * Get the Settings navigation items.
282 + *
283 + * @return array<int, array<string, mixed>> Settings navigation items.
284 + */
285 + public static function get_navigation_items( $context = 'default' ) {
286 + $core_items = array();
287 + $dynamic_items = array();
288 + $items = array();
289 +
290 + foreach ( static::get_core_pages() as $page ) {
291 + $core_items[ $page['slug'] ] = array(
292 + 'slug' => $page['slug'],
293 + 'title' => $page['nav_title'],
294 + 'href' => 'admin.php?page=' . $page['slug'],
295 + 'active_keys' => $page['active_keys'],
296 + 'menu_hidden' => false,
297 + );
298 + }
299 +
300 + if ( 'command_palette' === $context ) {
301 + $dynamic_items = static::get_filtered_subpage_navigation_items();
302 + } else {
303 + foreach ( static::get_subpages() as $subPage ) {
304 + if ( empty( $subPage['slug'] ) || MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) {
305 + continue;
306 + }
307 +
308 + $item = array(
309 + 'slug' => 'Settings' . $subPage['slug'],
310 + 'title' => $subPage['title'],
311 + 'href' => ! empty( $subPage['href'] ) ? $subPage['href'] : 'admin.php?page=Settings' . $subPage['slug'],
312 + 'active_keys' => array( $subPage['slug'], 'Settings' . $subPage['slug'] ),
313 + 'menu_hidden' => ! empty( $subPage['menu_hidden'] ),
314 + );
315 +
316 + if ( ! empty( $subPage['before_title'] ) ) {
317 + $item['before_title'] = $subPage['before_title'];
318 + }
319 +
320 + if ( isset( $subPage['class'] ) ) {
321 + $item['class'] = $subPage['class'];
322 + }
323 +
324 + if ( isset( $subPage['item_slug'] ) ) {
325 + $item['item_slug'] = $subPage['item_slug'];
326 + }
327 +
328 + $dynamic_items[] = $item;
329 + }
330 + }
331 +
332 + $base_order = array( 'Settings', 'SettingsAdvanced', 'MonitoringSettings', 'SettingsEmail', 'PremiumUpdates' );
333 +
334 + if ( in_array( $context, array( 'left_menu', 'left_menu_core' ), true ) ) {
335 + $base_order[] = 'MainWPTools';
336 + $base_order[] = 'CostTrackerSettings';
337 + } else {
338 + $base_order[] = 'CostTrackerSettings';
339 + }
340 +
341 + foreach ( $base_order as $slug ) {
342 + if ( isset( $core_items[ $slug ] ) ) {
343 + $items[] = $core_items[ $slug ];
344 + }
345 + }
346 +
347 + if ( 'left_menu_core' !== $context ) {
348 + $items = array_merge( $items, $dynamic_items );
349 + }
350 +
351 + if ( ! in_array( $context, array( 'left_menu', 'left_menu_core' ), true ) && isset( $core_items['MainWPTools'] ) ) {
352 + $items[] = $core_items['MainWPTools'];
353 + }
354 +
355 + return $items;
356 + }
357 +
358 + /**
359 + * Get the Settings command palette items.
360 + *
361 + * @return array<int, array<string, mixed>> Command palette item definitions.
362 + */
363 + public static function get_command_palette_items() {
364 + $items = array();
365 +
366 + foreach ( static::get_navigation_items( 'command_palette' ) as $item ) {
367 + if ( ! empty( $item['menu_hidden'] ) ) {
368 + continue;
369 + }
370 +
371 + $path_title = $item['title'];
372 + $path_titles = array( esc_html__( 'Settings', 'mainwp' ), $path_title );
373 +
374 + if ( ! empty( $item['before_title'] ) ) {
375 + $path_title = trim( wp_strip_all_tags( $item['before_title'] ) . ' ' . $item['title'] );
376 + $path_titles[1] = $path_title;
377 + }
378 +
379 + if ( 'Settings' === $item['slug'] ) {
380 + $path_titles[1] = esc_html__( 'General Settings', 'mainwp' );
381 + }
382 +
383 + $items[] = array(
384 + 'slug' => $item['slug'],
385 + 'href' => $item['href'],
386 + 'path_titles' => $path_titles,
387 + );
388 + }
389 +
390 + return $items;
391 + }
392 +
86 393 /** Run the export_sites method that exports the Child Sites .csv file */
87 394 public static function admin_init() { // phpcs:ignore -- NOSONAR - complex.
88 395 static::export_sites();
89 396 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
@@ -137,80 +444,26 @@
137 444 *
138 445 * @uses \MainWP\Dashboard\MainWP_Menu::is_disable_menu_item()
139 446 */
140 447 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' ) ) {
448 + foreach ( static::get_core_pages() as $page ) {
154 449 add_submenu_page(
155 450 'mainwp_tab',
156 - __( 'Tools', 'mainwp' ),
157 - ' <div class="mainwp-hidden">' . esc_html__( 'Tools', 'mainwp' ) . '</div>',
451 + $page['page_title'],
452 + $page['menu_title'],
158 453 'read',
159 - 'MainWPTools',
160 - array(
161 - static::get_class_name(),
162 - 'render_mainwp_tools',
163 - )
454 + $page['slug'],
455 + $page['callback']
164 456 );
165 457 }
166 458
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 - }
459 + foreach ( static::get_subpages() as $subPage ) {
460 + if ( empty( $subPage['slug'] ) || MainWP_Menu::is_disable_menu_item( 3, 'Settings' . $subPage['slug'] ) ) {
461 + continue;
462 + }
180 463
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 - );
464 + add_submenu_page( 'mainwp_tab', $subPage['title'], '<div class="mainwp-hidden">' . $subPage['title'] . '</div>', 'read', 'Settings' . $subPage['slug'], $subPage['callback'] );
193 465 }
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 466 }
214 467
215 468 /**
216 469 * Instantiate Settings SubPages Menu.
@@ -222,30 +475,11 @@
222 475 <div id="menu-mainwp-Settings" class="mainwp-submenu-wrapper">
223 476 <div class="wp-submenu sub-open" style="">
224 477 <div class="mainwp_boxout">
225 478 <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>
479 + <?php foreach ( static::get_navigation_items() as $item ) { ?>
480 + <a href="<?php echo esc_url( static::get_navigation_item_url( $item['href'] ) ); ?>" class="mainwp-submenu"><?php echo isset( $item['before_title'] ) ? $item['before_title'] . ' ' : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?><?php echo esc_html( $item['title'] ); ?></a>
229 481 <?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 482 </div>
249 483 </div>
250 484 </div>
251 485 <?php
@@ -273,42 +507,33 @@
273 507 ),
274 508 0
275 509 );
276 510
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 - );
511 + $init_sub_subleftmenu = array();
307 512
513 + foreach ( static::get_navigation_items( 'left_menu_core' ) as $item ) {
514 + $init_sub_subleftmenu[] = array(
515 + 'title' => $item['title'],
516 + 'parent_key' => 'Settings',
517 + 'href' => $item['href'],
518 + 'slug' => $item['slug'],
519 + 'right' => '',
520 + 'before_title' => isset( $item['before_title'] ) ? $item['before_title'] : '',
521 + );
522 + }
523 +
524 + if ( empty( $subPages ) ) {
525 + $subPages = static::get_subpages();
526 + }
527 +
308 528 MainWP_Menu::init_subpages_left_menu( $subPages, $init_sub_subleftmenu, 'Settings', 'Settings' );
529 +
309 530 foreach ( $init_sub_subleftmenu as $item ) {
310 - if ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
531 + if ( isset( $item['item_slug'] ) ) {
532 + if ( MainWP_Menu::is_disable_menu_item( 3, $item['item_slug'] ) ) {
533 + continue;
534 + }
535 + } elseif ( MainWP_Menu::is_disable_menu_item( 3, $item['slug'] ) ) {
311 536 continue;
312 537 }
313 538
314 539 MainWP_Menu::add_left_menu( $item, 2 );
@@ -333,59 +558,27 @@
333 558 MainWP_UI::render_top_header( $params );
334 559
335 560 $renderItems = array();
336 561
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,
562 + foreach ( static::get_navigation_items() as $item ) {
563 + $render_item = array(
564 + 'title' => $item['title'],
565 + 'href' => $item['href'],
566 + 'active' => in_array( $shownPage, $item['active_keys'], true ),
348 567 );
349 - }
350 568
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 - }
569 + if ( ! empty( $item['before_title'] ) ) {
570 + $render_item['before_title'] = $item['before_title'];
571 + }
358 572
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 - }
573 + if ( isset( $item['class'] ) ) {
574 + $render_item['class'] = $item['class'];
575 + }
366 576
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 - }
577 + $renderItems[] = $render_item;
385 578 }
386 579
387 - MainWP_UI::render_page_navigation( $renderItems );
580 + MainWP_UI::render_page_navigation( $renderItems, 'nav_mainwp_settings' );
388 581 }
389 582
390 583 /**
391 584 * Close the HTML container.
@@ -416,8 +609,10 @@
416 609
417 610 MainWP_DB_Common::instance()->update_user_extension( $userExtension );
418 611 if ( MainWP_System_Utility::is_admin() ) {
419 612
613 + $old_settings = self::get_all_settings_values();
614 +
420 615 /**
421 616 * Action: mainwp_before_save_general_settings
422 617 *
423 618 * Fires before general settings save.
@@ -429,8 +624,10 @@
429 624 $val = ( ! isset( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_pluginAutomaticDailyUpdate'] ) );
430 625 MainWP_Utility::update_option( 'mainwp_pluginAutomaticDailyUpdate', $val );
431 626 $val = ( ! isset( $_POST['mainwp_themeAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_themeAutomaticDailyUpdate'] ) );
432 627 MainWP_Utility::update_option( 'mainwp_themeAutomaticDailyUpdate', $val );
628 + $val = ( ! isset( $_POST['mainwp_transAutomaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_transAutomaticDailyUpdate'] ) );
629 + MainWP_Utility::update_option( 'mainwp_transAutomaticDailyUpdate', $val );
433 630 $val = ( ! isset( $_POST['mainwp_automaticDailyUpdate'] ) ? 0 : intval( $_POST['mainwp_automaticDailyUpdate'] ) );
434 631 MainWP_Utility::update_option( 'mainwp_automaticDailyUpdate', $val );
435 632 $val = ( ! isset( $_POST['mainwp_show_language_updates'] ) ? 0 : 1 );
436 633 MainWP_Utility::update_option( 'mainwp_show_language_updates', $val );
@@ -494,14 +691,9 @@
494 691 update_user_option( $user->ID, 'mainwp_sidebarPosition', $val, true );
495 692 }
496 693
497 694 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 695
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 696 $actions_notification_enable = ( isset( $_POST['mainwp_site_actions_notification_enable'] ) ? 1 : 0 );
505 697 MainWP_Utility::update_option( 'mainwp_site_actions_notification_enable', $actions_notification_enable );
506 698
507 699 //phpcs:disable WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
@@ -546,9 +738,8 @@
546 738 }
547 739 //phpcs:enable
548 740
549 741 MainWP_Utility::update_option( 'mainwp_use_favicon', 1 );
550 -
551 742 /**
552 743 * Action: mainwp_after_save_general_settings
553 744 *
554 745 * Fires after save general settings.
@@ -555,8 +746,23 @@
555 746 *
556 747 * @since 4.1
557 748 */
558 749 do_action( 'mainwp_after_save_general_settings', $_POST );
750 +
751 + $new_settings = self::get_all_settings_values();
752 +
753 + /**
754 + * Action: mainwp_after_save_settings
755 + *
756 + * Fires after save settings.
757 + *
758 + * @since 6.0
759 + *
760 + * @param array $new_settings The new settings.
761 + * @param array $old_settings The old settings.
762 + */
763 + do_action( 'mainwp_after_save_settings', $new_settings, $old_settings );
764 +
559 765 }
560 766
561 767 return true;
562 768 }
@@ -564,8 +770,92 @@
564 770 return false;
565 771 }
566 772
567 773 /**
774 + * Method get_all_settings_values().
775 + *
776 + * @param mixed $keys_only True if get Keys only.
777 + *
778 + * @return array All Settings Fields.
779 + */
780 + public static function get_all_settings_values( $keys_only = false ) {
781 + $keys = array(
782 + 'mainwp_hide_update_everything',
783 + 'mainwp_pluginAutomaticDailyUpdate',
784 + 'mainwp_themeAutomaticDailyUpdate',
785 + 'mainwp_transAutomaticDailyUpdate',
786 + 'mainwp_automaticDailyUpdate',
787 + 'mainwp_show_language_updates',
788 + 'mainwp_disable_update_confirmations',
789 + 'mainwp_backup_before_upgrade',
790 + 'mainwp_backup_before_upgrade_days',
791 + 'mainwp_maximumComments',
792 + 'mainwp_automatic_update_next_run_timestamp',
793 + 'mainwp_delay_autoupdate',
794 + 'mainwp_numberdays_Outdate_Plugin_Theme',
795 + 'mainwp_check_http_response',
796 + 'mainwp_check_http_response_method',
797 + 'mainwp_site_actions_notification_enable',
798 + 'mainwp_use_favicon',
799 + 'mainwp_backupsOnServer',
800 + 'mainwp_maximumFileDescriptors',
801 + 'mainwp_maximumFileDescriptorsAuto',
802 + 'mainwp_backupOnExternalSources',
803 + 'mainwp_archiveFormat',
804 + 'mainwp_notificationOnBackupFail',
805 + 'mainwp_notificationOnBackupStart',
806 + 'mainwp_chunkedBackupTasks',
807 + 'mainwp_primaryBackup',
808 + 'mainwp_enableLegacyBackupFeature',
809 + 'mainwp_global_uptime_monitoring_settings',
810 + 'mainwp_disableSitesHealthMonitoring',
811 + 'mainwp_sitehealthThreshold',
812 + 'mainwp_maximumRequests',
813 + 'mainwp_minimumDelay',
814 + 'mainwp_maximumIPRequests',
815 + 'mainwp_minimumIPDelay',
816 + 'mainwp_maximumSyncRequests',
817 + 'mainwp_maximumInstallUpdateRequests',
818 + 'mainwp_sslVerifyCertificate',
819 + 'mainwp_connect_signature_algo',
820 + 'mainwp_verify_connection_method',
821 + 'mainwp_forceUseIPv4',
822 + 'mainwp_wp_cron',
823 + 'mainwp_warm_cache_pages_ttl',
824 + 'mainwp_optimize',
825 + 'mainwp_maximum_uptime_monitoring_requests',
826 + 'mainwp_chunksitesnumber',
827 + 'mainwp_chunksleepinterval',
828 + 'mainwp_settings_sync_data',
829 + 'mainwp_module_log_settings',
830 + 'mainwp_module_log_settings_logs_selection_data',
831 + 'mainwp_uptimecheck_running',
832 + 'mainwp_uptimecheck_auto_main_counter_lasttime_started',
833 + 'mainwp_enable_guided_tours',
834 + 'mainwp_enable_guided_chatbase',
835 + 'mainwp_enable_guided_video',
836 + 'mainwp_enable_cloudways_api',
837 + 'mainwp_enable_gridpane_api',
838 + 'mainwp_enable_vultr_api',
839 + 'mainwp_enable_linode_api',
840 + 'mainwp_enable_digitalocean_api',
841 + 'mainwp_enable_cpanel_api',
842 + 'mainwp_enable_plesk_api',
843 + 'mainwp_enable_kinsta_api',
844 + );
845 +
846 + if ( $keys_only ) {
847 + return $keys;
848 + }
849 +
850 + $values = array();
851 + foreach ( $keys as $key ) {
852 + $values[ $key ] = get_option( $key );
853 + }
854 + return $values;
855 + }
856 +
857 + /**
568 858 * Render the MainWP Settings Page.
569 859 *
570 860 * @uses \MainWP\Dashboard\MainWP_Monitoring_View
571 861 * @uses \MainWP\Dashboard\MainWP_Manage_Backups::render_settings()
@@ -571,329 +861,303 @@
571 861 * @uses \MainWP\Dashboard\MainWP_Manage_Backups::render_settings()
572 862 * @uses \MainWP\Dashboard\MainWP_Utility::get_http_codes()
573 863 */
574 864 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' ) );
865 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) {
866 + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
577 867 return;
578 868 }
579 869
580 870 static::render_header( '' );
581 871 ?>
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>
872 + <div id="mainwp-general-settings" class="ui padded segment">
873 +
874 + <?php if ( isset( $_GET['message'] ) && 'saved' === $_GET['message'] ) : // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized ?>
875 + <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
588 876 <?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' ) ); ?>" />
877 + <div class="ui form">
878 + <form method="POST" action="admin.php?page=Settings" id="mainwp-settings-page-form">
879 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
880 + <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'Settings' ) ); ?>" />
881 + <?php
882 + /**
883 + * Action: mainwp_settings_form_top
884 + *
885 + * Fires at the top of settings form.
886 + *
887 + * @since 4.1
888 + */
889 + do_action( 'mainwp_settings_form_top' );
890 + ?>
891 + <h3 class="ui dividing header">
892 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-general' ); ?>
893 + <?php esc_html_e( 'General Settings', 'mainwp' ); ?></h3>
894 + <?php
895 + $timeDailyUpdate = get_option( 'mainwp_timeDailyUpdate' );
896 + $frequencyDailyUpdate = (int) get_option( 'mainwp_frequencyDailyUpdate', 2 );
897 + $run_timestamp = MainWP_System_Cron_Jobs::get_timestamp_from_hh_mm( $timeDailyUpdate );
898 + $delay_autoupdate = (int) get_option( 'mainwp_delay_autoupdate', 1 );
899 +
900 + ?>
901 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general">
902 + <label class="six wide column middle aligned">
596 903 <?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' );
904 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_timeDailyUpdate', $timeDailyUpdate );
905 + esc_html_e( 'Daily sync time', 'mainwp' );
605 906 ?>
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>
907 + </label>
908 + <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">
909 + <div class="time-selector">
910 + <div class="ui input left icon">
911 + <i class="clock icon"></i>
912 + <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 ); ?>" />
629 913 </div>
630 914 </div>
631 915 </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>
916 + </div>
917 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="2">
918 + <label class="six wide column middle aligned">
919 + <?php
920 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_frequencyDailyUpdate', $frequencyDailyUpdate );
921 + esc_html_e( 'Frequency of auto sync', 'mainwp' );
922 + ?>
923 + </label>
924 + <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" >
925 + <select name="mainwp_frequencyDailyUpdate" id="mainwp_frequencyDailyUpdate" class="ui dropdown settings-field-value-change-handler">
926 + <option value="1" <?php echo 1 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Once per day', 'mainwp' ); ?></option>
927 + <option value="2" <?php echo 2 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Twice per day', 'mainwp' ); ?></option>
928 + <option value="3" <?php echo 3 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Three times per day', 'mainwp' ); ?></option>
929 + <option value="4" <?php echo 4 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Four times per day', 'mainwp' ); ?></option>
930 + <option value="5" <?php echo 5 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Five times per day', 'mainwp' ); ?></option>
931 + <option value="6" <?php echo 6 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Six times per day', 'mainwp' ); ?></option>
932 + <option value="7" <?php echo 7 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Seven times per day', 'mainwp' ); ?></option>
933 + <option value="8" <?php echo 8 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Eight times per day', 'mainwp' ); ?></option>
934 + <option value="9" <?php echo 9 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Nine times per day', 'mainwp' ); ?></option>
935 + <option value="10" <?php echo 10 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Ten times per day', 'mainwp' ); ?></option>
936 + <option value="11" <?php echo 11 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Eleven times per day', 'mainwp' ); ?></option>
937 + <option value="12" <?php echo 12 === $frequencyDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Twelve times per day', 'mainwp' ); ?></option>
938 + </select>
655 939 </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 - } );
940 + </div>
941 + <script type="text/javascript">
942 + jQuery( document ).ready( function() {
943 + jQuery( '.time-selector' ).calendar( {
944 + type: 'time',
945 + ampm: false,
946 + formatter: {
947 + time: 'H:mm',
948 + cellTime: 'H:mm'
949 + }
666 950 } );
667 - </script>
951 + } );
952 + </script>
668 953
669 - <?php
954 + <?php
670 955
671 - static::render_timezone_settings();
672 - static::render_datetime_settings();
956 + static::render_timezone_settings();
957 + static::render_datetime_settings();
673 958
674 - $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
675 - if ( false === $sidebarPosition ) {
676 - $sidebarPosition = 1;
677 - }
959 + $sidebarPosition = get_user_option( 'mainwp_sidebarPosition' );
960 + if ( false === $sidebarPosition ) {
961 + $sidebarPosition = 1;
962 + }
678 963
964 + ?>
965 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general" default-indi-value="1">
966 + <label class="six wide column middle aligned">
967 + <?php
968 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sidebarPosition', (int) $sidebarPosition );
969 + esc_html_e( 'Sidebar position', 'mainwp' );
679 970 ?>
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>
971 + </label>
972 + <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">
973 + <select name="mainwp_sidebarPosition" id="mainwp_sidebarPosition" class="ui dropdown settings-field-value-change-handler">
974 + <option value="1" <?php echo 1 === (int) $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Right (default)', 'mainwp' ); ?></option>
975 + <option value="0" <?php echo 0 === (int) $sidebarPosition ? 'selected' : ''; ?>><?php esc_html_e( 'Left', 'mainwp' ); ?></option>
976 + </select>
693 977 </div>
694 - <?php MainWP_UI::render_screen_options(); ?>
978 + </div>
979 + <?php MainWP_UI::render_screen_options(); ?>
695 980
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>
981 + <h3 class="ui dividing header">
982 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-updates' ); ?>
983 + <?php esc_html_e( 'Updates Settings', 'mainwp' ); ?></h3>
984 + <?php
985 + $snAutomaticDailyUpdate = (int) get_option( 'mainwp_automaticDailyUpdate', 0 );
986 + $snPluginAutomaticDailyUpdate = (int) get_option( 'mainwp_pluginAutomaticDailyUpdate', 0 );
987 + $snThemeAutomaticDailyUpdate = (int) get_option( 'mainwp_themeAutomaticDailyUpdate', 0 );
988 + $snTransAutomaticUpdate = (int) get_option( 'mainwp_transAutomaticDailyUpdate', 0 );
989 +
990 + $backup_before_upgrade = get_option( 'mainwp_backup_before_upgrade' );
991 + $mainwp_backup_before_upgrade_days = get_option( 'mainwp_backup_before_upgrade_days' );
992 + if ( empty( $mainwp_backup_before_upgrade_days ) || ! ctype_digit( $mainwp_backup_before_upgrade_days ) ) {
993 + $mainwp_backup_before_upgrade_days = 7;
994 + }
995 + $mainwp_show_language_updates = get_option( 'mainwp_show_language_updates', 1 );
996 + $enableLegacyBackupFeature = get_option( 'mainwp_enableLegacyBackupFeature' );
997 + $primaryBackup = get_option( 'mainwp_primaryBackup' );
998 + $disableUpdateConfirmations = (int) get_option( 'mainwp_disable_update_confirmations', 0 );
999 + ?>
1000 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
1001 + <label class="six wide column middle aligned">
699 1002 <?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();
1003 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_pluginAutomaticDailyUpdate', $snPluginAutomaticDailyUpdate );
1004 + esc_html_e( 'Plugin advanced automatic updates', 'mainwp' );
714 1005 ?>
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>
1006 + </label>
1007 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic plugin updates. If enabled, MainWP will update only plugins that you have marked as Trusted.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1008 + <select name="mainwp_pluginAutomaticDailyUpdate" id="mainwp_pluginAutomaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
1009 + <option value="1" <?php echo 1 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
1010 + <option value="0" <?php echo 0 === $snPluginAutomaticDailyUpdate || 2 === $snPluginAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
1011 + </select>
728 1012 </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>
1013 + </div>
1014 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
1015 + <label class="six wide column middle aligned">
1016 + <?php
1017 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_themeAutomaticDailyUpdate', $snThemeAutomaticDailyUpdate );
1018 + esc_html_e( 'Theme advanced automatic updates', 'mainwp' );
1019 + ?>
1020 + </label>
1021 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic theme updates. If enabled, MainWP will update only themes that you have marked as Trusted.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1022 + <select name="mainwp_themeAutomaticDailyUpdate" id="mainwp_themeAutomaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
1023 + <option value="1" <?php echo 1 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
1024 + <option value="0" <?php echo 0 === $snThemeAutomaticDailyUpdate || 2 === $snThemeAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
1025 + </select>
742 1026 </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>
1027 + </div>
1028 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
1029 + <label class="six wide column middle aligned">
1030 + <?php
1031 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_stransAutomaticUpdate', $snTransAutomaticUpdate );
1032 + esc_html_e( 'Translation advanced automatic updates', 'mainwp' );
1033 + ?>
1034 + </label>
1035 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Enable or disable automatic Translation updates.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1036 + <select name="mainwp_transAutomaticDailyUpdate" id="mainwp_transAutomaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
1037 + <option value="1" <?php echo 1 === $snTransAutomaticUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
1038 + <option value="0" <?php echo 0 === $snTransAutomaticUpdate || 2 === (int) $snTransAutomaticUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
1039 + </select>
756 1040 </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>
1041 + </div>
1042 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
1043 + <label class="six wide column middle aligned">
1044 + <?php
1045 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_automaticDailyUpdate', $snAutomaticDailyUpdate );
1046 + esc_html_e( 'WP Core advanced automatic updates', 'mainwp' );
1047 + ?>
1048 + </label>
1049 + <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">
1050 + <select name="mainwp_automaticDailyUpdate" id="mainwp_automaticDailyUpdate" class="ui dropdown settings-field-value-change-handler">
1051 + <option value="1" <?php echo 1 === $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Install Trusted Updates', 'mainwp' ); ?></option>
1052 + <option value="0" <?php echo 0 === $snAutomaticDailyUpdate || 2 === (int) $snAutomaticDailyUpdate ? 'selected' : ''; ?>><?php esc_html_e( 'Disabled', 'mainwp' ); ?></option>
1053 + </select>
779 1054 </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>
1055 + </div>
1056 + <?php static::render_auto_updates_settings(); ?>
1057 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="1">
1058 + <label class="six wide column middle aligned">
1059 + <?php
1060 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_delay_autoupdate', $delay_autoupdate );
1061 + esc_html_e( 'Advanced automatic updates delay', 'mainwp' );
1062 + ?>
1063 + </label>
1064 + <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">
1065 + <select name="mainwp_delay_autoupdate" id="mainwp_delay_autoupdate" class="ui dropdown settings-field-value-change-handler">
1066 + <option value="0" <?php echo 0 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( 'Delay off', 'mainwp' ); ?></option>
1067 + <option value="1" <?php echo 1 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '1 day', 'mainwp' ); ?></option>
1068 + <option value="2" <?php echo 2 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '2 days', 'mainwp' ); ?></option>
1069 + <option value="3" <?php echo 3 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '3 days', 'mainwp' ); ?></option>
1070 + <option value="4" <?php echo 4 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '4 days', 'mainwp' ); ?></option>
1071 + <option value="5" <?php echo 5 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '5 days', 'mainwp' ); ?></option>
1072 + <option value="6" <?php echo 6 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '6 days', 'mainwp' ); ?></option>
1073 + <option value="7" <?php echo 7 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '7 days', 'mainwp' ); ?></option>
1074 + <option value="14" <?php echo 14 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '14 days', 'mainwp' ); ?></option>
1075 + <option value="30" <?php echo 30 === $delay_autoupdate ? 'selected' : ''; ?>><?php esc_html_e( '30 days', 'mainwp' ); ?></option>
1076 + </select>
790 1077 </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>
1078 + </div>
1079 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="1">
1080 + <label class="six wide column middle aligned">
1081 + <?php
1082 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_show_language_updates', $mainwp_show_language_updates );
1083 + esc_html_e( 'Show WordPress language updates', 'mainwp' );
1084 + ?>
1085 + </label>
1086 + <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">
1087 + <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"' : ''; ?>/>
805 1088 </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>
1089 + </div>
1090 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates">
1091 + <label class="six wide column middle aligned">
1092 + <?php
1093 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disable_update_confirmations', $disableUpdateConfirmations );
1094 + esc_html_e( 'Update confirmations', 'mainwp' );
1095 + ?>
1096 + </label>
1097 + <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">
1098 + <select name="mainwp_disable_update_confirmations" id="mainwp_disable_update_confirmations" class="ui dropdown settings-field-value-change-handler">
1099 + <option value="0" <?php echo 0 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Enable', 'mainwp' ); ?></option>
1100 + <option value="2" <?php echo 2 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable', 'mainwp' ); ?></option>
1101 + <option value="1" <?php echo 1 === $disableUpdateConfirmations ? 'selected' : ''; ?>><?php esc_html_e( 'Disable for single updates', 'mainwp' ); ?></option>
1102 + </select>
816 1103 </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>
1104 + </div>
1105 + <?php if ( ( $enableLegacyBackupFeature && empty( $primaryBackup ) ) || ( empty( $enableLegacyBackupFeature ) && ! empty( $primaryBackup ) ) ) { ?>
1106 + <div class="ui grid field mainwp-parent-toggle settings-field-indicator-wrapper settings-field-indicator-updates">
1107 + <label class="six wide column middle aligned">
1108 + <?php
1109 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backup_before_upgrade', (int) $backup_before_upgrade );
1110 + esc_html_e( 'Require a backup before an update', 'mainwp' );
1111 + ?>
1112 + </label>
1113 + <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">
1114 + <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"' : ''; ?>/>
840 1115 </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>
1116 + </div>
1117 + <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"'; ?> >
1118 + <label class="six wide column middle aligned">
1119 + <?php
1120 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_backup_before_upgrade_days', (int) $mainwp_backup_before_upgrade_days );
1121 + esc_html_e( 'Days without of a full backup tolerance', 'mainwp' );
1122 + ?>
1123 + </label>
1124 + <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">
1125 + <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 ); ?>" />
852 1126 </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 } ?>
1127 + </div>
1128 + <?php } ?>
865 1129
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 ) );
1130 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-updates" default-indi-value="365">
1131 + <label class="six wide column middle aligned">
1132 + <?php
1133 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_numberdays_Outdate_Plugin_Theme', (int) get_option( 'mainwp_numberdays_Outdate_Plugin_Theme', 365 ) );
870 1134
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>
1135 + esc_html_e( 'Abandoned plugins/themes tolerance', 'mainwp' );
1136 + ?>
1137 + </label>
1138 + <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">
1139 + <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' ) ); ?>"/>
877 1140 </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>
1141 + </div>
1142 +
1143 + <?php MainWP_Manage_Backups::render_settings(); ?>
1144 + <?php
1145 + /**
1146 + * Action: mainwp_settings_form_bottom
1147 + *
1148 + * Fires at the bottom of settings form.
1149 + *
1150 + * @since 4.1
1151 + */
1152 + do_action( 'mainwp_settings_form_bottom' );
1153 + ?>
1154 + <div class="ui divider"></div>
1155 + <input type="submit" name="submit" id="submit" class="ui button green big" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1156 + <div style="clear:both"></div>
1157 + </form>
895 1158 </div>
1159 + </div>
896 1160 <?php
897 1161 static::render_footer( '' );
898 1162 }
899 1163
@@ -1019,10 +1283,12 @@
1019 1283 * Render Timezone settings.
1020 1284 */
1021 1285 public static function render_timezone_settings() { // phpcs:ignore -- NOSONAR - complex.
1022 1286
1023 - $current_offset = get_option( 'gmt_offset' );
1024 - $tzstring = get_option( 'timezone_string' );
1287 + $current_offset = get_option( 'gmt_offset' );
1288 + $tzstring = get_option( 'timezone_string' );
1289 + $tzstring = MainWP_Utility::clean_wp_timezone_string( $tzstring );
1290 +
1025 1291 $check_zone_info = true;
1026 1292
1027 1293 // Remove old Etc mappings. Fallback to gmt_offset.
1028 1294 if ( false !== strpos( $tzstring, 'Etc/GMT' ) ) {
@@ -1039,23 +1305,33 @@
1039 1305 $tzstring = 'UTC+' . $current_offset;
1040 1306 }
1041 1307 }
1042 1308
1043 - $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format' );
1309 + $timezone_format = _x( 'Y-m-d H:i:s', 'timezone date format', 'mainwp' );
1044 1310
1045 1311 ?>
1046 1312 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-general">
1047 1313 <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">
1314 + <?php
1315 + // translators: %s is the abbreviation "UTC".
1316 + $timezone_tooltip = esc_attr__( 'Choose either a city in the same timezone as you or a %s (Coordinated Universal Time) time offset.', 'mainwp' );
1317 + ?>
1318 + <div class="ten wide column" data-tooltip="<?php echo $timezone_tooltip; // phpcs:ignore WordPress.Security.EscapeOutput ?>" data-inverted="" data-position="top left">
1049 1319 <select id="timezone_string" class="ui dropdown" name="timezone_string" aria-describedby="timezone-description">
1050 1320 <?php echo wp_timezone_choice( $tzstring, get_user_locale() ); // phpcs:ignore WordPress.Security.EscapeOutput ?>
1051 1321 </select>
1052 1322 <div class="ui hidden fitted divider"></div>
1053 1323 <div class="ui secondary segment">
1054 - <?php printf( esc_html__( 'Universal time is %s.' ), '<code>' . esc_html( date_i18n( $timezone_format, false, true ) ) . '</code>' ); ?>
1324 + <?php
1325 + // translators: %s is the current UTC date and time.
1326 + printf( esc_html__( 'Universal time is %s.', 'mainwp' ), '<code>' . esc_html( date_i18n( $timezone_format, false, true ) ) . '</code>' );
1327 + ?>
1055 1328 <div class="ui hidden fitted divider"></div>
1056 1329 <?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>' ); ?>
1330 + <?php
1331 + // translators: %s is the current local date and time.
1332 + printf( esc_html__( 'Local time is %s.', 'mainwp' ), '<code>' . esc_html( date_i18n( $timezone_format ) ) . '</code>' );
1333 + ?>
1058 1334 <div class="ui hidden fitted divider"></div>
1059 1335 <?php endif; ?>
1060 1336 <?php if ( $check_zone_info && $tzstring ) : ?>
1061 1337 <?php
@@ -1074,10 +1350,11 @@
1074 1350 $transitions = timezone_transitions_get( timezone_open( $tzstring ), time() );
1075 1351
1076 1352 if ( ! empty( $transitions[1] ) ) {
1077 1353 echo ' ';
1354 + // translators: %s is the date and time when the timezone transition occurs.
1078 1355 $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
1356 + printf( $message, '<code>' . wp_date( esc_html__( 'F j, Y', 'mainwp' ) . ' ' . esc_html__( 'g:i a', 'mainwp' ), esc_html( $transitions[1]['ts'] ) ) . '</code>' ); // phpcs:ignore WordPress.Security.EscapeOutput
1080 1357 } else {
1081 1358 esc_html_e( 'This timezone does not observe daylight saving time.', 'mainwp' );
1082 1359 }
1083 1360 }
@@ -1110,9 +1387,9 @@
1110 1387 * @since 4.0.0 Added ISO date standard YYYY-MM-DD format.
1111 1388 *
1112 1389 * @param string[] $default_date_formats Array of default date formats.
1113 1390 */
1114 - $date_formats = array_unique( apply_filters( 'date_formats', array( esc_html__( 'F j, Y' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
1391 + $date_formats = array_unique( apply_filters( 'date_formats', array( esc_html__( 'F j, Y', 'mainwp' ), 'Y-m-d', 'm/d/Y', 'd/m/Y' ) ) );
1115 1392
1116 1393 $custom = true;
1117 1394
1118 1395 foreach ( $date_formats as $format ) {
@@ -1124,13 +1401,13 @@
1124 1401 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
1125 1402 }
1126 1403 echo '<label><input type="radio" name="date_format" id="date_format_custom_radio" value="\c\u\s\t\o\m"';
1127 1404 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>' .
1405 + echo '/> <span class="date-time-text date-time-custom-text">' . esc_html__( 'Custom:', 'mainwp' ) . '<span class="screen-reader-text"> ' . esc_html__( 'enter a custom date format in the following field', 'mainwp' ) . '</span></span></label>' .
1406 + '<label for="date_format_custom" class="screen-reader-text">' . esc_html__( 'Custom date format:', 'mainwp' ) . '</label>' .
1130 1407 '<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 1408 '<br />' .
1132 - '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'date_format' ) ) ) . '</span>' .
1409 + '<em><strong>' . esc_html__( 'Preview:', 'mainwp' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'date_format' ) ) ) . '</span>' .
1133 1410 "<span class='spinner'></span>\n" . '</em>';
1134 1411 ?>
1135 1412 </div>
1136 1413 </div>
@@ -1150,9 +1427,9 @@
1150 1427 * @since 2.7.0
1151 1428 *
1152 1429 * @param string[] $default_time_formats Array of default time formats.
1153 1430 */
1154 - $time_formats = array_unique( apply_filters( 'time_formats', array( esc_html__( 'g:i a' ), 'g:i A', 'H:i' ) ) );
1431 + $time_formats = array_unique( apply_filters( 'time_formats', array( esc_html__( 'g:i a', 'mainwp' ), 'g:i A', 'H:i' ) ) );
1155 1432
1156 1433 $custom = true;
1157 1434
1158 1435 foreach ( $time_formats as $format ) {
@@ -1164,13 +1441,13 @@
1164 1441 echo ' /> <span class="date-time-text format-i18n">' . esc_html( date_i18n( $format ) ) . '</span><code>' . esc_html( $format ) . "</code></label><br />\n";
1165 1442 }
1166 1443 echo '<label><input type="radio" name="time_format" id="time_format_custom_radio" value="\c\u\s\t\o\m"';
1167 1444 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>' .
1445 + echo '/> <span class="date-time-text date-time-custom-text">' . esc_html__( 'Custom:', 'mainwp' ) . '<span class="screen-reader-text"> ' . esc_html__( 'enter a custom time format in the following field', 'mainwp' ) . '</span></span></label>' .
1446 + '<label for="time_format_custom" class="screen-reader-text">' . esc_html__( 'Custom time format:', 'mainwp' ) . '</label>' .
1170 1447 '<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 1448 '<br />' .
1172 - '<em><strong>' . esc_html__( 'Preview:' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'time_format' ) ) ) . '</span>' .
1449 + '<em><strong>' . esc_html__( 'Preview:', 'mainwp' ) . '</strong> <span class="example">' . esc_html( date_i18n( get_option( 'time_format' ) ) ) . '</span>' .
1173 1450 "<span class='spinner'></span>\n" . '</em>';
1174 1451 ?>
1175 1452 </div>
1176 1453 </div>
@@ -1236,9 +1513,8 @@
1236 1513 $lastAutomaticUpdate = MainWP_Auto_Updates_DB::instance()->get_websites_last_automatic_sync();
1237 1514 $lasttimeAutomatic = get_option( 'mainwp_updatescheck_last_timestamp' );
1238 1515 $lasttimeStartAutomatic = get_option( 'mainwp_updatescheck_start_last_timestamp' );
1239 1516 $local_timestamp = MainWP_Utility::get_timestamp();
1240 - $running = get_option( 'mainwp_cron_checksites_running' );
1241 1517
1242 1518 if ( empty( $lasttimeStartAutomatic ) && ! empty( $lasttimeAutomatic ) ) {
1243 1519 $lasttimeStartAutomatic = $lasttimeAutomatic;
1244 1520 }
@@ -1244,9 +1520,9 @@
1244 1520 }
1245 1521
1246 1522 if ( empty( $lastAutomaticUpdate ) ) {
1247 1523 $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 ) ) ) {
1524 + } elseif ( 0 < MainWP_Auto_Updates_DB::instance()->get_websites_check_updates_count( $lasttimeStartAutomatic ) ) {
1249 1525 $nextAutomaticUpdate = esc_html__( 'Processing your websites.', 'mainwp' );
1250 1526 } else {
1251 1527 $next_time = MainWP_System_Cron_Jobs::get_next_time_automatic_update_to_show();
1252 1528 if ( $next_time < $local_timestamp + 5 * MINUTE_IN_SECONDS ) {
@@ -1284,15 +1560,17 @@
1284 1560 *
1285 1561 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
1286 1562 */
1287 1563 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' ) );
1564 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) {
1565 + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1290 1566 return;
1291 1567 }
1292 1568
1293 1569 if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'SettingsAdvanced' ) ) {
1294 1570
1571 + $old_settings = static::get_all_settings_values();
1572 +
1295 1573 /**
1296 1574 * Action: mainwp_before_save_advanced_settings
1297 1575 *
1298 1576 * Fires before save advanced settings.
@@ -1310,16 +1588,45 @@
1310 1588 MainWP_Utility::update_option( 'mainwp_sslVerifyCertificate', isset( $_POST['mainwp_sslVerifyCertificate'] ) ? 1 : 0 );
1311 1589 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 1590 MainWP_Utility::update_option( 'mainwp_verify_connection_method', isset( $_POST['mainwp_settings_verify_connection_method'] ) ? intval( $_POST['mainwp_settings_verify_connection_method'] ) : 0 );
1313 1591 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 ) );
1592 + $use_wpcron = ! isset( $_POST['mainwp_options_wp_cron'] ) ? 0 : 1;
1593 + MainWP_Utility::update_option( 'mainwp_wp_cron', $use_wpcron );
1594 + MainWP_Utility::update_option( 'mainwp_warm_cache_pages_ttl', intval( $_POST['mainwp_warm_cache_pages_ttl'] ) );
1595 +
1315 1596 MainWP_Utility::update_option( 'mainwp_optimize', ( ! isset( $_POST['mainwp_optimize'] ) ? 0 : 1 ) );
1597 + MainWP_Utility::update_option( 'mainwp_auto_correct_site_url', ( ! isset( $_POST['mainwp_auto_correct_site_url'] ) ? 0 : 1 ) );
1598 + MainWP_Utility::update_option( 'mainwp_maximum_uptime_monitoring_requests', ! empty( $_POST['mainwp_maximumUptimeMonitoringRequests'] ) ? intval( $_POST['mainwp_maximumUptimeMonitoringRequests'] ) : 10 );
1599 + MainWP_Utility::update_option( 'mainwp_chunksitesnumber', isset( $_POST['mainwp_chunksitesnumber'] ) ? intval( $_POST['mainwp_chunksitesnumber'] ) : 10 );
1600 + MainWP_Utility::update_option( 'mainwp_chunksleepinterval', isset( $_POST['mainwp_chunksleepinterval'] ) ? intval( $_POST['mainwp_chunksleepinterval'] ) : 5 );
1316 1601
1602 + $sync_data = array();
1603 +
1604 + if ( isset( $_POST['mainwp_settings_sync_data'] ) && is_array( $_POST['mainwp_settings_sync_data'] ) ) {
1605 + $selected_data = array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_settings_sync_data'] ) );
1606 + foreach ( $selected_data as $name ) {
1607 + $sync_data[ $name ] = 1;
1608 + }
1609 + }
1610 +
1611 + if ( isset( $_POST['mainwp_settings_sync_name'] ) && is_array( $_POST['mainwp_settings_sync_name'] ) ) {
1612 + $name_data = array_map( 'sanitize_text_field', wp_unslash( $_POST['mainwp_settings_sync_name'] ) );
1613 + foreach ( $name_data as $name ) {
1614 + if ( ! isset( $sync_data[ $name ] ) ) {
1615 + $sync_data[ $name ] = 0;
1616 + }
1617 + }
1618 + }
1619 +
1620 + MainWP_Utility::update_option( 'mainwp_settings_sync_data', wp_json_encode( $sync_data ) );
1621 +
1622 + // required check.
1623 + MainWP_Uptime_Monitoring_Schedule::instance()->check_to_disable_schedule_individual_uptime_monitoring(); // required a check to sync the settings.
1624 +
1317 1625 if ( isset( $_POST['mainwp_openssl_lib_location'] ) ) {
1318 1626 $openssl_loc = ! empty( $_POST['mainwp_openssl_lib_location'] ) ? sanitize_text_field( wp_unslash( $_POST['mainwp_openssl_lib_location'] ) ) : '';
1319 1627 MainWP_Utility::update_option( 'mainwp_opensslLibLocation', $openssl_loc );
1320 1628 }
1321 -
1322 1629 /**
1323 1630 * Action: mainwp_after_save_advanced_settings
1324 1631 *
1325 1632 * Fires after advanced settings save.
@@ -1326,13 +1633,28 @@
1326 1633 *
1327 1634 * @since 4.1
1328 1635 */
1329 1636 do_action( 'mainwp_after_save_advanced_settings', $_POST );
1637 +
1638 + $new_settings = self::get_all_settings_values();
1639 +
1640 + /**
1641 + * Action: mainwp_after_save_settings
1642 + *
1643 + * Fires after save settings.
1644 + *
1645 + * @since 6.0
1646 + *
1647 + * @param array $new_settings The new settings.
1648 + * @param array $old_settings The old settings.
1649 + */
1650 + do_action( 'mainwp_after_save_settings', $new_settings, $old_settings );
1651 +
1330 1652 }
1331 1653 static::render_header( 'Advanced' );
1332 1654 ?>
1333 1655
1334 - <div id="mainwp-advanced-settings" class="ui segment">
1656 + <div id="mainwp-advanced-settings" class="ui padded segment">
1335 1657 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-advanced-settings-info-notice' ) ) : ?>
1336 1658 <div class="ui info message">
1337 1659 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-advanced-settings-info-notice"></i>
1338 1660 <?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' ); ?>
@@ -1342,9 +1664,9 @@
1342 1664 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?></div>
1343 1665 <?php endif; ?>
1344 1666 <div class="ui form">
1345 1667 <form method="POST" action="">
1346 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
1668 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
1347 1669 <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'SettingsAdvanced' ) ); ?>" />
1348 1670 <?php
1349 1671
1350 1672 /**
@@ -1366,27 +1688,37 @@
1366 1688 <div class="ui grid field">
1367 1689 <label class="six wide column middle aligned"><?php esc_html_e( 'OpenSSL.cnf location', 'mainwp' ); ?></label>
1368 1690 <div class="ten wide column ui field">
1369 1691 <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>
1692 + <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' ); ?>
1693 + <?php
1694 + // translators: 1: Opening anchor tag. 2: Closing anchor tag.
1695 + 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://docs.mainwp.com/troubleshooting/potential-issues#openssl-library-error-invalid-request" target="_blank">', '</a> <i class="external alternate icon"></i>' );
1696 + ?>
1697 + </em>
1371 1698 <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 1699 </div>
1373 1700 </div>
1374 - <?php } ?>
1701 + <?php } ?>
1375 1702
1376 1703 <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>
1704 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-cross-ip' ); ?>
1705 + <?php esc_html_e( 'Rate Limiting & Concurrency Controls', 'mainwp' ); ?>
1706 + <div class="sub header"><?php esc_html_e( 'Fine-tune how your system handles outgoing requests by managing both global and per-server concurrency limits.', 'mainwp' ); ?></div>
1707 + </h3>
1379 1708
1380 1709 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="4">
1381 1710 <label class="six wide column middle aligned">
1382 1711 <?php
1383 1712 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' );
1713 + esc_html_e( 'Global request limit (Default: 4)', 'mainwp' );
1385 1714 ?>
1386 1715 </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' ) ); ?>"/>
1716 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Defines the overall maximum number of simultaneous requests that can be active. Adjust this setting to balance system throughput with resource constraints (default is 4).', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1717 + <div class="ui bottom aligned labeled slider" id="mainwp_maximumRequests_slider"></div>
1718 + <div class="ui input">
1719 + <input type="hidden" 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' ) ); ?>"/>
1720 + </div>
1389 1721 </div>
1390 1722 </div>
1391 1723
1392 1724 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="200">
@@ -1392,29 +1724,31 @@
1392 1724 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="200">
1393 1725 <label class="six wide column middle aligned">
1394 1726 <?php
1395 1727 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' );
1728 + esc_html_e( 'Minimum delay between requests in milliseconds (Default: 200ms)', 'mainwp' );
1397 1729 ?>
1398 1730 </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' ) ); ?>"/>
1731 + <div class="ten wide column" 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">
1732 + <div class="ui bottom aligned labeled slider" id="mainwp_minimumDelay_slider"></div>
1733 + <div class="ui input">
1734 + <input type="hidden" 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' ) ); ?>"/>
1735 + </div>
1401 1736 </div>
1402 1737 </div>
1403 1738
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 1739 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-per-ip" default-indi-value="1">
1409 1740 <label class="six wide column middle aligned">
1410 1741 <?php
1411 1742 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' );
1743 + esc_html_e( 'Per-IP request limit (Default: 1)', 'mainwp' );
1413 1744 ?>
1414 1745 </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' ) ); ?>"/>
1746 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Sets the maximum number of concurrent requests allowed for any individual website\'s IP address. This setting safeguards target servers from excessive load (default is 1).', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1747 + <div class="ui bottom aligned labeled slider" id="mainwp_maximumIPRequests_slider"></div>
1748 + <div class="ui input">
1749 + <input type="hidden" 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' ) ); ?>"/>
1750 + </div>
1417 1751 </div>
1418 1752 </div>
1419 1753
1420 1754 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-per-ip" default-indi-value="1000">
@@ -1420,20 +1754,61 @@
1420 1754 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-per-ip" default-indi-value="1000">
1421 1755 <label class="six wide column middle aligned">
1422 1756 <?php
1423 1757 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' );
1758 + esc_html_e( 'Minimum delay between requests to the same IP in milliseconds (Default: 1000ms)', 'mainwp' );
1425 1759 ?>
1426 1760 </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' ) ); ?>"/>
1761 + <div class="ten wide column" 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">
1762 + <div class="ui bottom aligned labeled slider" id="mainwp_minimumIPDelay_slider"></div>
1763 + <div class="ui input">
1764 + <input type="hidden" 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' ) ); ?>"/>
1765 + </div>
1429 1766 </div>
1430 1767 </div>
1431 1768
1432 1769 <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>
1770 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-chunk-site' ); ?>
1771 + <?php esc_html_e( 'Batch Processing Settings', 'mainwp' ); ?>
1772 + <div class="sub header"><?php esc_html_e( 'Configure how many websites are processed at once and the delay between each batch to optimize system performance and prevent server overload.', 'mainwp' ); ?></div>
1773 + </h3>
1435 1774
1775 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="10">
1776 + <label class="six wide column middle aligned">
1777 + <?php
1778 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', 10 === (int) get_option( 'mainwp_chunksitesnumber', 10 ) ? '' : 1 );
1779 + esc_html_e( 'Maximum sites per batch (Default: 10)', 'mainwp' );
1780 + ?>
1781 + </label>
1782 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'The maximum number of websites processed concurrently. If too many requests are sent out, they will begin to time out.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1783 + <div class="ui bottom aligned labeled slider" id="mainwp_chunksitesnumber_slider"></div>
1784 + <div class="ui input">
1785 + <input type="hidden" class="settings-field-value-change-handler" name="mainwp_chunksitesnumber" id="mainwp_chunksitesnumber" value="<?php echo false === get_option( 'mainwp_chunksitesnumber' ) ? 10 : (int) get_option( 'mainwp_chunksitesnumber' ); ?>"/>
1786 + </div>
1787 + </div>
1788 + </div>
1789 +
1790 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-cross-ip" default-indi-value="5">
1791 + <label class="six wide column middle aligned">
1792 + <?php
1793 + MainWP_Settings_Indicator::render_not_default_indicator( 'none_preset_value', 5 === (int) get_option( 'mainwp_chunksleepinterval', 5 ) ? '' : 1 );
1794 + esc_html_e( 'Delay between batches (Default: 5ms)', 'mainwp' );
1795 + ?>
1796 + </label>
1797 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'The pause duration between processing each batch of websites.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1798 + <div class="ui bottom aligned labeled slider" id="mainwp_chunksleepinterval_slider"></div>
1799 + <div class="ui input">
1800 + <input type="hidden" class="settings-field-value-change-handler" name="mainwp_chunksleepinterval" id="mainwp_chunksleepinterval" value="<?php echo false === get_option( 'mainwp_chunksleepinterval' ) ? 5 : (int) get_option( 'mainwp_chunksleepinterval' ); ?>"/>
1801 + </div>
1802 + </div>
1803 + </div>
1804 +
1805 + <h3 class="ui dividing header">
1806 + <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-frontend-request' ); ?>
1807 + <?php esc_html_e( 'Frontend Request Settings', 'mainwp' ); ?>
1808 + <div class="sub header"><?php esc_html_e( 'Configure limits for concurrent background tasks such as synchronization, installation/updating, and uptime monitoring, ensuring efficient resource use and system stability.', 'mainwp' ); ?></div>
1809 + </h3>
1810 +
1436 1811 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-frontend-request" default-indi-value="8">
1437 1812 <label class="six wide column middle aligned">
1438 1813 <?php
1439 1814 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumSyncRequests', (int) get_option( 'mainwp_maximumSyncRequests', 8 ) );
@@ -1439,10 +1814,13 @@
1439 1814 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumSyncRequests', (int) get_option( 'mainwp_maximumSyncRequests', 8 ) );
1440 1815 esc_html_e( 'Maximum simultaneous sync requests (Default: 8)', 'mainwp' );
1441 1816 ?>
1442 1817 </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' ) ); ?>"/>
1818 + <div class="ten wide column" 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">
1819 + <div class="ui bottom aligned labeled slider" id="mainwp_maximumSyncRequests_slider"></div>
1820 + <div class="ui input">
1821 + <input type="hidden" 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' ) ); ?>"/>
1822 + </div>
1445 1823 </div>
1446 1824 </div>
1447 1825
1448 1826 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-frontend-request" default-indi-value="3">
@@ -1451,13 +1829,32 @@
1451 1829 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximumInstallUpdateRequests', (int) get_option( 'mainwp_maximumInstallUpdateRequests', 3 ) );
1452 1830 esc_html_e( 'Maximum simultaneous install and update requests (Default: 3)', 'mainwp' );
1453 1831 ?>
1454 1832 </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' ) ); ?>"/>
1833 + <div class="ten wide column" 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">
1834 + <div class="ui bottom aligned labeled slider" id="mainwp_maximumInstallUpdateRequests_slider"></div>
1835 + <div class="ui input">
1836 + <input type="hidden" 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 1837 </div>
1838 + </div>
1458 1839 </div>
1459 1840
1841 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-frontend-request" default-indi-value="10">
1842 + <label class="six wide column middle aligned">
1843 + <?php
1844 + $maximum_monitoring_requests = (int) get_option( 'mainwp_maximum_uptime_monitoring_requests', 10 );
1845 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_maximum_uptime_monitoring_requests', $maximum_monitoring_requests );
1846 + esc_html_e( 'Maximum simultaneous uptime monitoring requests (Default: 10)', 'mainwp' );
1847 + ?>
1848 + </label>
1849 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'This option allows you to control how many uptime monitoring requests your MainWP Dashboard should process at once.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1850 + <div class="ui bottom aligned labeled slider settings-field-value-change-handler" id="mainwp_maximumUptimeMonitoringRequests_slider"></div>
1851 + <div class="ui input">
1852 + <input type="hidden" class="settings-field-value-change-handler" name="mainwp_maximumUptimeMonitoringRequests" id="mainwp_maximumUptimeMonitoringRequests" value="<?php echo false === get_option( 'mainwp_maximum_uptime_monitoring_requests' ) ? 10 : esc_attr( get_option( 'mainwp_maximum_uptime_monitoring_requests' ) ); ?>"/>
1853 + </div>
1854 + </div>
1855 + </div>
1856 +
1460 1857 <h3 class="ui dividing header">
1461 1858 <?php MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-miscellaneous' ); ?>
1462 1859 <?php esc_html_e( 'Miscellaneous Settings', 'mainwp' ); ?></h3>
1463 1860 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1">
@@ -1467,20 +1864,43 @@
1467 1864 esc_html_e( 'Optimize data loading', 'mainwp' );
1468 1865 ?>
1469 1866 </label>
1470 1867 <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>
1868 + <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: Enabled', 'mainwp' ); ?></label>
1472 1869 </div>
1473 1870 </div>
1474 1871 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1">
1475 1872 <label class="six wide column middle aligned">
1476 1873 <?php
1874 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_auto_correct_site_url', (int) get_option( 'mainwp_auto_correct_site_url', 1 ) );
1875 + esc_html_e( 'Auto-correct site URLs', 'mainwp' );
1876 + ?>
1877 + </label>
1878 + <div class="ten wide column ui toggle checkbox" data-tooltip="<?php esc_attr_e( 'If enabled, your MainWP Dashboard will automatically correct the stored site URL when the child site reports a different address. Only safe changes are applied (www variant and HTTP to HTTPS); the corrected URL is verified before saving, and sites with a locked URL are never changed.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1879 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp_auto_correct_site_url" id="mainwp_auto_correct_site_url" <?php echo 1 === (int) get_option( 'mainwp_auto_correct_site_url', 1 ) ? 'checked="true"' : ''; ?> /><label><?php esc_html_e( 'Default: Enabled', 'mainwp' ); ?></label>
1880 + </div>
1881 + </div>
1882 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="10">
1883 + <label class="six wide column middle aligned">
1884 + <?php
1885 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_warm_cache_pages_ttl', (int) get_option( 'mainwp_warm_cache_pages_ttl', 10 ) );
1886 + esc_html_e( 'Browser cache expiration time', 'mainwp' );
1887 + $browser_cache_ttl = (int) get_option( 'mainwp_warm_cache_pages_ttl', 10 );
1888 + ?>
1889 + </label>
1890 + <div class="five wide column" data-tooltip="<?php esc_attr_e( 'Set how many minutes the browser cache should retain page content before it expires', 'mainwp' ); ?>" data-inverted="" data-position="top left">
1891 + <input type="number" class="settings-field-value-change-handler small-text" name="mainwp_warm_cache_pages_ttl" id="mainwp_warm_cache_pages_ttl" placeholder="" min="1" max="24" step="1" value="<?php echo intval( $browser_cache_ttl ); ?>">
1892 + </div>
1893 + </div>
1894 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1">
1895 + <label class="six wide column middle aligned">
1896 + <?php
1477 1897 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_wp_cron', (int) get_option( 'mainwp_wp_cron', 1 ) );
1478 1898 esc_html_e( 'Use WP Cron', 'mainwp' );
1479 1899 ?>
1480 1900 </label>
1481 1901 <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>
1902 + <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: Enabled', 'mainwp' ); ?></label>
1483 1903 </div>
1484 1904 </div>
1485 1905 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous" default-indi-value="1" >
1486 1906 <label class="six wide column middle aligned">
@@ -1490,9 +1910,9 @@
1490 1910 esc_html_e( 'Verify SSL certificate', 'mainwp' );
1491 1911 ?>
1492 1912 </label>
1493 1913 <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>
1914 + <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: Enabled', 'mainwp' ); ?></label>
1495 1915 </div>
1496 1916 </div>
1497 1917 <?php
1498 1918 $general_verify_con = (int) get_option( 'mainwp_verify_connection_method', 1 );
@@ -1549,14 +1969,14 @@
1549 1969 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_forceUseIPv4', (int) get_option( 'mainwp_forceUseIPv4' ) );
1550 1970 esc_html_e( 'Force IPv4', 'mainwp' );
1551 1971 ?>
1552 1972 </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>
1973 + <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 trying to connect child sites.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
1974 + <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: Disabled', 'mainwp' ); ?></label>
1555 1975 </div>
1556 1976 </div>
1557 1977 <?php
1558 -
1978 + static::render_sync_data_selection();
1559 1979 /**
1560 1980 * Action: mainwp_advanced_settings_form_bottom
1561 1981 *
1562 1982 * Fires at the bottom of advanced settings form.
@@ -1570,35 +1990,345 @@
1570 1990 <input type="submit" name="submit" id="submit" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1571 1991 </form>
1572 1992 </div>
1573 1993 </div>
1994 + <?php static::render_disable_installed_plugins_sync_modal(); ?>
1995 + <script>
1996 + jQuery(document).ready(function() {
1997 + const maximumRequests = <?php echo ! empty( get_option( 'mainwp_maximumRequests' ) ) ? esc_js( get_option( 'mainwp_maximumRequests' ) ) : 4; ?>;
1998 + jQuery('#mainwp_maximumRequests_slider').slider({
1999 + min: 1,
2000 + max: 20,
2001 + start: maximumRequests,
2002 + step: 1,
2003 + restrictedLabels: [1,20],
2004 + showThumbTooltip: true,
2005 + tooltipConfig: {
2006 + position: 'top center',
2007 + variation: 'small visible black'
2008 + },
2009 + onChange: function(value) {
2010 + jQuery('#mainwp_maximumRequests').val(value);
2011 + }
2012 + });
2013 + const minimumDelay = <?php echo ! empty( get_option( 'mainwp_minimumDelay' ) ) ? esc_js( get_option( 'mainwp_minimumDelay' ) ) : 200; ?>;
2014 + jQuery('#mainwp_minimumDelay_slider').slider({
2015 + min: 100,
2016 + max: 5000,
2017 + start: minimumDelay,
2018 + step: 100,
2019 + restrictedLabels: [100,5000],
2020 + showThumbTooltip: true,
2021 + tooltipConfig: {
2022 + position: 'top center',
2023 + variation: 'small visible black'
2024 + },
2025 + onChange: function(value) {
2026 + jQuery('#mainwp_minimumDelay').val(value);
2027 + }
2028 + });
2029 + const maximumIPRequests = <?php echo ! empty( get_option( 'mainwp_maximumIPRequests' ) ) ? esc_js( get_option( 'mainwp_maximumIPRequests' ) ) : 1; ?>;
2030 + jQuery('#mainwp_maximumIPRequests_slider').slider({
2031 + min: 1,
2032 + max: 10,
2033 + start: maximumIPRequests,
2034 + step: 1,
2035 + restrictedLabels: [1,10],
2036 + showThumbTooltip: true,
2037 + tooltipConfig: {
2038 + position: 'top center',
2039 + variation: 'small visible black'
2040 + },
2041 + onChange: function(value) {
2042 + jQuery('#mainwp_maximumIPRequests').val(value);
2043 + }
2044 + });
2045 + const minimumIPDelay = <?php echo ! empty( get_option( 'mainwp_minimumIPDelay' ) ) ? esc_js( get_option( 'mainwp_minimumIPDelay' ) ) : 1000; ?>;
2046 + jQuery('#mainwp_minimumIPDelay_slider').slider({
2047 + min: 500,
2048 + max: 5000,
2049 + start: minimumIPDelay,
2050 + step: 100,
2051 + restrictedLabels: [500,5000],
2052 + showThumbTooltip: true,
2053 + tooltipConfig: {
2054 + position: 'top center',
2055 + variation: 'small visible black'
2056 + },
2057 + onChange: function(value) {
2058 + jQuery('#mainwp_minimumIPDelay').val(value);
2059 + }
2060 + });
2061 + const maximumSyncRequests = <?php echo ! empty( get_option( 'mainwp_maximumSyncRequests' ) ) ? esc_js( get_option( 'mainwp_maximumSyncRequests' ) ) : 8; ?>;
2062 + jQuery('#mainwp_maximumSyncRequests_slider').slider({
2063 + min: 1,
2064 + max: 20,
2065 + start: maximumSyncRequests,
2066 + step: 1,
2067 + restrictedLabels: [1,20],
2068 + showThumbTooltip: true,
2069 + tooltipConfig: {
2070 + position: 'top center',
2071 + variation: 'small visible black'
2072 + },
2073 + onChange: function(value) {
2074 + jQuery('#mainwp_maximumSyncRequests').val(value);
2075 + }
2076 + });
2077 + const maximumInstallUpdateRequests = <?php echo ! empty( get_option( 'mainwp_maximumInstallUpdateRequests' ) ) ? esc_js( get_option( 'mainwp_maximumInstallUpdateRequests' ) ) : 3; ?>;
2078 + jQuery('#mainwp_maximumInstallUpdateRequests_slider').slider({
2079 + min: 1,
2080 + max: 20,
2081 + start: maximumInstallUpdateRequests,
2082 + step: 1,
2083 + restrictedLabels: [1,20],
2084 + showThumbTooltip: true,
2085 + tooltipConfig: {
2086 + position: 'top center',
2087 + variation: 'small visible black'
2088 + },
2089 + onChange: function(value) {
2090 + jQuery('#mainwp_maximumInstallUpdateRequests').val(value);
2091 + }
2092 + });
2093 + const maximumUptimeMonitoringRequests = <?php echo ! empty( get_option( 'mainwp_maximum_uptime_monitoring_requests' ) ) ? esc_js( get_option( 'mainwp_maximum_uptime_monitoring_requests' ) ) : 10; ?>;
2094 + jQuery('#mainwp_maximumUptimeMonitoringRequests_slider').slider({
2095 + min: 1,
2096 + max: 100,
2097 + start: maximumUptimeMonitoringRequests,
2098 + step: 1,
2099 + restrictedLabels: [1,100],
2100 + showThumbTooltip: true,
2101 + tooltipConfig: {
2102 + position: 'top center',
2103 + variation: 'small visible black'
2104 + },
2105 + onChange: function(value) {
2106 + jQuery('#mainwp_maximumUptimeMonitoringRequests').val(value).change();
2107 + }
2108 + });
2109 + jQuery('#mainwp_maximumUptimeMonitoringRequests_slider').slider('set value', maximumUptimeMonitoringRequests);
2110 +
2111 + jQuery('#mainwp_chunksitesnumber_slider').slider({
2112 + min: 1,
2113 + max: 30,
2114 + start: <?php echo false !== get_option( 'mainwp_chunksitesnumber' ) ? intval( get_option( 'mainwp_chunksitesnumber' ) ) : 10; ?>,
2115 + step: 1,
2116 + restrictedLabels: [1,30],
2117 + showThumbTooltip: true,
2118 + tooltipConfig: {
2119 + position: 'top center',
2120 + variation: 'small visible black'
2121 + },
2122 + onChange: function(value) {
2123 + jQuery('#mainwp_chunksitesnumber').val(value).change();
2124 + }
2125 + });
2126 +
2127 + jQuery('#mainwp_chunksleepinterval_slider').slider({
2128 + min: 0,
2129 + max: 20,
2130 + start: <?php echo false !== get_option( 'mainwp_chunksleepinterval' ) ? intval( get_option( 'mainwp_chunksleepinterval' ) ) : 5; ?>,
2131 + step: 1,
2132 + restrictedLabels: [0,20],
2133 + showThumbTooltip: true,
2134 + tooltipConfig: {
2135 + position: 'top center',
2136 + variation: 'small visible black'
2137 + },
2138 + onChange: function(value) {
2139 + jQuery('#mainwp_chunksleepinterval').val(value).change();
2140 + }
2141 + });
2142 + });
2143 + </script>
1574 2144 <?php
1575 2145 static::render_footer( 'Advanced' );
1576 2146 }
1577 2147
1578 2148 /**
2149 + * Method render_sync_data_selection().
2150 + *
2151 + * @return void
2152 + */
2153 + public static function render_sync_data_selection() {
2154 +
2155 + $default_sync = static::get_data_sync_default();
2156 +
2157 + $sync_data_settings = get_option( 'mainwp_settings_sync_data' );
2158 +
2159 + $sync_data_settings = ! empty( $sync_data_settings ) ? json_decode( $sync_data_settings, true ) : array();
2160 +
2161 + if ( ! is_array( $sync_data_settings ) ) {
2162 + $sync_data_settings = array();
2163 + }
2164 +
2165 + $setting_page = true;
2166 +
2167 + ?>
2168 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-miscellaneous">
2169 + <label class="six wide column top aligned">
2170 + <?php
2171 + MainWP_Settings_Indicator::render_indicator( 'header', 'settings-field-indicator-sync-data' );
2172 + esc_html_e( 'Select data to sync', 'mainwp' );
2173 + ?>
2174 + </label>
2175 + <div class="ten wide column" <?php echo $setting_page ? 'data-tooltip="' . esc_attr__( 'Select data that you want to sync.', 'mainwp' ) . '"' : ''; ?> data-inverted="" data-position="top left">
2176 + <ul class="mainwp_hide_wpmenu_checkboxes">
2177 + <?php
2178 + foreach ( $default_sync as $name => $title ) {
2179 + $_selected = '';
2180 + if ( ! isset( $sync_data_settings[ $name ] ) || 1 === (int) $sync_data_settings[ $name ] ) {
2181 + $_selected = 'checked';
2182 + }
2183 + ?>
2184 + <li>
2185 + <div class="ui checkbox">
2186 + <input type="checkbox" class="settings-field-value-change-handler" id="mainwp_select_sync_<?php echo esc_attr( $name ); ?>" name="mainwp_settings_sync_data[]" <?php echo esc_html( $_selected ); ?> value="<?php echo esc_attr( $name ); ?>">
2187 + <label for="mainwp_select_sync_<?php echo esc_attr( $name ); ?>" ><?php echo esc_html( $title ); ?></label>
2188 + </div>
2189 + <input type="hidden" name="mainwp_settings_sync_name[]" value="<?php echo esc_attr( $name ); ?>">
2190 + </li>
2191 + <?php
2192 + }
2193 + ?>
2194 + </ul>
2195 + </div>
2196 + </div>
2197 + <?php
2198 + }
2199 +
2200 + /**
2201 + * Render the Installed plugins sync warning modal.
2202 + *
2203 + * @since 6.1.3
2204 + *
2205 + * @return void
2206 + */
2207 + public static function render_disable_installed_plugins_sync_modal() {
2208 + ?>
2209 + <div class="ui small modal" id="mainwp-disable-installed-plugins-sync-modal">
2210 + <div class="header"><?php esc_html_e( 'Disable Installed Plugins Sync?', 'mainwp' ); ?></div>
2211 + <div class="content">
2212 + <div class="ui yellow message">
2213 + <div class="header"><?php esc_html_e( 'MainWP Add-ons may not work as expected', 'mainwp' ); ?></div>
2214 + <p><?php esc_html_e( 'Some MainWP Add-ons need the installed plugins data to detect required plugins on your Child Sites. If you disable this option, those Add-ons may not work as expected.', 'mainwp' ); ?></p>
2215 + </div>
2216 + </div>
2217 + <div class="actions">
2218 + <div class="ui basic cancel button"><?php esc_html_e( 'Cancel', 'mainwp' ); ?></div>
2219 + <div class="ui green approve button"><?php esc_html_e( 'I understand', 'mainwp' ); ?></div>
2220 + </div>
2221 + </div>
2222 + <script type="text/javascript">
2223 + jQuery( document ).ready( function () {
2224 + const installedPluginsCheckbox = jQuery( '#mainwp_select_sync_plugins' );
2225 + const warningModal = jQuery( '#mainwp-disable-installed-plugins-sync-modal' );
2226 + let disableConfirmed = false;
2227 +
2228 + installedPluginsCheckbox.on( 'change', function () {
2229 + if ( installedPluginsCheckbox.is( ':checked' ) ) {
2230 + disableConfirmed = false;
2231 + return;
2232 + }
2233 +
2234 + if ( disableConfirmed ) {
2235 + return;
2236 + }
2237 +
2238 + warningModal.modal( {
2239 + closable: false,
2240 + onApprove: function () {
2241 + disableConfirmed = true;
2242 + },
2243 + onDeny: function () {
2244 + installedPluginsCheckbox.prop( 'checked', true ).trigger( 'change' );
2245 + }
2246 + } ).modal( 'show' );
2247 + } );
2248 + } );
2249 + </script>
2250 + <?php
2251 + }
2252 +
2253 + /**
2254 + * Method get_data_sync_default().
2255 + *
2256 + * @return array data.
2257 + */
2258 + public static function get_data_sync_default() {
2259 + return array(
2260 + 'wp_updates' => __( 'WordPress updates information', 'mainwp' ),
2261 + 'plugin_updates' => __( 'Plugins updates information', 'mainwp' ),
2262 + 'theme_updates' => __( 'Themes updates information', 'mainwp' ),
2263 + 'translation_updates' => __( 'Translations updates information', 'mainwp' ),
2264 + 'recent_comments' => __( 'Recent comments', 'mainwp' ),
2265 + 'recent_posts' => __( 'Recent posts', 'mainwp' ),
2266 + 'recent_pages' => __( 'Recent pages', 'mainwp' ),
2267 + 'securityStats' => __( 'Site hardening information', 'mainwp' ),
2268 + 'directories' => __( 'Site directory listing (needed for legacy backup feature)', 'mainwp' ),
2269 + 'categories' => __( 'Posts catetegories', 'mainwp' ),
2270 + 'totalsize' => __( 'Website size (needed for Clone and legacy backup features)', 'mainwp' ),
2271 + 'dbsize' => __( 'Database size information', 'mainwp' ),
2272 + 'plugins' => __( 'Installed plugins', 'mainwp' ),
2273 + 'themes' => __( 'Installed Themes', 'mainwp' ),
2274 + 'users' => __( 'Users information', 'mainwp' ),
2275 + 'plugins_outdate_info' => __( 'Abandoned plugins information', 'mainwp' ),
2276 + 'themes_outdate_info' => __( 'Abandoned themes information', 'mainwp' ),
2277 + 'health_site_status' => __( 'Site health information', 'mainwp' ),
2278 + 'child_site_actions_data' => __( 'Non-MainWP changes data', 'mainwp' ),
2279 + 'othersData' => __( 'Other data (required by some extensions)', 'mainwp' ),
2280 + );
2281 + }
2282 +
2283 + /**
2284 + * Method get_data_list_to_sync().
2285 + *
2286 + * @return array Data list to sync.
2287 + */
2288 + public function get_data_list_to_sync() {
2289 + $sync_data_settings = get_option( 'mainwp_settings_sync_data' );
2290 +
2291 + if ( false === $sync_data_settings ) {
2292 + $default_sync = static::get_data_sync_default();
2293 + $sync_lists = array_fill_keys( array_keys( $default_sync ), 1 );
2294 + MainWP_Utility::update_option( 'mainwp_settings_sync_data', wp_json_encode( $sync_lists ) );
2295 + return $sync_lists;
2296 + }
2297 +
2298 + $sync_lists = ! empty( $sync_data_settings ) ? json_decode( $sync_data_settings, true ) : array();
2299 +
2300 + if ( ! is_array( $sync_lists ) ) {
2301 + $sync_lists = array();
2302 + }
2303 + return $sync_lists;
2304 + }
2305 +
2306 +
2307 + /**
1579 2308 * Render MainWP Tools SubPage.
1580 2309 *
1581 2310 * @uses \MainWP\Dashboard\MainWP_UI::render_screen_options()
1582 2311 */
1583 2312 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 -
2313 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) {
2314 + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
1587 2315 return;
1588 2316 }
1589 2317 static::render_header( 'MainWPTools' );
1590 - $is_demo = MainWP_Demo_Handle::is_demo_mode();
1591 2318 ?>
1592 - <div id="mainwp-tools-settings" class="ui segment">
2319 + <div id="mainwp-tools-settings" class="ui padded segment">
1593 2320 <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' ) ) : ?>
2321 + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-message' ) ) : ?>
1595 2322 <div class="ui info message">
1596 2323 <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>' ); ?>
2324 + <?php
2325 + // translators: 1: Opening anchor tag. 2: Closing anchor tag.
2326 + 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://docs.mainwp.com/sites/management/mainwp-dashboard-settings#mainwp-dashboard-settings" target="_blank">', '</a> <i class="external alternate icon"></i>' );
2327 + ?>
1598 2328 </div>
1599 2329 <?php endif; ?>
1600 - <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-custom-theme' ) ) : ?>
2330 + <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-tools-info-custom-theme' ) ) : ?>
1601 2331 <div class="ui info message">
1602 2332 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-tools-info-custom-theme"></i>
1603 2333 <div><?php esc_html_e( 'Here you can select a theme for your MainWP Dashboard.', 'mainwp' ); ?></div>
1604 2334 <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>
@@ -1603,21 +2333,31 @@
1603 2333 <div><?php esc_html_e( 'Here you can select a theme for your MainWP Dashboard.', 'mainwp' ); ?></div>
1604 2334 <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 2335 </div>
1606 2336 <?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' ) ) : ?>
2337 + <?php
2338 + $show_saved_message = false;
2339 + if ( isset( $_POST['submit'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) {
2340 + $show_saved_message = true;
2341 + } elseif ( get_transient( 'mainwp_settings_saved' ) ) {
2342 + $show_saved_message = true;
2343 + delete_transient( 'mainwp_settings_saved' ); // Remove transient after showing message.
2344 + }
2345 + ?>
2346 + <?php if ( $show_saved_message ) : ?>
2347 + <div class="ui green message">
2348 + <i class="close icon"></i>
2349 + <?php esc_html_e( 'Settings have been saved successfully!', 'mainwp' ); ?>
2350 + </div>
2351 + <?php endif; ?>
2352 + <?php if ( isset( $_POST['mainwp_restore_info_messages'] ) && isset( $_POST['wp_nonce'] ) && wp_verify_nonce( sanitize_key( $_POST['wp_nonce'] ), 'MainWPTools' ) ) : ?>
1611 2353 <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Info messages have been restored successfully!', 'mainwp' ); ?></div>
1612 2354 <?php endif; ?>
1613 2355 <div class="ui form">
1614 2356 <form method="POST" action="">
1615 - <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2357 + <?php MainWP_UI::generate_wp_nonce( 'mainwp-admin-nonce' ); ?>
1616 2358 <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>
2359 +
1620 2360 <?php
1621 2361 /**
1622 2362 * Action: mainwp_tools_form_top
1623 2363 *
@@ -1631,50 +2371,30 @@
1631 2371
1632 2372 static::get_instance()->render_select_custom_themes();
1633 2373
1634 2374 ?>
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>
2375 + <?php if ( get_option( 'mainwp_not_start_encrypt_keys' ) ) { ?>
2376 + <div class="ui grid field">
2377 + <label class="six wide column middle aligned"><?php esc_html_e( 'OpenSSL Key Encryption', 'mainwp' ); ?></label>
2378 + <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'To enhance security, we\'ve added a feature to encrypt your private keys stored in the database.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
2379 + <input type="button" name="" id="increase-connection-security-btn" data-inverted="" data-position="top right" data-tooltip="<?php esc_attr_e( 'To enhance security, we\'ve added a feature to encrypt your private keys stored in the database.', 'mainwp' ); ?>" class="ui green basic button" value="<?php esc_attr_e( 'Encrypt Keys Now', 'mainwp' ); ?>" />
1649 2380 </div>
1650 2381 </div>
2382 + <?php } ?>
1651 2383 <div class="ui grid field">
1652 2384 <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashboard to establish a new connection', 'mainwp' ); ?></label>
1653 2385 <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 2386 <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>
2387 + </div>
2388 + </div>
2389 + <div class="ui grid field">
2390 + <label class="six wide column middle aligned"><?php esc_html_e( 'Force your MainWP Dashboard to set a new pair of OpenSSL Keys', 'mainwp' ); ?></label>
2391 + <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">
2392 + <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>
2393 + </div>
2394 + </div>
2395 + <?php if ( $show_qsw ) { ?>
1663 2396 <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 2397 <label class="six wide column middle aligned"><?php esc_html_e( 'Start the MainWP Quick Setup Wizard', 'mainwp' ); ?></label>
1678 2398 <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 2399 </div>
1680 2400 <?php } ?>
@@ -1688,23 +2408,23 @@
1688 2408 </div>
1689 2409 <div class="ui grid field">
1690 2410 <label class="six wide column middle aligned"><?php esc_html_e( 'Disconnect all child sites', 'mainwp' ); ?></label>
1691 2411 <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 2412 <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 2413 </div>
2414 + </div>
2415 + <div class="ui grid field">
2416 + <label class="six wide column middle aligned"><?php esc_html_e( 'Delete add-ons API Activation data', 'mainwp' ); ?></label>
2417 + <div class="ten wide column" id="mainwp-clear-activation-data" data-content="<?php esc_attr_e( 'This does not affect extensions settings, it just removes API activation data.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left">
2418 + <a href="admin.php?page=MainWPTools&clearActivationData=yes&_wpnonce=<?php echo esc_attr( wp_create_nonce( 'clear_activation_data' ) ); ?>" onclick="mainwp_tool_confirm_to_process(this); return false;" class="ui button green basic"><?php esc_html_e( 'Delete Add-ons API Activation Data', 'mainwp' ); ?></a>
1700 2419 </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>
2420 + </div>
2421 + <div class="ui grid field">
2422 + <label class="six wide column middle aligned"><?php esc_html_e( 'Delete archived Network Activity data', 'mainwp' ); ?></label>
2423 + <div class="ten wide column" id="mainwp-clear-archived-sites-changes-data" data-content="<?php esc_attr_e( 'Delete archived sNetwork Activity data.', 'mainwp' ); ?>" data-variation="inverted" data-position="top left">
2424 + <a href="admin.php?page=MainWPTools&clearArchivedSitesChangesData=yes&_wpnonce=<?php echo esc_attr( wp_create_nonce( 'clear_archived_sites_changes' ) ); ?>" onclick="mainwp_tool_confirm_to_process(this); return false;" class="ui button green basic"><?php esc_html_e( 'Delete Archived Network Activity Data', 'mainwp' ); ?></a>
1706 2425 </div>
2426 + </div>
1707 2427 <div class="ui grid field">
1708 2428 <label class="six wide column middle aligned"><?php esc_html_e( 'Restore all info messages', 'mainwp' ); ?></label>
1709 2429 <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 2430 <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' ); ?>"/>
@@ -1709,36 +2429,73 @@
1709 2429 <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 2430 <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 2431 </div>
1712 2432 </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 } ?>
2433 +
2434 + <h3 class="ui dividing header">
2435 + <?php esc_html_e( 'Privacy & Third-Party Services Permissions', 'mainwp' ); ?>
2436 + <div class="sub header"><?php esc_html_e( 'These tools are implemented using JavaScript and are subject to their respective privacy policies. You can choose which services to enable below, and update preferences at any time.', 'mainwp' ); ?></div>
2437 + </h3>
2438 +
2439 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-tools">
2440 + <label class="six wide column middle aligned">
2441 + <?php
2442 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_enable_guided_tours', (int) get_option( 'mainwp_enable_guided_tours', 0 ) );
2443 + esc_html_e( 'Usetiful (Interactive Guides & Tips)', 'mainwp' );
2444 + ?>
2445 + <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span>
2446 + </label>
2447 + <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">
2448 + <div class="ui toggle checkbox">
2449 + <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"' : ''; ?> />
2450 + <label><?php esc_html_e( 'Enable guided tours, tooltips, and onboarding assistance to help you navigate MainWP more efficiently.', 'mainwp' ); ?></label>
1726 2451 </div>
2452 + </div>
1727 2453 </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' );
2454 +
2455 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-tools">
2456 + <label class="six wide column middle aligned">
2457 + <?php
2458 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_enable_guided_chatbase', (int) get_option( 'mainwp_enable_guided_chatbase', 0 ) );
2459 + esc_html_e( 'Chatbase (AI-Powered Chat Support)', 'mainwp' );
2460 + ?>
2461 + <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span>
2462 + </label>
2463 + <div class="ten wide column " data-tooltip="<?php esc_attr_e( 'Check this option to enable, or uncheck to disable MainWP AI drive support.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2464 + <div class="ui toggle checkbox">
2465 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp-guided-chatbase-option" id="mainwp-guided-chatbase-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_chatbase', 0 ) ? 'checked="true"' : ''; ?> />
2466 + <label><?php esc_html_e( 'Get AI-driven support within the MainWP Dashboard for quick answers to common questions.', 'mainwp' ); ?></label>
2467 + </div>
2468 + </div>
2469 + </div>
2470 +
2471 + <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-tools">
2472 + <label class="six wide column middle aligned">
2473 + <?php
2474 + MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_enable_guided_video', (int) get_option( 'mainwp_enable_guided_video', 0 ) );
2475 + esc_html_e( 'Youtube Embeds (Video Tutorials)', 'mainwp' );
2476 + ?>
2477 + </label>
2478 + <div class="ten wide column " data-tooltip="<?php esc_attr_e( 'Check this option to enable, or uncheck to disable MainWP video tutorials.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
2479 + <div class="ui toggle checkbox">
2480 + <input type="checkbox" class="settings-field-value-change-handler" name="mainwp-guided-video-option" id="mainwp-guided-video-option" <?php echo 1 === (int) get_option( 'mainwp_enable_guided_video', 0 ) ? 'checked="true"' : ''; ?> />
2481 + <label><?php esc_html_e( 'Enable embedded YouTube video tutorials within MainWP for step-by-step guidance.', 'mainwp' ); ?></label>
2482 + </div>
2483 + </div>
2484 + </div>
2485 + <?php
2486 + /**
2487 + * Action: mainwp_tools_form_bottom
2488 + *
2489 + * Fires at the bottom of mainwp tools form.
2490 + *
2491 + * @since 4.1
2492 + */
2493 + do_action( 'mainwp_tools_form_bottom' );
2494 + $el_id_sbm_btn_1 = 'submit';
1738 2495 ?>
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' ); ?>"/>
2496 + <div class="ui divider"></div>
2497 + <input type="submit" name="submit" id="<?php echo esc_attr( $el_id_sbm_btn_1 ); ?>" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
1741 2498 </form>
1742 2499 </div>
1743 2500 </div>
1744 2501 <script type="text/javascript">
@@ -1750,8 +2507,23 @@
1750 2507 MainWP_Connect_Helper::render_renew_connections_modal();
1751 2508 }
1752 2509
1753 2510 /**
2511 + * Method is_basic_auth_dashboard_enabled.
2512 + *
2513 + * @return bool true|false.
2514 + */
2515 + public static function is_basic_auth_dashboard_enabled() { // phpcs:ignore -- NOSONAR - complex.
2516 + $response = wp_remote_get( get_site_url() . '/wp-json' );
2517 + $code = wp_remote_retrieve_response_code( $response );
2518 + if ( 404 === (int) $code || 401 === (int) $code ) {
2519 + return true;
2520 + }
2521 + return false;
2522 + }
2523 +
2524 +
2525 + /**
1754 2526 * Render MainWP themes selection.
1755 2527 */
1756 2528 public function render_select_custom_themes() { // phpcs:ignore -- NOSONAR - complex.
1757 2529 $custom_theme = $this->get_current_user_theme();
@@ -1773,18 +2545,30 @@
1773 2545 <div class="ui grid field settings-field-indicator-wrapper settings-field-indicator-tools" default-indi-value="default">
1774 2546 <label class="six wide column middle aligned">
1775 2547 <?php
1776 2548 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_selected_theme', $custom_theme );
1777 - esc_html_e( 'Select MainWP Theme', 'mainwp' );
2549 + esc_html_e( 'Select MainWP Dashboard theme', 'mainwp' );
1778 2550 ?>
1779 2551 </label>
1780 2552 <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 2553 <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>
2554 + <option value="default" <?php echo ( 'default' === $custom_theme || empty( $custom_theme ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Light', 'mainwp' ); ?></option>
2555 + <option value="default-dark" <?php echo ( 'default-dark' === $custom_theme || empty( $custom_theme ) ) ? 'selected' : ''; ?>><?php esc_html_e( 'Dark', 'mainwp' ); ?></option>
2556 + <?php if ( 'default-2024' === $custom_theme ) { ?>
2557 + <option value="default-2024" <?php echo ( 'default-2024' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Default 2024', 'mainwp' ); ?></option>
2558 + <?php } ?>
2559 + <?php if ( 'dark' === $custom_theme ) { ?>
2560 + <option value="dark" <?php echo ( 'dark' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Dark 2024', 'mainwp' ); ?></option>
2561 + <?php } ?>
2562 + <?php if ( 'classic' === $custom_theme ) { ?>
2563 + <option value="classic" <?php echo ( 'classic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Classic (Legacy)', 'mainwp' ); ?></option>
2564 + <?php } ?>
2565 + <?php if ( 'wpadmin' === $custom_theme ) { ?>
2566 + <option value="wpadmin" <?php echo ( 'wpadmin' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'WP Admin (Legacy)', 'mainwp' ); ?></option>
2567 + <?php } ?>
2568 + <?php if ( 'minimalistic' === $custom_theme ) { ?>
2569 + <option value="minimalistic" <?php echo ( 'minimalistic' === $custom_theme ) ? 'selected' : ''; ?>><?php esc_html_e( 'Minimalistic (Legacy)', 'mainwp' ); ?></option>
2570 + <?php } ?>
1787 2571 <?php
1788 2572 foreach ( $themes_files as $file_name => $theme ) {
1789 2573 $theme = ucfirst( $theme );
1790 2574 $_select = '';
@@ -1848,9 +2632,9 @@
1848 2632 }
1849 2633 }
1850 2634
1851 2635 if ( ! empty( $custom_theme ) ) {
1852 - if ( 'default' === $custom_theme || 'dark' === $custom_theme || 'wpadmin' === $custom_theme || 'minimalistic' === $custom_theme ) {
2636 + if ( 'default' === $custom_theme || 'default-dark' === $custom_theme || 'default-2024' === $custom_theme || 'dark' === $custom_theme || 'wpadmin' === $custom_theme || 'minimalistic' === $custom_theme ) {
1853 2637 return $custom_theme;
1854 2638 }
1855 2639 $dirs = $this->get_custom_theme_folder();
1856 2640 $theme_dir = $dirs[0];
@@ -1906,18 +2690,41 @@
1906 2690 if ( ! $websites ) {
1907 2691 die( 'Not found sites' );
1908 2692 }
1909 2693
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";
2694 + $keys = array( 'name', 'url', 'adminname', 'adminpasswd', 'wpgroups', 'uniqueId', 'http_user', 'http_pass', 'verify_certificate', 'ssl_version' );
2695 + $allowedHeaders = array( 'site name', 'url', 'admin name', 'admin password', 'tag', 'security id', 'http username', 'http password', 'verify certificate', 'ssl version' );
2696 + $csv = "#\r";
2697 + $csv .= '# Your password is never stored by your Dashboard and never sent to MainWP.com. Once this initial connection is complete, your MainWP Dashboard generates a secure Public and Private key pair (2048 bits) using OpenSSL, allowing future connections without needing your password again. For added security, you can even change this admin password once connected, just be sure not to delete the admin account, as this would disrupt the connection.' . "\r";
2698 + $csv .= "#\r";
2699 + $csv .= implode( ',', $allowedHeaders ) . "\r";
1914 2700 MainWP_DB::data_seek( $websites, 0 );
1915 2701 while ( $websites && ( $website = MainWP_DB::fetch_object( $websites ) ) ) {
1916 2702 if ( empty( $website ) ) {
1917 2703 continue;
1918 2704 }
1919 - $row = MainWP_Utility::map_site( $website, $keys, false );
2705 + $row = MainWP_Utility::map_site( $website, $keys, false );
2706 + // MWP-1548: decrypt http_user / http_pass before they hit
2707 + // the CSV. The export file is meant for cross-install
2708 + // transfer (admin re-imports on another dashboard); a
2709 + // file_key envelope from this install would be unreadable
2710 + // there. Plaintext on disk preserves today's portability
2711 + // contract -- the export was already plaintext pre-fix,
2712 + // and this hop neither widens nor narrows that exposure.
2713 + if ( isset( $row['http_user'] ) ) {
2714 + $row['http_user'] = MainWP_Credential_Storage::decrypt_credential( $row['http_user'] );
2715 + }
2716 + if ( isset( $row['http_pass'] ) ) {
2717 + $row['http_pass'] = MainWP_Credential_Storage::decrypt_credential( $row['http_pass'] );
2718 + }
2719 +
2720 + $row = array_map(
2721 + static function ( $value ) {
2722 + return str_replace( '"', '""', (string) $value );
2723 + },
2724 + $row
2725 + );
2726 +
1920 2727 $csv .= '"' . implode( '","', $row ) . '"' . "\r";
1921 2728 }
1922 2729
1923 2730 header( 'Content-Type: text/csv; charset=utf-8' );
@@ -1955,20 +2762,13 @@
1955 2762 *
1956 2763 * Creates the MainWP Help Documentation List for the help component in the sidebar.
1957 2764 */
1958 2765 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
2766 + if ( isset( $_GET['page'] ) && ( 'Settings' === $_GET['page'] || 'SettingsAdvanced' === $_GET['page'] || 'MainWPTools' === $_GET['page'] || 'MonitoringSettings' === $_GET['page'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
1960 2767 ?>
1961 2768 <p><?php esc_html_e( 'If you need help with your MainWP Dashboard settings, please review following help documents', 'mainwp' ); ?></p>
1962 2769 <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>
2770 + <div class="item"><i class="external alternate icon"></i> <a href="https://docs.mainwp.com/sites/management/mainwp-dashboard-settings#mainwp-dashboard-settings" target="_blank">MainWP Dashboard Settings</a></div>
1971 2771 </div>
1972 2772 <?php
1973 2773 /**
1974 2774 * Action: mainwp_settings_help_item
@@ -1983,6 +2783,58 @@
1983 2783 */
1984 2784 do_action( 'mainwp_settings_help_item' );
1985 2785
1986 2786 }
2787 + }
2788 +
2789 + /**
2790 + * Method render_monitoring()
2791 + *
2792 + * Render Monitoring Settings.
2793 + *
2794 + * @uses \MainWP\Dashboard\MainWP_Monitoring_View::render_settings()
2795 + */
2796 + public static function render_monitoring() {
2797 + if ( ! \mainwp_current_user_can( 'dashboard', 'manage_dashboard_settings' ) ) {
2798 + \mainwp_do_not_have_permissions( esc_html__( 'manage dashboard settings', 'mainwp' ) );
2799 + return;
2800 + }
2801 + static::render_header( 'Monitoring' );
2802 + ?>
2803 + <div id="mainwp-monitoring-settings" class="ui padded segment">
2804 + <?php if ( isset( $_GET['message'] ) && 'saved' === sanitize_text_field( wp_unslash( $_GET['message'] ) ) ) : // phpcs:ignore WordPress.Security.NonceVerification.Recommended ?>
2805 + <div class="ui green message"><i class="close icon"></i><?php esc_html_e( 'Monitoring settings have been saved successfully!', 'mainwp' ); ?></div>
2806 + <?php endif; ?>
2807 + <div class="ui form">
2808 + <form method="POST" action="">
2809 + <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
2810 + <input type="hidden" name="wp_nonce" value="<?php echo esc_attr( wp_create_nonce( 'MonitoringSettings' ) ); ?>" />
2811 + <?php
2812 + /**
2813 + * Action: mainwp_monitoring_settings_form_top
2814 + *
2815 + * Fires at the top of monitoring settings form.
2816 + *
2817 + * @since 4.1
2818 + */
2819 + do_action( 'mainwp_monitoring_settings_form_top' );
2820 + ?>
2821 + <?php MainWP_Monitoring_View::render_settings(); ?>
2822 + <?php
2823 + /**
2824 + * Action: mainwp_monitoring_form_bottom
2825 + *
2826 + * Fires at the bottom of mainwp monitoring form.
2827 + *
2828 + * @since 4.1
2829 + */
2830 + do_action( 'mainwp_monitoring_settings_form_bottom' );
2831 + ?>
2832 + <div class="ui divider"></div>
2833 + <input type="submit" name="submit" id="submit-monitoring" class="ui green big button" value="<?php esc_attr_e( 'Save Settings', 'mainwp' ); ?>"/>
2834 + </form>
2835 + </div>
2836 + </div>
2837 + <?php
2838 + static::render_footer( 'Monitoring' );
1987 2839 }
1988 2840 }