PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.6
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / admin / setup-wizard.php

setup-wizard.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.6, at admin/setup-wizard.php

627 lines 24.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' ) ) exit;
4
5 class WPPB_Setup_Wizard {
6 private $step = '';
7 private $steps = array();
8 public $general_settings = array();
9 public $user_pages = array();
10
11 public function __construct() {
12 if( apply_filters( 'wppb_run_setup_wizard', true ) && current_user_can( 'manage_options' ) ){
13 add_action( 'admin_menu', array( $this, 'add_page' ) );
14 add_action( 'admin_head', array( $this, 'hide_page_from_dashboard' ) );
15 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) );
16 add_filter( 'wppb_output_dashboard_setup_wizard', array( $this, 'setup_wizard' ) );
17 add_action( 'admin_init', array( $this, 'redirect_to_setup' ) );
18 add_action( 'admin_init', array( $this, 'save_data' ) );
19 //add_action( 'admin_init', array( $this, 'set_existing_user_pages' ) );
20 add_action( 'wp_ajax_dismiss_setup_wizard_newsletter_subscribe', array( $this, 'dismiss_setup_wizard_newsletter_subscribe' ) );
21 }
22 }
23
24 public function add_page() {
25 add_dashboard_page( '', '', 'manage_options', 'wppb-setup', '' );
26 }
27
28 public function hide_page_from_dashboard() {
29 remove_submenu_page( 'index.php', 'wppb-setup' );
30 }
31
32 public function enqueue_scripts_and_styles() {
33 if( isset( $_GET['subpage'] ) && $_GET['subpage'] == 'wppb-setup' ) {
34 wp_enqueue_style( 'wppb-setup-wizard', WPPB_PLUGIN_URL . 'assets/css/style-setup-wizard.css', array(), PROFILE_BUILDER_VERSION );
35 wp_enqueue_script( 'wppb-wizard-js', WPPB_PLUGIN_URL . 'assets/js/setup-wizard.js', array( 'jquery', 'jquery-ui-core', 'jquery-ui-dialog' ), PROFILE_BUILDER_VERSION );
36 }
37 }
38
39 public function get_default_steps(){
40 return array(
41 'user-pages' => __( 'User Pages', 'profile-builder' ),
42 'general' => __( 'Design & UI', 'profile-builder' ),
43 'addons' => __( 'Add-Ons', 'profile-builder' ),
44 'next' => __( 'Ready!', 'profile-builder' ),
45 );
46 }
47
48 public function redirect_to_setup(){
49 $run_setup = get_transient( 'wppb_run_setup_wizard' );
50
51 if( $run_setup == true ){
52 delete_transient( 'wppb_run_setup_wizard' );
53 wp_safe_redirect( admin_url( 'admin.php?page=profile-builder-dashboard&subpage=wppb-setup' ) );
54 die();
55 }
56 }
57
58 public function setup_wizard() {
59 if( empty( $_GET['page'] ) || $_GET['page'] != 'profile-builder-dashboard' )
60 return;
61
62 if( empty( $_GET['subpage'] ) || $_GET['subpage'] != 'wppb-setup' )
63 return;
64
65 $this->general_settings = get_option( 'wppb_general_settings', array() );
66 $this->user_pages = get_option( 'wppb_user_pages', array() );
67
68 $default_steps = $this->get_default_steps();
69
70 reset( $default_steps );
71
72 $this->steps = apply_filters( 'wppb_setup_wizard_steps', $default_steps );
73
74 $step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : key( $default_steps );
75 $valid_steps = array_keys( $this->steps );
76
77 if ( !in_array( $step, $valid_steps ) ) {
78 $step = 'user-pages'; // default
79 }
80
81 $this->step = $step;
82
83 include_once 'setup-wizard/view-page-setup-wizard.php';
84
85 exit;
86 }
87
88 public function save_data() {
89 if( empty( $_POST['wppb_setup_wizard_nonce'] ) )
90 return;
91
92 check_admin_referer( 'wppb-setup-wizard-nonce', 'wppb_setup_wizard_nonce' );
93
94 if( !current_user_can( 'manage_options' ) )
95 return;
96
97 $default_steps = $this->get_default_steps();
98
99 reset( $default_steps );
100
101 $this->steps = apply_filters( 'wppb_setup_wizard_steps', $default_steps );
102 $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : key( $default_steps );
103
104 // save data
105 if( $this->step === 'user-pages' ) {
106
107 if( !empty( $_POST['wppb_user_pages'] ) ) {
108
109 $pages = array(
110 'register' => array(
111 'title' => 'Register',
112 'option' => 'register_page',
113 'content' => '[wppb-register]',
114 'block_content' => '<!-- wp:wppb/register /-->',
115 ),
116 'login' => array(
117 'title' => 'Login',
118 'option' => 'login_page',
119 'content' => '[wppb-login]',
120 'block_content' => '<!-- wp:wppb/login /-->',
121 ),
122 'edit_profile' => array(
123 'title' => 'Edit Profile',
124 'option' => 'edit_profile_page',
125 'content' => '[wppb-edit-profile]',
126 'block_content' => '<!-- wp:wppb/edit-profile /-->',
127 ),
128 'reset_password' => array(
129 'title' => 'Password Reset',
130 'option' => 'lost_password_page',
131 'content' => '[wppb-recover-password]',
132 'block_content' => '<!-- wp:wppb/recover-password /-->',
133 ),
134 );
135
136
137 foreach( $_POST['wppb_user_pages'] as $page_slug => $value ) { /* phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized */
138 if( $value == 1 ){
139 $this->create_page( $pages[$page_slug]['option'], $pages[$page_slug]['title'], $pages[$page_slug]['content'], $pages[$page_slug]['block_content'] );
140 }
141 }
142
143 update_option( 'wppb_user_pages', $this->user_pages );
144
145 }
146
147 } elseif( $this->step === 'general' ) {
148
149 $general_settings = get_option( 'wppb_general_settings', array() );
150
151 // Form Design
152 if ( isset( $_POST['wppb_general_settings'] ) && !empty( $_POST['wppb_general_settings']['formsDesign'] ) )
153 $general_settings['formsDesign'] = sanitize_text_field( $_POST['wppb_general_settings']['formsDesign'] );
154 else $general_settings['formsDesign'] = 'form-style-default';
155
156 // Automatically Log-in
157 if( isset( $_POST['automaticallyLogIn'] ) )
158 $general_settings['automaticallyLogIn'] = sanitize_text_field( $_POST['automaticallyLogIn'] );
159 else
160 unset( $general_settings['automaticallyLogIn'] );
161
162 // Hide Admin Bar For Subscriber Role
163 if( isset( $_POST['hide_admin_bar_for_subscriber'] ) ) {
164
165 if ( empty( $general_settings['hide_admin_bar_for'] ) && !is_array( $general_settings['hide_admin_bar_for'] ) ) {
166 $general_settings['hide_admin_bar_for'] = array();
167 }
168
169 if ( empty( $general_settings['hide_admin_bar_for'] ) || !in_array( 'Subscriber', $general_settings['hide_admin_bar_for'] ) )
170 $general_settings['hide_admin_bar_for'][] = 'Subscriber';
171
172 } elseif ( !empty( $general_settings['hide_admin_bar_for'] ) && in_array( 'Subscriber', $general_settings['hide_admin_bar_for'] ) ) {
173
174 $subscriber_key = array_search('Subscriber', $general_settings['hide_admin_bar_for']);
175 unset( $general_settings['hide_admin_bar_for'][$subscriber_key] );
176
177 }
178
179 // Email Confirmation After Registration
180 if( isset( $_POST['emailConfirmation'] ) )
181 $general_settings['emailConfirmation'] = sanitize_text_field( $_POST['emailConfirmation'] );
182 else
183 unset( $general_settings['emailConfirmation'] );
184
185 // Admin Approval
186 if( isset( $_POST['adminApproval'] ) )
187 $general_settings['adminApproval'] = sanitize_text_field( $_POST['adminApproval'] );
188 else
189 unset( $general_settings['adminApproval'] );
190
191 if( !empty( $general_settings ) )
192 update_option( 'wppb_general_settings', $general_settings );
193
194 } elseif( $this->step === 'addons' ) {
195 $pro_addons = get_option( 'wppb_module_settings', 'not_found' );
196
197 // User Listing Addon
198 if( isset( $_POST['wppb_userListing'] ) )
199 $pro_addons['wppb_userListing'] = 'show';
200 else $pro_addons['wppb_userListing'] = 'hide';
201
202 // Custom Redirects Addon
203 if( isset( $_POST['wppb_customRedirect'] ) )
204 $pro_addons['wppb_customRedirect'] = 'show';
205 else $pro_addons['wppb_customRedirect'] = 'hide';
206
207 update_option( 'wppb_module_settings', $pro_addons );
208
209
210 $basic_addons = get_option( 'wppb_advanced_add_ons_settings', array() );
211
212 // Multi Step Form Addon
213 if( isset( $_POST['multi-step-forms'] ) )
214 $basic_addons['multi-step-forms'] = true;
215 else $basic_addons['multi-step-forms'] = false;
216
217 // Social Connect Addon
218 if( isset( $_POST['social-connect'] ) )
219 $basic_addons['social-connect'] = true;
220 else $basic_addons['social-connect'] = false;
221
222 update_option( 'wppb_advanced_add_ons_settings', $basic_addons );
223
224 }
225
226 // step completion for setup
227 $steps_completion = $this->get_completed_progress_steps();
228
229 if( !empty( $this->step ) ){
230 if( empty( $steps_completion ) ){
231
232 $steps_completion = array(
233 $this->step => 1,
234 );
235
236 } else {
237
238 $steps_completion[$this->step] = 1;
239
240 }
241 }
242
243 update_option( 'wppb_setup_wizard_steps', $steps_completion, false );
244
245 // redirect to the next step at the end
246 wp_safe_redirect( esc_url_raw( $this->get_next_step_link() ) );
247 exit;
248 }
249
250 public static function get_completed_progress_steps() {
251 $steps = get_option( 'wppb_setup_wizard_steps', array() );
252
253 return is_array( $steps ) ? $steps : array();
254 }
255
256 private function get_next_step_link( $step = '' ) {
257 if( !$step )
258 $step = $this->step;
259
260 $keys = array_keys( $this->steps );
261
262 if( end( $keys ) === $step )
263 return admin_url();
264
265 $step_index = array_search( $step, $keys, true );
266
267 if( $step_index === false )
268 return '';
269
270 return add_query_arg( 'step', $keys[$step_index + 1] );
271 }
272
273 /**
274 * Check if Gutenberg block editor is available and active
275 *
276 * @return bool
277 */
278 private function is_gutenberg_available() {
279 // use_block_editor_for_post_type() checks if block editor is available (WP 5.0+),
280 // respects Classic Editor plugin settings, and any filters
281 return function_exists( 'use_block_editor_for_post_type' ) && use_block_editor_for_post_type( 'page' );
282 }
283
284 private function create_page( $option, $title, $content = '', $block_content = '' ) {
285 if( empty( $this->user_pages ) )
286 $this->user_pages = get_option( 'wppb_user_pages', array() );
287
288 //try to find an existing page with the shortcode or block
289 if( empty( $this->user_pages[$option] ) || $this->user_pages[$option] == '-1' ) {
290
291 if( !empty( $content ) ){
292 global $wpdb;
293
294 // Clean shortcode for searching (remove wp:shortcode wrapper if present)
295 $shortcode = str_replace( array( '<!-- wp:shortcode -->', '<!-- /wp:shortcode -->' ), '', $content );
296
297 // Search for existing page with shortcode
298 $existing_page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", '%' . $shortcode . '%' ) );
299
300 // If no shortcode page found, and we have block content, search for block
301 if( empty( $existing_page ) && !empty( $block_content ) ) {
302 $existing_page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", '%' . $wpdb->esc_like( $block_content ) . '%' ) );
303 }
304
305 if( !empty( $existing_page ) ) {
306 $this->user_pages[$option] = $existing_page;
307
308 return $existing_page;
309 }
310 }
311
312 // Determine which content to use: blocks if available, otherwise shortcodes
313 $page_content = $content;
314 if( $this->is_gutenberg_available() && !empty( $block_content ) ) {
315 $page_content = $block_content;
316 }
317
318 $page = array(
319 'post_type' => 'page',
320 'post_status' => 'publish',
321 'post_title' => $title,
322 'post_content' => $page_content
323 );
324
325 $page_id = wp_insert_post( $page );
326 $this->user_pages[$option] = $page_id;
327 }
328 }
329
330 public function set_existing_user_pages() {
331
332 if( !current_user_can( 'manage_options' ) )
333 return;
334
335 $user_pages = get_option( 'wppb_user_pages', array() );
336
337 $pages = array(
338 'register' => array(
339 'title' => 'Register',
340 'option' => 'register_page',
341 'content' => '[wppb-register]',
342 'block_content' => '<!-- wp:wppb/register /-->',
343 ),
344 'login' => array(
345 'title' => 'Login',
346 'option' => 'login_page',
347 'content' => '[wppb-login]',
348 'block_content' => '<!-- wp:wppb/login /-->',
349 ),
350 'edit_profile' => array(
351 'title' => 'Edit Profile',
352 'option' => 'edit_profile_page',
353 'content' => '[wppb-edit-profile]',
354 'block_content' => '<!-- wp:wppb/edit-profile /-->',
355 ),
356 'reset_password' => array(
357 'title' => 'Password Reset',
358 'option' => 'lost_password_page',
359 'content' => '[wppb-recover-password]',
360 'block_content' => '<!-- wp:wppb/recover-password /-->',
361 ),
362 );
363
364 global $wpdb;
365 foreach ( $pages as $page ) {
366 if( empty( $user_pages[$page['option']] ) && !empty( $page['content'] ) ){
367 // Search for shortcode-based pages
368 $shortcode = str_replace( array( '<!-- wp:shortcode -->', '<!-- /wp:shortcode -->' ), '', $page['content'] );
369 $existing_page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", '%' . $shortcode . '%' ) );
370
371 // If no shortcode page found, search for block-based pages
372 if( empty( $existing_page ) && !empty( $page['block_content'] ) ) {
373 $existing_page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", '%' . $wpdb->esc_like( $page['block_content'] ) . '%' ) );
374 }
375
376 if( !empty( $existing_page ) ) {
377 $user_pages[$page['option']] = $existing_page;
378 }
379 }
380 }
381
382 if ( !empty( $user_pages ) )
383 update_option( 'wppb_user_pages', $user_pages );
384
385 $this->user_pages = get_option( 'wppb_user_pages', array() );
386
387 }
388
389 public static function get_progress_steps() {
390
391 $wppb_generalSettings = get_option( 'wppb_general_settings', 'not_found' );
392 $roles_editor_enabled = ( $wppb_generalSettings !== 'not_found' && isset( $wppb_generalSettings['rolesEditor'] ) && !empty( $wppb_generalSettings['rolesEditor'] ) && $wppb_generalSettings['rolesEditor'] === 'yes' );
393
394 if ( $roles_editor_enabled ) {
395 $roles_editor_url = admin_url( 'edit.php?post_type=wppb-roles-editor' );
396 } else {
397 // URL with nonce for activating Roles Editor
398 $roles_editor_url = wp_nonce_url( admin_url( 'admin.php?action=wppb_enable_roles_editor' ), 'wppb_enable_roles_editor_nonce', 'wppb_nonce' );
399 }
400
401 $progress_steps = array(
402 'user-pages' => array(
403 'label' => __( 'Create user pages for registration, login, edit profile and password reset.', 'profile-builder' ),
404 'url' => admin_url( 'admin.php?page=profile-builder-dashboard&subpage=wppb-setup' ),
405 ),
406 'general' => array(
407 'label' => __( 'Choose a design and optimize the login and registration flow for your users.', 'profile-builder' ),
408 'url' => admin_url( 'admin.php?page=profile-builder-dashboard&subpage=wppb-setup&step=general' ),
409 ),
410 'addons' => array(
411 'label' => __( 'Learn about and enable addons for extra functionality.', 'profile-builder' ),
412 'url' => admin_url( 'admin.php?page=profile-builder-dashboard&subpage=wppb-setup&step=addons' ),
413 ),
414 'extra_form_field' => array(
415 'label' => __( 'Add extra fields to the registration and edit profile forms.', 'profile-builder' ),
416 'url' => admin_url( 'admin.php?page=manage-fields#manage-fields' ),
417 ),
418 'restrict_content' => array(
419 'label' => __( 'Restrict your content based on the user role.', 'profile-builder' ),
420 'url' => admin_url( 'admin.php?page=profile-builder-content_restriction' ),
421 ),
422 'extra_user_roles' => array(
423 'label' => __( 'Create new user roles with the Role Editor.', 'profile-builder' ),
424 'url' => $roles_editor_url,
425 ),
426 );
427
428 return $progress_steps;
429 }
430
431 public static function output_progress_steps() {
432 $steps = self::get_progress_steps();
433 $steps_completion = self::get_completed_progress_steps();
434
435 // User Pages and General Settings Completion
436 if( !isset( $steps_completion['user-pages'] ) && self::website_has_plugin_pages() ){
437 $steps_completion['user-pages'] = 1;
438 $steps_completion['general'] = 1;
439 }
440
441 // Addons Completion
442 if( !isset( $steps_completion['addons'] ) && self::website_has_active_addons() )
443 $steps_completion['addons'] = 1;
444
445 // Extra Form Field Completion
446 if( !isset( $steps_completion['extra_form_field'] ) && self::website_edited_form_fields() )
447 $steps_completion['extra_form_field'] = 1;
448
449 // Restrict Content Completion
450 if( !isset( $steps_completion['restrict_content'] ) && self::website_has_restricted_content() )
451 $steps_completion['restrict_content'] = 1;
452
453 // User Roles Completion
454 if( !isset( $steps_completion['extra_user_roles'] ) && self::website_has_extra_user_roles() )
455 $steps_completion['extra_user_roles'] = 1;
456
457 update_option( 'wppb_setup_wizard_steps', $steps_completion, false );
458
459 $current_step = is_array( $steps_completion ) ? count( $steps_completion ) : 0;
460 $total_steps = count( $steps );
461
462 ob_start(); ?>
463
464 <div class="wppb-setup-progress">
465 <h3><?php esc_html_e( 'Progress Review', 'profile-builder' ); ?></h3>
466 <p><?php printf( esc_html__( 'Follow these steps to start registering users on your website. %1s out of %2s complete.', 'profile-builder' ), esc_html( $current_step ), esc_html( $total_steps ) ); ?></p>
467
468 <div class="wppb-setup-progress__bar">
469 <?php foreach( $steps as $slug => $step ) : ?>
470 <div class="item <?php echo isset( $steps_completion[$slug] ) && $steps_completion[$slug] == 1 ? 'completed' : ''; ?>"></div>
471 <?php endforeach; ?>
472 </div>
473
474 <div class="wppb-setup-progress__steps">
475 <?php foreach( $steps as $slug => $step ) : ?>
476 <a class="wppb-setup-progress__step <?php echo isset( $steps_completion[$slug] ) && $steps_completion[$slug] == 1 ? 'completed' : ''; ?>" href="<?php echo esc_url( $step['url'] ) ?>" target="<?php echo isset( $step['target'] ) ? esc_html( $step['target'] ) : '' ?>">
477 <?php echo esc_html( $step['label'] ); ?>
478 </a>
479 <?php endforeach; ?>
480 </div>
481 </div>
482
483 <?php
484 $output = ob_get_clean();
485
486 echo $output; //phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
487 }
488
489 public static function website_has_plugin_pages() {
490 global $wpdb;
491
492 // Check for both shortcode and block-based pages
493 $search_patterns = array(
494 '[wppb-register]',
495 '[wppb-login]',
496 '[wppb-edit-profile]',
497 '[wppb-recover-password]',
498 '<!-- wp:wppb/register',
499 '<!-- wp:wppb/login',
500 '<!-- wp:wppb/edit-profile',
501 '<!-- wp:wppb/recover-password',
502 );
503
504 foreach ( $search_patterns as $pattern ) {
505 $existing_page = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE post_type='page' AND post_status NOT IN ( 'pending', 'trash', 'future', 'auto-draft' ) AND post_content LIKE %s LIMIT 1;", '%' . $wpdb->esc_like( $pattern ) . '%' ) );
506
507 if( !empty( $existing_page ) )
508 return true;
509 }
510
511 return false;
512 }
513
514 public static function website_has_active_addons() {
515 $free_addons = get_option( 'wppb_free_add_ons_settings', array() );
516 $pro_addons = get_option( 'wppb_module_settings', 'not_found' );
517 $basic_addons = get_option( 'wppb_advanced_add_ons_settings', array() );
518
519 $all_addons = array_merge( $free_addons, $pro_addons, $basic_addons );
520
521 foreach ( $all_addons as $addon => $value ) {
522 if( $value === true || $value === 'show' )
523 return true;
524 }
525
526 return false;
527 }
528
529 public static function website_edited_form_fields() {
530 $default_fields = array(
531 'Default - Name (Heading)',
532 'Default - Contact Info (Heading)',
533 'Default - About Yourself (Heading)',
534 'Default - Username',
535 'Default - First Name',
536 'Default - Last Name',
537 'Default - Nickname',
538 'Default - E-mail',
539 'Default - Website',
540 'Default - Password',
541 'Default - Repeat Password',
542 'Default - Biographical Info',
543 'Default - Display name publicly as',
544 );
545
546 $wppb_manage_fields = get_option ( 'wppb_manage_fields', 'not_set' );
547
548
549 if ( empty( $wppb_manage_fields ) || count( $default_fields ) !== count( $wppb_manage_fields ) )
550 return true;
551
552 foreach ( $wppb_manage_fields as $field ) {
553 if ( !in_array( $field['field'], $default_fields ) )
554 return true;
555 }
556
557 return false;
558 }
559
560 public static function website_has_restricted_content() {
561 $args = [
562 'posts_per_page' => '1',
563 'post_type' => array( 'post', 'page' ),
564 'meta_query' => [
565 [
566 'key' => 'wppb-content-restrict-user-role',
567 'compare' => 'EXISTS'
568 ]
569 ],
570 ];
571
572 $result = new WP_Query( $args );
573
574 if( $result->have_posts() )
575 return true;
576
577 // Logged in meta
578 $args = [
579 'posts_per_page' => '1',
580 'post_type' => array( 'post', 'page' ),
581 'meta_query' => [
582 [
583 'key' => 'wppb-content-restrict-user-status',
584 'compare' => 'EXISTS'
585 ]
586 ],
587 ];
588
589 $result = new WP_Query( $args );
590
591 if( $result->have_posts() )
592 return true;
593
594 return false;
595 }
596
597 public static function website_has_extra_user_roles() {
598 global $wp_roles;
599
600 $user_roles = $wp_roles->roles;
601 $default_roles = array( 'administrator', 'editor', 'author', 'contributor', 'subscriber' );
602
603 foreach ( $user_roles as $slug => $details ) {
604 if ( !in_array( $slug, $default_roles ) )
605 return true;
606 }
607
608 return false;
609 }
610
611 public function dismiss_setup_wizard_newsletter_subscribe() {
612
613 check_ajax_referer( 'dismiss_setup_wizard_newsletter_subscribe', 'wppb_nonce' );
614
615 $user_id = get_current_user_id();
616
617 if( !empty( $user_id ) )
618 update_user_meta( $user_id, 'wppb_setup_wizard_newsletter', 1 );
619
620 wp_die();
621
622 }
623
624 }
625
626 new WPPB_Setup_Wizard();
627