| 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 { // phpcs:ignore Generic.Classes.OpeningBraceSameLine.ContentAfterBrace -- NOSONAR. |
| 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 get_instance(). |
| 55 |
*/ |
| 56 |
public static function get_instance() { |
| 57 |
return new self(); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Method admin_menus() |
| 62 |
* |
| 63 |
* Add Quick Setup Wizard page. |
| 64 |
*/ |
| 65 |
public function admin_menus() { |
| 66 |
add_dashboard_page( '', '', 'manage_options', 'mainwp-setup', '' ); |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Medthod admin_init() |
| 71 |
* |
| 72 |
* Initiate Quick Setup Wizard page. |
| 73 |
*/ |
| 74 |
public function admin_init() { |
| 75 |
if ( empty( $_GET['page'] ) || 'mainwp-setup' !== $_GET['page'] ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 76 |
return; |
| 77 |
} |
| 78 |
$this->steps = array( |
| 79 |
'welcome' => array( |
| 80 |
'name' => esc_html__( 'Welcome', 'mainwp' ), |
| 81 |
'view' => array( $this, 'mwp_setup_welcome' ), |
| 82 |
'handler' => '', |
| 83 |
), |
| 84 |
'introduction' => array( |
| 85 |
'name' => esc_html__( 'Introduction', 'mainwp' ), |
| 86 |
'view' => array( $this, 'mwp_setup_introduction' ), |
| 87 |
'handler' => array( $this, 'mwp_setup_introduction_save' ), |
| 88 |
), |
| 89 |
'system_check' => array( |
| 90 |
'name' => esc_html__( 'System', 'mainwp' ), |
| 91 |
'view' => array( $this, 'mwp_setup_system_requirements' ), |
| 92 |
'handler' => array( $this, 'mwp_setup_system_requirements_save' ), |
| 93 |
), |
| 94 |
'connect_first_site' => array( |
| 95 |
'name' => esc_html__( 'Connect', 'mainwp' ), |
| 96 |
'view' => array( $this, 'mwp_setup_connect_first_site' ), |
| 97 |
'handler' => array( $this, 'mwp_setup_connect_first_site_save' ), |
| 98 |
), |
| 99 |
'add_client' => array( |
| 100 |
'name' => esc_html__( 'Add Client', 'mainwp' ), |
| 101 |
'view' => array( $this, 'mwp_setup_add_client' ), |
| 102 |
'handler' => '', |
| 103 |
), |
| 104 |
'monitoring' => array( |
| 105 |
'name' => esc_html__( 'Monitoring', 'mainwp' ), |
| 106 |
'view' => array( $this, 'mwp_setup_monitoring' ), |
| 107 |
'handler' => array( $this, 'mwp_setup_monitoring_save' ), |
| 108 |
), |
| 109 |
'next_steps' => array( |
| 110 |
'name' => esc_html__( 'Finish', 'mainwp' ), |
| 111 |
'view' => array( $this, 'mwp_setup_ready' ), |
| 112 |
'handler' => '', |
| 113 |
), |
| 114 |
); |
| 115 |
|
| 116 |
$this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 117 |
|
| 118 |
wp_enqueue_script( 'fomantic-ui', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.js', array( 'jquery' ), MAINWP_VERSION, false ); |
| 119 |
wp_localize_script( 'mainwp-setup', 'mainwpSetupLocalize', array( 'nonce' => wp_create_nonce( 'MainWPSetup' ) ) ); |
| 120 |
wp_enqueue_script( 'mainwp', MAINWP_PLUGIN_URL . 'assets/js/mainwp.js', array( 'jquery' ), MAINWP_VERSION, true ); |
| 121 |
wp_enqueue_script( 'mainwp-clients', MAINWP_PLUGIN_URL . 'assets/js/mainwp-clients.js', array(), MAINWP_VERSION, true ); |
| 122 |
wp_enqueue_script( 'mainwp-setup', MAINWP_PLUGIN_URL . 'assets/js/mainwp-setup.js', array( 'jquery', 'fomantic-ui' ), MAINWP_VERSION, true ); |
| 123 |
wp_enqueue_script( 'mainwp-ui', MAINWP_PLUGIN_URL . 'assets/js/mainwp-ui.js', array(), MAINWP_VERSION, true ); |
| 124 |
wp_enqueue_style( 'mainwp', MAINWP_PLUGIN_URL . 'assets/css/mainwp.css', array(), MAINWP_VERSION ); |
| 125 |
wp_enqueue_style( 'mainwp-fonts', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fonts.css', array(), MAINWP_VERSION ); |
| 126 |
wp_enqueue_style( 'fomantic', MAINWP_PLUGIN_URL . 'assets/js/fomantic-ui/fomantic-ui.css', array(), MAINWP_VERSION ); |
| 127 |
wp_enqueue_style( 'mainwp-fomantic', MAINWP_PLUGIN_URL . 'assets/css/mainwp-fomantic.css', array(), MAINWP_VERSION ); |
| 128 |
|
| 129 |
// load custom MainWP theme. |
| 130 |
$selected_theme = MainWP_Settings::get_instance()->get_selected_theme(); |
| 131 |
if ( ! empty( $selected_theme ) ) { |
| 132 |
if ( 'dark' === $selected_theme ) { |
| 133 |
wp_enqueue_style( 'mainwp-custom-dashboard-extension-dark-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-dark-theme.css', array(), MAINWP_VERSION ); |
| 134 |
} elseif ( 'wpadmin' === $selected_theme ) { |
| 135 |
wp_enqueue_style( 'mainwp-custom-dashboard-extension-wp-admin-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-wpadmin-theme.css', array(), MAINWP_VERSION ); |
| 136 |
} elseif ( 'minimalistic' === $selected_theme ) { |
| 137 |
wp_enqueue_style( 'mainwp-custom-dashboard-extension-minimalistic-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-minimalistic-theme.css', array(), MAINWP_VERSION ); |
| 138 |
} elseif ( 'default' === $selected_theme ) { |
| 139 |
wp_enqueue_style( 'mainwp-custom-dashboard-extension-default-theme', MAINWP_PLUGIN_URL . 'assets/css/themes/mainwp-default-theme.css', array(), MAINWP_VERSION ); |
| 140 |
} else { |
| 141 |
$dirs = MainWP_Settings::get_instance()->get_custom_theme_folder(); |
| 142 |
$custom_theme_url = $dirs[1]; |
| 143 |
wp_enqueue_style( 'mainwp-custom-dashboard-theme', $custom_theme_url . $selected_theme, array(), MAINWP_VERSION ); |
| 144 |
} |
| 145 |
} |
| 146 |
|
| 147 |
if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 148 |
call_user_func( $this->steps[ $this->step ]['handler'] ); |
| 149 |
} |
| 150 |
|
| 151 |
if ( MainWP_Utility::instance()->is_disabled_functions( 'error_log' ) || ! function_exists( '\error_log' ) ) { |
| 152 |
error_reporting(0); // phpcs:ignore -- try to disabled the error_log somewhere in WP. |
| 153 |
} |
| 154 |
|
| 155 |
ob_start(); |
| 156 |
$this->setup_wizard_header(); |
| 157 |
$this->setup_wizard_steps(); |
| 158 |
$this->setup_wizard_content(); |
| 159 |
$this->setup_wizard_footer(); |
| 160 |
?> |
| 161 |
<?php |
| 162 |
if ( get_option( 'mainwp_enable_guided_tours', 0 ) ) { |
| 163 |
static::mainwp_usetiful_tours(); |
| 164 |
} |
| 165 |
exit; |
| 166 |
} |
| 167 |
|
| 168 |
/** |
| 169 |
* Method get_next_step_link() |
| 170 |
* |
| 171 |
* Get the link for the next step. |
| 172 |
* |
| 173 |
* @param string $step Next step link. |
| 174 |
* |
| 175 |
* @return string Link for next step. |
| 176 |
*/ |
| 177 |
public function get_next_step_link( $step = '' ) { |
| 178 |
if ( ! empty( $step ) && isset( $step, $this->steps ) ) { |
| 179 |
return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $step ) ) ); |
| 180 |
} |
| 181 |
$keys = array_keys( $this->steps ); |
| 182 |
return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) + 1 ] ) ) ); |
| 183 |
} |
| 184 |
|
| 185 |
/** |
| 186 |
* Method get_back_step_link() |
| 187 |
* |
| 188 |
* Get the link for the previouse step. |
| 189 |
* |
| 190 |
* @param string $step Previouse step link. |
| 191 |
* |
| 192 |
* @return string Link for previouse step. |
| 193 |
*/ |
| 194 |
public function get_back_step_link( $step = '' ) { |
| 195 |
if ( ! empty( $step ) && isset( $step, $this->steps ) ) { |
| 196 |
return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $step ) ) ); |
| 197 |
} |
| 198 |
$keys = array_keys( $this->steps ); |
| 199 |
return esc_url_raw( remove_query_arg( array( 'noregister', 'message' ), add_query_arg( 'step', $keys[ array_search( $this->step, array_keys( $this->steps ) ) - 1 ] ) ) ); |
| 200 |
} |
| 201 |
|
| 202 |
/** |
| 203 |
* Method setup_wizard_header() |
| 204 |
* |
| 205 |
* Render Setup Wizard's header. |
| 206 |
*/ |
| 207 |
public function setup_wizard_header() { |
| 208 |
$selected_theme = MainWP_Settings::get_instance()->get_selected_theme(); |
| 209 |
?> |
| 210 |
<!DOCTYPE html> |
| 211 |
<html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?> class="mainwp-quick-setup"> |
| 212 |
<head> |
| 213 |
<meta name="viewport" content="width=device-width" /> |
| 214 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> |
| 215 |
<title><?php esc_html_e( 'MainWP › Setup Wizard', 'mainwp' ); ?></title> |
| 216 |
<?php wp_print_scripts( 'mainwp' ); ?> |
| 217 |
<?php wp_print_scripts( 'mainwp-clients' ); ?> |
| 218 |
<?php wp_print_scripts( 'mainwp-setup' ); ?> |
| 219 |
<?php wp_print_scripts( 'fomantic' ); ?> |
| 220 |
<?php wp_print_scripts( 'mainwp-ui' ); ?> |
| 221 |
<?php |
| 222 |
// to fix warning. |
| 223 |
/** |
| 224 |
* Remove the deprecated `print_emoji_styles` handler. |
| 225 |
* It avoids breaking style generation with a deprecation message. |
| 226 |
*/ |
| 227 |
$has_emoji_styles = has_action( 'admin_print_styles', 'print_emoji_styles' ); |
| 228 |
if ( $has_emoji_styles ) { |
| 229 |
remove_action( 'admin_print_styles', 'print_emoji_styles' ); |
| 230 |
} |
| 231 |
?> |
| 232 |
<?php do_action( 'admin_print_styles' ); ?> |
| 233 |
<script type="text/javascript"> let ajaxurl = '<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>';</script> |
| 234 |
<script type="text/javascript">let 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> |
| 235 |
</head> |
| 236 |
<body class="mainwp-ui <?php echo ! empty( $selected_theme ) ? 'mainwp-custom-theme' : ''; ?> mainwp-ui-setup"> |
| 237 |
<div class="ui hidden divider"></div> |
| 238 |
<div class="ui hidden divider"></div> |
| 239 |
<div id="mainwp-quick-setup-wizard" class="ui padded container segment"> |
| 240 |
<?php |
| 241 |
} |
| 242 |
|
| 243 |
/** |
| 244 |
* Method setup_wizard_footer() |
| 245 |
* |
| 246 |
* Render Setup Wizard's footer. |
| 247 |
*/ |
| 248 |
public function setup_wizard_footer() { |
| 249 |
?> |
| 250 |
</div> |
| 251 |
<div class="ui grid"> |
| 252 |
<div class="row"> |
| 253 |
<div class="center aligned column"> |
| 254 |
<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> |
| 255 |
</div> |
| 256 |
</div> |
| 257 |
</div> |
| 258 |
</body> |
| 259 |
</html> |
| 260 |
<?php |
| 261 |
} |
| 262 |
|
| 263 |
/** |
| 264 |
* Method setup_wizard_steps() |
| 265 |
* |
| 266 |
* Render Setup Wizards Steps. |
| 267 |
*/ |
| 268 |
public function setup_wizard_steps() { |
| 269 |
$ouput_steps = $this->steps; |
| 270 |
?> |
| 271 |
<div id="mainwp-quick-setup-wizard-steps" class="ui ordered fluid steps" style=""> |
| 272 |
<?php foreach ( $ouput_steps as $step_key => $step ) { ?> |
| 273 |
<?php |
| 274 |
if ( isset( $step['hidden'] ) && $step['hidden'] ) { |
| 275 |
continue; |
| 276 |
} |
| 277 |
|
| 278 |
if ( 'welcome' === $step_key ) { |
| 279 |
continue; |
| 280 |
} |
| 281 |
?> |
| 282 |
<div class="step |
| 283 |
<?php |
| 284 |
if ( $step_key === $this->step ) { |
| 285 |
echo 'active'; |
| 286 |
} elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) { |
| 287 |
echo 'completed'; |
| 288 |
} |
| 289 |
?> |
| 290 |
"> |
| 291 |
<div class="content"> |
| 292 |
<div class="title"><?php echo esc_html( $step['name'] ); ?></div> |
| 293 |
</div> |
| 294 |
</div> |
| 295 |
<?php } ?> |
| 296 |
</div> |
| 297 |
<?php |
| 298 |
} |
| 299 |
|
| 300 |
/** |
| 301 |
* Method setup_wizard_content() |
| 302 |
* |
| 303 |
* Render setup Wizard's current step view. |
| 304 |
*/ |
| 305 |
public function setup_wizard_content() { |
| 306 |
echo '<div class="mainwp-quick-setup-wizard-steps-content" style="margin-top:3em;">'; |
| 307 |
call_user_func( $this->steps[ $this->step ]['view'] ); |
| 308 |
echo '</div>'; |
| 309 |
echo '<div class="ui clearing hidden divider"></div>'; |
| 310 |
} |
| 311 |
|
| 312 |
/** |
| 313 |
* Method mwp_setup_welcome() |
| 314 |
* |
| 315 |
* Renders the Welcome screen of the Quick Start Wizard |
| 316 |
*/ |
| 317 |
public function mwp_setup_welcome() { |
| 318 |
delete_option( 'mainwp_run_quick_setup' ); |
| 319 |
$is_new = MainWP_Demo_Handle::get_instance()->is_new_instance(); |
| 320 |
$enabled_demo = apply_filters( 'mainwp_demo_mode_enabled', false ); |
| 321 |
$count_sites = MainWP_DB::instance()->get_websites_count(); |
| 322 |
?> |
| 323 |
<h1 class="ui header"><?php esc_html_e( 'Welcome to your MainWP Dashboard!', 'mainwp' ); ?></h1> |
| 324 |
<div class="ui message" id="mainwp-message-zone" style="display:none"></div> |
| 325 |
<div class="ui hidden divider"></div> |
| 326 |
<h3><?php esc_html_e( 'Are you ready to get started adding your sites?', 'mainwp' ); ?></h3> |
| 327 |
<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> |
| 328 |
<?php if ( 0 === $count_sites ) : ?> |
| 329 |
<div class="ui hidden divider"></div> |
| 330 |
<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> |
| 331 |
<p><?php esc_attr_e( 'Explore MainWP\'s capabilities using our pre-loaded demo content.', 'mainwp' ); ?></p> |
| 332 |
<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> |
| 333 |
<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> |
| 334 |
<p><?php esc_attr_e( 'Click this button to import the Demo content to your MainWP Dashboard and enable the Demo mode.', 'mainwp' ); ?></p> |
| 335 |
<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> |
| 336 |
<div class="ui blue message"> |
| 337 |
<?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>' ); ?> |
| 338 |
</div> |
| 339 |
<?php endif; ?> |
| 340 |
<?php |
| 341 |
MainWP_System_View::render_comfirm_modal(); |
| 342 |
} |
| 343 |
|
| 344 |
/** |
| 345 |
* Method mwp_setup_introduction() |
| 346 |
* |
| 347 |
* Renders the Introduction screen of the Quick Start Wizard |
| 348 |
*/ |
| 349 |
public function mwp_setup_introduction() { |
| 350 |
?> |
| 351 |
<div class="ui message" id="mainwp-message-zone" style="display:none"></div> |
| 352 |
<h1 class="ui header"><?php esc_html_e( 'MainWP Quick Setup Wizard', 'mainwp' ); ?></h1> |
| 353 |
<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> |
| 354 |
<div class="ui hidden divider"></div> |
| 355 |
<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> |
| 356 |
<div class="ui hidden divider"></div> |
| 357 |
<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> |
| 358 |
<div class="ui hidden divider"></div> |
| 359 |
<form method="post" class="ui form"> |
| 360 |
<h1><?php esc_html_e( 'MainWP Guided Tours', 'mainwp' ); ?> <span class="ui blue mini label"><?php esc_html_e( 'BETA', 'mainwp' ); ?></span></h1> |
| 361 |
<?php esc_html_e( 'MainWP guided tours are designed to provide information about all essential features on each MainWP Dashboard page.', 'mainwp' ); ?> |
| 362 |
<div class="ui blue message"> |
| 363 |
<?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>' ); ?> |
| 364 |
</div> |
| 365 |
<div class="ui form"> |
| 366 |
<div class="field"> |
| 367 |
<div class="ui hidden divider"></div> |
| 368 |
<label><?php esc_html_e( 'Do you want to enable MainWP Guided Tours?', 'mainwp' ); ?></label> |
| 369 |
<div class="ui hidden divider"></div> |
| 370 |
<div class="ui toggle checkbox"> |
| 371 |
<input type="checkbox" name="mainwp-guided-tours-option" id="mainwp-guided-tours-option" checked="true"> |
| 372 |
<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> |
| 373 |
</div> |
| 374 |
</div> |
| 375 |
</div> |
| 376 |
<div class="ui hidden divider"></div> |
| 377 |
<p><?php esc_html_e( 'To go back to the WordPress Admin section, click the "Back to WP Admin" button.', 'mainwp' ); ?></p> |
| 378 |
<div class="ui hidden divider"></div> |
| 379 |
<div class="ui hidden divider"></div> |
| 380 |
<div class="ui hidden divider"></div> |
| 381 |
<input type="submit" class="ui big green right floated button" value="<?php esc_html_e( 'Let\'s Go!', 'mainwp' ); ?>" name="save_step" /> |
| 382 |
<a href="<?php echo esc_url( admin_url( 'index.php' ) ); ?>" class="ui big button"><?php esc_html_e( 'Back to WP Admin', 'mainwp' ); ?></a> |
| 383 |
<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> |
| 384 |
<?php wp_nonce_field( 'mwp-setup' ); ?> |
| 385 |
</form> |
| 386 |
<?php |
| 387 |
MainWP_System_View::render_comfirm_modal(); |
| 388 |
} |
| 389 |
|
| 390 |
|
| 391 |
/** |
| 392 |
* Method mwp_setup_system_requirements() |
| 393 |
* |
| 394 |
* Render System Requirements Step. |
| 395 |
* |
| 396 |
* @uses \MainWP\Dashboard\MainWP_Server_Information::render_quick_setup_system_check() |
| 397 |
*/ |
| 398 |
public function mwp_setup_system_requirements() { |
| 399 |
?> |
| 400 |
<h1><?php esc_html_e( 'System Requirements Check', 'mainwp' ); ?></h1> |
| 401 |
<?php MainWP_System_View::mainwp_warning_notice(); ?> |
| 402 |
<form method="post" class="ui form"> |
| 403 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 404 |
<?php |
| 405 |
$show_ssl = false; |
| 406 |
if ( MainWP_Server_Information_Handler::is_openssl_config_warning() ) { |
| 407 |
$openssl_loc = MainWP_System_Utility::get_openssl_conf(); |
| 408 |
?> |
| 409 |
<div class="ui secondary segment"> |
| 410 |
<div class="grouped fields"> |
| 411 |
<label><?php esc_html_e( 'What is the openssl.cnf file location on your computer?', 'mainwp' ); ?></label> |
| 412 |
<div class="field" id="mainwp-setup-installation-openssl-location"> |
| 413 |
<div class="ui fluid input"> |
| 414 |
<input type="text" name="mwp_setup_openssl_lib_location" value="<?php echo esc_attr( $openssl_loc ); ?>"> |
| 415 |
</div> |
| 416 |
<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> |
| 417 |
</div> |
| 418 |
</div> |
| 419 |
</div> |
| 420 |
<?php |
| 421 |
$show_ssl = true; |
| 422 |
} |
| 423 |
?> |
| 424 |
<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> |
| 425 |
<?php MainWP_Server_Information::render_quick_setup_system_check(); ?> |
| 426 |
<div class="ui hidden divider"></div> |
| 427 |
<div class="ui hidden divider"></div> |
| 428 |
<div class="ui hidden divider"></div> |
| 429 |
<?php |
| 430 |
if ( $show_ssl ) { |
| 431 |
?> |
| 432 |
<input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" /> |
| 433 |
<?php |
| 434 |
} else { |
| 435 |
?> |
| 436 |
<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> |
| 437 |
<?php } ?> |
| 438 |
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big button"><?php esc_html_e( 'Skip', 'mainwp' ); ?></a> |
| 439 |
<a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> |
| 440 |
<?php wp_nonce_field( 'mwp-setup' ); ?> |
| 441 |
</form> |
| 442 |
<?php |
| 443 |
} |
| 444 |
|
| 445 |
|
| 446 |
/** |
| 447 |
* Method mwp_setup_introduction_save() |
| 448 |
* |
| 449 |
* Installation Step save to DB. |
| 450 |
* |
| 451 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 452 |
*/ |
| 453 |
public function mwp_setup_introduction_save() { |
| 454 |
check_admin_referer( 'mwp-setup' ); |
| 455 |
$enabled_tours = ! isset( $_POST['mainwp-guided-tours-option'] ) ? 0 : 1; // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 456 |
MainWP_Utility::update_option( 'mainwp_enable_guided_tours', $enabled_tours ); |
| 457 |
wp_safe_redirect( $this->get_next_step_link() ); |
| 458 |
exit; |
| 459 |
} |
| 460 |
|
| 461 |
/** |
| 462 |
* Method mwp_setup_connect_first_site_save() |
| 463 |
* |
| 464 |
* Installation Step after connect first site. |
| 465 |
*/ |
| 466 |
public function mwp_setup_connect_first_site_save() { |
| 467 |
check_admin_referer( 'mwp-setup' ); |
| 468 |
if ( isset( $_POST['mainwp-qsw-confirm-add-new-client'] ) && ! empty( $_POST['mainwp-qsw-confirm-add-new-client'] ) ) { |
| 469 |
wp_safe_redirect( $this->get_next_step_link() ); |
| 470 |
} else { |
| 471 |
wp_safe_redirect( $this->get_next_step_link( 'monitoring' ) ); |
| 472 |
} |
| 473 |
exit; |
| 474 |
} |
| 475 |
|
| 476 |
/** |
| 477 |
* Method mwp_setup_system_requirements_save() |
| 478 |
* |
| 479 |
* Installation Step save to DB. |
| 480 |
* |
| 481 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 482 |
*/ |
| 483 |
public function mwp_setup_system_requirements_save() { |
| 484 |
check_admin_referer( 'mwp-setup' ); |
| 485 |
if ( isset( $_POST['mwp_setup_openssl_lib_location'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 486 |
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 |
| 487 |
} |
| 488 |
wp_safe_redirect( $this->get_next_step_link() ); |
| 489 |
exit; |
| 490 |
} |
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
/** |
| 495 |
* Method mwp_setup_connect_first_site_already() |
| 496 |
* |
| 497 |
* Render Added first Child Site Step form. |
| 498 |
*/ |
| 499 |
public function mwp_setup_connect_first_site_already() { |
| 500 |
$count_clients = MainWP_DB_Client::instance()->count_total_clients(); |
| 501 |
?> |
| 502 |
<h1 class="ui header"><?php esc_html_e( 'Congratulations!', 'mainwp' ); ?></h1> |
| 503 |
<p><?php esc_html_e( 'You have successfully connected your first site to your MainWP Dashboard!', 'mainwp' ); ?></p> |
| 504 |
<div class="ui form"> |
| 505 |
<form method="post" class="ui form"> |
| 506 |
<?php if ( empty( $count_clients ) ) { ?> |
| 507 |
<div class="field"> |
| 508 |
<label><?php esc_html_e( 'Do you want to create a client for your first child site?', 'mainwp' ); ?></label> |
| 509 |
<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> |
| 510 |
<div class="ui hidden divider"></div> |
| 511 |
<div class="ui toggle checkbox"> |
| 512 |
<input type="checkbox" name="mainwp-qsw-confirm-add-new-client" id="mainwp-qsw-confirm-add-new-client" checked="true"/> |
| 513 |
<label><?php esc_html_e( 'Select to create a New Client', 'mainwp' ); ?></label> |
| 514 |
</div> |
| 515 |
</div> |
| 516 |
<?php } ?> |
| 517 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 518 |
<div class="ui clearing hidden divider"></div> |
| 519 |
<div class="ui hidden divider"></div> |
| 520 |
<div class="ui hidden divider"></div> |
| 521 |
<input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" /> |
| 522 |
<a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> |
| 523 |
<?php wp_nonce_field( 'mwp-setup' ); ?> |
| 524 |
<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' ) ); ?>" /> |
| 525 |
</form> |
| 526 |
</div> |
| 527 |
<?php |
| 528 |
} |
| 529 |
|
| 530 |
|
| 531 |
/** |
| 532 |
* Method mwp_setup_connect_first_site() |
| 533 |
* |
| 534 |
* Render Install first Child Site Step form. |
| 535 |
*/ |
| 536 |
public function mwp_setup_connect_first_site() { |
| 537 |
$count = MainWP_DB::instance()->get_websites_count( null, true ); |
| 538 |
if ( 1 <= $count ) { |
| 539 |
$this->mwp_setup_connect_first_site_already(); |
| 540 |
return; |
| 541 |
} |
| 542 |
?> |
| 543 |
<h1><?php esc_html_e( 'Connect Your First Child Site', 'mainwp' ); ?></h1> |
| 544 |
<?php if ( MainWP_Utility::show_mainwp_message( 'notice', 'mainwp-qsw-add-site-message' ) ) { ?> |
| 545 |
<div class="ui info message"> |
| 546 |
<i class="close icon mainwp-notice-dismiss" notice-id="mainwp-qsw-add-site-message"></i> |
| 547 |
<?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' ); ?> |
| 548 |
<?php esc_html_e( 'To install the MainWP Child plugin, please follow these steps:', 'mainwp' ); ?> |
| 549 |
<ol> |
| 550 |
<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> |
| 551 |
<li><?php printf( esc_html__( 'Go to the %1$sWP > Plugins%2$s page', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 552 |
<li><?php printf( esc_html__( 'Click %1$sAdd New%2$s to install a new plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 553 |
<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> |
| 554 |
<li><?php printf( esc_html__( '%1$sActivate%2$s the plugin', 'mainwp' ), '<strong>', '</strong>' ); ?></li> |
| 555 |
</ol> |
| 556 |
</div> |
| 557 |
<?php } ?> |
| 558 |
<div class="ui form"> |
| 559 |
<div class="field"> |
| 560 |
<div class="ui hidden divider"></div> |
| 561 |
<label><?php esc_html_e( 'Is MainWP Child plugin installed and activated on the WordPress site that you want to connect?', 'mainwp' ); ?></label> |
| 562 |
<div class="ui hidden divider"></div> |
| 563 |
<div class="ui toggle checkbox"> |
| 564 |
<input type="checkbox" name="mainwp-qsw-verify-mainwp-child-active" id="mainwp-qsw-verify-mainwp-child-active"> |
| 565 |
<label for="mainwp-qsw-verify-mainwp-child-active"><?php esc_html_e( 'Select to confirm that the MainWP Child plugin is active.', 'mainwp' ); ?></label> |
| 566 |
</div> |
| 567 |
</div> |
| 568 |
</div> |
| 569 |
<form method="post" class="ui form"> |
| 570 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 571 |
<div id="mainwp-qsw-connect-site-form" style="display:none"> |
| 572 |
<div class="ui hidden divider"></div> |
| 573 |
<div class="ui hidden divider"></div> |
| 574 |
<div class="ui message" id="mainwp-message-zone" style="display:none"></div> |
| 575 |
<div class="ui red message" id="mainwp-error-zone" style="display:none"></div> |
| 576 |
<div class="ui green message" id="mainwp-success-zone" style="display:none"></div> |
| 577 |
<div class="ui info message" id="mainwp-info-zone" style="display:none"></div> |
| 578 |
<div class="ui hidden divider"></div> |
| 579 |
<div class="ui secondary segment"> |
| 580 |
<div class="ui hidden divider"></div> |
| 581 |
<div class="ui hidden divider"></div> |
| 582 |
<div class="ui horizontal divider"><?php esc_html_e( 'Required Fields', 'mainwp' ); ?></div> |
| 583 |
<div class="ui hidden divider"></div> |
| 584 |
<div class="ui hidden divider"></div> |
| 585 |
<div class="field"> |
| 586 |
<label><?php esc_html_e( 'What is the site URL? ', 'mainwp' ); ?></label> |
| 587 |
<div class="ui left action input"> |
| 588 |
<select class="ui compact selection dropdown" id="mainwp_managesites_add_wpurl_protocol" name="mainwp_managesites_add_wpurl_protocol" style="width:120px;padding:0px;"> |
| 589 |
<option value="https">https://</option> |
| 590 |
<option value="http">http://</option> |
| 591 |
</select> |
| 592 |
<input type="text" id="mainwp_managesites_add_wpurl" name="mainwp_managesites_add_wpurl" value="" placeholder="yoursite.com" /> |
| 593 |
</div> |
| 594 |
</div> |
| 595 |
<div class="field"> |
| 596 |
<label><?php esc_html_e( 'What is your administrator username on that site? ', 'mainwp' ); ?></label> |
| 597 |
<input type="text" id="mainwp_managesites_add_wpadmin" name="mainwp_managesites_add_wpadmin" value="" /> |
| 598 |
</div> |
| 599 |
<div class="field"> |
| 600 |
<label><?php esc_html_e( 'Add site title. If left blank URL is used.', 'mainwp' ); ?></label> |
| 601 |
<input type="text" id="mainwp_managesites_add_wpname" name="mainwp_managesites_add_wpname" value="" /> |
| 602 |
</div> |
| 603 |
<div class="ui hidden divider"></div> |
| 604 |
<a href="#" id="mainwp-toggle-optional-settings"><i class="ui eye icon"></i> <?php esc_html_e( 'Advanced options', 'mainwp' ); ?></a> |
| 605 |
<div class="ui hidden divider"></div> |
| 606 |
<div id="mainwp-qsw-optional-settings-form" style="display:none"> |
| 607 |
<div class="ui hidden divider"></div> |
| 608 |
<div class="ui horizontal divider"><?php esc_html_e( 'Advanced Options (optional)', 'mainwp' ); ?></div> |
| 609 |
<div class="ui hidden divider"></div> |
| 610 |
<div class="ui hidden divider"></div> |
| 611 |
<div class="field"> |
| 612 |
<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> |
| 613 |
<input type="text" id="mainwp_managesites_add_uniqueId" name="mainwp_managesites_add_uniqueId" value="" /> |
| 614 |
</div> |
| 615 |
</div> |
| 616 |
</div> |
| 617 |
</div> |
| 618 |
<div class="ui clearing hidden divider"></div> |
| 619 |
<div class="ui hidden divider"></div> |
| 620 |
<div class="ui hidden divider"></div> |
| 621 |
<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' ); ?>" /> |
| 622 |
<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> |
| 623 |
<a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> |
| 624 |
<?php wp_nonce_field( 'mwp-setup' ); ?> |
| 625 |
<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' ) ); ?>" /> |
| 626 |
</form> |
| 627 |
<?php |
| 628 |
} |
| 629 |
|
| 630 |
/** |
| 631 |
* Method mwp_setup_add_client() |
| 632 |
* |
| 633 |
* Render Add first Client Step form. |
| 634 |
*/ |
| 635 |
public function mwp_setup_add_client() { |
| 636 |
$count_clients = MainWP_DB_Client::instance()->count_total_clients(); |
| 637 |
if ( ! empty( $count_clients ) ) { |
| 638 |
?> |
| 639 |
<h1 class="ui header"><?php esc_html_e( 'Congratulations!', 'mainwp' ); ?></h1> |
| 640 |
<p><?php esc_html_e( 'You have successfully created your first Client.', 'mainwp' ); ?></p> |
| 641 |
<?php |
| 642 |
} else { |
| 643 |
$first_site_id = get_transient( 'mainwp_transient_just_connected_site_id' ); |
| 644 |
?> |
| 645 |
<h1><?php esc_html_e( 'Create a Client', 'mainwp' ); ?></h1> |
| 646 |
<div class="ui secondary segment"> |
| 647 |
<form action="" method="post" enctype="multipart/form-data" name="createclient_form" id="createclient_form" class="add:clients: validate"> |
| 648 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 649 |
<div class=""> |
| 650 |
<div class="ui hidden divider"></div> |
| 651 |
<div class="ui message" id="mainwp-message-zone-client" style="display:none;"></div> |
| 652 |
<div id="mainwp-add-new-client-form" > |
| 653 |
<?php $this->render_add_client_content( false, true ); ?> |
| 654 |
</div> |
| 655 |
</div> |
| 656 |
<input type="hidden" name="selected_first_site" value="<?php echo intval( $first_site_id ); ?>"> |
| 657 |
</form> |
| 658 |
<div class="ui clearing hidden divider"></div> |
| 659 |
</div> |
| 660 |
<?php |
| 661 |
} |
| 662 |
?> |
| 663 |
<div class="ui hidden divider"></div> |
| 664 |
<div class="ui hidden divider"></div> |
| 665 |
<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' ); ?> "/> |
| 666 |
<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> |
| 667 |
<a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> |
| 668 |
<?php |
| 669 |
} |
| 670 |
|
| 671 |
|
| 672 |
/** |
| 673 |
* Method render_add_client_content(). |
| 674 |
* |
| 675 |
* Renders add client content window. |
| 676 |
*/ |
| 677 |
public function render_add_client_content() { |
| 678 |
$edit_client = false; |
| 679 |
$client_id = 0; |
| 680 |
$default_client_fields = MainWP_Client_Handler::get_mini_default_client_fields(); |
| 681 |
?> |
| 682 |
<div class="ui form"> |
| 683 |
<?php |
| 684 |
foreach ( $default_client_fields as $field_name => $field ) { |
| 685 |
$db_field = isset( $field['db_field'] ) ? $field['db_field'] : ''; |
| 686 |
$val = $edit_client && '' !== $db_field && property_exists( $edit_client, $db_field ) ? $edit_client->{$db_field} : ''; |
| 687 |
$tip = isset( $field['tooltip'] ) ? $field['tooltip'] : ''; |
| 688 |
?> |
| 689 |
<div class="field"> |
| 690 |
<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> |
| 691 |
<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 ); ?>]"/> |
| 692 |
</div> |
| 693 |
<?php |
| 694 |
|
| 695 |
if ( 'client.email' === $field_name ) { |
| 696 |
?> |
| 697 |
<div class="field"> |
| 698 |
<label><?php esc_html_e( 'Client photo', 'mainwp' ); ?></label> |
| 699 |
<div data-tooltip="<?php esc_attr_e( 'Upload a client photo.', 'mainwp' ); ?>" data-inverted="" data-position="top left"> |
| 700 |
<div class="ui file input"> |
| 701 |
<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' ); ?>" /> |
| 702 |
</div> |
| 703 |
</div> |
| 704 |
</div> |
| 705 |
<?php |
| 706 |
} |
| 707 |
} |
| 708 |
$temp = $this->get_add_contact_temp( false ); |
| 709 |
?> |
| 710 |
<div class="field"> |
| 711 |
<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> |
| 712 |
</div> |
| 713 |
<div class="ui section hidden divider after-add-contact-field"></div> |
| 714 |
</div> |
| 715 |
<input type="hidden" name="client_fields[client_id]" value="<?php echo intval( $client_id ); ?>"> |
| 716 |
<?php |
| 717 |
} |
| 718 |
|
| 719 |
|
| 720 |
/** |
| 721 |
* Method get_add_contact_temp(). |
| 722 |
* |
| 723 |
* Get add contact template. |
| 724 |
* |
| 725 |
* @param bool $echo_out Echo template or not. |
| 726 |
*/ |
| 727 |
public function get_add_contact_temp( $echo_out = false ) { |
| 728 |
|
| 729 |
$input_name = 'new_contacts_field'; |
| 730 |
$contact_id = 0; |
| 731 |
ob_start(); |
| 732 |
?> |
| 733 |
<div class="ui hidden divider top-contact-fields"></div> <?php // must have class: top-contact-fields. ?> |
| 734 |
<div class="ui horizontal divider"><?php esc_html_e( 'Add Contact', 'mainwp' ); ?></div> |
| 735 |
<div class="ui hidden divider"></div> |
| 736 |
<div class="ui hidden divider"></div> |
| 737 |
<?php |
| 738 |
$contact_fields = MainWP_Client_Handler::get_mini_default_contact_fields(); |
| 739 |
foreach ( $contact_fields as $field_name => $field ) { |
| 740 |
$val = ''; |
| 741 |
$contact_id = ''; |
| 742 |
?> |
| 743 |
<div class="field"> |
| 744 |
<label><?php echo esc_html( $field['title'] ); ?></label> |
| 745 |
<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 ); ?>][]"/> |
| 746 |
</div> |
| 747 |
<?php |
| 748 |
} |
| 749 |
?> |
| 750 |
<div class="field remove-contact-field-parent"> |
| 751 |
<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> |
| 752 |
</div> |
| 753 |
<div class="ui section hidden divider bottom-contact-fields"></div> |
| 754 |
<?php |
| 755 |
$html = ob_get_clean(); |
| 756 |
if ( $echo_out ) { |
| 757 |
echo $html; //phpcs:ignore -- validated content. |
| 758 |
} |
| 759 |
return $html; |
| 760 |
} |
| 761 |
|
| 762 |
/** |
| 763 |
* Method mwp_setup_monitoring() |
| 764 |
* |
| 765 |
* Render Monitoring Step. |
| 766 |
*/ |
| 767 |
public function mwp_setup_monitoring() { |
| 768 |
|
| 769 |
$disableSitesMonitoring = (int) get_option( 'mainwp_disableSitesChecking', 1 ); |
| 770 |
$frequencySitesChecking = (int) get_option( 'mainwp_frequencySitesChecking', 60 ); |
| 771 |
|
| 772 |
$disableSitesHealthMonitoring = get_option( 'mainwp_disableSitesHealthMonitoring', 1 ); |
| 773 |
$sitehealthThreshold = get_option( 'mainwp_sitehealthThreshold', 80 ); // "Should be improved" threshold. |
| 774 |
|
| 775 |
?> |
| 776 |
<h1 class="ui header"> |
| 777 |
<?php esc_html_e( 'Basic Uptime Monitoring', 'mainwp' ); ?> |
| 778 |
</h1> |
| 779 |
<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> |
| 780 |
<div class="ui hidden divider"></div> |
| 781 |
<div class="ui hidden divider"></div> |
| 782 |
<form method="post" class="ui form"> |
| 783 |
<?php wp_nonce_field( 'mainwp-admin-nonce' ); ?> |
| 784 |
<div class="ui grid field settings-field-indicator-wrapper" default-indi-value="1"> |
| 785 |
<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>' ); // NOSONAR - noopener - open safe. ?></div> |
| 786 |
<label class="six wide column middle aligned"> |
| 787 |
<?php |
| 788 |
MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disableSitesChecking', (int) $disableSitesMonitoring ); |
| 789 |
esc_html_e( 'Enable basic uptime monitoring', 'mainwp' ); |
| 790 |
?> |
| 791 |
</label> |
| 792 |
<div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="monitoring" style="max-width:100px !important;"> |
| 793 |
<input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_setup_disableSitesChecking" id="mainwp_setup_disableSitesChecking" <?php echo 1 === $disableSitesMonitoring ? '' : 'checked="true"'; ?>/> |
| 794 |
<label class=""></label> |
| 795 |
</div> |
| 796 |
</div> |
| 797 |
|
| 798 |
<div class="ui grid field" <?php echo $disableSitesMonitoring ? 'style="display:none"' : ''; ?> hide-element="monitoring"> |
| 799 |
<label class="six wide column middle aligned"><?php esc_html_e( 'Check interval', 'mainwp' ); ?></label> |
| 800 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Select preferred checking interval.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left"> |
| 801 |
<select name="mainwp_setup_frequency_sitesChecking" id="mainwp_setup_frequency_sitesChecking" class="ui dropdown"> |
| 802 |
<option value="5" <?php echo 5 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Every 5 minutes', 'mainwp' ); ?></option> |
| 803 |
<option value="10" <?php echo 10 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Every 10 minutes', 'mainwp' ); ?></option> |
| 804 |
<option value="30" <?php echo 30 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Every 30 minutes', 'mainwp' ); ?></option> |
| 805 |
<option value="60" <?php echo 60 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Every hour', 'mainwp' ); ?></option> |
| 806 |
<option value="180" <?php echo 180 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Every 3 hours', 'mainwp' ); ?></option> |
| 807 |
<option value="360" <?php echo 360 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Every 6 hours', 'mainwp' ); ?></option> |
| 808 |
<option value="720" <?php echo 720 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Twice a day', 'mainwp' ); ?></option> |
| 809 |
<option value="1440" <?php echo 1440 === $frequencySitesChecking ? 'selected' : ''; ?>><?php esc_html_e( 'Once a day', 'mainwp' ); ?></option> |
| 810 |
</select> |
| 811 |
</div> |
| 812 |
</div> |
| 813 |
<h1 class="ui header"> |
| 814 |
<?php esc_html_e( 'Site Health Monitoring', 'mainwp' ); ?> |
| 815 |
</h1> |
| 816 |
<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> |
| 817 |
<div class="ui hidden divider"></div> |
| 818 |
<div class="ui hidden divider"></div> |
| 819 |
<div class="ui grid field settings-field-indicator-wrapper" default-indi-value="1"> |
| 820 |
<label class="six wide column middle aligned"> |
| 821 |
<?php |
| 822 |
MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_disableSitesHealthMonitoring', (int) $disableSitesHealthMonitoring ); |
| 823 |
esc_html_e( 'Enable Site Health monitoring', 'mainwp' ); |
| 824 |
?> |
| 825 |
</label> |
| 826 |
<div class="ten wide column ui toggle checkbox mainwp-checkbox-showhide-elements" hide-parent="health-monitoring" style="max-width:100px !important;"> |
| 827 |
<input type="checkbox" class="settings-field-value-change-handler" inverted-value="1" name="mainwp_setup_disable_sitesHealthMonitoring" id="mainwp_setup_disable_sitesHealthMonitoring" <?php echo 1 === (int) $disableSitesHealthMonitoring ? '' : 'checked="true"'; ?>/> |
| 828 |
</div> |
| 829 |
</div> |
| 830 |
|
| 831 |
<div class="ui grid field settings-field-indicator-wrapper" default-indi-value="80" <?php echo $disableSitesHealthMonitoring ? 'style="display:none"' : ''; ?> hide-element="health-monitoring"> |
| 832 |
<label class="six wide column middle aligned"> |
| 833 |
<?php |
| 834 |
MainWP_Settings_Indicator::render_not_default_indicator( 'mainwp_sitehealthThreshold', (int) $sitehealthThreshold ); |
| 835 |
esc_html_e( 'Site health threshold', 'mainwp' ); |
| 836 |
?> |
| 837 |
</label> |
| 838 |
<div class="ten wide column" data-tooltip="<?php esc_attr_e( 'Set preferred site health threshold.', 'mainwp' ); ?>" data-inverted="" data-position="bottom left"> |
| 839 |
<select name="mainwp_setup_site_healthThreshold" id="mainwp_setup_site_healthThreshold" class="ui dropdown settings-field-value-change-handler"> |
| 840 |
<option value="80" <?php echo 80 === $sitehealthThreshold || 0 === $sitehealthThreshold ? 'selected' : ''; ?>><?php esc_html_e( 'Should be improved', 'mainwp' ); ?></option> |
| 841 |
<option value="100" <?php echo 100 === $sitehealthThreshold ? 'selected' : ''; ?>><?php esc_html_e( 'Good', 'mainwp' ); ?></option> |
| 842 |
</select> |
| 843 |
</div> |
| 844 |
</div> |
| 845 |
<div class="ui hidden divider"></div> |
| 846 |
<div class="ui hidden divider"></div> |
| 847 |
<input type="submit" class="ui big green right floated button" value="<?php esc_attr_e( 'Continue', 'mainwp' ); ?>" name="save_step" /> |
| 848 |
<a href="<?php echo esc_url( $this->get_next_step_link() ); ?>" class="ui big button"><?php esc_html_e( 'Skip', 'mainwp' ); ?></a> |
| 849 |
<a href="<?php echo esc_url( $this->get_back_step_link() ); ?>" class="ui big basic green button"><?php esc_html_e( 'Back', 'mainwp' ); ?></a> |
| 850 |
|
| 851 |
<?php wp_nonce_field( 'mwp-setup' ); ?> |
| 852 |
</form> |
| 853 |
<?php |
| 854 |
} |
| 855 |
|
| 856 |
/** |
| 857 |
* Method mwp_setup_monitoring_save() |
| 858 |
* |
| 859 |
* Save Monitoring form data. |
| 860 |
* |
| 861 |
* @uses \MainWP\Dashboard\MainWP_Utility::update_option() |
| 862 |
*/ |
| 863 |
public function mwp_setup_monitoring_save() { |
| 864 |
check_admin_referer( 'mwp-setup' ); |
| 865 |
// phpcs:disable WordPress.Security.NonceVerification,WordPress.Security.ValidatedSanitizedInput.InputNotSanitized |
| 866 |
MainWP_Utility::update_option( 'mainwp_disableSitesChecking', ( ! isset( $_POST['mainwp_setup_disableSitesChecking'] ) ? 1 : 0 ) ); |
| 867 |
$val = isset( $_POST['mainwp_setup_frequency_sitesChecking'] ) ? intval( $_POST['mainwp_setup_frequency_sitesChecking'] ) : 1440; |
| 868 |
MainWP_Utility::update_option( 'mainwp_frequencySitesChecking', $val ); |
| 869 |
MainWP_Utility::update_option( 'mainwp_disableSitesHealthMonitoring', ( ! isset( $_POST['mainwp_setup_disable_sitesHealthMonitoring'] ) ? 1 : 0 ) ); |
| 870 |
$val = isset( $_POST['mainwp_setup_site_healthThreshold'] ) ? intval( $_POST['mainwp_setup_site_healthThreshold'] ) : 80; |
| 871 |
MainWP_Utility::update_option( 'mainwp_sitehealthThreshold', $val ); |
| 872 |
// phpcs:enable |
| 873 |
wp_safe_redirect( $this->get_next_step_link() ); |
| 874 |
exit; |
| 875 |
} |
| 876 |
|
| 877 |
/** |
| 878 |
* Method mwp_setup_ready() |
| 879 |
* |
| 880 |
* Render MainWP Dashboard ready message. |
| 881 |
*/ |
| 882 |
public function mwp_setup_ready() { |
| 883 |
?> |
| 884 |
<div class="ui hidden divider"></div> |
| 885 |
<div class="ui hidden divider"></div> |
| 886 |
<h1 class="ui icon header" style="display:block"> |
| 887 |
<i class="thumbs up outline icon"></i> |
| 888 |
<div class="content"> |
| 889 |
<?php esc_html_e( 'Your MainWP Dashboard is Ready!', 'mainwp' ); ?> |
| 890 |
<div class="sub header"><?php esc_html_e( 'Congratulations! Now you are ready to start managing your WordPress sites.', 'mainwp' ); ?></div> |
| 891 |
<div class="ui hidden divider"></div> |
| 892 |
<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> |
| 893 |
</div> |
| 894 |
</h1> |
| 895 |
<div class="ui hidden divider"></div> |
| 896 |
<div class="ui hidden divider"></div> |
| 897 |
<?php |
| 898 |
} |
| 899 |
|
| 900 |
/** |
| 901 |
* Render usetiful tours. |
| 902 |
*/ |
| 903 |
public static function mainwp_usetiful_tours() { |
| 904 |
echo " |
| 905 |
<script> |
| 906 |
(function (w, d, s) { |
| 907 |
let a = d.getElementsByTagName('head')[0]; |
| 908 |
let r = d.createElement('script'); |
| 909 |
r.async = 1; |
| 910 |
r.src = s; |
| 911 |
r.setAttribute('id', 'usetifulScript'); |
| 912 |
r.dataset.token = '480fa17b0507a1c60abba94bfdadd0a7'; |
| 913 |
a.appendChild(r); |
| 914 |
})(window, document, 'https://www.usetiful.com/dist/usetiful.js');</script> |
| 915 |
"; |
| 916 |
} |
| 917 |
} |
| 918 |
|