PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 4.0.3
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v4.0.3
4.0.3 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 All 341 releases
← All changes | admin/setup-wizard.php +98 -32 3.16.34.0.3 View file →
@@ -6,8 +6,9 @@
6 6 private $step = '';
7 7 private $steps = array();
8 8 public $general_settings = array();
9 9 public $user_pages = array();
10 + public $content_restriction_settings = array();
10 11
11 12 public function __construct() {
12 13 if( apply_filters( 'wppb_run_setup_wizard', true ) && current_user_can( 'manage_options' ) ){
13 14 add_action( 'admin_menu', array( $this, 'add_page' ) );
@@ -12,8 +13,9 @@
12 13 if( apply_filters( 'wppb_run_setup_wizard', true ) && current_user_can( 'manage_options' ) ){
13 14 add_action( 'admin_menu', array( $this, 'add_page' ) );
14 15 add_action( 'admin_head', array( $this, 'hide_page_from_dashboard' ) );
15 16 add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts_and_styles' ) );
17 + add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_wizard_forms_pointer' ) );
16 18 add_filter( 'wppb_output_dashboard_setup_wizard', array( $this, 'setup_wizard' ) );
17 19 add_action( 'admin_init', array( $this, 'redirect_to_setup' ) );
18 20 add_action( 'admin_init', array( $this, 'save_data' ) );
19 21 //add_action( 'admin_init', array( $this, 'set_existing_user_pages' ) );
@@ -35,15 +37,82 @@
35 37 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 38 }
37 39 }
38 40
41 + /**
42 + * Native WP pointer on the Registration Forms list after the setup wizard.
43 + *
44 + * @param string $hook Current admin page hook.
45 + */
46 + public function enqueue_wizard_forms_pointer( $hook ) {
47 + if ( $hook !== 'edit.php' ) {
48 + return;
49 + }
50 +
51 + if ( empty( $_GET['post_type'] ) || sanitize_text_field( $_GET['post_type'] ) !== 'wppb-rf-cpt' ) {
52 + return;
53 + }
54 +
55 + if ( empty( $_GET['wppb_wizard_hint'] ) || sanitize_text_field( $_GET['wppb_wizard_hint'] ) !== '1' ) {
56 + return;
57 + }
58 +
59 + $pointer_id = 'wppb_setup_customize_form';
60 + $dismissed = explode( ',', (string) get_user_meta( get_current_user_id(), 'dismissed_wp_pointers', true ) );
61 +
62 + if ( in_array( $pointer_id, $dismissed, true ) ) {
63 + return;
64 + }
65 +
66 + $defaults = get_option( 'wppb_default_form_ids', array() );
67 + $form_id = ( is_array( $defaults ) && ! empty( $defaults['register'] ) ) ? absint( $defaults['register'] ) : 0;
68 + $target = $form_id ? '#post-' . $form_id . ' .row-title' : '#the-list .row-title:first';
69 +
70 + wp_enqueue_style( 'wp-pointer' );
71 + wp_enqueue_script(
72 + 'wppb-setup-wizard-pointer',
73 + WPPB_PLUGIN_URL . 'assets/js/setup-wizard-pointer.js',
74 + array( 'jquery', 'wp-pointer' ),
75 + PROFILE_BUILDER_VERSION,
76 + true
77 + );
78 + wp_localize_script(
79 + 'wppb-setup-wizard-pointer',
80 + 'wppbSetupWizardPointer',
81 + array(
82 + 'pointerId' => $pointer_id,
83 + 'target' => $target,
84 + 'content' => '<h3>' . esc_html__( 'Customize your registration form', 'profile-builder' ) . '</h3><p>' . esc_html__( 'Your registration form is ready. Click the form name to open the Form Builder and customize it.', 'profile-builder' ) . '</p>',
85 + )
86 + );
87 + }
88 +
89 + /**
90 + * Registration Forms list, with a query flag that opens the post-wizard pointer.
91 + *
92 + * @return string
93 + */
94 + public static function get_setup_complete_url() {
95 + return add_query_arg(
96 + 'wppb_wizard_hint',
97 + '1',
98 + admin_url( 'edit.php?post_type=wppb-rf-cpt' )
99 + );
100 + }
101 +
39 102 public function get_default_steps(){
40 - return array(
103 + $steps = array(
41 104 'user-pages' => __( 'User Pages', 'profile-builder' ),
42 - 'general' => __( 'Design & UI', 'profile-builder' ),
43 - 'addons' => __( 'Add-Ons', 'profile-builder' ),
44 - 'next' => __( 'Ready!', 'profile-builder' ),
105 + 'general' => __( 'User Flow', 'profile-builder' ),
45 106 );
107 +
108 + if ( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) {
109 + $steps['addons'] = __( 'Add-Ons', 'profile-builder' );
110 + }
111 +
112 + $steps['next'] = __( 'Ready!', 'profile-builder' );
113 +
114 + return $steps;
46 115 }
47 116
48 117 public function redirect_to_setup(){
49 118 $run_setup = get_transient( 'wppb_run_setup_wizard' );
@@ -63,8 +132,9 @@
63 132 return;
64 133
65 134 $this->general_settings = get_option( 'wppb_general_settings', array() );
66 135 $this->user_pages = get_option( 'wppb_user_pages', array() );
136 + $this->content_restriction_settings = get_option( 'wppb_content_restriction_settings', array() );
67 137
68 138 $default_steps = $this->get_default_steps();
69 139
70 140 reset( $default_steps );
@@ -187,12 +257,31 @@
187 257 $general_settings['adminApproval'] = sanitize_text_field( $_POST['adminApproval'] );
188 258 else
189 259 unset( $general_settings['adminApproval'] );
190 260
261 + // Roles Editor
262 + if ( isset( $_POST['rolesEditor'] ) )
263 + $general_settings['rolesEditor'] = 'yes';
264 + else
265 + unset( $general_settings['rolesEditor'] );
266 +
191 267 if( !empty( $general_settings ) )
192 268 update_option( 'wppb_general_settings', $general_settings );
193 269
194 - } elseif( $this->step === 'addons' ) {
270 + // Content Restriction
271 + $content_restriction_settings = get_option( 'wppb_content_restriction_settings', array() );
272 + if ( ! is_array( $content_restriction_settings ) ) {
273 + $content_restriction_settings = array();
274 + }
275 +
276 + if ( isset( $_POST['contentRestriction'] ) )
277 + $content_restriction_settings['contentRestriction'] = 'yes';
278 + else
279 + $content_restriction_settings['contentRestriction'] = 'no';
280 +
281 + update_option( 'wppb_content_restriction_settings', $content_restriction_settings );
282 +
283 + } elseif( $this->step === 'addons' && defined( 'WPPB_PAID_PLUGIN_DIR' ) ) {
195 284 $pro_addons = get_option( 'wppb_module_settings', 'not_found' );
196 285
197 286 // User Listing Addon
198 287 if( isset( $_POST['wppb_userListing'] ) )
@@ -259,9 +348,9 @@
259 348
260 349 $keys = array_keys( $this->steps );
261 350
262 351 if( end( $keys ) === $step )
263 - return admin_url();
352 + return $this->get_setup_complete_url();
264 353
265 354 $step_index = array_search( $step, $keys, true );
266 355
267 356 if( $step_index === false )
@@ -403,18 +492,14 @@
403 492 'label' => __( 'Create user pages for registration, login, edit profile and password reset.', 'profile-builder' ),
404 493 'url' => admin_url( 'admin.php?page=profile-builder-dashboard&subpage=wppb-setup' ),
405 494 ),
406 495 'general' => array(
407 - 'label' => __( 'Choose a design and optimize the login and registration flow for your users.', 'profile-builder' ),
496 + 'label' => __( 'Optimize the login and registration flow for your users', 'profile-builder' ),
408 497 'url' => admin_url( 'admin.php?page=profile-builder-dashboard&subpage=wppb-setup&step=general' ),
409 498 ),
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 499 'extra_form_field' => array(
415 500 'label' => __( 'Add extra fields to the registration and edit profile forms.', 'profile-builder' ),
416 - 'url' => admin_url( 'admin.php?page=manage-fields#manage-fields' ),
501 + 'url' => admin_url( 'edit.php?post_type=wppb-rf-cpt' ),
417 502 ),
418 503 'restrict_content' => array(
419 504 'label' => __( 'Restrict your content based on the user role.', 'profile-builder' ),
420 505 'url' => admin_url( 'admin.php?page=profile-builder-content_restriction' ),
@@ -437,12 +522,8 @@
437 522 $steps_completion['user-pages'] = 1;
438 523 $steps_completion['general'] = 1;
439 524 }
440 525
441 - // Addons Completion
442 - if( !isset( $steps_completion['addons'] ) && self::website_has_active_addons() )
443 - $steps_completion['addons'] = 1;
444 -
445 526 // Extra Form Field Completion
446 527 if( !isset( $steps_completion['extra_form_field'] ) && self::website_edited_form_fields() )
447 528 $steps_completion['extra_form_field'] = 1;
448 529
@@ -455,9 +536,9 @@
455 536 $steps_completion['extra_user_roles'] = 1;
456 537
457 538 update_option( 'wppb_setup_wizard_steps', $steps_completion, false );
458 539
459 - $current_step = is_array( $steps_completion ) ? count( $steps_completion ) : 0;
540 + $current_step = count( array_intersect_key( $steps_completion, $steps ) );
460 541 $total_steps = count( $steps );
461 542
462 543 ob_start(); ?>
463 544
@@ -504,23 +585,8 @@
504 585 foreach ( $search_patterns as $pattern ) {
505 586 $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 587
507 588 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 589 return true;
524 590 }
525 591
526 592 return false;