PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.2.35
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.2.35
1.2.73 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 All 173 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.2.35, at admin/class-admin-setup-wizard.php

736 lines 28.4 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 _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 _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 _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( __( 'Action failed. Please refresh the page and retry.', 'userswp' ) );
52 }
53
54 if ( ! current_user_can( 'manage_options' ) ) {
55 wp_die( __( '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 _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 _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 _e( 'Heads Up!', 'userswp' ); ?></strong> <?php _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 _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 _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 _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 _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 _e( 'Heads Up!', 'userswp' ); ?></strong> <?php _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 _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 _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 _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 _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 _e( "Select the theme main menu", "userswp" ); ?></strong>
377 </td>
378 <td style="width: 20%">
379 <strong><?php _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 = '';
394
395 if ( strpos( strtolower( $menu_location ), 'primary' ) !== false || strpos( strtolower( $menu_location ), 'main' ) !== false ) {
396 $selected = 'selected="selected"';
397 }
398
399 $menu_item = wp_get_nav_menus( $menu_id )[0];
400
401 ?>
402 <option value="<?php echo esc_attr( $menu_id ); ?>" <?php echo $selected; ?>>
403 <?php echo esc_attr( $menu_item->name );
404 if ( $selected ) {
405 echo ' ';
406 _e( '( Auto detected )', 'userswp' );
407 } ?>
408 </option>
409 <?php
410 }
411
412 echo "</select>";
413
414 } else {
415 $menus = get_registered_nav_menus();
416
417 if ( ! empty( $menus ) ) {
418
419 echo "<select id='uwp_wizard_menu_location' data-type='create' class='uwp-select'>";
420
421 foreach ( $menus as $menu_slug => $menu_name ) {
422 $selected = '';
423
424 if ( strpos( strtolower( $menu_slug ), 'primary' ) !== false || strpos( strtolower( $menu_slug ), 'main' ) !== false ) {
425 $selected = 'selected="selected"';
426 }
427 ?>
428 <option value="<?php echo esc_attr( $menu_slug ); ?>" <?php echo $selected; ?>>
429 <?php _e( 'Create new menu in:', 'userswp' );
430 echo ' ' . esc_attr( $menu_name );
431 if ( $selected ) {
432 echo ' ';
433 _e( '( Auto detected )', 'userswp' );
434 } ?>
435 </option>
436 <?php
437 }
438 echo "</select>";
439 }
440 }
441 ?>
442 <div class="notice inline notice-success notice-alt uwp-wizard-menu uwp-wizard-menu-result"></div>
443 </td>
444 <td>
445 <input type="button" value="<?php _e( "Insert menu items", "userswp" ); ?>"
446 class="button-primary uwp_dummy_button"
447 onclick="uwp_wizard_setup_menu('<?php echo wp_create_nonce( "uwp-wizard-setup-menu" ); ?>'); return false;">
448 </td>
449 </tr>
450 </tbody>
451 </table>
452 <?php
453
454 }
455
456 public function content_dummy_users() {
457
458 $get_dummy_user_passowrd = $this->get_dummy_user_passowrd();
459 $dummy_users = get_users( array(
460 'meta_key' => 'uwp_dummy_user',
461 'meta_value' => '1',
462 'fields' => array( 'ID' )
463 ) );
464 $total_dummy_users = ! empty( $dummy_users ) ? count( $dummy_users ) : 0;
465 ?>
466 <table class="form-table uwp-dummy-table">
467 <tbody>
468 <tr>
469 <td>
470 <p><?php echo sprintf( __( 'Dummy Users for Testing. Password for all dummy users: <strong>%s</strong>', 'userswp' ), $get_dummy_user_passowrd ); ?></p>
471 </td>
472 <td style="width: 20%">
473 <input style="display: <?php echo ( $total_dummy_users > 0 ) ? 'block' : 'none'; ?>" type="button"
474 value="<?php _e( 'Remove', 'userswp' ); ?>"
475 class="button-primary button uwp_diagnosis_button uwp_dummy_users_button uwp_remove_dummy_users_button"
476 onclick="uwp_wizard_setup_dummy_users('<?php echo wp_create_nonce( "uwp_process_diagnosis" ); ?>','remove_dummy_users'); return false;"/>
477 <input style="display: <?php echo ( $total_dummy_users > 0 ) ? 'none' : 'block'; ?>" type="button"
478 value="<?php _e( "Create Users", "userswp" ); ?>"
479 class="button-primary button uwp_diagnosis_button uwp_dummy_users_button uwp_add_dummy_users_button"
480 onclick="uwp_wizard_setup_dummy_users('<?php echo wp_create_nonce( "uwp_process_diagnosis" ); ?>','add_dummy_users'); return false;">
481 </td>
482 </tr>
483 <tr>
484 <td colspan="2" class="has-pbar">
485 <div id="uwp_diagnose_pb_add_dummy_users" class="uwp-pb-wrapper">
486 <div class="progressBar" style="display: none;">
487 <div></div>
488 </div>
489 </div>
490 <div id="uwp_diagnose_add_dummy_users"></div>
491 <div id="uwp_diagnose_pb_remove_dummy_users" class="uwp-pb-wrapper">
492 <div class="progressBar" style="display: none;">
493 <div></div>
494 </div>
495 </div>
496 <div id="uwp_diagnose_remove_dummy_users"></div>
497 </td>
498 </tr>
499 </tbody>
500 </table>
501 <?php
502 }
503
504 public function get_dummy_user_passowrd() {
505 return substr( hash( 'SHA256', AUTH_KEY . site_url() ), 0, 15 );
506 }
507
508 public function setup_content_save() {
509 check_admin_referer( 'uwp-setup' );
510
511 if ( ! empty( $_REQUEST['step'] ) && 'content' === $_REQUEST['step'] ) {
512 $this->save_content_step_data();
513 }
514
515 wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
516 exit;
517 }
518
519 public function save_content_step_data() {
520
521 $login_register_page = ! empty( $_POST['login_register_page'] ) ? absint( $_POST['login_register_page'] ) : '';
522 $user_profiles_page = ! empty( $_POST['user_profiles_page'] ) ? absint( $_POST['user_profiles_page'] ) : '';
523 $member_directory_page = ! empty( $_POST['member_directory_page'] ) ? absint( $_POST['member_directory_page'] ) : '';
524
525 if ( is_multisite() ) {
526 if ( isset( $_POST['registration'] ) && ! empty( $_POST['registration'] ) ) {
527 update_site_option( 'registration', esc_attr( $_POST['registration'] ) );
528 }
529 } else {
530 if ( isset( $_POST['users_can_register'] ) && 1 == absint( $_POST['users_can_register'] ) ) {
531 update_option( 'users_can_register', 1 );
532 }
533 }
534
535 $login_page = uwp_get_page_id( 'login_page' );
536 $register_page = uwp_get_page_id( 'register_page' );
537 $change_page = uwp_get_page_id( 'change_page' );
538 $forgot_page = uwp_get_page_id( 'forgot_page' );
539 $reset_page = uwp_get_page_id( 'reset_page' );
540 $profile_page = uwp_get_page_id( 'profile_page' );
541 $account_page = uwp_get_page_id( 'account_page' );
542 $users_page = uwp_get_page_id( 'users_page' );
543 $user_list_item_page = uwp_get_page_id( 'user_list_item_page' );
544
545 $login_pages = array( $login_page, $register_page, $change_page, $forgot_page, $reset_page );
546
547 if ( ! empty( $login_pages ) && count( $login_pages ) > 0 ) {
548 $login_page_status = 'draft';
549 foreach ( $login_pages as $login_page_id ) {
550
551 if ( ! empty( $login_register_page ) ) {
552 $login_page_status = 'publish';
553 }
554
555 wp_update_post( array(
556 'ID' => $login_page_id,
557 'post_status' => $login_page_status
558 ) );
559
560 }
561 }
562
563 $profile_pages = array( $profile_page, $account_page );
564
565 if ( ! empty( $profile_pages ) && count( $profile_pages ) > 0 ) {
566 $profile_page_status = 'draft';
567 foreach ( $profile_pages as $profile_page_id ) {
568
569 if ( ! empty( $user_profiles_page ) ) {
570 $profile_page_status = 'publish';
571 }
572
573 wp_update_post( array(
574 'ID' => $profile_page_id,
575 'post_status' => $profile_page_status
576 ) );
577
578 }
579 }
580
581 $users_pages = array( $users_page, $user_list_item_page );
582
583 if ( ! empty( $users_pages ) && count( $users_pages ) > 0 ) {
584 $user_page_status = 'draft';
585 foreach ( $users_pages as $user_page_id ) {
586
587 if ( ! empty( $member_directory_page ) ) {
588 $user_page_status = 'publish';
589 }
590
591 wp_update_post( array(
592 'ID' => $user_page_id,
593 'post_status' => $user_page_status
594 ) );
595
596 }
597 }
598
599 }
600
601 public function setup_recommend() {
602 ?>
603 <form method="post">
604 <div class="uwp-wizard-recommend">
605 <h2 class="uwp-settings-title "><?php _e( "Recommended Plugins", "userswp" ); ?></h2>
606 <p><?php _e( "Below are a few recommended plugins that will help you with your site.", "userswp" ); ?></p>
607 <?php
608 include_once( ABSPATH . 'wp-admin/includes/plugin-install.php' );
609
610 $recommend_wp_plugins = self::get_recommend_wp_plugins();
611
612 if ( ! empty( $recommend_wp_plugins ) ) {
613 echo "<ul>";
614
615 $installed_text = '<i class="fas fa-check-circle" aria-hidden="true"></i> ' . __( 'Installed', 'userswp' );
616 $installing_text = '<i class="fas fa-sync fa-spin" aria-hidden="true"></i> ' . __( 'Installing', 'userswp' );
617
618 echo "<input type='hidden' id='uwp-installing-text' value='$installing_text' >";
619 echo "<input type='hidden' id='uwp-installed-text' value='$installed_text' >";
620
621 foreach ( $recommend_wp_plugins as $plugin ) {
622 $status = install_plugin_install_status( array( "slug" => $plugin['slug'], "version" => "" ) );
623
624 $plugin_status = isset( $status['status'] ) ? $status['status'] : '';
625 $url = isset( $status['url'] ) ? $status['url'] : '';
626
627 if ( $plugin_status == 'install' ) {
628 $checked = "checked";
629 $disabled = "";
630 $checkbox_class = "class='uwp_install_plugins'";
631 } else {
632 $checked = "checked";
633 $disabled = "disabled";
634 $checkbox_class = "";
635 }
636
637 $uwp_html_tip = '<span class="uwp-help-tip dashicons dashicons-editor-help" title="' . $plugin['desc'] . '"></span>';
638 echo "<li class='" . $plugin['slug'] . "'>";
639 echo "<input type='checkbox' id='" . $plugin['slug'] . "' $checked $disabled $checkbox_class />";
640 echo $plugin['name'] . " " . $uwp_html_tip;
641 echo " | <a href='" . admin_url( "plugin-install.php?uwp_wizard_recommend=true&tab=plugin-information&plugin=" . $plugin['slug'] . '&TB_iframe=true&width=772&height=407' ) . "' class='thickbox'>" . __( 'More info', 'userswp' ) . "</a>";
642 if ( $plugin_status == 'install' && $url ) {
643 echo " | <span class='uwp-plugin-status' >( " . __( 'Tick to install', 'userswp' ) . " )</span>";
644 } else {
645 if ( ! empty( $plugin_status ) ) {
646 $plugin_status = $installed_text;
647 }
648 echo " | <span class='uwp-plugin-status'>$plugin_status</span>";
649 }
650 echo "</li>";
651
652 }
653 echo "</ul>";
654 }
655 ?>
656 </div>
657 <p class="uwp-setup-actions step">
658 <?php wp_nonce_field( 'uwp-setup' ); ?>
659 <a href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
660 class="button button-large button-next"><?php esc_html_e( 'Skip this step', 'userswp' ); ?></a>
661 <input type="submit" class="button-primary button button-large button-next uwp-continue-recommend"
662 value="<?php esc_attr_e( 'Continue', 'userswp' ); ?>" name="save_step"/>
663 <input type="submit" class="button-primary button button-large button-next uwp-install-recommend"
664 value="<?php esc_attr_e( 'Install', 'userswp' ); ?>" name="install_recommend"
665 onclick="uwp_wizard_install_plugins('<?php echo wp_create_nonce( 'updates' ); ?>');return false;"/>
666 </p>
667 </form>
668 <?php
669 }
670
671 public static function get_recommend_wp_plugins() {
672
673 $plugins = array(
674 'ayecode-connect' => array(
675 'url' => 'https://wordpress.org/plugins/ayecode-connect/',
676 'slug' => 'ayecode-connect',
677 'name' => 'AyeCode Connect',
678 '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' ),
679 ),
680 'userswp-social-login' => array(
681 'url' => 'https://wordpress.org/plugins/userswp-social-login/',
682 'slug' => 'userswp-social-login',
683 'name' => __( 'UsersWP – Social Login', 'userswp' ),
684 'desc' => __( 'This plugin lets your user to register and login with popular sites like Facebook, Google, Twitter, LinkedIn, Instagram, Yahoo, WordPress, vkontakte etc.', 'userswp' ),
685 ),
686 'userswp-recaptcha' => array(
687 'url' => 'https://wordpress.org/plugins/userswp-recaptcha/',
688 'slug' => 'userswp-recaptcha',
689 'name' => __( 'UsersWP – ReCaptcha', 'userswp' ),
690 'desc' => __( 'This plugin allows you to implement a super security captcha into forms like registration, login forms etc.', 'userswp' ),
691 ),
692 );
693
694 return $plugins;
695 }
696
697 public function setup_recommend_save() {
698 check_admin_referer( 'uwp-setup' );
699 wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
700 exit;
701 }
702
703 public function setup_ready() {
704 $this->setup_ready_actions();
705 ?>
706 <h2><?php esc_html_e( 'Awesome, you are ready to go!', 'userswp' ); ?></h2>
707 <div class="uwp-message">
708 <p><?php _e( 'Thank you for using UsersWP :)', 'userswp' ); ?></p>
709 </div>
710 <div class="uwp-setup-next-steps-last">
711 <h2><?php _e( 'Learn more', 'userswp' ); ?></h2>
712 <ul>
713 <li class="uwp-getting-started">
714 <a href="https://userswp.io/docs/?utm_source=setupwizard&utm_medium=product&utm_content=getting-started&utm_campaign=userswpplugin"
715 target="_blank"><?php esc_html_e( 'Getting started guide', 'userswp' ); ?></a>
716 </li>
717 <li class="uwp-newsletter">
718 <a href="https://userswp.io/newsletter-signup/?utm_source=setupwizard&utm_medium=product&utm_content=newsletter&utm_campaign=userswpplugin"
719 target="_blank"><?php esc_html_e( 'Get Userswp advice in your inbox', 'userswp' ); ?></a>
720 </li>
721 <li class="uwp-get-help">
722 <a href="https://userswp.io/support/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=userswpplugin"
723 target="_blank"><?php esc_html_e( 'Have questions? Get help.', 'userswp' ); ?></a>
724 </li>
725 </ul>
726 </div>
727 <?php
728 }
729
730 private function setup_ready_actions() {
731 delete_option( 'uwp_setup_wizard_notice' );
732 }
733
734 }
735
736 new UsersWP_Admin_Setup_Wizard();