PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.27
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.27
1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 All 172 releases
userswp / admin / class-admin-setup-wizard.php

class-admin-setup-wizard.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.27, at admin/class-admin-setup-wizard.php

733 lines 28.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
7 class UsersWP_Admin_Setup_Wizard {
8
9 private $step = '';
10
11 private $steps = array();
12
13 public function __construct() {
14
15 add_action( 'admin_menu', array( $this, 'admin_menus' ) );
16 add_action( 'current_screen', array( $this, 'setup_wizard' ) );
17 add_action( 'uwp_wizard_content_general_settings', array( $this, 'content_general_settings' ) );
18 add_action( 'uwp_wizard_content_use_userswp', array( $this, 'content_use_userswp' ) );
19 add_action( 'uwp_wizard_content_menus', array( $this, 'content_menus' ) );
20 add_action( 'uwp_wizard_content_dummy_users', array( $this, 'content_dummy_users' ) );
21 add_action( 'admin_notices', array( $this, 'setup_wizard_notice' ) );
22 add_action( 'wp_loaded', array( $this, 'hide_wizard_notices' ) );
23
24 }
25
26 public function setup_wizard_notice() {
27
28 $show_notice = get_option( "uwp_setup_wizard_notice" );
29
30 if ( isset( $show_notice ) && 1 == $show_notice ) {
31 ?>
32 <div id="message" class="updated notice-alt uwp-message">
33 <p><?php esc_html_e( '<strong>Welcome to UsersWP</strong> &#8211; You&lsquo;re almost ready to start your site. :)', 'userswp' ); ?></p>
34 <p class="submit">
35 <a href="<?php echo esc_url( admin_url( 'admin.php?page=uwp-setup' ) ); ?>"
36 class="button-primary"><?php esc_html_e( 'Run the Setup Wizard', 'userswp' ); ?></a>
37 <a class="button-secondary skip"
38 href="<?php echo esc_url( wp_nonce_url( add_query_arg( 'uwp-hide-notice', 'install' ), 'uwp_hide_notices_nonce', '_uwp_notice_nonce' ) ); ?>"><?php esc_html_e( 'Skip setup', 'userswp' ); ?></a>
39 </p>
40 </div>
41 <?php
42 }
43
44 }
45
46 public function hide_wizard_notices() {
47
48 if ( isset( $_GET['uwp-hide-notice'] ) && isset( $_GET['_uwp_notice_nonce'] ) ) {
49
50 if ( ! wp_verify_nonce( $_GET['_uwp_notice_nonce'], 'uwp_hide_notices_nonce' ) ) {
51 wp_die( esc_html__( 'Action failed. Please refresh the page and retry.', 'userswp' ) );
52 }
53
54 if ( ! current_user_can( 'manage_options' ) ) {
55 wp_die( esc_html__( 'Cheatin&#8217; huh?', 'userswp' ) );
56 }
57
58 delete_option( 'uwp_setup_wizard_notice' );
59 }
60 }
61
62 public function admin_menus() {
63 add_dashboard_page( '', '', 'manage_options', 'uwp-setup', '' );
64 }
65
66 public function setup_wizard() {
67
68 if ( empty( $_GET['page'] ) || 'uwp-setup' !== $_GET['page'] ) {
69 return;
70 }
71
72 $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min';
73
74 $default_steps = array(
75 'introduction' => array(
76 'name' => __( 'Introduction', 'userswp' ),
77 'view' => array( $this, 'setup_introduction' ),
78 'handler' => '',
79 ),
80 'content' => array(
81 'name' => __( 'Content', 'userswp' ),
82 'view' => array( $this, 'setup_content' ),
83 'handler' => array( $this, 'setup_content_save' ),
84 ),
85 'recommend' => array(
86 'name' => __( 'Recommend', 'userswp' ),
87 'view' => array( $this, 'setup_recommend' ),
88 'handler' => array( $this, 'setup_recommend_save' ),
89 ),
90 'next_steps' => array(
91 'name' => __( 'Ready!', 'userswp' ),
92 'view' => array( $this, 'setup_ready' ),
93 'handler' => '',
94 ),
95 );
96
97 $this->steps = apply_filters( 'uwp_setup_wizard_steps', $default_steps );
98 $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) );
99
100 wp_enqueue_style( 'wp-admin' );
101 $obj = WP_Font_Awesome_Settings::instance();
102 $obj->enqueue_style();
103 $obj->enqueue_scripts();
104 wp_enqueue_style( 'uwp-setup-wizard-style', USERSWP_PLUGIN_URL . 'admin/assets/css/setup-wizard' . $suffix . '.css', array(
105 'dashicons',
106 'install',
107 'thickbox'
108 ), '', '' );
109
110 $required_scripts = array(
111 'jquery',
112 'jquery-ui-tooltip',
113 'thickbox',
114 'jquery-ui-progressbar'
115 );
116
117 wp_register_script( 'uwp-setup', USERSWP_PLUGIN_URL . 'admin/assets/js/setup-wizard' . $suffix . '.js', $required_scripts, USERSWP_VERSION );
118
119 wp_localize_script( 'uwp-setup', 'uwp_wizard_obj', array(
120 'ajaxurl' => admin_url( 'admin-ajax.php' )
121 ) );
122
123 if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
124 call_user_func( $this->steps[ $this->step ]['handler'], $this );
125 }
126
127 ob_start();
128
129 $this->setup_wizard_header();
130 $this->setup_wizard_steps();
131 $this->setup_wizard_content();
132 $this->setup_wizard_footer();
133 exit;
134 }
135
136 public function setup_wizard_header() {
137 ?>
138 <!DOCTYPE html>
139 <html <?php language_attributes(); ?>>
140 <head>
141 <meta name="viewport" content="width=device-width"/>
142 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
143 <title><?php esc_html_e( 'Userswp &rsaquo; Setup Wizard', 'userswp' ); ?></title>
144 <?php do_action( 'admin_print_styles' ); ?>
145 <?php wp_print_scripts( 'uwp-setup' ); ?>
146 <?php do_action( 'admin_head' ); ?>
147 </head>
148 <body class="uwp-setup wp-core-ui">
149 <h1 id="uwp-logo">
150 <a href="https://userswp.io/"><span class="dashicons dashicons-groups"></span>
151 <span><span class="text-secondary">Users</span><span class="text-primary">WP</span></span>
152 </a>
153 </h1>
154 <?php
155 }
156
157 public function setup_wizard_steps() {
158
159 $ouput_steps = $this->steps;
160
161 array_shift( $ouput_steps );
162 ?>
163 <ol class="uwp-setup-steps">
164 <?php foreach ( $ouput_steps as $step_key => $step ) : ?>
165 <li class="<?php
166 if ( $step_key === $this->step ) {
167 echo 'active';
168 } elseif ( array_search( $this->step, array_keys( $this->steps ) ) > array_search( $step_key, array_keys( $this->steps ) ) ) {
169 echo 'done';
170 }
171 ?>">
172 <?php echo esc_html( $step['name'] ); ?>
173 </li>
174 <?php endforeach; ?>
175 </ol>
176 <?php
177 }
178
179 public function setup_wizard_content() {
180 echo '<div class="uwp-setup-content">';
181 call_user_func( $this->steps[ $this->step ]['view'], $this );
182 echo '</div>';
183 }
184
185 public function setup_wizard_footer() {
186 if ( 'next_steps' === $this->step ) : ?>
187 <p class="uwp-return-to-dashboard-wrap">
188 <a class="uwp-return-to-dashboard" href="<?php echo esc_url( admin_url() ); ?>">
189 <?php esc_html_e( 'Return to the WordPress Dashboard', 'userswp' ); ?>
190 </a>
191 </p>
192 <?php endif; ?>
193 </body>
194 </html>
195 <?php
196 }
197
198 public function setup_introduction() {
199 ?>
200 <h2><?php esc_html_e( 'Thank you for choosing UsersWP!', 'userswp' ); ?></h2>
201 <p><?php esc_html_e( 'This quick setup wizard will help you configure the basic settings. It\'s completely optional and shouldn\'t take longer than two minutes.', 'userswp' ); ?></p>
202 <p><?php esc_html_e( 'No time right now? If you don\'t want to go through the wizard, you can skip and return to the WordPress dashboard. Come back anytime if you change your mind!', 'userswp' ); ?></p>
203
204 <p class="uwp-setup-actions step">
205 <a href="<?php echo esc_url( admin_url() ); ?>"
206 class="button button-large"><?php esc_html_e( 'Not right now', 'userswp' ); ?></a>
207 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
208 class="button-primary button button-large button-next"><?php esc_html_e( "Let's go!", 'userswp' ); ?></a>
209 </p>
210 <?php
211 }
212
213 public function get_next_step_link( $step = '' ) {
214 if ( ! $step ) {
215 $step = $this->step;
216 }
217
218 $keys = array_keys( $this->steps );
219 if ( end( $keys ) === $step ) {
220 return admin_url();
221 }
222
223 $step_index = array_search( $step, $keys );
224 if ( false === $step_index ) {
225 return '';
226 }
227
228 return add_query_arg( 'step', $keys[ $step_index + 1 ] );
229 }
230
231 public function setup_content() {
232
233 $wizard_content = array();
234
235 if ( is_multisite() ) {
236 $reg = get_site_option( 'registration' );
237
238 if ( $reg == 'none' ) {
239 $wizard_content['general_settings'] = __( "General Settings", "userswp" );
240 }
241
242 } else {
243 if ( ! get_option( 'users_can_register' ) ) {
244 $wizard_content['general_settings'] = __( "General Settings", "userswp" );
245 }
246 }
247
248 $wizard_content['use_userswp'] = __( "How will you use UsersWP", "userswp" );
249 $wizard_content['menus'] = __( "Menus", "userswp" );
250 $wizard_content['dummy_users'] = __( "Dummy Users", "userswp" );
251
252 $wizard_content = apply_filters( 'uwp_wizard_content', $wizard_content );
253 ?>
254 <div class="uwp-wizard-content-parts">
255 <ul>
256 <?php
257 foreach ( $wizard_content as $slug => $title ) {
258 echo '<li class="uwp-sub-menu-tab"><a href="#' . esc_attr( $slug ) . '">' . esc_attr( $title ) . '</a></li>' . " \n";
259 }
260 ?>
261 </ul>
262 </div>
263 <form method="post">
264 <?php
265 foreach ( $wizard_content as $slug => $title ) {
266 echo '<h2 class="uwp-settings-title "><a id="' . esc_attr( $slug ) . '"></a>' . esc_attr( $title ) . '</h2>' . " \n"; // line break adds a nice spacing
267 do_action( "uwp_wizard_content_{$slug}" );
268 }
269 ?>
270 <p class="uwp-setup-actions step">
271 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
272 class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'userswp' ); ?></a>
273 <input type="submit" class="button-primary button button-large button-next"
274 value="<?php esc_attr_e( 'Continue', 'userswp' ); ?>" name="save_step"/>
275 <?php wp_nonce_field( 'uwp-setup' ); ?>
276 </p>
277 </form>
278 <?php
279 }
280
281 public function content_general_settings() {
282
283 if ( is_multisite() ) {
284
285 $reg = get_site_option( 'registration' );
286
287 if ( $reg == 'none' ) {
288 ?>
289 <table class="form-table">
290 <tbody>
291 <tr>
292 <td>
293 <p class="description-tooltip danger" style="color: red;"><i
294 class="fas fa-exclamation-circle"></i>
295 <strong><?php esc_html_e( 'Heads Up!', 'userswp' ); ?></strong> <?php esc_html_e( ' User registration is currently not allowed.', 'userswp' ); ?>
296 </p>
297 <label><input class="uwp-general-seetings" name="registration" type="radio"
298 id="registration1"
299 value="none"<?php checked( $reg, 'none' ); ?> /> <?php esc_html_e( 'Registration is disabled', 'userswp' ); ?>
300 </label><br/>
301 <label><input class="uwp-general-seetings" name="registration" type="radio"
302 id="registration2"
303 value="user"<?php checked( $reg, 'user' ); ?> /> <?php esc_html_e( 'User accounts may be registered', 'userswp' ); ?>
304 </label><br/>
305 <label><input class="uwp-general-seetings" name="registration" type="radio"
306 id="registration3"
307 value="blog"<?php checked( $reg, 'blog' ); ?> /> <?php esc_html_e( 'Logged in users may register new sites', 'userswp' ); ?>
308 </label><br/>
309 <label><input class="uwp-general-seetings" name="registration" type="radio"
310 id="registration4"
311 value="all"<?php checked( $reg, 'all' ); ?> /> <?php esc_html_e( 'Both sites and user accounts can be registered', 'userswp' ); ?>
312 </label>
313 </td>
314 <td></td>
315 </tr>
316 </tbody>
317 </table>
318 <?php
319 }
320 } else {
321 if ( ! get_option( 'users_can_register' ) ) {
322 ?>
323 <table class="form-table">
324 <tbody>
325 <tr>
326 <td>
327 <p class="description-tooltip danger" style="color: red;"><i
328 class="fas fa-exclamation-circle"></i>
329 <strong><?php esc_html_e( 'Heads Up!', 'userswp' ); ?></strong> <?php esc_html_e( ' User registration is currently not allowed.', 'userswp' ); ?>
330 </p>
331 <input type="checkbox" name="users_can_register" class="uwp-general-seetings" value="1">
332 <strong><?php esc_html_e( " Anyone can register", "userswp" ); ?></strong>
333 </td>
334 <td></td>
335 </tr>
336 </tbody>
337 </table>
338 <?php
339 }
340 }
341 }
342
343 public function content_use_userswp() {
344 ?>
345 <table class="form-table uwp-dummy-table">
346 <tbody>
347 <tr>
348 <td>
349 <input type="checkbox" name="login_register_page" class="use-uwp-pages" value="1" checked>
350 <strong><?php esc_html_e( "Login/Register", "userswp" ); ?></strong></td>
351 <td></td>
352 </tr>
353 <tr>
354 <td>
355 <input type="checkbox" name="user_profiles_page" class="use-uwp-pages" value="1" checked>
356 <strong><?php esc_html_e( "User Profiles", "userswp" ); ?></strong></td>
357 <td></td>
358 </tr>
359 <tr>
360 <td>
361 <input type="checkbox" name="member_directory_page" class="use-uwp-pages" value="1" checked>
362 <strong><?php esc_html_e( "Members Directory", "userswp" ); ?></strong></td>
363 <td></td>
364 </tr>
365 </tbody>
366 </table>
367 <?php
368 }
369
370 public function content_menus() {
371 ?>
372 <table class="form-table uwp-dummy-table">
373 <tbody>
374 <tr>
375 <td>
376 <strong><?php esc_html_e( "Select the theme main menu", "userswp" ); ?></strong>
377 </td>
378 <td style="width: 20%">
379 <strong><?php esc_html_e( "Action", "userswp" ); ?></strong>
380 </td>
381 </tr>
382 <tr>
383 <td>
384 <?php
385 $set_menus = get_nav_menu_locations();
386 $set_menus = array_filter( $set_menus );
387
388 if ( ! empty( $set_menus ) ) {
389
390 echo "<select id='uwp_wizard_menu_id' data-type='add' class='uwp-select'>";
391
392 foreach ( $set_menus as $menu_location => $menu_id ) {
393 $selected = false;
394
395 if ( strpos( strtolower( $menu_location ), 'primary' ) !== false || strpos( strtolower( $menu_location ), 'main' ) !== false ) {
396 $selected = true;
397 }
398
399 $menu_item = wp_get_nav_menus( $menu_id )[0];
400
401 ?>
402 <option value="<?php echo esc_attr( $menu_id ); ?>" <?php selected( $selected, true ); ?>>
403 <?php echo esc_html( $menu_item->name );
404 if ( $selected ) {
405 echo ' ' . esc_html__( '( Auto detected )', 'userswp' );
406 } ?>
407 </option>
408 <?php
409 }
410
411 echo "</select>";
412
413 } else {
414 $menus = get_registered_nav_menus();
415
416 if ( ! empty( $menus ) ) {
417
418 echo "<select id='uwp_wizard_menu_location' data-type='create' class='uwp-select'>";
419
420 foreach ( $menus as $menu_slug => $menu_name ) {
421 $selected = false;
422
423 if ( strpos( strtolower( $menu_slug ), 'primary' ) !== false || strpos( strtolower( $menu_slug ), 'main' ) !== false ) {
424 $selected = true;
425 }
426 ?>
427 <option value="<?php echo esc_attr( $menu_slug ); ?>" <?php selected( $selected, true ); ?>>
428 <?php esc_html_e( 'Create new menu in:', 'userswp' );
429 echo ' ' . esc_html__( $menu_name );
430 if ( $selected ) {
431 echo ' ' . esc_html__( '( Auto detected )', 'userswp' );
432 } ?>
433 </option>
434 <?php
435 }
436 echo "</select>";
437 }
438 }
439 ?>
440 <div class="notice inline notice-success notice-alt uwp-wizard-menu uwp-wizard-menu-result"></div>
441 </td>
442 <td>
443 <input type="button" value="<?php esc_attr_e( "Insert menu items", "userswp" ); ?>"
444 class="button-primary uwp_dummy_button"
445 onclick="uwp_wizard_setup_menu('<?php echo esc_attr( wp_create_nonce( "uwp-wizard-setup-menu" ) ); ?>'); return false;">
446 </td>
447 </tr>
448 </tbody>
449 </table>
450 <?php
451
452 }
453
454 public function content_dummy_users() {
455
456 $get_dummy_user_passowrd = $this->get_dummy_user_passowrd();
457 $dummy_users = get_users( array(
458 'meta_key' => 'uwp_dummy_user',
459 'meta_value' => '1',
460 'fields' => array( 'ID' )
461 ) );
462 $total_dummy_users = ! empty( $dummy_users ) ? count( $dummy_users ) : 0;
463 ?>
464 <table class="form-table uwp-dummy-table">
465 <tbody>
466 <tr>
467 <td>
468 <p><?php echo wp_sprintf( __( 'Dummy Users for Testing. Password for all dummy users: <strong>%s</strong>', 'userswp' ), $get_dummy_user_passowrd ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></p>
469 </td>
470 <td style="width: 20%">
471 <input style="display: <?php echo ( $total_dummy_users > 0 ) ? 'block' : 'none'; ?>" type="button"
472 value="<?php esc_attr_e( 'Remove', 'userswp' ); ?>"
473 class="button-primary button uwp_diagnosis_button uwp_dummy_users_button uwp_remove_dummy_users_button"
474 onclick="uwp_wizard_setup_dummy_users('<?php echo esc_attr( wp_create_nonce( "uwp_process_diagnosis" ) ); ?>','remove_dummy_users'); return false;"/>
475 <input style="display: <?php echo ( $total_dummy_users > 0 ) ? 'none' : 'block'; ?>" type="button"
476 value="<?php esc_attr_e( "Create Users", "userswp" ); ?>"
477 class="button-primary button uwp_diagnosis_button uwp_dummy_users_button uwp_add_dummy_users_button"
478 onclick="uwp_wizard_setup_dummy_users('<?php echo esc_attr( wp_create_nonce( "uwp_process_diagnosis" ) ); ?>','add_dummy_users'); return false;">
479 </td>
480 </tr>
481 <tr>
482 <td colspan="2" class="has-pbar">
483 <div id="uwp_diagnose_pb_add_dummy_users" class="uwp-pb-wrapper">
484 <div class="progressBar" style="display: none;">
485 <div></div>
486 </div>
487 </div>
488 <div id="uwp_diagnose_add_dummy_users"></div>
489 <div id="uwp_diagnose_pb_remove_dummy_users" class="uwp-pb-wrapper">
490 <div class="progressBar" style="display: none;">
491 <div></div>
492 </div>
493 </div>
494 <div id="uwp_diagnose_remove_dummy_users"></div>
495 </td>
496 </tr>
497 </tbody>
498 </table>
499 <?php
500 }
501
502 public function get_dummy_user_passowrd() {
503 return substr( hash( 'SHA256', AUTH_KEY . site_url() ), 0, 15 );
504 }
505
506 public function setup_content_save() {
507 check_admin_referer( 'uwp-setup' );
508
509 if ( ! empty( $_REQUEST['step'] ) && 'content' === $_REQUEST['step'] ) {
510 $this->save_content_step_data();
511 }
512
513 wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
514 exit;
515 }
516
517 public function save_content_step_data() {
518
519 $login_register_page = ! empty( $_POST['login_register_page'] ) ? absint( $_POST['login_register_page'] ) : '';
520 $user_profiles_page = ! empty( $_POST['user_profiles_page'] ) ? absint( $_POST['user_profiles_page'] ) : '';
521 $member_directory_page = ! empty( $_POST['member_directory_page'] ) ? absint( $_POST['member_directory_page'] ) : '';
522
523 if ( is_multisite() ) {
524 if ( isset( $_POST['registration'] ) && ! empty( $_POST['registration'] ) ) {
525 update_site_option( 'registration', esc_attr( $_POST['registration'] ) );
526 }
527 } else {
528 if ( isset( $_POST['users_can_register'] ) && 1 == absint( $_POST['users_can_register'] ) ) {
529 update_option( 'users_can_register', 1 );
530 }
531 }
532
533 $login_page = uwp_get_page_id( 'login_page' );
534 $register_page = uwp_get_page_id( 'register_page' );
535 $change_page = uwp_get_page_id( 'change_page' );
536 $forgot_page = uwp_get_page_id( 'forgot_page' );
537 $reset_page = uwp_get_page_id( 'reset_page' );
538 $profile_page = uwp_get_page_id( 'profile_page' );
539 $account_page = uwp_get_page_id( 'account_page' );
540 $users_page = uwp_get_page_id( 'users_page' );
541 $user_list_item_page = uwp_get_page_id( 'user_list_item_page' );
542
543 $login_pages = array( $login_page, $register_page, $change_page, $forgot_page, $reset_page );
544
545 if ( ! empty( $login_pages ) && count( $login_pages ) > 0 ) {
546 $login_page_status = 'draft';
547 foreach ( $login_pages as $login_page_id ) {
548
549 if ( ! empty( $login_register_page ) ) {
550 $login_page_status = 'publish';
551 }
552
553 wp_update_post( array(
554 'ID' => $login_page_id,
555 'post_status' => $login_page_status
556 ) );
557
558 }
559 }
560
561 $profile_pages = array( $profile_page, $account_page );
562
563 if ( ! empty( $profile_pages ) && count( $profile_pages ) > 0 ) {
564 $profile_page_status = 'draft';
565 foreach ( $profile_pages as $profile_page_id ) {
566
567 if ( ! empty( $user_profiles_page ) ) {
568 $profile_page_status = 'publish';
569 }
570
571 wp_update_post( array(
572 'ID' => $profile_page_id,
573 'post_status' => $profile_page_status
574 ) );
575
576 }
577 }
578
579 $users_pages = array( $users_page, $user_list_item_page );
580
581 if ( ! empty( $users_pages ) && count( $users_pages ) > 0 ) {
582 $user_page_status = 'draft';
583 foreach ( $users_pages as $user_page_id ) {
584
585 if ( ! empty( $member_directory_page ) ) {
586 $user_page_status = 'publish';
587 }
588
589 wp_update_post( array(
590 'ID' => $user_page_id,
591 'post_status' => $user_page_status
592 ) );
593
594 }
595 }
596
597 }
598
599 public function setup_recommend() {
600 ?>
601 <form method="post">
602 <div class="uwp-wizard-recommend">
603 <h2 class="uwp-settings-title "><?php esc_html_e( "Recommended Plugins", "userswp" ); ?></h2>
604 <p><?php esc_html_e( "Below are a few recommended plugins that will help you with your site.", "userswp" ); ?></p>
605 <?php
606 include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
607
608 $recommend_wp_plugins = self::get_recommend_wp_plugins();
609
610 if ( ! empty( $recommend_wp_plugins ) ) {
611 echo "<ul>";
612
613 $installed_text = '<i class="fas fa-check-circle" aria-hidden="true"></i> ' . __( 'Installed', 'userswp' );
614 $installing_text = '<i class="fas fa-sync fa-spin" aria-hidden="true"></i> ' . __( 'Installing', 'userswp' );
615
616 echo "<input type='hidden' id='uwp-installing-text' value='" . esc_attr( $installing_text ) . "' >";
617 echo "<input type='hidden' id='uwp-installed-text' value='" . esc_attr( $installed_text ) . "' >";
618
619 foreach ( $recommend_wp_plugins as $plugin ) {
620 $status = install_plugin_install_status( array( "slug" => $plugin['slug'], "version" => "" ) );
621
622 $plugin_status = isset( $status['status'] ) ? $status['status'] : '';
623 $url = isset( $status['url'] ) ? $status['url'] : '';
624
625 if ( $plugin_status == 'install' ) {
626 $checked = "checked";
627 $disabled = "";
628 $checkbox_class = "class='uwp_install_plugins'";
629 } else {
630 $checked = "checked";
631 $disabled = "disabled";
632 $checkbox_class = "";
633 }
634
635 $uwp_html_tip = '<span class="uwp-help-tip dashicons dashicons-editor-help" title="' . esc_attr( $plugin['desc'] ) . '"></span>';
636 echo "<li class='" . esc_attr( $plugin['slug'] ) . "'>";
637 echo "<input type='checkbox' id='" . esc_attr( $plugin['slug'] ) . "' $checked $disabled $checkbox_class />" . $plugin['name'] . " " . $uwp_html_tip; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
638 echo " | <a href='" . esc_url( admin_url( "plugin-install.php?uwp_wizard_recommend=true&tab=plugin-information&plugin=" . $plugin['slug'] . '&TB_iframe=true&width=772&height=407' ) ) . "' class='thickbox'>" . esc_html__( 'More info', 'userswp' ) . "</a>";
639 if ( $plugin_status == 'install' && $url ) {
640 echo " | <span class='uwp-plugin-status' >( " . esc_html__( 'Tick to install', 'userswp' ) . " )</span>";
641 } else {
642 if ( ! empty( $plugin_status ) ) {
643 $plugin_status = $installed_text;
644 }
645 echo " | <span class='uwp-plugin-status'>" . esc_html( $plugin_status ) . "</span>";
646 }
647 echo "</li>";
648
649 }
650 echo "</ul>";
651 }
652 ?>
653 </div>
654 <p class="uwp-setup-actions step">
655 <?php wp_nonce_field( 'uwp-setup' ); ?>
656 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
657 class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'userswp' ); ?></a>
658 <input type="submit" class="button-primary button button-large button-next uwp-continue-recommend"
659 value="<?php esc_attr_e( 'Continue', 'userswp' ); ?>" name="save_step"/>
660 <input type="submit" class="button-primary button button-large button-next uwp-install-recommend"
661 value="<?php esc_attr_e( 'Install', 'userswp' ); ?>" name="install_recommend"
662 onclick="uwp_wizard_install_plugins('<?php echo esc_attr( wp_create_nonce( 'updates' ) ); ?>');return false;"/>
663 </p>
664 </form>
665 <?php
666 }
667
668 public static function get_recommend_wp_plugins() {
669
670 $plugins = array(
671 'ayecode-connect' => array(
672 'url' => 'https://wordpress.org/plugins/ayecode-connect/',
673 'slug' => 'ayecode-connect',
674 'name' => 'AyeCode Connect',
675 'desc' => __( 'Allows you to install any purchased AyeCode Ltd product add-ons without a zip file. It also installs and activates licences automatically, so there is no need to copy/paste licenses.', 'userswp' ),
676 ),
677 'userswp-social-login' => array(
678 'url' => 'https://wordpress.org/plugins/userswp-social-login/',
679 'slug' => 'userswp-social-login',
680 'name' => __( 'UsersWP – Social Login', 'userswp' ),
681 'desc' => __( 'This plugin lets your user to register and login with popular sites like Facebook, Google, Twitter, LinkedIn, Instagram, Yahoo, WordPress, vkontakte etc.', 'userswp' ),
682 ),
683 'userswp-recaptcha' => array(
684 'url' => 'https://wordpress.org/plugins/userswp-recaptcha/',
685 'slug' => 'userswp-recaptcha',
686 'name' => __( 'UsersWP – ReCaptcha', 'userswp' ),
687 'desc' => __( 'This plugin allows you to implement a super security captcha into forms like registration, login forms etc.', 'userswp' ),
688 ),
689 );
690
691 return $plugins;
692 }
693
694 public function setup_recommend_save() {
695 check_admin_referer( 'uwp-setup' );
696 wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
697 exit;
698 }
699
700 public function setup_ready() {
701 $this->setup_ready_actions();
702 ?>
703 <h2><?php esc_html_e( 'Awesome, you are ready to go!', 'userswp' ); ?></h2>
704 <div class="uwp-message">
705 <p><?php esc_html_e( 'Thank you for using UsersWP :)', 'userswp' ); ?></p>
706 </div>
707 <div class="uwp-setup-next-steps-last">
708 <h2><?php esc_html_e( 'Learn more', 'userswp' ); ?></h2>
709 <ul>
710 <li class="uwp-getting-started">
711 <a href="https://userswp.io/docs/?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=userswpplugin"
712 target="_blank"><?php esc_html_e( 'Getting started guide', 'userswp' ); ?></a>
713 </li>
714 <li class="uwp-newsletter">
715 <a href="https://userswp.io/newsletter-signup/?utm_source=setupwizard&utm_medium=product&utm_content=newsletter&utm_campaign=userswpplugin"
716 target="_blank"><?php esc_html_e( 'Get Userswp advice in your inbox', 'userswp' ); ?></a>
717 </li>
718 <li class="uwp-get-help">
719 <a href="https://userswp.io/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=userswpplugin"
720 target="_blank"><?php esc_html_e( 'Have questions? Get help.', 'userswp' ); ?></a>
721 </li>
722 </ul>
723 </div>
724 <?php
725 }
726
727 private function setup_ready_actions() {
728 delete_option( 'uwp_setup_wizard_notice' );
729 }
730
731 }
732
733 new UsersWP_Admin_Setup_Wizard();