PluginProbe
MainWP Dashboard: Self-hosted WordPress Management for Agencies / 5.0
MainWP Dashboard: Self-hosted WordPress Management for Agencies v5.0
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 5.2.2 5.3 All 153 releases
mainwp / pages / page-mainwp-setup-wizard.php

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

911 lines 44.8 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 $this->mwp_setup_ready_actions();
311 $is_new = MainWP_Demo_Handle::get_instance()->is_new_instance();
312 $enabled_demo = apply_filters( 'mainwp_demo_mode_enabled', false );
313 $count_sites = MainWP_DB::instance()->get_websites_count();
314 ?>
315 <h1 class="ui header"><?php esc_html_e( 'Welcome to your MainWP Dashboard!', 'mainwp' ); ?></h1>
316 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
317 <div class="ui hidden divider"></div>
318 <h3><?php esc_html_e( 'Are you ready to get started adding your sites?', 'mainwp' ); ?></h3>
319 <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>
320 <?php if ( 0 === $count_sites ) : ?>
321 <div class="ui hidden divider"></div>
322 <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>
323 <p><?php esc_attr_e( 'Explore MainWP\'s capabilities using our pre-loaded demo content.', 'mainwp' ); ?></p>
324 <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>
325 <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>
326 <p><?php esc_attr_e( 'Click this button to import the Demo content to your MainWP Dashboard and enable the Demo mode.', 'mainwp' ); ?></p>
327 <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>
328 <div class="ui blue message">
329 <?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>' ); ?>
330 </div>
331 <?php endif; ?>
332 <?php
333 MainWP_System_View::render_comfirm_modal();
334 }
335
336 /**
337 * Method mwp_setup_introduction()
338 *
339 * Renders the Introduction screen of the Quick Start Wizard
340 */
341 public function mwp_setup_introduction() {
342 ?>
343 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
344 <h1 class="ui header"><?php esc_html_e( 'MainWP Quick Setup Wizard', 'mainwp' ); ?></h1>
345 <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>
346 <div class="ui hidden divider"></div>
347 <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>
348 <div class="ui hidden divider"></div>
349 <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>
350 <div class="ui hidden divider"></div>
351 <form method="post" class="ui form">
352 <h1><?php esc_html_e( 'MainWP Guided Tours', 'mainwp' ); ?> <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></h1>
353 <?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?>
354 <div class="ui blue message">
355 <?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>' ); ?>
356 </div>
357 <div class="ui form">
358 <div class="field">
359 <div class="ui hidden divider"></div>
360 <label><?php esc_html_e( 'Do you want to enable MainWP Guided Tours?', 'mainwp' ); ?></label>
361 <div class="ui hidden divider"></div>
362 <div class="ui toggle checkbox">
363 <input type="checkbox" name="mainwp-guided-tours-option" id="mainwp-guided-tours-option" checked="true">
364 <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>
365 </div>
366 </div>
367 </div>
368 <div class="ui hidden divider"></div>
369 <p><?php esc_html_e( 'To go back to the WordPress Admin section, click the "Back to WP Admin" button.', 'mainwp' ); ?></p>
370 <div class="ui hidden divider"></div>
371 <div class="ui hidden divider"></div>
372 <div class="ui hidden divider"></div>
373 <input type="submit" class="ui big green right floated button" value="<?php esc_html_e( 'Let\'s Go!', 'mainwp' ); ?>" name="save_step" />
374 <a href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>" class="ui big button"><?php esc_html_e( 'Back to WP Admin', 'mainwp' ); ?></a>
375 <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>
376 <?php wp_nonce_field( 'mwp-setup' ); ?>
377 </form>
378 <?php
379 MainWP_System_View::render_comfirm_modal();
380 }
381
382
383 /**
384 * Method mwp_setup_system_requirements()
385 *
386 * Render System Requirements Step.
387 *
388 * @uses \MainWP\Dashboard\MainWP_Server_Information::render_quick_setup_system_check()
389 */
390 public function mwp_setup_system_requirements() {
391 ?>
392 <h1><?php esc_html_e( 'System Requirements Check', 'mainwp' ); ?></h1>
393 <?php MainWP_System_View::mainwp_warning_notice(); ?>
394 <form method="post" class="ui form">
395 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
396 <?php
397 $show_ssl = false;
398 if ( MainWP_Server_Information_Handler::is_openssl_config_warning() ) {
399 $openssl_loc = MainWP_System_Utility::get_openssl_conf();
400 ?>
401 <div class="ui secondary segment">
402 <div class="grouped fields">
403 <label><?php esc_html_e( 'What is the openssl.cnf file location on your computer?', 'mainwp' ); ?></label>
404 <div class="field" id="mainwp-setup-installation-openssl-location">
405 <div class="ui fluid input">
406 <input type="text" name="mwp_setup_openssl_lib_location" value="<?php echo esc_attr( $openssl_loc ); ?>">
407 </div>
408 <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>
409 </div>
410 </div>
411 </div>
412 <?php
413 $show_ssl = true;
414 }
415 ?>
416 <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>
417 <?php MainWP_Server_Information::render_quick_setup_system_check(); ?>
418 <div class="ui hidden divider"></div>
419 <div class="ui hidden divider"></div>
420 <div class="ui hidden divider"></div>
421 <?php
422 if ( $show_ssl ) {
423 ?>
424 <input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" />
425 <?php
426 } else {
427 ?>
428 <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>
429 <?php } ?>
430 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big button"><?php esc_html_e( 'Skip', 'mainwp' ); ?></a>
431 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
432 <?php wp_nonce_field( 'mwp-setup' ); ?>
433 </form>
434 <?php
435 }
436
437
438 /**
439 * Method mwp_setup_introduction_save()
440 *
441 * Installation Step save to DB.
442 *
443 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
444 */
445 public function mwp_setup_introduction_save() {
446 check_admin_referer( 'mwp-setup' );
447 $enabled_tours = ! isset( $_POST['mainwp-guided-tours-option'] ) ? 0 : 1; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
448 MainWP_Utility::update_option( 'mainwp_enable_guided_tours', $enabled_tours );
449 wp_safe_redirect( $this->get_next_step_link() );
450 exit;
451 }
452
453 /**
454 * Method mwp_setup_connect_first_site_save()
455 *
456 * Installation Step after connect first site.
457 */
458 public function mwp_setup_connect_first_site_save() {
459 check_admin_referer( 'mwp-setup' );
460 if ( isset( $_POST['mainwp-qsw-confirm-add-new-client'] ) && ! empty( $_POST['mainwp-qsw-confirm-add-new-client'] ) ) {
461 wp_safe_redirect( $this->get_next_step_link() );
462 } else {
463 wp_safe_redirect( $this->get_next_step_link( 'monitoring' ) );
464 }
465 exit;
466 }
467
468 /**
469 * Method mwp_setup_system_requirements_save()
470 *
471 * Installation Step save to DB.
472 *
473 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
474 */
475 public function mwp_setup_system_requirements_save() {
476 check_admin_referer( 'mwp-setup' );
477 if ( isset( $_POST['mwp_setup_openssl_lib_location'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
478 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
479 }
480 wp_safe_redirect( $this->get_next_step_link() );
481 exit;
482 }
483
484
485
486 /**
487 * Method mwp_setup_connect_first_site_already()
488 *
489 * Render Added first Child Site Step form.
490 */
491 public function mwp_setup_connect_first_site_already() {
492 $count_clients = MainWP_DB_Client::instance()->count_total_clients();
493 ?>
494 <h1 class="ui header"><?php esc_html_e( 'Congratulations!', 'mainwp' ); ?></h1>
495 <p><?php esc_html_e( 'You have successfully connected your first site to your MainWP Dashboard!', 'mainwp' ); ?></p>
496 <div class="ui form">
497 <form method="post" class="ui form">
498 <?php if ( empty( $count_clients ) ) { ?>
499 <div class="field">
500 <label><?php esc_html_e( 'Do you want to create a client for your first child site?', 'mainwp' ); ?></label>
501 <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>
502 <div class="ui hidden divider"></div>
503 <div class="ui toggle checkbox">
504 <input type="checkbox" name="mainwp-qsw-confirm-add-new-client" id="mainwp-qsw-confirm-add-new-client" checked="true"/>
505 <label><?php esc_html_e( 'Select to create a New Client', 'mainwp' ); ?></label>
506 </div>
507 </div>
508 <?php } ?>
509 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
510 <div class="ui clearing hidden divider"></div>
511 <div class="ui hidden divider"></div>
512 <div class="ui hidden divider"></div>
513 <input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" />
514 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
515 <?php wp_nonce_field( 'mwp-setup' ); ?>
516 <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' ) ); ?>" />
517 </form>
518 </div>
519 <?php
520 }
521
522
523 /**
524 * Method mwp_setup_connect_first_site()
525 *
526 * Render Install first Child Site Step form.
527 */
528 public function mwp_setup_connect_first_site() {
529 $count = MainWP_DB::instance()->get_websites_count( null, true );
530 if ( 1 <= $count ) {
531 $this->mwp_setup_connect_first_site_already();
532 return;
533 }
534 ?>
535 <h1><?php esc_html_e( 'Connect Your First Child Site', 'mainwp' ); ?></h1>
536 <?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-qsw-add-site-message' ) ) { ?>
537 <div class="ui info message">
538 <i class="close icon mainwp-notice-dismiss" notice-id="mainwp-qsw-add-site-message"></i>
539 <?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' ); ?>
540 <?php esc_html_e( 'To install the MainWP Child plugin, please follow these steps:', 'mainwp' ); ?>
541 <ol>
542 <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>
543 <li><?php printf( esc_html__( 'Go to the %1$sWP > Plugins%2$s page', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
544 <li><?php printf( esc_html__( 'Click %1$sAdd New%2$s to install a new plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
545 <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>
546 <li><?php printf( esc_html__( '%1$sActivate%2$s the plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li>
547 </ol>
548 </div>
549 <?php } ?>
550 <div class="ui form">
551 <div class="field">
552 <div class="ui hidden divider"></div>
553 <label><?php esc_html_e( 'Is MainWP Child plugin installed and activated on the WordPress site that you want to connect?', 'mainwp' ); ?></label>
554 <div class="ui hidden divider"></div>
555 <div class="ui toggle checkbox">
556 <input type="checkbox" name="mainwp-qsw-verify-mainwp-child-active" id="mainwp-qsw-verify-mainwp-child-active">
557 <label for="mainwp-qsw-verify-mainwp-child-active"><?php esc_html_e( 'Select to confirm that the MainWP Child plugin is active.', 'mainwp' ); ?></label>
558 </div>
559 </div>
560 </div>
561 <form method="post" class="ui form">
562 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
563 <div id="mainwp-qsw-connect-site-form" style="display:none">
564 <div class="ui hidden divider"></div>
565 <div class="ui hidden divider"></div>
566 <div class="ui message" id="mainwp-message-zone" style="display:none"></div>
567 <div class="ui red message" id="mainwp-error-zone" style="display:none"></div>
568 <div class="ui green message" id="mainwp-success-zone" style="display:none"></div>
569 <div class="ui info message" id="mainwp-info-zone" style="display:none"></div>
570 <div class="ui hidden divider"></div>
571 <div class="ui secondary segment">
572 <div class="ui hidden divider"></div>
573 <div class="ui hidden divider"></div>
574 <div class="ui horizontal divider"><?php esc_html_e( 'Required Fields', 'mainwp' ); ?></div>
575 <div class="ui hidden divider"></div>
576 <div class="ui hidden divider"></div>
577 <div class="field">
578 <label><?php esc_html_e( 'What is the site URL? ', 'mainwp' ); ?></label>
579 <div class="ui left action input">
580 <select class="ui compact selection dropdown" id="mainwp_managesites_add_wpurl_protocol" name="mainwp_managesites_add_wpurl_protocol" style="width:120px;padding:0px;">
581 <option value="https">https://</option>
582 <option value="http">http://</option>
583 </select>
584 <input type="text" id="mainwp_managesites_add_wpurl" name="mainwp_managesites_add_wpurl" value="" placeholder="yoursite.com" />
585 </div>
586 </div>
587 <div class="field">
588 <label><?php esc_html_e( 'What is your administrator username on that site? ', 'mainwp' ); ?></label>
589 <input type="text" id="mainwp_managesites_add_wpadmin" name="mainwp_managesites_add_wpadmin" value="" />
590 </div>
591 <div class="field">
592 <label><?php esc_html_e( 'Add site title. If left blank URL is used.', 'mainwp' ); ?></label>
593 <input type="text" id="mainwp_managesites_add_wpname" name="mainwp_managesites_add_wpname" value="" />
594 </div>
595 <div class="ui hidden divider"></div>
596 <a href="#" id="mainwp-toggle-optional-settings"><i class="ui eye icon"></i> <?php esc_html_e( 'Advanced options', 'mainwp' ); ?></a>
597 <div class="ui hidden divider"></div>
598 <div id="mainwp-qsw-optional-settings-form" style="display:none">
599 <div class="ui hidden divider"></div>
600 <div class="ui horizontal divider"><?php esc_html_e( 'Advanced Options (optional)', 'mainwp' ); ?></div>
601 <div class="ui hidden divider"></div>
602 <div class="ui hidden divider"></div>
603 <div class="field">
604 <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>
605 <input type="text" id="mainwp_managesites_add_uniqueId" name="mainwp_managesites_add_uniqueId" value="" />
606 </div>
607 </div>
608 </div>
609 </div>
610 <div class="ui clearing hidden divider"></div>
611 <div class="ui hidden divider"></div>
612 <div class="ui hidden divider"></div>
613 <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' ); ?>" />
614 <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>
615 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
616 <?php wp_nonce_field( 'mwp-setup' ); ?>
617 <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' ) ); ?>" />
618 </form>
619 <?php
620 }
621
622 /**
623 * Method mwp_setup_add_client()
624 *
625 * Render Add first Client Step form.
626 */
627 public function mwp_setup_add_client() {
628 $count = MainWP_DB::instance()->get_websites_count( null, true );
629 $count_clients = MainWP_DB_Client::instance()->count_total_clients();
630 if ( ! empty( $count_clients ) ) {
631 ?>
632 <h1 class="ui header"><?php esc_html_e( 'Congratulations!', 'mainwp' ); ?></h1>
633 <p><?php esc_html_e( 'You have successfully created your first Client.', 'mainwp' ); ?></p>
634 <?php
635 } else {
636 $first_site_id = get_transient( 'mainwp_transient_just_connected_site_id' );
637 ?>
638 <h1><?php esc_html_e( 'Create a Client', 'mainwp' ); ?></h1>
639 <div class="ui secondary segment">
640 <form action="" method="post" enctype="multipart/form-data" name="createclient_form" id="createclient_form" class="add:clients: validate">
641 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
642 <div class="">
643 <div class="ui hidden divider"></div>
644 <div class="ui message" id="mainwp-message-zone-client" style="display:none;"></div>
645 <div id="mainwp-add-new-client-form" >
646 <?php $this->render_add_client_content( false, true ); ?>
647 </div>
648 </div>
649 <input type="hidden" name="selected_first_site" value="<?php echo intval( $first_site_id ); ?>">
650 </form>
651 <div class="ui clearing hidden divider"></div>
652 </div>
653 <?php
654 }
655 ?>
656 <div class="ui hidden divider"></div>
657 <div class="ui hidden divider"></div>
658 <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' ); ?> "/>
659 <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>
660 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
661 <?php
662 }
663
664
665 /**
666 * Method render_add_client_content().
667 *
668 * Renders add client content window.
669 */
670 public function render_add_client_content() {
671 $edit_client = false;
672 $client_id = 0;
673 $client_image = '';
674 $default_client_fields = MainWP_Client_Handler::get_mini_default_client_fields();
675 ?>
676 <div class="ui form">
677 <?php
678 foreach ( $default_client_fields as $field_name => $field ) {
679 $db_field = isset( $field['db_field'] ) ? $field['db_field'] : '';
680 $val = $edit_client && '' !== $db_field && property_exists( $edit_client, $db_field ) ? $edit_client->{$db_field} : '';
681 $tip = isset( $field['tooltip'] ) ? $field['tooltip'] : '';
682 ?>
683 <div class="field">
684 <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>
685 <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 ); ?>]"/>
686 </div>
687 <?php
688
689 if ( 'client.name' === $field_name ) {
690 ?>
691 <div class="field">
692 <label><?php esc_html_e( 'Client photo', 'mainwp' ); ?></label>
693 <div data-tooltip="<?php esc_attr_e( 'Upload a client photo.', 'mainwp' ); ?>" data-inverted="" data-position="top left">
694 <div class="ui file input">
695 <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' ); ?>" />
696 </div>
697 </div>
698 </div>
699 <?php
700 }
701 }
702 $primary_contact_id = 0;
703 $temp = $this->get_add_contact_temp( false );
704 ?>
705 <div class="field">
706 <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>
707 </div>
708 <div class="ui section hidden divider after-add-contact-field"></div>
709 </div>
710 <input type="hidden" name="client_fields[client_id]" value="<?php echo intval( $client_id ); ?>">
711 <?php
712 }
713
714
715 /**
716 * Method get_add_contact_temp().
717 *
718 * Get add contact template.
719 *
720 * @param bool $echo_out Echo template or not.
721 */
722 public function get_add_contact_temp( $echo_out = false ) {
723
724 $input_name = 'new_contacts_field';
725 $contact_id = 0;
726 $contact_image = '';
727
728 ob_start();
729 ?>
730 <div class="ui hidden divider top-contact-fields"></div> <?php // must have class: top-contact-fields. ?>
731 <div class="ui horizontal divider"><?php esc_html_e( 'Add Contact', 'mainwp' ); ?></div>
732 <div class="ui hidden divider"></div>
733 <div class="ui hidden divider"></div>
734 <?php
735 $contact_fields = MainWP_Client_Handler::get_mini_default_contact_fields();
736 foreach ( $contact_fields as $field_name => $field ) {
737 $db_field = isset( $field['db_field'] ) ? $field['db_field'] : '';
738 $val = '';
739 $contact_id = '';
740 ?>
741 <div class="field">
742 <label><?php echo esc_html( $field['title'] ); ?></label>
743 <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 ); ?>][]"/>
744 </div>
745 <?php
746 }
747 ?>
748 <div class="field remove-contact-field-parent">
749 <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>
750 </div>
751 <div class="ui section hidden divider bottom-contact-fields"></div>
752 <?php
753 $html = ob_get_clean();
754 if ( $echo_out ) {
755 echo $html; //phpcs:ignore -- validated content.
756 }
757 return $html;
758 }
759
760 /**
761 * Method mwp_setup_monitoring()
762 *
763 * Render Monitoring Step.
764 */
765 public function mwp_setup_monitoring() {
766
767 $disableSitesMonitoring = get_option( 'mainwp_disableSitesChecking', 1 );
768 $frequencySitesChecking = (int) get_option( 'mainwp_frequencySitesChecking', 60 );
769
770 $disableSitesHealthMonitoring = get_option( 'mainwp_disableSitesHealthMonitoring', 1 );
771 $sitehealthThreshold = get_option( 'mainwp_sitehealthThreshold', 80 ); // "Should be improved" threshold.
772
773 ?>
774 <h1 class="ui header">
775 <?php esc_html_e( 'Basic Uptime Monitoring', 'mainwp' ); ?>
776 </h1>
777 <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>
778 <div class="ui hidden divider"></div>
779 <div class="ui hidden divider"></div>
780 <form method="post" class="ui form">
781 <?php wp_nonce_field( 'mainwp-admin-nonce' ); ?>
782 <div class="ui grid field">
783 <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>
784 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable basic uptime monitoring', 'mainwp' ); ?></label>
785 <div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="monitoring" style="max-width:100px !important;">
786 <input type="checkbox" name="mainwp_setup_disableSitesChecking" id="mainwp_setup_disableSitesChecking" <?php echo ( 1 === $disableSitesMonitoring ? '' : 'checked="true"' ); ?>/>
787 <label class=""></label>
788 </div>
789 </div>
790
791 <div class="ui grid field" <?php echo $disableSitesMonitoring ? 'style="display:none"' : ''; ?> hide-element="monitoring">
792 <label class="six wide column middle aligned"><?php esc_html_e( 'Check interval', 'mainwp' ); ?></label>
793 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Select preferred checking interval.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
794 <select name="mainwp_setup_frequency_sitesChecking" id="mainwp_setup_frequency_sitesChecking" class="ui dropdown">
795 <option value="5" <?php echo ( 5 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 5 minutes', 'mainwp' ); ?></option>
796 <option value="10" <?php echo ( 10 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 10 minutes', 'mainwp' ); ?></option>
797 <option value="30" <?php echo ( 30 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 30 minutes', 'mainwp' ); ?></option>
798 <option value="60" <?php echo ( 60 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every hour', 'mainwp' ); ?></option>
799 <option value="180" <?php echo ( 180 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 3 hours', 'mainwp' ); ?></option>
800 <option value="360" <?php echo ( 360 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Every 6 hours', 'mainwp' ); ?></option>
801 <option value="720" <?php echo ( 720 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Twice a day', 'mainwp' ); ?></option>
802 <option value="1440" <?php echo ( 1440 === $frequencySitesChecking ? 'selected' : '' ); ?>><?php esc_html_e( 'Once a day', 'mainwp' ); ?></option>
803 </select>
804 </div>
805 </div>
806 <h1 class="ui header">
807 <?php esc_html_e( 'Site Health Monitoring', 'mainwp' ); ?>
808 </h1>
809 <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>
810 <div class="ui hidden divider"></div>
811 <div class="ui hidden divider"></div>
812 <div class="ui grid field">
813 <label class="six wide column middle aligned"><?php esc_html_e( 'Enable Site Health monitoring', 'mainwp' ); ?></label>
814 <div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="health-monitoring" style="max-width:100px !important;">
815 <input type="checkbox" name="mainwp_setup_disable_sitesHealthMonitoring" id="mainwp_setup_disable_sitesHealthMonitoring" <?php echo ( 1 === $disableSitesHealthMonitoring ? '' : 'checked="true"' ); ?>/>
816 </div>
817 </div>
818
819 <div class="ui grid field" <?php echo $disableSitesHealthMonitoring ? 'style="display:none"' : ''; ?> hide-element="health-monitoring">
820 <label class="six wide column middle aligned"><?php esc_html_e( 'Site health threshold', 'mainwp' ); ?></label>
821 <div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set preferred site health threshold.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left">
822 <select name="mainwp_setup_site_healthThreshold" id="mainwp_setup_site_healthThreshold" class="ui dropdown">
823 <option value="80" <?php echo ( ( 80 === $sitehealthThreshold || 0 === $sitehealthThreshold ) ? 'selected' : '' ); ?>><?php esc_html_e( 'Should be improved', 'mainwp' ); ?></option>
824 <option value="100" <?php echo ( 100 === $sitehealthThreshold ? 'selected' : '' ); ?>><?php esc_html_e( 'Good', 'mainwp' ); ?></option>
825 </select>
826 </div>
827 </div>
828 <div class="ui hidden divider"></div>
829 <div class="ui hidden divider"></div>
830 <input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" />
831 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big button"><?php esc_html_e( 'Skip', 'mainwp' ); ?></a>
832 <a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a>
833
834 <?php wp_nonce_field( 'mwp-setup' ); ?>
835 </form>
836 <?php
837 }
838
839 /**
840 * Method mwp_setup_monitoring_save()
841 *
842 * Save Monitoring form data.
843 *
844 * @uses \MainWP\Dashboard\MainWP_Utility::update_option()
845 */
846 public function mwp_setup_monitoring_save() {
847 check_admin_referer( 'mwp-setup' );
848 // phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
849 MainWP_Utility::update_option( 'mainwp_disableSitesChecking', ( ! isset( $_POST['mainwp_setup_disableSitesChecking'] ) ? 1 : 0 ) );
850 $val = isset( $_POST['mainwp_setup_frequency_sitesChecking'] ) ? intval( $_POST['mainwp_setup_frequency_sitesChecking'] ) : 1440;
851 MainWP_Utility::update_option( 'mainwp_frequencySitesChecking', $val );
852 MainWP_Utility::update_option( 'mainwp_disableSitesHealthMonitoring', ( ! isset( $_POST['mainwp_setup_disable_sitesHealthMonitoring'] ) ? 1 : 0 ) );
853 $val = isset( $_POST['mainwp_setup_site_healthThreshold'] ) ? intval( $_POST['mainwp_setup_site_healthThreshold'] ) : 80;
854 MainWP_Utility::update_option( 'mainwp_sitehealthThreshold', $val );
855 // phpcs:enable
856 wp_safe_redirect( $this->get_next_step_link() );
857 exit;
858 }
859
860 /**
861 * Method mwp_setup_ready_actions()
862 *
863 * Delete option 'mainwp_run_quick_setup' when Quick Wizard
864 * Setup is completed.
865 */
866 private function mwp_setup_ready_actions() {
867 delete_option( 'mainwp_run_quick_setup' );
868 }
869
870 /**
871 * Method mwp_setup_ready()
872 *
873 * Render MainWP Dashboard ready message.
874 */
875 public function mwp_setup_ready() {
876 ?>
877 <div class="ui hidden divider"></div>
878 <div class="ui hidden divider"></div>
879 <h1 class="ui icon header" style="display:block">
880 <i class="thumbs up outline icon"></i>
881 <div class="content">
882 <?php esc_html_e( 'Your MainWP Dashboard is Ready!', 'mainwp' ); ?>
883 <div class="sub header"><?php esc_html_e( 'Congratulations! Now you are ready to start managing your WordPress sites.', 'mainwp' ); ?></div>
884 <div class="ui hidden divider"></div>
885 <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>
886 </div>
887 </h1>
888 <div class="ui hidden divider"></div>
889 <div class="ui hidden divider"></div>
890 <?php
891 }
892
893 /**
894 * Render usetiful tours.
895 */
896 public function mainwp_usetiful_tours() {
897 echo "
898 <script>
899 (function (w, d, s) {
900 var a = d.getElementsByTagName('head')[0];
901 var r = d.createElement('script');
902 r.async = 1;
903 r.src = s;
904 r.setAttribute('id', 'usetifulScript');
905 r.dataset.token = '480fa17b0507a1c60abba94bfdadd0a7';
906 a.appendChild(r);
907 })(window, document, 'https://www.usetiful.com/dist/usetiful.js');</script>
908 ";
909 }
910 }
911