PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | widgets/login.php +211 -65 1.0.131.2.74 View file →
@@ -1,81 +1,227 @@
1 1 <?php
2 -add_action('widgets_init', 'uwp_init_login_widget');
3 -function uwp_init_login_widget() {
4 - register_widget("UWP_Login_Widget");
2 +
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit;
5 5 }
6 -class UWP_Login_Widget extends WP_Widget
7 -{
8 6
9 - /**
10 - * Class constructor.
11 - */
12 - function __construct()
13 - {
14 - $widget_ops = array(
15 - 'description' => __('Displays Login Form', 'userswp'),
16 - 'classname' => 'uwp_progress_users',
7 +/**
8 + * UsersWP forgot password widget.
9 + *
10 + * @since 1.0.22
11 + */
12 +
13 +class UWP_Login_Widget extends WP_Super_Duper {
14 +
15 + /**
16 + * Register the login widget with WordPress.
17 + *
18 + */
19 + public function __construct() {
20 +
21 + $options = array(
22 + 'textdomain' => 'userswp',
23 + 'block-icon' => 'fas fa-user',
24 + 'block-category'=> 'widgets',
25 + 'block-keywords'=> "['userswp','login']",
26 + 'block-supports'=> array(
27 + 'customClassName' => false
28 + ),
29 + 'class_name' => __CLASS__,
30 + 'base_id' => 'uwp_login',
31 + 'name' => __('UWP > Login','userswp'),
32 + 'widget_ops' => array(
33 + 'classname' => 'uwp-login-class bsui',
34 + 'description' => esc_html__('Displays login form or current logged in user.','userswp'),
35 + ),
36 + 'arguments' => array(
37 + 'title' => array(
38 + 'title' => __( 'Widget title', 'userswp' ),
39 + 'desc' => __( 'Enter widget title', 'userswp' ),
40 + 'type' => 'text',
41 + 'desc_tip' => true,
42 + 'default' => '',
43 + ),
44 + 'form_title' => array(
45 + 'title' => __( 'Form title', 'userswp' ),
46 + 'desc' => __( 'Enter the form title (or `0` for no title)', 'userswp' ),
47 + 'type' => 'text',
48 + 'desc_tip' => true,
49 + 'default' => '',
50 + 'placeholder' => __('Login','userswp'),
51 + 'advanced' => true
52 + ),
53 + 'logged_in_show' => array(
54 + 'title' => __('Logged in show', 'userswp'),
55 + 'desc' => __('What to show when logged in.', 'userswp'),
56 + 'type' => 'select',
57 + 'options' => array(
58 + "" => __('User Dashboard (default)', 'userswp'),
59 + "simple" => __('Simple username and logout link', 'userswp'),
60 + "empty" => __('Nothing', 'userswp'),
61 + ),
62 + 'default' => '',
63 + 'desc_tip' => true,
64 + 'advanced' => true
65 + ),
66 + 'redirect_to' => array(
67 + 'type' => 'text',
68 + 'title' => __('Redirect to:', 'userswp'),
69 + 'desc' => __('Enter the url you want to redirect after login.', 'userswp'),
70 + 'placeholder' => '',
71 + 'default' => '',
72 + 'desc_tip' => true,
73 + 'advanced' => true
74 + ),
75 + 'design_style' => array(
76 + 'title' => __('Design Style', 'userswp'),
77 + 'desc' => __('The design style to use.', 'userswp'),
78 + 'type' => 'select',
79 + 'options' => array(
80 + "" => __('default', 'userswp'),
81 + "bootstrap" => __('Style 1', 'userswp'),
82 + ),
83 + 'default' => '',
84 + 'desc_tip' => true,
85 + 'group' => __("Design","userswp")
86 + ),
87 + 'css_class' => array(
88 + 'type' => 'text',
89 + 'title' => __('Extra class:', 'userswp'),
90 + 'desc' => __('Give the wrapper an extra class so you can style things as you want.', 'userswp'),
91 + 'placeholder' => '',
92 + 'default' => '',
93 + 'desc_tip' => true,
94 + 'group' => __("Design","userswp")
95 + ),
96 + )
97 +
17 98 );
18 - parent::__construct(false, $name = _x('UWP > Login', 'widget name', 'userswp'), $widget_ops);
19 99
100 + // GD options
101 + if(class_exists( 'GeoDirectory' )){
102 + $options['arguments']['disable_gd'] = array(
103 + 'title' => __("Disable GeoDirectory links from the user dashboard.", 'userswp'),
104 + 'type' => 'checkbox',
105 + 'desc_tip' => true,
106 + 'value' => '1',
107 + 'default' => '',
108 + 'group' => __("Addons","userswp"),
109 + 'element_require' => '[%logged_in_show%]==""',
110 + );
111 + }
112 +
113 + // WPI options
114 + if(class_exists( 'WPInv_Plugin' )){
115 + $options['arguments']['disable_wpi'] = array(
116 + 'title' => __("Disable WP Invoicing links from the user dashboard.", 'userswp'),
117 + 'type' => 'checkbox',
118 + 'desc_tip' => true,
119 + 'value' => '1',
120 + 'default' => '',
121 + 'group' => __("Addons","userswp"),
122 + 'element_require' => '[%logged_in_show%]==""',
123 + );
124 + }
125 +
126 + parent::__construct( $options );
20 127 }
21 128
22 - /**
23 - * Display the widget.
24 - *
25 - * @param array $args Widget arguments.
26 - * @param array $instance The widget settings, as saved by the user.
27 - */
28 - function widget($args, $instance)
29 - {
30 - extract($args, EXTR_SKIP);
31 - $title = empty($instance['title']) ? __('Login', 'userswp') : apply_filters('uwp_login_widget_title', $instance['title']);
129 + /**
130 + * The Super block output function.
131 + *
132 + * @param array $args
133 + * @param array $widget_args
134 + * @param string $content
135 + *
136 + * @return mixed|string
137 + */
138 + public function output( $args = array(), $widget_args = array(), $content = '' ) {
32 139
33 - echo '<div class="uwp_widgets">';
34 - echo $before_widget;
35 - if ($title) {
36 - echo $before_title . $title . $after_title;
140 + $defaults = array(
141 + 'form_title' => __('Login','userswp'),
142 + 'logged_in_show' => '',
143 + 'css_class' => 'border-0',
144 + 'redirect_to' => '',
145 + );
146 +
147 + if ( $this->is_preview() ) {
148 + return;
37 149 }
38 - if(is_user_logged_in()){
39 - global $current_user;
40 - $template = new UsersWP_Templates();
41 - $logout_url = $template->uwp_logout_url();
42 - echo '<div class="uwp-login-widget user-loggedin">';
43 - echo '<p>'.__( 'Logged in as ', 'userswp' );
44 - echo '<a href="'. apply_filters('uwp_profile_link', get_author_posts_url($current_user->ID), $current_user->ID).'">' . get_avatar( $current_user->ID, 35 ). '<strong>'. apply_filters('uwp_profile_display_name', $current_user->display_name).'</strong></a>';
45 - echo '<span>';
46 - printf(__( '<a href="%1$s">Log out</a>', 'userswp'), esc_url( $logout_url ));
47 - echo '</span></p>';
48 - echo '</div>';
150 +
151 + /**
152 + * Parse incoming $args into an array and merge it with $defaults
153 + */
154 + $args = wp_parse_args( $args, $defaults );
155 +
156 + // if logged in and set to show nothing then bail.
157 + if(is_user_logged_in() && $args['logged_in_show']=='empty'){
158 + return '';
159 + }
160 +
161 + $design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap');
162 +
163 + ob_start();
164 +
165 + if(is_user_logged_in()) {
166 +
167 + if($args['logged_in_show']=='simple'){
168 + $template = $design_style ? $design_style."/dashboard-simple.php" : "dashboard-simple.php";
169 + }else{
170 +
171 + $user_id = get_current_user_id();
172 +
173 + $dashboard_links = array(
174 + 'placeholder' => array(
175 + 'url' => '',
176 + 'text' => __('Select an action','userswp'),
177 + 'disabled' => true,
178 + 'selected' => true,
179 + 'display_none' => true
180 + )
181 + );
182 +
183 + $dashboard_links['uwp_profile'][] = array(
184 + 'optgroup' => 'open',
185 + 'text' => esc_attr( __( 'My Profile', 'userswp' ) )
186 + );
187 + $dashboard_links['uwp_profile'][] = array(
188 + 'url' => uwp_build_profile_tab_url( $user_id ),
189 + 'text' => esc_attr( __( 'View Profile', 'userswp' ) )
190 + );
191 + $account_page = uwp_get_page_id('account_page', false);
192 + $account_link = get_permalink( $account_page );
193 + if($account_link){
194 + $dashboard_links['uwp_profile'][] = array(
195 + 'url' => $account_link,
196 + 'text' => esc_attr( __( 'Edit Profile', 'userswp' ) )
197 + );
198 + }
199 +
200 + $dashboard_links['uwp_profile'][] = array(
201 + 'optgroup' => 'close',
202 + );
203 +
204 + $dashboard_links = apply_filters( 'uwp_dashboard_links',$dashboard_links,$args);
205 +
206 + $args['template_args']= array(
207 + 'dashboard_links' => $dashboard_links
208 + );
209 +
210 + $template = $design_style ? $design_style."/dashboard.php" : "dashboard.php";
211 + }
212 +
49 213 } else {
50 - echo do_shortcode('[uwp_login]');
214 + $template = $design_style ? $design_style."/login.php" : "login.php";
51 215 }
52 - echo $after_widget;
216 +
217 + echo '<div class="uwp_page">';
218 +
219 + uwp_get_template($template, $args);
220 +
53 221 echo '</div>';
54 - }
55 222
56 - function update($new_instance, $old_instance)
57 - {
58 - //save the widget
59 - $instance = $old_instance;
60 - $instance['title'] = strip_tags($new_instance['title']);
61 - return $instance;
62 - }
223 + return ob_get_clean();
63 224
64 - function form($instance)
65 - {
66 - //widgetform in backend
67 - $instance = wp_parse_args((array)$instance, array(
68 - 'title' => __('Login', 'userswp'),
69 - ));
70 - $title = strip_tags($instance['title']);
71 - ?>
72 - <p><label for="<?php echo $this->get_field_id('title'); ?>"><?php echo __("Widget Title:", 'userswp'); ?> <input class="widefat"
73 - id="<?php echo $this->get_field_id('title'); ?>"
74 - name="<?php echo $this->get_field_name('title'); ?>"
75 - type="text"
76 - value="<?php echo esc_attr($title); ?>"/></label>
77 - </p>
78 - <?php
79 225 }
80 -
226 +
81 227 }