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

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

915 lines 44.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * MainWP Setup Wizard
4 *
5 * MainWP Quick Setup Wizard enables you to quickly set basic plugin settings
6 *
7 * @package MainWP/Setup_Wizard
8 */
9
10 namespace MainWP\Dashboard;
11
12 /**
13 * Copyright
14 * Plugin: WooCommerce
15 * Plugin URI: http://www.woothemes.com/woocommerce/
16 * Description: An e-commerce toolkit that helps you sell anything. Beautifully.
17 * Version: 2.4.4
18 * Author: WooThemes
19 * Author URI: http://woothemes.com
20 */
21
22 /**
23 * Class MainWP_Setup_Wizard
24 *
25 * @package MainWP\Dashboard
26 */
27 class MainWP_Setup_Wizard {
28
29 /**
30 * Private variable to hold current quick setup wizard step.
31 *
32 * @var string Current QSW step.
33 */
34 private $step = '';
35
36 /**
37 * Private variable to hold quick setup wizard steps.
38 *
39 * @var array QSW steps.
40 */
41 private $steps = array();
42
43 /**
44 * MainWP_Setup_Wizard constructor.
45 *
46 * Run each time the class is called.
47 */
48 public function __construct() {
49 add_action( 'admin_menu', array( $this, 'admin_menus' ) );
50 add_action( 'admin_init', array( $this, 'admin_init' ), 999 );
51 }
52
53 /**
54 * Method admin_menus()
55 *
56 * Add Quick Setup Wizard page.
57 */
58 public function admin_menus() {
59 add_dashboard_page( '', '', 'manage_options', 'mainwp-setup', '' );
60 }
61
62 /**
63 * Medthod admin_init()
64 *
65 * Initiate Quick Setup Wizard page.
66 */
67 public function admin_init() {
68 if ( empty( $_GET['page'] ) || 'mainwp-setup' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
69 return;
70 }
71 $this->steps = array(
72 'welcome' => array(
73 'name' => esc_html__( 'Welcome', 'mainwp' ),
74 'view' => array( $this, 'mwp_setup_welcome' ),
75 'handler' => '',
76 ),
77 'introduction' => array(
78 'name' => esc_html__( 'Introduction', 'mainwp' ),
79 'view' => array( $this, 'mwp_setup_introduction' ),
80 'handler' => array( $this, 'mwp_setup_introduction_save' ),
81 ),
82 'system_check' => array(
83 'name' => esc_html__( 'System', 'mainwp' ),
84 'view' => array( $this, 'mwp_setup_system_requirements' ),
85 'handler' => array( $this, 'mwp_setup_system_requirements_save' ),
86 ),
87 'connect_first_site' => array(
88 'name' => esc_html__( 'Connect', 'mainwp' ),
89 'view' => array( $this, 'mwp_setup_connect_first_site' ),
90 'handler' => array( $this, 'mwp_setup_connect_first_site_save' ),
91 ),
92 'add_client' => array(
93 'name' => esc_html__( 'Add Client', 'mainwp' ),
94 'view' => array( $this, 'mwp_setup_add_client' ),
95 'handler' => '',
96 ),
97 'monitoring' => array(
98 'name' => esc_html__( 'Monitoring', 'mainwp' ),
99 'view' => array( $this, 'mwp_setup_monitoring' ),
100 'handler' => array( $this, 'mwp_setup_monitoring_save' ),
101 ),
102 'next_steps' => array(
103 'name' => esc_html__( 'Finish', 'mainwp' ),
104 'view' => array( $this, 'mwp_setup_ready' ),
105 'handler' => '',
106 ),
107 );
108
109 $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
110
111 wp_enqueue_script( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.js', array( 'jquery' ), MAINWP_VERSION, false );
112 wp_localize_script( 'mainwp-setup', 'mainwpSetupLocalize', array( 'nonce' => wp_create_nonce( 'MainWPSetup' ) ) );
113 wp_enqueue_script( 'mainwp', MAINWP_PLUGIN_URL . 'assets/js/mainwp.js', array( 'jquery' ), MAINWP_VERSION, true );
114 wp_enqueue_script( 'mainwp-clients', MAINWP_PLUGIN_URL . 'assets/js/mainwp-clients.js', array(), MAINWP_VERSION, true );
115 wp_enqueue_script( 'mainwp-setup', MAINWP_PLUGIN_URL . 'assets/js/mainwp-setup.js', array( 'jquery', 'fomantic-ui' ), MAINWP_VERSION, true );
116 wp_enqueue_script( 'mainwp-ui', MAINWP_PLUGIN_URL . 'assets/js/mainwp-ui.js', array(), MAINWP_VERSION, true );
117 wp_enqueue_style( 'mainwp', MAINWP_PLUGIN_URL . 'assets/css/mainwp.css', array(), MAINWP_VERSION );
118 wp_enqueue_style( 'mainwp-fonts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fonts.css', array(), MAINWP_VERSION );
119 wp_enqueue_style( 'fomantic', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.css', array(), MAINWP_VERSION );
120 wp_enqueue_style( 'mainwp-fomantic', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fomantic.css', array(), MAINWP_VERSION );
121
122 // load custom MainWP theme.
123 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
124 if ( ! empty( $selected_theme ) ) {
125 if ( 'dark' === $selected_theme ) {
126 wp_enqueue_style( 'mainwp-custom-dashboard-extension-dark-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-dark-theme.css', array(), MAINWP_VERSION );
127 } elseif ( 'wpadmin' === $selected_theme ) {
128 wp_enqueue_style( 'mainwp-custom-dashboard-extension-wp-admin-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-wpadmin-theme.css', array(), MAINWP_VERSION );
129 } elseif ( 'minimalistic' === $selected_theme ) {
130 wp_enqueue_style( 'mainwp-custom-dashboard-extension-minimalistic-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-minimalistic-theme.css', array(), MAINWP_VERSION );
131 } elseif ( 'default' === $selected_theme ) {
132 wp_enqueue_style( 'mainwp-custom-dashboard-extension-default-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-default-theme.css', array(), MAINWP_VERSION );
133 } else {
134 $dirs = MainWP_Settings::get_instance()->get_custom_theme_folder();
135 $custom_theme_url = $dirs[1];
136 wp_enqueue_style( 'mainwp-custom-dashboard-theme', $custom_theme_url . $selected_theme, array(), MAINWP_VERSION );
137 }
138 }
139
140 if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
141 call_user_func( $this->steps[ $this->step ]['handler'] );
142 }
143
144 if ( MainWP_Utility::instance()->is_disabled_functions( 'error_log' ) || ! function_exists( '\error_log' ) ) {
145 error_reporting(0); // phpcs:ignore -- try to disabled the error_log somewhere in WP.
146 }
147
148 ob_start();
149 $this->setup_wizard_header();
150 $this->setup_wizard_steps();
151 $this->setup_wizard_content();
152 $this->setup_wizard_footer();
153 ?>
154 <?php
155 if ( get_option( 'mainwp_enable_guided_tours', 0 ) ) {
156 self::mainwp_usetiful_tours();
157 }
158 exit;
159 }
160
161 /**
162 * Method get_next_step_link()
163 *
164 * Get the link for the next step.
165 *
166 * @param string $step Next step link.
167 *
168 * @return string Link for next step.
169 */
170 public function get_next_step_link( $step = '' ) {
171 if ( ! empty( $step ) && isset( $step, $this->steps ) ) {
172 return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $step ) ) );
173 }
174 $keys = array_keys( $this->steps );
175 return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] ) ) );
176 }
177
178 /**
179 * Method get_back_step_link()
180 *
181 * Get the link for the previouse step.
182 *
183 * @param string $step Previouse step link.
184 *
185 * @return string Link for previouse step.
186 */
187 public function get_back_step_link( $step = '' ) {
188 if ( ! empty( $step ) && isset( $step, $this->steps ) ) {
189 return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $step ) ) );
190 }
191 $keys = array_keys( $this->steps );
192 return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) - 1 ] ) ) );
193 }
194
195 /**
196 * Method setup_wizard_header()
197 *
198 * Render Setup Wizard's header.
199 */
200 public function setup_wizard_header() {
201 $selected_theme = MainWP_Settings::get_instance()->get_selected_theme();
202 ?>
203 <!DOCTYPE html>
204 <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?> class="mainwp-quick-setup">
205 <head>
206 <meta name="viewport" content="width=device-width" />
207 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
208 <title><?php esc_html_e( 'MainWP &rsaquo; Setup Wizard', 'mainwp' ); ?></title>
209 <?php wp_print_scripts( 'mainwp' ); ?>
210 <?php wp_print_scripts( 'mainwp-clients' ); ?>
211 <?php wp_print_scripts( 'mainwp-setup' ); ?>
212 <?php wp_print_scripts( 'fomantic' ); ?>
213 <?php wp_print_scripts( 'mainwp-ui' ); ?>
214 <?php
215 // to fix warning.
216 /**
217 * Remove the deprecated `print_emoji_styles` handler.
218 * It avoids breaking style generation with a deprecation message.
219 */
220 $has_emoji_styles = has_action( 'admin_print_styles', 'print_emoji_styles' );
221 if ( $has_emoji_styles ) {
222 remove_action( 'admin_print_styles', 'print_emoji_styles' );
223 }
224 ?>
225 <?php do_action( 'admin_print_styles' ); ?>
226 <script type="text/javascript"> var ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>';</script>
227 <script type="text/javascript">var mainwp_ajax_nonce = "<?php echo esc_js( wp_create_nonce( 'mainwp_ajax' ) ); ?>", mainwp_js_nonce = "<?php echo esc_js( wp_create_nonce( 'mainwp_nonce' ) ); ?>";</script>
228 </head>
229 <body class="mainwp-ui <?php echo ! empty( $selected_theme ) ? 'mainwp-custom-theme' : ''; ?> mainwp-ui-setup">
230 <div class="ui hidden divider"></div>
231 <div class="ui hidden divider"></div>
232 <div id="mainwp-quick-setup-wizard" class="ui padded container segment">
233 <?php
234 }
235
236 /**
237 * Method setup_wizard_footer()
238 *
239 * Render Setup Wizard's footer.
240 */
241 public function setup_wizard_footer() {
242 ?>
243 </div>
244 <div class="ui grid">
245 <div class="row">
246 <div class="center aligned column">
247 <a class="" href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>"><?php esc_html_e( 'Quit MainWP Quick Setup Wizard and Go to WP Admin', 'mainwp' ); ?></a> | <a class="" href="<?php echo esc_url( admin_url( 'admin.php?page=mainwp_tab' ) ); ?>"><?php esc_html_e( 'Quit MainWP Quick Setup Wizard and Go to MainWP', 'mainwp' ); ?></a>
248 </div>
249 </div>
250 </div>
251 </body>
252 </html>
253 <?php
254 }
255
256 /**
257 * Method setup_wizard_steps()
258 *
259 * Render Setup Wizards Steps.
260 */
261 public function setup_wizard_steps() {
262 $ouput_steps = $this->steps;
263 ?>
264 <div id="mainwp-quick-setup-wizard-steps" class="ui ordered fluid steps" style="">
265 <?php foreach ( $ouput_steps as $step_key => $step ) { ?>
266 <?php
267 if ( isset( $step['hidden'] ) && $step['hidden'] ) {
268 continue;
269 }
270
271 if ( 'welcome' === $step_key ) {
272 continue;
273 }
274 ?>
275 <div class="step
276 <?php
277 if ( $step_key === $this->step ) {
278 echo 'active';
279 } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
280 echo 'completed'; }
281 ?>
282 ">
283 <div class="content">
284 <div class="title"><?php echo esc_html( $step['name'] ); ?></div>
285 </div>
286 </div>
287 <?php } ?>
288 </div>
289 <?php
290 }
291
292 /**
293 * Method setup_wizard_content()
294 *
295 * Render setup Wizard's current step view.
296 */
297 public function setup_wizard_content() {
298 echo '<div class="mainwp-quick-setup-wizard-steps-content" style="margin-top:3em;">';
299 call_user_func( $this->steps[ $this->step ]['view'] );
300 echo '</div>';
301 echo '<div class="ui clearing hidden divider"></div>';
302 }
303
304 /**
305 * Method mwp_setup_welcome()
306 *
307 * Renders the Welcome screen of the Quick Start Wizard
308 */
309 public function mwp_setup_welcome() {
310 $is_new = MainWP_Demo_Handle::get_instance()->is_new_instance();
311 $enabled_demo = apply_filters( 'mainwp_demo_mode_enabled', false );
312 $count_sites = MainWP_DB::instance()->get_websites_count();
313 ?>
314 <h1 class="ui header"><?php esc_html_e( 'Welcome to your MainWP Dashboard!', 'mainwp' ); ?></h1>
315 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
316 <div class="ui hidden divider"></div>
317 <h3><?php esc_html_e( 'Are you ready to get started adding your sites?', 'mainwp' ); ?></h3>
318 <a class="ui big green basic button" href="<?php echo esc_url( admin_url( 'admin.php?page=mainwp-setup&step=introduction' ) ); ?>"><?php esc_html_e( 'Start the MainWP Quick Setup Wizard', 'mainwp' ); ?></a>
319 <?php if ( 0 === $count_sites ) : ?>
320 <div class="ui hidden divider"></div>
321 <h3><?php esc_html_e( 'Would you like to see Demo content first? ', 'mainwp' ); ?> - <?php printf( esc_html__( '%sWhat is this?%s', 'mainwp' ), '<a href="https://www.youtube.com/watch?v=fCHT47AKt7s" target="_blank">', '</a>' ); ?></h3>
322 <p><?php esc_attr_e( 'Explore MainWP\'s capabilities using our pre-loaded demo content.', 'mainwp' ); ?></p>
323 <p><?php esc_attr_e( 'It\'s the perfect way to experience the benefits and ease of use MainWP provides without connecting to any of your own sites.', 'mainwp' ); ?></p>
324 <p><?php esc_html_e( 'The demo content serves as placeholder data to give you a feel for the MainWP Dashboard. Please note that because no real websites are connected in this demo, some functionality will be restricted. Features that require a connection to actual websites will be disabled for the duration of the demo.', 'mainwp' ); ?></p>
325 <p><?php esc_attr_e( 'Click this button to import the Demo content to your MainWP Dashboard and enable the Demo mode.', 'mainwp' ); ?></p>
326 <p><span><button class="ui big green button mainwp-import-demo-data-button" page-import="qsw-import" <?php echo ( ! $is_new || $enabled_demo ? 'disabled="disabled"' : '' ); ?>><?php esc_html_e( 'Enable Demo Mode With Guided Tours', 'mainwp' ); ?></button></span></p>
327 <div class="ui blue message">
328 <?php printf( esc_html__( 'Guided tours 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>' ); ?>
329 </div>
330 <?php endif; ?>
331 <?php
332 MainWP_System_View::render_comfirm_modal();
333 }
334
335 /**
336 * Method mwp_setup_introduction()
337 *
338 * Renders the Introduction screen of the Quick Start Wizard
339 */
340 public function mwp_setup_introduction() {
341 ?>
342 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
343 <h1 class="ui header"><?php esc_html_e( 'MainWP Quick Setup Wizard', 'mainwp' ); ?></h1>
344 <div><?php esc_html_e( 'Thank you for choosing MainWP for managing your WordPress sites. This quick setup wizard will help you configure the basic settings. It\'s completely optional and shouldn\'t take longer than five minutes.', 'mainwp' ); ?></div>
345 <div class="ui hidden divider"></div>
346 <a href="https://kb.mainwp.com/docs/quick-setup-wizard-video/" target="_blank" class="ui big icon green button"><i class="youtube icon"></i> <?php esc_html_e( 'Walkthrough', 'mainwp' ); ?></a>
347 <div class="ui hidden divider"></div>
348 <p><?php esc_html_e( 'If you don\'t want to go through the setup wizard, you can skip and proceed to your MainWP Dashboard by clicking the "Not right now" button. If you change your mind, you can come back later by starting the Setup Wizard from the MainWP > Settings > MainWP Tools page!', 'mainwp' ); ?></p>
349 <div class="ui hidden divider"></div>
350 <form method="post" class="ui form">
351 <h1><?php esc_html_e( 'MainWP Guided Tours', 'mainwp' ); ?> <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></h1>
352 <?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?>
353 <div class="ui blue message">
354 <?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>' ); ?>
355 </div>
356 <div class="ui form">
357 <div class="field">
358 <div class="ui hidden divider"></div>
359 <label><?php esc_html_e( 'Do you want to enable MainWP Guided Tours?', 'mainwp' ); ?></label>
360 <div class="ui hidden divider"></div>
361 <div class="ui toggle checkbox">
362 <input type="checkbox" name="mainwp-guided-tours-option" id="mainwp-guided-tours-option" checked="true">
363 <label for="mainwp-guided-tours-option"><?php esc_html_e( 'Select to enable the MainWP Guided Tours.', 'mainwp' ); ?><span class="ui left pointing green label"><?php esc_html_e( 'Highly recommended if new to MainWP!', 'mainwp' ); ?></span></label>
364 </div>
365 </div>
366 </div>
367 <div class="ui hidden divider"></div>
368 <p><?php esc_html_e( 'To go back to the WordPress Admin section, click the "Back to WP Admin" button.', 'mainwp' ); ?></p>
369 <div class="ui hidden divider"></div>
370 <div class="ui hidden divider"></div>
371 <div class="ui hidden divider"></div>
372 <input type="submit" class="ui big green right floated button" value="<?php esc_html_e( 'Let\'s Go!', 'mainwp' ); ?>" name="save_step" />
373 <a href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>" class="ui big button"><?php esc_html_e( 'Back to WP Admin', 'mainwp' ); ?></a>
374 <a href="<?php echo esc_url( admin_url( 'admin.php?page=managesites&do=new' ) ); ?>" class="ui big button"><?php esc_html_e( 'Not Right Now', 'mainwp' ); ?></a>
375 <?php wp_nonce_field( 'mwp-setup' ); ?>
376 </form>
377 <?php
378 MainWP_System_View::render_comfirm_modal();
379 }
380
381
382 /**
383 * Method mwp_setup_system_requirements()
384 *
385 * Render System Requirements Step.
386 *
387 * @uses \MainWP\Dashboard\MainWP_Server_Information::render_quick_setup_system_check()
388 */
389 public function mwp_setup_system_requirements() {
390 ?>
391 <h1><?php esc_html_e( 'System Requirements Check', 'mainwp' ); ?></h1>
392 <?php MainWP_System_View::mainwp_warning_notice(); ?>
393 <form method="post" class="ui form">
394 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
395 <?php
396 $show_ssl = false;
397 if ( MainWP_Server_Information_Handler::is_openssl_config_warning() ) {
398 $openssl_loc = MainWP_System_Utility::get_openssl_conf();
399 ?>
400 <div class="ui secondary segment">
401 <div class="grouped fields">
402 <label><?php esc_html_e( 'What is the openssl.cnf file location on your computer?', 'mainwp' ); ?></label>
403 <div class="field" id="mainwp-setup-installation-openssl-location">
404 <div class="ui fluid input">
405 <input type="text" name="mwp_setup_openssl_lib_location" value="<?php echo esc_attr( $openssl_loc ); ?>">
406 </div>
407 <div><em><?php esc_html_e( 'Due to bug with PHP on some servers, enter the openssl.cnf file location so MainWP Dashboard can connect to your child sites. If your openssl.cnf file is saved to a different path from what is entered above please enter your exact path. ', 'mainwp' ); ?><?php printf( esc_html__( '%1$sClick here%2$s to see how to find the OpenSSL.cnf file.', '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></div>
408 </div>
409 </div>
410 </div>
411 <?php
412 $show_ssl = true;
413 }
414 ?>
415 <div class="ui message warning"><?php esc_html_e( 'Any warning here may cause the MainWP Dashboard to malfunction. After you complete the Quick Start setup it is recommended to contact your host’s support and updating your server configuration for optimal performance.', 'mainwp' ); ?></div>
416 <?php MainWP_Server_Information::render_quick_setup_system_check(); ?>
417 <div class="ui hidden divider"></div>
418 <div class="ui hidden divider"></div>
419 <div class="ui hidden divider"></div>
420 <?php
421 if ( $show_ssl ) {
422 ?>
423 <input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" />
424 <?php
425 } else {
426 ?>
427 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big green right floated button"><?php esc_html_e( 'Continue', 'mainwp' ); ?></a>
428 <?php } ?>
429 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big button"><?php esc_html_e( 'Skip', 'mainwp' ); ?></a>
430 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
431 <?php wp_nonce_field( 'mwp-setup' ); ?>
432 </form>
433 <?php
434 }
435
436
437 /**
438 * Method mwp_setup_introduction_save()
439 *
440 * Installation Step save to DB.
441 *
442 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
443 */
444 public function mwp_setup_introduction_save() {
445 check_admin_referer( 'mwp-setup' );
446 $enabled_tours = ! isset( $_POST['mainwp-guided-tours-option'] ) ? 0 : 1; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
447 MainWP_Utility::update_option( 'mainwp_enable_guided_tours', $enabled_tours );
448 wp_safe_redirect( $this->get_next_step_link() );
449 exit;
450 }
451
452 /**
453 * Method mwp_setup_connect_first_site_save()
454 *
455 * Installation Step after connect first site.
456 */
457 public function mwp_setup_connect_first_site_save() {
458 check_admin_referer( 'mwp-setup' );
459 if ( isset( $_POST['mainwp-qsw-confirm-add-new-client'] ) && ! empty( $_POST['mainwp-qsw-confirm-add-new-client'] ) ) {
460 wp_safe_redirect( $this->get_next_step_link() );
461 } else {
462 wp_safe_redirect( $this->get_next_step_link( 'monitoring' ) );
463 }
464 exit;
465 }
466
467 /**
468 * Method mwp_setup_system_requirements_save()
469 *
470 * Installation Step save to DB.
471 *
472 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
473 */
474 public function mwp_setup_system_requirements_save() {
475 check_admin_referer( 'mwp-setup' );
476 if ( isset( $_POST['mwp_setup_openssl_lib_location'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
477 MainWP_Utility::update_option( 'mainwp_opensslLibLocation', isset( $_POST['mwp_setup_openssl_lib_location'] ) ? sanitize_text_field( wp_unslash( $_POST['mwp_setup_openssl_lib_location'] ) ) : '' ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
478 }
479 wp_safe_redirect( $this->get_next_step_link() );
480 exit;
481 }
482
483
484
485 /**
486 * Method mwp_setup_connect_first_site_already()
487 *
488 * Render Added first Child Site Step form.
489 */
490 public function mwp_setup_connect_first_site_already() {
491 $count_clients = MainWP_DB_Client::instance()->count_total_clients();
492 ?>
493 <h1 class="ui header"><?php esc_html_e( 'Congratulations!', 'mainwp' ); ?></h1>
494 <p><?php esc_html_e( 'You have successfully connected your first site to your MainWP Dashboard!', 'mainwp' ); ?></p>
495 <div class="ui form">
496 <form method="post" class="ui form">
497 <?php if ( empty( $count_clients ) ) { ?>
498 <div class="field">
499 <label><?php esc_html_e( 'Do you want to create a client for your first child site?', 'mainwp' ); ?></label>
500 <div><?php esc_html_e( 'By adding a new client, you streamline site management within MainWP. Assigning sites to clients allows you to group and manage websites according to the clients they belong to for better organization and accessibility.', 'mainwp' ); ?></div>
501 <div class="ui hidden divider"></div>
502 <div class="ui toggle checkbox">
503 <input type="checkbox" name="mainwp-qsw-confirm-add-new-client" id="mainwp-qsw-confirm-add-new-client" checked="true"/>
504 <label><?php esc_html_e( 'Select to create a New Client', 'mainwp' ); ?></label>
505 </div>
506 </div>
507 <?php } ?>
508 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
509 <div class="ui clearing hidden divider"></div>
510 <div class="ui hidden divider"></div>
511 <div class="ui hidden divider"></div>
512 <input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" />
513 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
514 <?php wp_nonce_field( 'mwp-setup' ); ?>
515 <input type="hidden" id="nonce_secure_data" mainwp_addwp="<?php echo esc_js( wp_create_nonce( 'mainwp_addwp' ) ); ?>" mainwp_checkwp="<?php echo esc_attr( wp_create_nonce( 'mainwp_checkwp' ) ); ?>" />
516 </form>
517 </div>
518 <?php
519 }
520
521
522 /**
523 * Method mwp_setup_connect_first_site()
524 *
525 * Render Install first Child Site Step form.
526 */
527 public function mwp_setup_connect_first_site() {
528 $count = MainWP_DB::instance()->get_websites_count( null, true );
529 if ( 1 <= $count ) {
530 $this->mwp_setup_connect_first_site_already();
531 return;
532 }
533 ?>
534 <h1><?php esc_html_e( 'Connect Your First Child Site', 'mainwp' ); ?></h1>
535 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-qsw-add-site-message' ) ) { ?>
536 <div class="ui info message">
537 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-qsw-add-site-message"></i>
538 <?php esc_html_e( 'MainWP requires the MainWP Child plugin to be installed and activated on the WordPress site that you want to connect to your MainWP Dashboard. ', 'mainwp' ); ?>
539 <?php esc_html_e( 'To install the MainWP Child plugin, please follow these steps:', 'mainwp' ); ?>
540 <ol>
541 <li><?php printf( esc_html__( 'Login to the WordPress site you want to connect %1$s(open it in a new browser tab)%2$s', 'mainwp' ), '<em>', '</em>' ); ?></li>
542 <li><?php printf( esc_html__( 'Go to the %1$sWP > Plugins%2$s page', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
543 <li><?php printf( esc_html__( 'Click %1$sAdd New%2$s to install a new plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
544 <li><?php printf( esc_html__( 'In the %1$sSearch Field%2$s, enter "MainWP Child" and once the plugin shows, click the Install button', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
545 <li><?php printf( esc_html__( '%1$sActivate%2$s the plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
546 </ol>
547 </div>
548 <?php } ?>
549 <div class="ui form">
550 <div class="field">
551 <div class="ui hidden divider"></div>
552 <label><?php esc_html_e( 'Is MainWP Child plugin installed and activated on the WordPress site that you want to connect?', 'mainwp' ); ?></label>
553 <div class="ui hidden divider"></div>
554 <div class="ui toggle checkbox">
555 <input type="checkbox" name="mainwp-qsw-verify-mainwp-child-active" id="mainwp-qsw-verify-mainwp-child-active">
556 <label for="mainwp-qsw-verify-mainwp-child-active"><?php esc_html_e( 'Select to confirm that the MainWP Child plugin is active.', 'mainwp' ); ?></label>
557 </div>
558 </div>
559 </div>
560 <form method="post" class="ui form">
561 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
562 <div id="mainwp-qsw-connect-site-form" style="display:none">
563 <div class="ui hidden divider"></div>
564 <div class="ui hidden divider"></div>
565 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
566 <div class="ui red message" id="mainwp-error-zone" style="display:none"></div>
567 <div class="ui green message" id="mainwp-success-zone" style="display:none"></div>
568 <div class="ui info message" id="mainwp-info-zone" style="display:none"></div>
569 <div class="ui hidden divider"></div>
570 <div class="ui secondary segment">
571 <div class="ui hidden divider"></div>
572 <div class="ui hidden divider"></div>
573 <div class="ui horizontal divider"><?php esc_html_e( 'Required Fields', 'mainwp' ); ?></div>
574 <div class="ui hidden divider"></div>
575 <div class="ui hidden divider"></div>
576 <div class="field">
577 <label><?php esc_html_e( 'What is the site URL? ', 'mainwp' ); ?></label>
578 <div class="ui left action input">
579 <select class="ui compact selection dropdown" id="mainwp_managesites_add_wpurl_protocol" name="mainwp_managesites_add_wpurl_protocol" style="width:120px;padding:0px;">
580 <option value="https">https://</option>
581 <option value="http">http://</option>
582 </select>
583 <input type="text" id="mainwp_managesites_add_wpurl" name="mainwp_managesites_add_wpurl" value="" placeholder="yoursite.com" />
584 </div>
585 </div>
586 <div class="field">
587 <label><?php esc_html_e( 'What is your administrator username on that site? ', 'mainwp' ); ?></label>
588 <input type="text" id="mainwp_managesites_add_wpadmin" name="mainwp_managesites_add_wpadmin" value="" />
589 </div>
590 <div class="field">
591 <label><?php esc_html_e( 'Add site title. If left blank URL is used.', 'mainwp' ); ?></label>
592 <input type="text" id="mainwp_managesites_add_wpname" name="mainwp_managesites_add_wpname" value="" />
593 </div>
594 <div class="ui hidden divider"></div>
595 <a href="#" id="mainwp-toggle-optional-settings"><i class="ui eye icon"></i> <?php esc_html_e( 'Advanced options', 'mainwp' ); ?></a>
596 <div class="ui hidden divider"></div>
597 <div id="mainwp-qsw-optional-settings-form" style="display:none">
598 <div class="ui hidden divider"></div>
599 <div class="ui horizontal divider"><?php esc_html_e( 'Advanced Options (optional)', 'mainwp' ); ?></div>
600 <div class="ui hidden divider"></div>
601 <div class="ui hidden divider"></div>
602 <div class="field">
603 <label><?php esc_html_e( 'Did you generate unique security ID on the site? If yes, copy it here, if not, leave this field blank. ', 'mainwp' ); ?></label>
604 <input type="text" id="mainwp_managesites_add_uniqueId" name="mainwp_managesites_add_uniqueId" value="" />
605 </div>
606 </div>
607 </div>
608 </div>
609 <div class="ui clearing hidden divider"></div>
610 <div class="ui hidden divider"></div>
611 <div class="ui hidden divider"></div>
612 <input type="button" style="display:none" name="mainwp_managesites_add" id="mainwp_managesites_add" class="ui button green big right floated" value="<?php esc_attr_e( 'Connect Site', 'mainwp' ); ?>" />
613 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" id="mainwp_addsite_continue_button" class="ui big green right floated button"><?php esc_html_e( 'Continue', 'mainwp' ); ?></a>
614 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
615 <?php wp_nonce_field( 'mwp-setup' ); ?>
616 <input type="hidden" id="nonce_secure_data" mainwp_addwp="<?php echo esc_js( wp_create_nonce( 'mainwp_addwp' ) ); ?>" mainwp_checkwp="<?php echo esc_attr( wp_create_nonce( 'mainwp_checkwp' ) ); ?>" />
617 </form>
618 <?php
619 }
620
621 /**
622 * Method mwp_setup_add_client()
623 *
624 * Render Add first Client Step form.
625 */
626 public function mwp_setup_add_client() {
627 $count = MainWP_DB::instance()->get_websites_count( null, true );
628 $count_clients = MainWP_DB_Client::instance()->count_total_clients();
629 if ( ! empty( $count_clients ) ) {
630 ?>
631 <h1 class="ui header"><?php esc_html_e( 'Congratulations!', 'mainwp' ); ?></h1>
632 <p><?php esc_html_e( 'You have successfully created your first Client.', 'mainwp' ); ?></p>
633 <?php
634 } else {
635 $first_site_id = get_transient( 'mainwp_transient_just_connected_site_id' );
636 ?>
637 <h1><?php esc_html_e( 'Create a Client', 'mainwp' ); ?></h1>
638 <div class="ui secondary segment">
639 <form action="" method="post" enctype="multipart/form-data" name="createclient_form" id="createclient_form" class="add:clients: validate">
640 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
641 <div class="">
642 <div class="ui hidden divider"></div>
643 <div class="ui message" id="mainwp-message-zone-client" style="display:none;"></div>
644 <div id="mainwp-add-new-client-form" >
645 <?php $this->render_add_client_content( false, true ); ?>
646 </div>
647 </div>
648 <input type="hidden" name="selected_first_site" value="<?php echo intval( $first_site_id ); ?>">
649 </form>
650 <div class="ui clearing hidden divider"></div>
651 </div>
652 <?php
653 }
654 ?>
655 <div class="ui hidden divider"></div>
656 <div class="ui hidden divider"></div>
657 <input type="button" style="display:none" name="createclient" current-page="qsw-add" id="bulk_add_createclient" class="ui big green right floated button" value="<?php echo esc_attr__( 'Add Client', 'mainwp' ); ?> "/>
658 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" id="mainwp_qsw_add_client_continue_button" class="ui big green right floated button"><?php esc_html_e( 'Continue', 'mainwp' ); ?></a>
659 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
660 <?php
661 }
662
663
664 /**
665 * Method render_add_client_content().
666 *
667 * Renders add client content window.
668 */
669 public function render_add_client_content() {
670 $edit_client = false;
671 $client_id = 0;
672 $client_image = '';
673 $default_client_fields = MainWP_Client_Handler::get_mini_default_client_fields();
674 ?>
675 <div class="ui form">
676 <?php
677 foreach ( $default_client_fields as $field_name => $field ) {
678 $db_field = isset( $field['db_field'] ) ? $field['db_field'] : '';
679 $val = $edit_client && '' !== $db_field && property_exists( $edit_client, $db_field ) ? $edit_client->{$db_field} : '';
680 $tip = isset( $field['tooltip'] ) ? $field['tooltip'] : '';
681 ?>
682 <div class="field">
683 <label <?php echo '' !== $tip ? 'data-tooltip="' . esc_attr( $tip ) . '" data-inverted="" data-position="top left"' : ''; // phpcs:ignore WordPress.Security.EscapeOutput ?>><?php echo esc_html( $field['title'] ); ?></label>
684 <input type="text" value="<?php echo esc_html( $val ); ?>" id="mainwp_qsw_client_name_field" class="regular-text" name="client_fields[default_field][<?php echo esc_attr( $field_name ); ?>]"/>
685 </div>
686 <?php
687
688 if ( 'client.name' === $field_name ) {
689 ?>
690 <div class="field">
691 <label><?php esc_html_e( 'Client photo', 'mainwp' ); ?></label>
692 <div data-tooltip="<?php esc_attr_e( 'Upload a client photo.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
693 <div class="ui file input">
694 <input type="file" name="mainwp_client_image_uploader[client_field]" accept="image/*" data-inverted="" data-tooltip="<?php esc_attr_e( "Image must be 500KB maximum. It will be cropped to 310px wide and 70px tall. For best results us an image of this site. Allowed formats: jpeg, gif and png. Note that animated gifs aren't going to be preserved.", 'mainwp' ); ?>" />
695 </div>
696 </div>
697 </div>
698 <?php
699 }
700 }
701 $primary_contact_id = 0;
702 $temp = $this->get_add_contact_temp( false );
703 ?>
704 <div class="field">
705 <a href="javascript:void(0);" class="mainwp-client-add-contact" add-contact-temp="<?php echo esc_attr( $temp ); ?>"><i class="ui eye icon"></i><?php esc_html_e( 'Add Additional Contact', 'mainwp' ); ?></a>
706 </div>
707 <div class="ui section hidden divider after-add-contact-field"></div>
708 </div>
709 <input type="hidden" name="client_fields[client_id]" value="<?php echo intval( $client_id ); ?>">
710 <?php
711 }
712
713
714 /**
715 * Method get_add_contact_temp().
716 *
717 * Get add contact template.
718 *
719 * @param bool $echo_out Echo template or not.
720 */
721 public function get_add_contact_temp( $echo_out = false ) {
722
723 $input_name = 'new_contacts_field';
724 $contact_id = 0;
725 $contact_image = '';
726
727 ob_start();
728 ?>
729 <div class="ui hidden divider top-contact-fields"></div> <?php // must have class: top-contact-fields. ?>
730 <div class="ui horizontal divider"><?php esc_html_e( 'Add Contact', 'mainwp' ); ?></div>
731 <div class="ui hidden divider"></div>
732 <div class="ui hidden divider"></div>
733 <?php
734 $contact_fields = MainWP_Client_Handler::get_mini_default_contact_fields();
735 foreach ( $contact_fields as $field_name => $field ) {
736 $db_field = isset( $field['db_field'] ) ? $field['db_field'] : '';
737 $val = '';
738 $contact_id = '';
739 ?>
740 <div class="field">
741 <label><?php echo esc_html( $field['title'] ); ?></label>
742 <input type="text" value="<?php echo esc_html( $val ); ?>" class="regular-text" name="client_fields[<?php echo esc_html( $input_name ); ?>][<?php echo esc_attr( $field_name ); ?>][]"/>
743 </div>
744 <?php
745 }
746 ?>
747 <div class="field remove-contact-field-parent">
748 <a href="javascript:void(0);" contact-id="<?php echo intval( $contact_id ); ?>" class="mainwp-client-remove-contact"><i class="ui eye icon"></i><?php esc_html_e( 'Remove contact', 'mainwp' ); ?></a>
749 </div>
750 <div class="ui section hidden divider bottom-contact-fields"></div>
751 <?php
752 $html = ob_get_clean();
753 if ( $echo_out ) {
754 echo $html; //phpcs:ignore -- validated content.
755 }
756 return $html;
757 }
758
759 /**
760 * Method mwp_setup_monitoring()
761 *
762 * Render Monitoring Step.
763 */
764 public function mwp_setup_monitoring() {
765
766 $disableSitesMonitoring = (int) get_option( 'mainwp_disableSitesChecking', 1 );
767 $frequencySitesChecking = (int) get_option( 'mainwp_frequencySitesChecking', 60 );
768
769 $disableSitesHealthMonitoring = get_option( 'mainwp_disableSitesHealthMonitoring', 1 );
770 $sitehealthThreshold = get_option( 'mainwp_sitehealthThreshold', 80 ); // "Should be improved" threshold.
771
772 ?>
773 <h1 class="ui header">
774 <?php esc_html_e( 'Basic Uptime Monitoring', 'mainwp' ); ?>
775 </h1>
776 <div><?php esc_html_e( 'The MainWP Basic Uptime Monitoring function periodically sends HTTP requests to your child sites, based on a chosen frequency from every 5 minutes to once daily, to check their operational status. It uses a direct cURL request to obtain an HTTP Header response, alerting you via email if a site fails to return a Status Code 200 (OK). This feature operates independently of third-party services, providing a straightforward and no-cost option for uptime monitoring across all your managed sites. However, it does not diagnose the specific nature of errors leading to site unavailability.', 'mainwp' ); ?></div>
777 <div class="ui hidden divider"></div>
778 <div class="ui hidden divider"></div>
779 <form method="post" class="ui form">
780 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
781 <div class="ui grid field">
782 <div class="ui info message"><?php printf( esc_html__( 'Excessive checking can cause server resource issues. For frequent checks or lots of sites, we recommend the %1$sMainWP Advanced Uptime Monitoring%2$s extension.', 'mainwp' ), '<a href="https://mainwp.com/extension/advanced-uptime-monitor" target="_blank">', '</a>' ); ?></div>
783 <label class="six wide column middle aligned">
784 <?php
785 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disableSitesChecking', (int) $disableSitesMonitoring );
786 esc_html_e( 'Enable basic uptime monitoring', 'mainwp' );
787 ?>
788 </label>
789 <div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="monitoring" style="max-width:100px !important;">
790 <input type="checkbox" name="mainwp_setup_disableSitesChecking" id="mainwp_setup_disableSitesChecking" <?php echo ( 1 === $disableSitesMonitoring ? '' : 'checked="true"' ); ?>/>
791 <label class=""></label>
792 </div>
793 </div>
794
795 <div class="ui grid field" <?php echo $disableSitesMonitoring ? 'style="display:none"' : ''; ?> hide-element="monitoring">
796 <label class="six wide column middle aligned"><?php esc_html_e( 'Check interval', 'mainwp' ); ?></label>
797 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Select preferred checking interval.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
798 <select name="mainwp_setup_frequency_sitesChecking" id="mainwp_setup_frequency_sitesChecking" class="ui dropdown">
799 <option value="5" <?php echo ( 5 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 5 minutes', 'mainwp' ); ?></option>
800 <option value="10" <?php echo ( 10 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 10 minutes', 'mainwp' ); ?></option>
801 <option value="30" <?php echo ( 30 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 30 minutes', 'mainwp' ); ?></option>
802 <option value="60" <?php echo ( 60 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every hour', 'mainwp' ); ?></option>
803 <option value="180" <?php echo ( 180 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 3 hours', 'mainwp' ); ?></option>
804 <option value="360" <?php echo ( 360 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 6 hours', 'mainwp' ); ?></option>
805 <option value="720" <?php echo ( 720 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Twice a day', 'mainwp' ); ?></option>
806 <option value="1440" <?php echo ( 1440 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Once a day', 'mainwp' ); ?></option>
807 </select>
808 </div>
809 </div>
810 <h1 class="ui header">
811 <?php esc_html_e( 'Site Health Monitoring', 'mainwp' ); ?>
812 </h1>
813 <div><?php esc_html_e( "The MainWP Site Health Monitoring feature integrates with WordPress 5.1's Site Health tool, providing centralized notifications regarding the health status of your child sites. It allows you to choose between being notified for any status changes or only when the health drops below the 'Good' threshold, ensuring you're informed about crucial security and performance metrics.", 'mainwp' ); ?></div>
814 <div class="ui hidden divider"></div>
815 <div class="ui hidden divider"></div>
816 <div class="ui grid field">
817 <label class="six wide column middle aligned">
818 <?php
819 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disableSitesHealthMonitoring', (int) $disableSitesHealthMonitoring );
820 esc_html_e( 'Enable Site Health monitoring', 'mainwp' );
821 ?>
822 </label>
823 <div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="health-monitoring" style="max-width:100px !important;">
824 <input type="checkbox" name="mainwp_setup_disable_sitesHealthMonitoring" id="mainwp_setup_disable_sitesHealthMonitoring" <?php echo ( 1 === $disableSitesHealthMonitoring ? '' : 'checked="true"' ); ?>/>
825 </div>
826 </div>
827
828 <div class="ui grid field" <?php echo $disableSitesHealthMonitoring ? 'style="display:none"' : ''; ?> hide-element="health-monitoring">
829 <label class="six wide column middle aligned">
830 <?php
831 MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sitehealthThreshold', (int) $sitehealthThreshold );
832 esc_html_e( 'Site health threshold', 'mainwp' );
833 ?>
834 </label>
835 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set preferred site health threshold.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
836 <select name="mainwp_setup_site_healthThreshold" id="mainwp_setup_site_healthThreshold" class="ui dropdown">
837 <option value="80" <?php echo ( ( 80 === $sitehealthThreshold || 0 === $sitehealthThreshold ) ? 'selected' : '' ); ?>><?php esc_html_e( 'Should be improved', 'mainwp' ); ?></option>
838 <option value="100" <?php echo ( 100 === $sitehealthThreshold ? 'selected' : '' ); ?>><?php esc_html_e( 'Good', 'mainwp' ); ?></option>
839 </select>
840 </div>
841 </div>
842 <div class="ui hidden divider"></div>
843 <div class="ui hidden divider"></div>
844 <input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" />
845 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big button"><?php esc_html_e( 'Skip', 'mainwp' ); ?></a>
846 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
847
848 <?php wp_nonce_field( 'mwp-setup' ); ?>
849 </form>
850 <?php
851 }
852
853 /**
854 * Method mwp_setup_monitoring_save()
855 *
856 * Save Monitoring form data.
857 *
858 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
859 */
860 public function mwp_setup_monitoring_save() {
861 check_admin_referer( 'mwp-setup' );
862 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
863 MainWP_Utility::update_option( 'mainwp_disableSitesChecking', ( ! isset( $_POST['mainwp_setup_disableSitesChecking'] ) ? 1 : 0 ) );
864 $val = isset( $_POST['mainwp_setup_frequency_sitesChecking'] ) ? intval( $_POST['mainwp_setup_frequency_sitesChecking'] ) : 1440;
865 MainWP_Utility::update_option( 'mainwp_frequencySitesChecking', $val );
866 MainWP_Utility::update_option( 'mainwp_disableSitesHealthMonitoring', ( ! isset( $_POST['mainwp_setup_disable_sitesHealthMonitoring'] ) ? 1 : 0 ) );
867 $val = isset( $_POST['mainwp_setup_site_healthThreshold'] ) ? intval( $_POST['mainwp_setup_site_healthThreshold'] ) : 80;
868 MainWP_Utility::update_option( 'mainwp_sitehealthThreshold', $val );
869 // phpcs:enable
870 wp_safe_redirect( $this->get_next_step_link() );
871 exit;
872 }
873
874 /**
875 * Method mwp_setup_ready()
876 *
877 * Render MainWP Dashboard ready message.
878 */
879 public function mwp_setup_ready() {
880 ?>
881 <div class="ui hidden divider"></div>
882 <div class="ui hidden divider"></div>
883 <h1 class="ui icon header" style="display:block">
884 <i class="thumbs up outline icon"></i>
885 <div class="content">
886 <?php esc_html_e( 'Your MainWP Dashboard is Ready!', 'mainwp' ); ?>
887 <div class="sub header"><?php esc_html_e( 'Congratulations! Now you are ready to start managing your WordPress sites.', 'mainwp' ); ?></div>
888 <div class="ui hidden divider"></div>
889 <a class="ui massive green button" href="<?php echo esc_url( admin_url( 'admin.php?page=mainwp_tab' ) ); ?>"><?php esc_html_e( 'Start Managing Your Sites', 'mainwp' ); ?></a>
890 </div>
891 </h1>
892 <div class="ui hidden divider"></div>
893 <div class="ui hidden divider"></div>
894 <?php
895 }
896
897 /**
898 * Render usetiful tours.
899 */
900 public function mainwp_usetiful_tours() {
901 echo "
902 <script>
903 (function (w, d, s) {
904 var a = d.getElementsByTagName('head')[0];
905 var r = d.createElement('script');
906 r.async = 1;
907 r.src = s;
908 r.setAttribute('id', 'usetifulScript');
909 r.dataset.token = '480fa17b0507a1c60abba94bfdadd0a7';
910 a.appendChild(r);
911 })(window, document, 'https://www.usetiful.com/dist/usetiful.js');</script>
912 ";
913 }
914 }
915