PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 2.0.7
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v2.0.7
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 / features / login-widget / login-widget.php

login-widget.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 2.0.7, at features/login-widget/login-widget.php

97 lines 3.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 function wppb_register_login_widget() {
3 register_widget( 'wppb_login_widget' );
4 }
5 add_action( 'widgets_init', 'wppb_register_login_widget' );
6
7 class wppb_login_widget extends WP_Widget {
8
9 function wppb_login_widget() {
10 $widget_ops = array( 'classname' => 'login', 'description' => __( 'This login widget lets you add a login form in the sidebar.', 'profilebuilder' ) );
11 $control_ops = array( 'width' => 300, 'height' => 350, 'id_base' => 'wppb-login-widget' );
12
13 do_action( 'wppb_login_widget_settings', $widget_ops, $control_ops);
14
15 $this->WP_Widget( 'wppb-login-widget', __('Profile Builder Login Widget', 'profilebuilder'), $widget_ops, $control_ops );
16
17 }
18
19 function widget( $args, $instance ) {
20 extract( $args );
21
22 $title = apply_filters('wppb_login_widget_title', $instance['title'] );
23 $redirect = trim($instance['redirect']);
24 $register = trim($instance['register']);
25 $lostpass = trim($instance['lostpass']);
26
27 echo $before_widget;
28
29 if ( $title )
30 echo $before_title . $title . $after_title;
31
32 echo do_shortcode('[wppb-login display="false" register_url="'.$register.'" lostpassword_url="'.$lostpass.'" redirect="'.$redirect.'"]');
33
34 do_action( 'wppb_login_widget_display', $args, $instance);
35
36 echo $after_widget;
37 }
38
39 /**
40 * Update the widget settings.
41 */
42 function update( $new_instance, $old_instance ) {
43 $instance = $old_instance;
44
45 $instance['title'] = strip_tags( $new_instance['title'] );
46 $instance['redirect'] = strip_tags( $new_instance['redirect'] );
47 $instance['register'] = strip_tags( $new_instance['register'] );
48 $instance['lostpass'] = strip_tags( $new_instance['lostpass'] );
49
50 do_action( 'wppb_login_widget_update_action', $new_instance, $old_instance);
51
52 return $instance;
53
54 }
55
56
57 function form( $instance ) {
58
59 $defaults = array( 'title' => __('Login', 'profilebuilder'), 'redirect' => '', 'register' => '', 'lostpass' => '' );
60 $instance = wp_parse_args( (array) $instance, $defaults ); ?>
61
62 <p>
63 <label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e( 'Title:', 'profilebuilder' ); ?></label>
64 <input id="<?php echo $this->get_field_id( 'title' ); ?>" class="widefat" type="text" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" style="width:100%;" />
65 </p>
66
67 <p>
68 <label for="<?php echo $this->get_field_id( 'redirect' ); ?>"><?php _e( 'After login redirect URL (optional):', 'profilebuilder' ); ?></label>
69 <input id="<?php echo $this->get_field_id( 'redirect' ); ?>" class="widefat" type="url" name="<?php echo $this->get_field_name( 'redirect' ); ?>" value="<?php echo $instance['redirect']; ?>" style="width:100%;" />
70 </p>
71
72 <p>
73 <label for="<?php echo $this->get_field_id( 'register' ); ?>"><?php _e( 'Register page URL (optional):', 'profilebuilder' ); ?></label>
74 <input id="<?php echo $this->get_field_id( 'register' ); ?>" class="widefat" type="url" name="<?php echo $this->get_field_name( 'register' ); ?>" value="<?php echo $instance['register']; ?>" style="width:100%;" />
75 </p>
76
77 <p>
78 <label for="<?php echo $this->get_field_id( 'lostpass' ); ?>"><?php _e( 'Password Recovery page URL (optional):', 'profilebuilder' ); ?></label>
79 <input id="<?php echo $this->get_field_id( 'lostpass' ); ?>" class="widefat" type="url" name="<?php echo $this->get_field_name( 'lostpass' ); ?>" value="<?php echo $instance['lostpass']; ?>" style="width:100%;" />
80 </p>
81
82 <?php
83
84 do_action( 'wppb_login_widget_after_display', $instance);
85 }
86 }
87
88 // we can apply this easily, if we need it
89 function wppb_scroll_down_to_widget($content){
90 return "<script> jQuery('html, body').animate({scrollTop: jQuery('#wppb_login').offset().top }) </script>" . $content;
91 }
92 //add_filter('wppb_login_wp_error_message', 'wppb_scroll_down_to_widget');
93
94 function wppb_require_jquery(){
95 wp_enqueue_script( 'jquery' );
96 }
97 //add_action( 'wp_enqueue_scripts', 'wppb_require_jquery' );