PluginProbe ʕ •ᴥ•ʔ
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress / trunk
Paid Membership Plugin, Ecommerce, User Registration Form, Login Form, User Profile & Restrict Content – ProfilePress vtrunk
4.16.18 4.16.17 4.16.16 trunk 1.0 1.0.1 1.0.2 1.1 1.1.1 1.1.2 1.1.3 1.1.4 1.1.5 1.1.5a 1.1.6 1.1.7 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 1.3.6 1.4 1.4.1 1.4.2 1.5 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.5.8 1.6 1.6.1 1.6.2 1.6.3 1.6.4 1.6.5 1.6.6 1.6.7 1.6.8 1.7 1.7.1 1.7.2 1.8 1.8.1 1.8.10 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 1.9 1.9.1 1.9.10 1.9.11 1.9.12 1.9.13 1.9.2 1.9.3 1.9.4 1.9.5 1.9.6 1.9.7 1.9.8 1.9.9 2.1.9 2.2.10 2.2.11 2.2.12 2.2.13 2.2.14 2.2.15 2.2.16 2.2.2 2.2.5 2.2.6 2.2.7 2.2.8 2.2.9 3.0 3.1 3.1.1 3.1.10 3.1.11 3.1.12 3.1.13 3.1.14 3.1.15 3.1.16 3.1.17 3.1.18 3.1.19 3.1.2 3.1.3 3.1.4 3.1.5 3.1.6 3.1.7 3.1.8 3.1.9 3.2.0 3.2.1 3.2.10 3.2.11 3.2.12 3.2.13 3.2.14 3.2.15 3.2.16 3.2.2 3.2.3 3.2.4 3.2.5 3.2.6 3.2.7 3.2.8 3.2.9 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.10.0 4.10.1 4.10.2 4.10.3 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.15.0 4.15.1 4.15.10 4.15.11 4.15.12 4.15.13 4.15.14 4.15.15 4.15.16 4.15.17 4.15.18 4.15.19 4.15.2 4.15.20 4.15.20.1 4.15.21 4.15.22 4.15.23 4.15.24 4.15.25 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.0 4.16.1 4.16.10 4.16.11 4.16.12 4.16.13 4.16.14 4.16.15 4.16.2 4.16.3 4.16.4 4.16.5 4.16.6 4.16.7 4.16.8 4.16.9 4.2.0 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.5.0 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.7.0 4.8.0 4.9.0
wp-user-avatar / src / Widgets / TabbedWidget.php
wp-user-avatar / src / Widgets Last commit date
Form.php 11 months ago Init.php 5 years ago TabbedWidget.php 4 years ago TabbedWidgetDependency.php 1 year ago UserPanel.php 2 years ago index.php 5 years ago
TabbedWidget.php
520 lines
1 <?php
2
3 namespace ProfilePress\Core\Widgets;
4
5 class TabbedWidget extends \WP_Widget
6 {
7 public $widget_status;
8
9 /**
10 * Register widget with WordPress.
11 */
12 function __construct()
13 {
14 parent::__construct(
15 'pp_tabbed_widget', // Base ID
16 esc_html__('ProfilePress Tabbed Widget', 'wp-user-avatar'), // Name
17 array(
18 'description' => esc_html__('A tabbed login, registration and lost password widget', 'wp-user-avatar'),
19 ),
20 array('width' => 400, 'height' => 350)// Args
21 );
22
23 add_action('wp', [$this, 'process_form']);
24 }
25
26 public function process_form()
27 {
28 if (isset($_POST['tabbed_login_submit'])) {
29 $this->widget_status = @TabbedWidgetDependency::login(
30 trim(wp_unslash($_POST['tabbed-login-name'])), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
31 $_POST['tabbed-login-password'] // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
32 );
33 }
34
35 if (isset($_POST['tabbed_reset_passkey'])) {
36 $this->widget_status = @TabbedWidgetDependency::retrieve_password_process($_POST['tabbed-user-login']);
37 }
38
39 if (isset($_POST['tabbed_reg_submit'])) {
40 $this->widget_status = @TabbedWidgetDependency::registration(
41 wp_unslash($_POST['tabbed-reg-username']), // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
42 $_POST['tabbed-reg-password'], // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized, WordPress.Security.ValidatedSanitizedInput.MissingUnslash
43 wp_unslash($_POST['tabbed-reg-email']) // phpcs:ignore WordPress.Security.ValidatedSanitizedInput.InputNotSanitized
44 );
45 }
46 }
47
48 public function script()
49 {
50 ob_start();
51 ?>
52 <script>
53 if (typeof jQuery !== 'undefined') {
54 (function ($) {
55 $('.pp-tab-widget').on('click', 'li a', function (e) {
56 e.preventDefault();
57 var $tab = $(this),
58 href = $tab.attr('href');
59
60 $('.pp-active').removeClass('pp-active');
61 $tab.addClass('pp-active');
62
63 $('.pp-show')
64 .removeClass('pp-show')
65 .addClass('pp-hide')
66 .hide();
67
68 $(href)
69 .removeClass('pp-hide')
70 .addClass('pp-show')
71 .hide()
72 .fadeIn(550);
73 });
74 })(jQuery);
75 }
76 </script>
77 <?php
78 echo ppress_minify_js(ob_get_clean());
79 }
80
81 public function widget($args, $instance)
82 {
83 add_action('wp_footer', [$this, 'script']);
84
85 $title = apply_filters('widget_title', $instance['title']);
86
87 $processing_label = apply_filters('ppress_tab_widget_processing_label', esc_html__('Processing', 'wp-user-avatar'));
88 $login_btn_label = esc_html__('Log In', 'wp-user-avatar');
89 $signup_btn_label = esc_html__('Sign Up', 'wp-user-avatar');
90 $password_reset_btn_label = esc_html__('Get New Password', 'wp-user-avatar');
91
92 echo '<style>';
93 echo $instance['tabbed_css'];
94
95 if (ppress_var($GLOBALS, 'pp_form_processor_tab_widget_is_2fa') !== true) {
96 // "html body" is important to increase specificity
97 echo 'html body .pp-tab-widget-form .pp-2fa {display:none;}';
98 }
99 echo '</style>';
100
101 if ( ! is_user_logged_in() && ! empty($title)) {
102 echo $args['before_title'] . $title . $args['after_title'];
103 }
104
105 if ( ! is_user_logged_in()) {
106 echo $args['before_widget'];
107
108 if (isset($this->widget_status)) echo '<div class="pp-tab-status">', $this->widget_status, '</div>';
109 ?>
110 <div class="pp-tab-widget-form">
111 <ul class="pp-tab-widget">
112 <li>
113 <a href="#pp-login" class="pp-active"><?php echo apply_filters('ppress_tab_login_text', esc_html__('Login', 'wp-user-avatar')); ?></a>
114 </li>
115 <li>
116 <a href="#pp-register"><?php echo apply_filters('ppress_tab_register_text', esc_html__('Register', 'wp-user-avatar')); ?></a>
117 </li>
118 <li>
119 <a href="#pp-reset"><?php echo apply_filters('ppress_tab_password_reset_text', esc_html__('Forgot?', 'wp-user-avatar')); ?></a>
120 </li>
121 </ul>
122 <div id="pp-login" class="pp-form-action pp-show">
123 <div class="heading"><?php echo isset($instance['login_text']) ? $instance['login_text'] : 'Have an account?'; ?></div>
124 <form data-pp-form-submit="login" method="post" action="<?php echo esc_url_raw($_SERVER['REQUEST_URI']); ?>">
125 <ul class="tab-widget" style="list-style: none">
126 <li>
127 <?php
128 $login_username_email_restrict_settings = ppress_get_setting('login_username_email_restrict');
129
130 $login_placeholder = esc_html__('Username', 'wp-user-avatar');
131
132 if ( ! empty($login_username_email_restrict_settings) && $login_username_email_restrict_settings == 'both') {
133 $login_placeholder = esc_html__('Username or Email', 'wp-user-avatar');
134 }
135
136 if ( ! empty($login_username_email_restrict_settings) && $login_username_email_restrict_settings == 'email') {
137 $login_placeholder = esc_html__('Email Address', 'wp-user-avatar');
138 }
139 ?>
140 <input type="hidden" name="is-pp-tab-widget" value="true">
141 <input type="text" name="tabbed-login-name" value="<?php echo esc_attr(ppress_var($_POST, 'tabbed-login-name', '')); ?>" placeholder="<?php echo $login_placeholder; ?>" required/>
142 </li>
143 <li>
144 <input name="tabbed-login-password" value="<?php echo esc_attr(ppress_var($_POST, 'tabbed-login-password', '')); ?>" type="password" placeholder="<?php echo esc_html__('Password', 'wp-user-avatar'); ?>" required/>
145 </li>
146
147 <li class="pp-2fa">
148 <?php echo do_shortcode('[pp-2fa class=""]'); ?>
149 </li>
150
151 <li>
152 <input data-pp-submit-label="<?= $login_btn_label ?>" data-pp-processing-label="<?= $processing_label ?>" name="tabbed_login_submit" type="submit" value="<?= $login_btn_label ?>" class="tb-button"/>
153 </li>
154 </ul>
155 </form>
156 </div>
157 <!--/#login.pp-form-action-->
158 <div id="pp-register" class="pp-form-action pp-hide">
159 <div class="heading"><?php echo isset($instance['reg_text']) ? $instance['reg_text'] : 'Don\'t have an account?'; ?></div>
160
161 <div class="tab-widget">
162 <form data-pp-form-submit="signup" method="post" action="<?php echo esc_url_raw($_SERVER['REQUEST_URI']); ?>">
163 <ul class="tab-widget" style="list-style: none">
164 <li>
165 <input type="hidden" name="is-pp-tab-widget" value="true">
166 <input type="text" name="tabbed-reg-username" placeholder="<?php echo esc_html__('Username', 'wp-user-avatar'); ?>" value="<?php echo esc_attr(ppress_var($_POST, 'tabbed-reg-username', '')); ?>" required/>
167 </li>
168 <li>
169 <input type="email" name="tabbed-reg-email" placeholder="<?php echo esc_html__('Email', 'wp-user-avatar'); ?>" value="<?php echo esc_attr(ppress_var($_POST, 'tabbed-reg-email', '')); ?>" required/>
170 </li>
171 <li>
172 <input type="password" name="tabbed-reg-password" placeholder="<?php echo esc_html__('Password', 'wp-user-avatar'); ?>" value="<?php echo esc_attr(ppress_var($_POST, 'tabbed-reg-password', '')); ?>" required/>
173 </li>
174 <li>
175 <input data-pp-submit-label="<?= $signup_btn_label ?>" data-pp-processing-label="<?= $processing_label ?>" name="tabbed_reg_submit" type="submit" value="<?= $signup_btn_label ?>" class="tb-button"/>
176 </li>
177 </ul>
178 </form>
179 </div>
180 </div>
181
182 <div id="pp-reset" class="pp-form-action pp-hide">
183 <div class="heading">
184 <?php echo isset($instance['lostp_text']) ? $instance['lostp_text'] : 'Forgot Password?'; ?>
185 </div>
186
187 <div class="tab-widget">
188 <form data-pp-form-submit="passwordreset" method="post" action="<?php echo esc_url($_SERVER['REQUEST_URI']); ?>">
189 <ul class="tab-widget" style="list-style: none">
190 <li>
191 <input name="tabbed-user-login" value="<?php echo esc_attr(ppress_var($_POST, 'tabbed-user-login', '')); ?>" type="text" placeholder="<?php echo esc_html__('Username or E-mail:', 'wp-user-avatar'); ?>" required/>
192 <input type="hidden" name="is-pp-tab-widget" value="true">
193 </li>
194 <li>
195 <input data-pp-submit-label="<?= $password_reset_btn_label ?>" data-pp-processing-label="<?= $processing_label ?>" name="tabbed_reset_passkey" type="submit" value="<?= $password_reset_btn_label ?>" class="tb-button"/>
196 </li>
197 </ul>
198 </form>
199 </div>
200 </div>
201 </div>
202 <?php
203 echo $args['after_widget'];
204
205 return;
206 }
207
208 $user_data = wp_get_current_user();
209 echo $args['before_widget'];
210 ?>
211
212 <div class="pp-tabbed-user-panel">
213 <?php
214 echo '<a href="' . ppress_profile_url() . '"><div class="pp-tab-widget-avatar">';
215 echo get_avatar($user_data->ID, 500);
216 echo '</div></a>';
217 ?>
218 <h3 class="pp-tabbed-user-panel-title"><?php printf(__('Welcome %s', 'wp-user-avatar'), ucfirst($user_data->display_name)); ?></h3>
219 <br/>
220 <p>
221 <a class="pp-tabbed-btn pp-tabbed-btn-inverse" href="<?php echo ppress_edit_profile_url(); ?>"><?php _e('Edit your profile', 'wp-user-avatar'); ?></a>
222 </p>
223 <p>
224 <a class="pp-tabbed-btn pp-tabbed-btn-inverse" href="<?php echo wp_logout_url(); ?>"><?php _e('Log out', 'wp-user-avatar'); ?></a>
225 </p>
226 </div>
227 <?php
228
229 echo $args['after_widget'];
230 }
231
232
233 public function form($instance)
234 {
235 if (isset($instance['title'])) {
236 $title = $instance['title'];
237 } else {
238 $title = esc_html__('Login / Sign up', 'wp-user-avatar');
239 }
240
241 if (isset($instance['login_text'])) {
242 $login_text = $instance['login_text'];
243 } else {
244 $login_text = esc_html__('Have an account?', 'wp-user-avatar');
245 }
246
247 if (isset($instance['reg_text'])) {
248 $reg_text = $instance['reg_text'];
249 } else {
250 $reg_text = esc_html__('Don\'t have an account?', 'wp-user-avatar');
251 }
252
253 if (isset($instance['lostp_text'])) {
254 $lostp_text = $instance['lostp_text'];
255 } else {
256 $lostp_text = esc_html__('Forgot Password?', 'wp-user-avatar');
257 }
258
259 $auto_login_after_reg = ppress_get_setting('set_auto_login_after_reg', 'off');
260
261 if (isset($instance['auto_login_after_reg'])) {
262 $auto_login_after_reg = $instance['auto_login_after_reg'];
263 }
264
265 $tabbed_css = isset($instance['tabbed_css']) ? $instance['tabbed_css'] : <<<CSS
266 .pp-tab-status {
267 background: rgba(247, 245, 231, 0.7);
268 padding: 10px 8px;
269 margin: 0;
270 color: #141412;
271 border-radius: 5px;
272 max-width: 350px;
273 }
274
275 .pp-tab-status a {
276 color: #bc360a !important;
277 }
278
279 .pp-tab-widget-form {
280 background: #edeff1;
281 padding-bottom: 20px;
282 margin: 10px auto;
283 width: 100%;
284 max-width: 350px;
285 position: relative;
286 font-family: Helvetica, Arial, sans-serif;
287 }
288
289 .pp-tab-widget-form li.remember-login {
290 margin-bottom: 10px;
291 }
292
293 .pp-tab-widget-form .pp-tab-widget {
294 color: #fff !important;
295 background: #2f4154;
296 height: 40px;
297 margin: 0;
298 padding: 0;
299 list-style-type: none;
300 width: 100%;
301 position: relative;
302 display: block;
303 margin-bottom: 20px;
304 }
305
306 .pp-tab-widget-form .pp-tab-widget li {
307 color: #fff !important;
308 width: 30%;
309 display: block;
310 float: left;
311 margin: 0;
312 padding: 0;
313 }
314
315 .pp-tab-widget-form ul li:before {
316 content: none !important;
317 }
318
319 .pp-tab-widget-form .pp-tab-widget a {
320 color: #fff !important;
321 background: #2f4154;
322 display: block;
323 float: left;
324 text-decoration: none;
325 font-size: 16px;
326 padding: 5px 6px;
327
328 }
329
330 .pp-tab-widget-form .pp-tab-widget li:last-child a {
331 border-right: none;
332 width: 90%;
333 padding-left: 0;
334 padding-right: 0;
335 text-align: center;
336 }
337
338 .pp-tab-widget-form ul.pp-tab-widget {
339 margin-left: 0 !important;
340 }
341
342
343 .pp-tab-widget-form .pp-tab-widget a.pp-active {
344 border-top: 4px solid #1abc9c;
345 padding: 3px 6px;
346 border-right: none;
347 -webkit-transition: all 0.5s linear;
348 -moz-transition: all 0.5s linear;
349 transition: all 0.5s linear;
350 }
351
352 .pp-tab-widget-form .pp-tab-widget a.focus {
353 color: #2f4154 !important;
354 outline: none !important;
355 }
356
357 .pp-tab-widget-form .pp-form-action {
358 padding: 0 20px;
359 position: relative;
360 }
361
362 .pp-tab-widget-form .pp-form-action h1 {
363 font-size: 22px;
364 font-weight: 500;
365 margin: 0;
366 padding-bottom: 10px;
367 }
368
369 .pp-tab-widget-form .pp-form-action .heading {
370 font-size: 22px;
371 font-weight: 500;
372 margin: 0;
373 padding-bottom: 10px;
374 }
375
376 .pp-tab-widget-form .pp-form-action p {
377 font-size: 12px;
378 padding-bottom: 10px;
379 line-height: 25px;
380 }
381
382 .pp-tab-widget-form .tab-widget input[type=text],
383 .pp-tab-widget-form .tab-widget input[type=email],
384 .pp-tab-widget-form .tab-widget input[type=password] {
385 -webkit-box-sizing: border-box;
386 -moz-box-sizing: border-box;
387 box-sizing: border-box;
388 width: 100%;
389 height: 40px;
390 margin-bottom: 10px;
391 padding-left: 15px;
392 background: #fff;
393 border: none;
394 color: #6d7680;
395 outline: none;
396 }
397
398 .pp-tab-widget-form .pp-show {
399 display: block;
400 }
401
402 .pp-tab-widget-form .pp-hide {
403 display: none;
404 }
405
406 .pp-tab-widget-form input.tb-button {
407 border: none;
408 display: block;
409 background: #136899;
410 height: 40px;
411 width: 100%;
412 color: #ffffff;
413 text-align: center;
414 border-radius: 5px;
415 -webkit-transition: all 0.15s linear;
416 -moz-transition: all 0.15s linear;
417 transition: all 0.15s linear;
418 }
419
420 .pp-tab-widget-form input.tb-button:hover {
421 background: #1e75aa;
422 }
423
424 .pp-tab-widget-form input.tb-button:active {
425 background: #136899;
426 }
427
428 .pp-tab-widget-avatar img {
429 display: block;
430 border-radius: 50%;
431 height: 190px;
432 margin: 0 auto 10px !important;
433 padding: 2px;
434 text-align: center;
435 width: 190px;
436 float: none !important;
437 }
438
439 .pp-tabbed-user-panel {
440 border-radius: 6px;
441 text-align: center;
442 }
443
444 .pp-tabbed-user-panel-title {
445 font-size: 20px;
446 margin: 0;
447 }
448
449 .pp-tabbed-user-panel p {
450 font-size: 15px;
451 margin-bottom: 23px;
452 }
453
454 .pp-tabbed-btn {
455 border: none;
456 font-size: 15px;
457 font-weight: 400;
458 line-height: 1.4;
459 border-radius: 4px;
460 padding: 10px 15px;
461 -webkit-font-smoothing: subpixel-antialiased;
462 -webkit-transition: border .25s linear,color .25s linear,background-color .25s linear;
463 transition: border .25s linear,color .25s linear,background-color .25s linear;
464 }
465
466 .pp-tabbed-btn-inverse {
467 color: #fff!important;
468 background-color: #34495e;
469 }
470 CSS;
471 ?>
472 <p>
473 <label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label>
474 <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>">
475 </p>
476
477
478 <p>
479 <label for="<?php echo $this->get_field_id('login_text'); ?>"><?php _e('Login text:'); ?></label>
480 <input class="widefat" id="<?php echo $this->get_field_id('login_text'); ?>" name="<?php echo $this->get_field_name('login_text'); ?>" type="text" value="<?php echo esc_attr($login_text); ?>">
481 </p>
482
483 <p>
484 <label for="<?php echo $this->get_field_id('reg_text'); ?>"><?php _e('Registration text:'); ?></label>
485 <input class="widefat" id="<?php echo $this->get_field_id('reg_text'); ?>" name="<?php echo $this->get_field_name('reg_text'); ?>" type="text" value="<?php echo esc_attr($reg_text); ?>">
486 </p>
487
488 <p>
489 <label for="<?php echo $this->get_field_id('lostp_text'); ?>"><?php _e('Lost-password text:'); ?></label>
490 <input class="widefat" id="<?php echo $this->get_field_id('lostp_text'); ?>" name="<?php echo $this->get_field_name('lostp_text'); ?>" type="text" value="<?php echo esc_attr($lostp_text); ?>">
491 </p>
492
493 <p>
494 <input class="widefat" id="<?php echo $this->get_field_id('auto_login_after_reg'); ?>" name="<?php echo $this->get_field_name('auto_login_after_reg'); ?>" type="checkbox" value="on" <?php checked($auto_login_after_reg, 'on'); ?>>
495 <label for="<?php echo $this->get_field_id('auto_login_after_reg'); ?>"><?php _e('Automatically login user after successful registration'); ?></label>
496
497 </p>
498
499 <p>
500 <label
501 for="<?php echo $this->get_field_id('tabbed_css'); ?>"><?php _e('Widget CSS:'); ?></label>
502 <textarea name="<?php echo $this->get_field_name('tabbed_css'); ?>" id="<?php echo $this->get_field_id('tabbed_css'); ?>" cols="20" rows="16" class="widefat"><?php echo esc_textarea($tabbed_css); ?></textarea>
503 </p>
504 <?php
505 }
506
507 public function update($new_instance, $old_instance)
508 {
509 $instance = array();
510 $instance['title'] = ( ! empty($new_instance['title'])) ? strip_tags($new_instance['title']) : '';
511 $instance['login_text'] = ( ! empty($new_instance['login_text'])) ? strip_tags($new_instance['login_text']) : '';
512 $instance['reg_text'] = ( ! empty($new_instance['reg_text'])) ? strip_tags($new_instance['reg_text']) : '';
513 $instance['lostp_text'] = ( ! empty($new_instance['lostp_text'])) ? strip_tags($new_instance['lostp_text']) : '';
514 $instance['auto_login_after_reg'] = ( ! empty($new_instance['auto_login_after_reg'])) ? strip_tags($new_instance['auto_login_after_reg']) : '';
515 $instance['tabbed_css'] = ( ! empty($new_instance['tabbed_css'])) ? strip_tags($new_instance['tabbed_css']) : '';
516
517 return $instance;
518 }
519
520 }