PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.16.5
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.16.5
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 / elementor / widgets / class-pb-widget-l.php

class-pb-widget-l.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.16.5, at assets/misc/elementor/widgets/class-pb-widget-l.php

297 lines 9.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 // Exit if accessed directly
4 if ( ! defined( 'ABSPATH' ) ) exit;
5
6 require_once "class-pb-widget-base.php";
7
8 /**
9 * Elementor widget for our wppb-login shortcode
10 */
11 class PB_Elementor_Login_Widget extends PB_Elementor_Widget {
12
13 /**
14 * Get widget name.
15 *
16 */
17 public function get_name() {
18 return 'wppb-login';
19 }
20
21 /**
22 * Get widget title.
23 *
24 */
25 public function get_title() {
26 return __( 'Login', 'profile-builder' );
27 }
28
29 /**
30 * Get widget icon.
31 *
32 */
33 public function get_icon() {
34 return 'eicon-lock-user';
35 }
36
37 /**
38 * Register widget controls.
39 *
40 */
41 protected function register_controls() {
42
43 $page_titles = $this->get_all_pages();
44
45 $this->start_controls_section(
46 'pb_login_links',
47 array(
48 'label' => __( 'Form Settings', 'profile-builder' ),
49 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
50 )
51 );
52
53 $this->add_control(
54 'pb_register_url',
55 array(
56 'label' => __( 'Registration', 'profile-builder' ),
57 'type' => \Elementor\Controls_Manager::SELECT,
58 'options' => $page_titles,
59 'default' => '',
60 )
61 );
62
63 $this->add_control(
64 'pb_lostpassword_url',
65 array(
66 'label' => __( 'Recover Password', 'profile-builder' ),
67 'type' => \Elementor\Controls_Manager::SELECT,
68 'options' => $page_titles,
69 'default' => '',
70 )
71 );
72
73 if ( $this->is_2fa_active() ) {
74 $this->add_control(
75 'pb_auth_field',
76 array(
77 'label' => __('Show Authenticator Code Field', 'profile-builder'),
78 'type' => \Elementor\Controls_Manager::SWITCHER,
79 'label_on' => __('Yes', 'profile-builder'),
80 'label_off' => __('No', 'profile-builder'),
81 'return_value' => 'yes',
82 'default' => '',
83 )
84 );
85 }
86
87 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) ) {
88 $this->add_control(
89 'pb_ajax',
90 array(
91 'label' => __( 'AJAX Validation', 'profile-builder' ),
92 'type' => \Elementor\Controls_Manager::SWITCHER,
93 'label_on' => __( 'Yes', 'profile-builder' ),
94 'label_off' => __( 'No', 'profile-builder' ),
95 'return_value' => 'true',
96 'default' => 'false',
97 )
98 );
99 }
100
101 $this->end_controls_section();
102
103 $this->start_controls_section(
104 'pb_login_redirects',
105 array(
106 'label' => __( 'Redirects', 'profile-builder' ),
107 'tab' => \Elementor\Controls_Manager::TAB_CONTENT,
108 )
109 );
110
111 $this->add_control(
112 'pb_after_login_redirect_url',
113 array(
114 'label' => __( 'After Login', 'profile-builder' ),
115 'type' => \Elementor\Controls_Manager::SELECT,
116 'options' => $page_titles,
117 'default' => '',
118 )
119 );
120
121 $this->add_control(
122 'pb_after_logout_redirect_url',
123 array(
124 'label' => __( 'After Logout', 'profile-builder' ),
125 'type' => \Elementor\Controls_Manager::SELECT,
126 'options' => $page_titles,
127 'default' => '',
128 )
129 );
130
131 $this->end_controls_section();
132
133 // User Login Style tab
134 if( !$this->is_placeholder_labels_active() ) {
135 $sections['label'] = [
136 'selector' => '#wppb-login-wrap .login-username label[for=user_login]',
137 'section_name' => 'Label',
138 ];
139 }
140 $sections['input'] = [
141 'selector' => '#wppb-login-wrap .login-username input#wppb_user_login',
142 'section_name' => 'Input',
143 ];
144 $this->add_styling_control_group(
145 'User Login',
146 '',
147 'pb_user_login_username',
148 $sections
149 );
150 unset($sections);
151
152 // Password Style tab
153 if( !$this->is_placeholder_labels_active() ) {
154 $sections['label'] = [
155 'selector' => '#wppb-login-wrap .login-password label[for=user_pass]',
156 'section_name' => 'Label',
157 ];
158 }
159 $sections['input'] = [
160 'selector' => '#wppb-login-wrap .login-password input#wppb_user_pass',
161 'section_name' => 'Input',
162 ];
163 $this->add_styling_control_group(
164 'Password',
165 '',
166 'pb_user_login_password',
167 $sections
168 );
169 unset($sections);
170
171 if ( $this->is_2fa_active() ) {
172 // Authenticator Code Style tab
173 if (!$this->is_placeholder_labels_active()) {
174 $sections['label'] = [
175 'selector' => '#wppb-login-wrap .login-auth label[for=login_auth]',
176 'section_name' => 'Label',
177 ];
178 }
179 $sections['input'] = [
180 'selector' => '#wppb-login-wrap .login-auth input#login_auth',
181 'section_name' => 'Input',
182 ];
183 $this->add_styling_control_group(
184 'Authenticator Code',
185 '',
186 'pb_user_auth_code',
187 $sections
188 );
189 unset($sections);
190 }
191
192 // reCAPTCHA Style tab
193 if( !$this->is_placeholder_labels_active() ) {
194 include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/recaptcha/recaptcha.php');
195 include_once(WPPB_PLUGIN_DIR . '/front-end/default-fields/turnstile/turnstile.php');
196 $field = wppb_get_recaptcha_field();
197 if (!empty($field) && isset($field['captcha-pb-forms']) && (strpos($field['captcha-pb-forms'], 'pb_recover_password') !== false)) {
198 $this->add_styling_control_group(
199 'reCAPTCHA',
200 '',
201 'pb_user_login_recaptcha',
202 [
203 'label' => [
204 'selector' => '#wppb-login-wrap .wppb-form-field.wppb-recaptcha label[for=recaptcha_response_field]',
205 'section_name' => 'Label',
206 ]
207 ]
208 );
209 }
210 }
211
212 // Remember Checkbox Style tab
213 $this->add_styling_control_group(
214 'Remember Me Checkbox',
215 '',
216 'pb_user_login_remember',
217 [
218 'label' => [
219 'selector' => '#wppb-login-wrap .login-remember label',
220 'section_name' => 'Label',
221 ],
222 'input' => [
223 'selector' => '#wppb-login-wrap .login-remember input',
224 'section_name' => 'Input',
225 ]
226 ]
227 );
228
229 // Submit Button Style tab
230 $this->add_styling_control_group(
231 'Login Button',
232 '',
233 'pb_user_login_button',
234 [
235 'input' => [
236 'selector' => '#wppb-login-wrap .login-submit input#wppb-submit',
237 'section_name' => 'Input',
238 ]
239 ]
240 );
241
242 // Social Connect Style tab
243 $social_connect_settings = get_option( 'wppb_social_connect_settings' );
244 if ( is_array($social_connect_settings) ) {
245 $social_connect_settings = reset($social_connect_settings);
246 }
247
248 if ( $social_connect_settings && strpos($social_connect_settings['display-on-the-following-forms'], 'pb-login' ) !== false ) {
249 $this->add_styling_control_group(
250 'Social Connect',
251 '',
252 'pb_user_login_social_connect',
253 [
254 'sc_heading' => [
255 'selector' => '.wppb-sc-buttons-container .wppb-sc-heading-before-reg-buttons h3',
256 'section_name' => 'Heading',
257 ],
258 'sc_buttons' => [
259 'selector' => '.wppb-sc-buttons-container a.wppb-sc-button',
260 'section_name' => 'Buttons',
261 ]
262 ]
263 );
264 }
265 }
266
267 /**
268 * Render widget output in the front-end.
269 *
270 */
271 protected function render() {
272 $output = $this->render_widget( 'l' );
273 echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
274
275 // check if the form is being displayed in the Elementor editor
276 $is_elementor_edit_mode = false;
277 if( class_exists ( '\Elementor\Plugin' ) ){
278 $is_elementor_edit_mode = \Elementor\Plugin::$instance->editor->is_edit_mode();
279 $message= "";
280 }
281
282 if ($is_elementor_edit_mode && !empty($output) && $this->is_placeholder_labels_active()) {
283 echo '
284 <script id="wppb_elementor_login_pbpl_init">
285 jQuery(".login-username input, .login-password input").each( function ( index, elem ) {
286 var element_id = jQuery( elem ).attr( "id" );
287 if( element_id && ( label = jQuery( elem ).parents( "#wppb-login-wrap" ).find( "label[for=" + element_id + "]" ) ).length === 1 ) {
288 jQuery( elem ).attr( "placeholder", jQuery( label ).text() );
289 }
290 });
291 </script>
292 ';
293 }
294 }
295
296 }
297