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
profile-builder / assets / misc / divi / includes / modules / login / login.php

login.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 4.0.3, at assets/misc/divi/includes/modules/login/login.php

176 lines 7.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class WPPB_Login extends ET_Builder_Module {
4
5 public $slug = 'wppb_login';
6 public $vb_support = 'on';
7
8 protected $module_credits = array(
9 'module_uri' => 'https://wordpress.org/plugins/profile-builder/',
10 'author' => 'Cozmoslabs',
11 'author_uri' => 'https://www.cozmoslabs.com/',
12 );
13
14 public function init() {
15 $this->name = esc_html__( 'PB Login', 'profile-builder' );
16
17 $this->settings_modal_toggles = array(
18 'general' => array(
19 'toggles' => array(
20 'main_content' => esc_html__( 'Form Settings', 'profile-builder' ),
21 ),
22 ),
23 );
24
25 $this->advanced_fields = array(
26 'link_options' => false,
27 'background' => false,
28 'admin_label' => false,
29 );
30 }
31
32 public function get_fields() {
33 $args = array(
34 'post_type' => 'page',
35 'posts_per_page' => -1
36 );
37
38 if( function_exists( 'wc_get_page_id' ) )
39 $args['exclude'] = wc_get_page_id( 'shop' );
40
41 $all_pages = get_posts( $args );
42 $pages ['default'] = 'None';
43
44 if( !empty( $all_pages ) ){
45 foreach ( $all_pages as $page ){
46 $pages [ esc_url( get_page_link( $page->ID ) ) ] = esc_html( $page->post_title );
47 }
48 }
49
50 $wppb_module_settings = get_option( 'wppb_module_settings', 'not_found' );
51
52 $registration_forms ['default'] = esc_html__( 'Default' , 'profile-builder' );
53
54 if ( !( ( $wppb_module_settings !== 'not_found' && (
55 !isset( $wppb_module_settings['wppb_multipleRegistrationForms'] ) ||
56 $wppb_module_settings['wppb_multipleRegistrationForms'] !== 'show'
57 ) ) ||
58 $wppb_module_settings === 'not_found' ) ){
59 $args = array(
60 'post_type' => 'wppb-rf-cpt',
61 'posts_per_page' => -1
62 );
63
64 $the_query = new WP_Query( $args );
65
66 if ( $the_query->have_posts() ) {
67 foreach ( $the_query->posts as $post ) {
68 $registration_forms [esc_attr( Wordpress_Creation_Kit_PB::wck_generate_slug( $post->post_title ) )] = esc_html( $post->post_title );
69 }
70 wp_reset_postdata();
71 }
72 }
73
74 if (!function_exists('get_editable_roles')) {
75 require_once ABSPATH . 'wp-admin/includes/user.php';
76 }
77 $user_roles ['default'] = esc_html__( 'Default' , 'profile-builder' );
78 $editable_roles = get_editable_roles();
79 foreach ($editable_roles as $key => $role) {
80 $user_roles [$key] = $role['name'];
81 }
82
83 $fields = array(
84 'register_url' => array(
85 'label' => esc_html__( 'Registration Page', 'profile-builder' ),
86 'type' => 'select',
87 'options' => $pages,
88 'default' => 'default',
89 'option_category' => 'basic_option',
90 'description' => esc_html__( 'Add a link to a Registration Page.', 'profile-builder' ),
91 'toggle_slug' => 'main_content',
92 ),
93 'lostpassword_url' => array(
94 'label' => esc_html__( 'Recover Password Page', 'profile-builder' ),
95 'type' => 'select',
96 'options' => $pages,
97 'default' => 'default',
98 'option_category' => 'basic_option',
99 'description' => esc_html__( 'Add a link to a Recover Password Page.', 'profile-builder' ),
100 'toggle_slug' => 'main_content',
101 ),
102 'redirect_url' => array(
103 'label' => esc_html__( 'Redirect After Login', 'profile-builder' ),
104 'type' => 'select',
105 'options' => $pages,
106 'default' => 'default',
107 'option_category' => 'basic_option',
108 'description' => esc_html__( 'Select a page for an After Login Redirect.', 'profile-builder' ),
109 'toggle_slug' => 'main_content',
110 ),
111 'logout_redirect_url' => array(
112 'label' => esc_html__( 'Redirect After Logout', 'profile-builder' ),
113 'type' => 'select',
114 'options' => $pages,
115 'default' => 'default',
116 'option_category' => 'basic_option',
117 'description' => esc_html__( 'Select a page for an After Logout Redirect.', 'profile-builder' ),
118 'toggle_slug' => 'main_content',
119 ),
120 );
121
122 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) {
123 $fields['toggle_ajax_validation'] = array(
124 'label' => esc_html__( 'AJAX Validation', 'profile-builder' ),
125 'type' => 'yes_no_button',
126 'options' => array(
127 'on' => esc_html__( 'Yes', 'profile-builder'),
128 'off' => esc_html__( 'No', 'profile-builder'),
129 ),
130 'option_category' => 'basic_option',
131 'description' => esc_html__( 'Use AJAX to Validate the Login Form without reloading the page.', 'profile-builder' ),
132 'toggle_slug' => 'main_content',
133 );
134 }
135
136 $wppb_two_factor_authentication_settings = get_option( 'wppb_two_factor_authentication_settings', 'not_found' );
137 if( isset( $wppb_two_factor_authentication_settings['enabled'] ) && $wppb_two_factor_authentication_settings['enabled'] === 'yes' ) {
138 $fields ['toggle_auth_field'] = array(
139 'label' => esc_html__( 'Show Authenticator Code Field', 'profile-builder' ),
140 'type' => 'yes_no_button',
141 'options' => array(
142 'on' => esc_html__( 'Yes', 'profile-builder'),
143 'off' => esc_html__( 'No', 'profile-builder'),
144 ),
145 'option_category' => 'basic_option',
146 'description' => esc_html__( 'Select if the form should show the Authenticator Code Field.', 'profile-builder' ),
147 'toggle_slug' => 'main_content',
148 );
149 }
150
151 return $fields;
152 }
153
154 public function render( $attrs, $content, $render_slug ) {
155
156 if ( !is_array( $attrs ) ) {
157 return;
158 }
159
160 include_once( WPPB_PLUGIN_DIR.'/front-end/login.php' );
161
162 $atts = [
163 'register_url' => array_key_exists( 'register_url', $attrs ) && $attrs['register_url'] !== '' ? pb_divi_parse_url( $attrs['register_url'] ) : '',
164 'lostpassword_url' => array_key_exists( 'lostpassword_url', $attrs ) && $attrs['lostpassword_url'] !== '' ? pb_divi_parse_url( $attrs['lostpassword_url'] ) : '',
165 'redirect_url' => array_key_exists( 'redirect_url', $attrs ) && $attrs['redirect_url'] !== '' ? pb_divi_parse_url( $attrs['redirect_url'] ) : '',
166 'logout_redirect_url' => array_key_exists( 'logout_redirect_url', $attrs ) && $attrs['logout_redirect_url'] !== '' ? pb_divi_parse_url( $attrs['logout_redirect_url'] ) : '',
167 'ajax' => array_key_exists( 'toggle_ajax_validation', $attrs ) && $attrs['toggle_ajax_validation'] === 'on' ? 'true' : false,
168 'auth_field' => array_key_exists( 'toggle_auth_field', $attrs ) && $attrs['toggle_auth_field'] === 'on' ? 'yes' : '',
169 ];
170
171 return '<div class="wppb-divi-front-end-container">' . wppb_front_end_login( $atts ) . '</div>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
172 }
173 }
174
175 new WPPB_Login;
176