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 +174 -44 1.0.191.2.74 View file →
@@ -1,97 +1,227 @@
1 1 <?php
2 2
3 -add_action('widgets_init', 'uwp_init_login_widget');
3 +if ( ! defined( 'ABSPATH' ) ) {
4 + exit;
5 +}
4 6
5 -function uwp_init_login_widget() {
7 +/**
8 + * UsersWP forgot password widget.
9 + *
10 + * @since 1.0.22
11 + */
6 12
7 - register_widget("UWP_Login_Widget");
8 -
9 -}
10 -
11 13 class UWP_Login_Widget extends WP_Super_Duper {
12 14
15 + /**
16 + * Register the login widget with WordPress.
17 + *
18 + */
13 19 public function __construct() {
14 20
15 21 $options = array(
16 22 'textdomain' => 'userswp',
17 - 'block-icon' => 'admin-site',
23 + 'block-icon' => 'fas fa-user',
18 24 'block-category'=> 'widgets',
19 25 'block-keywords'=> "['userswp','login']",
26 + 'block-supports'=> array(
27 + 'customClassName' => false
28 + ),
20 29 'class_name' => __CLASS__,
21 30 'base_id' => 'uwp_login',
22 31 'name' => __('UWP > Login','userswp'),
23 32 'widget_ops' => array(
24 - 'classname' => 'uwp-login-class',
33 + 'classname' => 'uwp-login-class bsui',
25 34 'description' => esc_html__('Displays login form or current logged in user.','userswp'),
26 35 ),
27 36 'arguments' => array(
28 37 'title' => array(
29 - 'title' => __( 'Login widget title', 'userswp' ),
30 - 'desc' => __( 'Enter login widget title', 'userswp' ),
38 + 'title' => __( 'Widget title', 'userswp' ),
39 + 'desc' => __( 'Enter widget title', 'userswp' ),
31 40 'type' => 'text',
32 41 'desc_tip' => true,
33 42 'default' => '',
34 - 'advanced' => false
35 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 + ),
36 96 )
37 97
38 98 );
39 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 +
40 126 parent::__construct( $options );
41 127 }
42 128
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 + */
43 138 public function output( $args = array(), $widget_args = array(), $content = '' ) {
44 139
45 - ob_start();
140 + $defaults = array(
141 + 'form_title' => __('Login','userswp'),
142 + 'logged_in_show' => '',
143 + 'css_class' => 'border-0',
144 + 'redirect_to' => '',
145 + );
46 146
47 - echo '<div class="uwp_widgets uwp_widget_login">';
147 + if ( $this->is_preview() ) {
148 + return;
149 + }
48 150
49 - if(is_user_logged_in()) {
151 + /**
152 + * Parse incoming $args into an array and merge it with $defaults
153 + */
154 + $args = wp_parse_args( $args, $defaults );
50 155
51 - global $current_user;
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 + }
52 160
53 - $template = new UsersWP_Templates();
161 + $design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap');
54 162
55 - $logout_url = $template->uwp_logout_url();
163 + ob_start();
164 +
165 + if(is_user_logged_in()) {
56 166
57 - echo '<div class="uwp-login-widget user-loggedin">';
167 + if($args['logged_in_show']=='simple'){
168 + $template = $design_style ? $design_style."/dashboard-simple.php" : "dashboard-simple.php";
169 + }else{
58 170
59 - echo '<p>'.__( 'Logged in as ', 'userswp' );
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 + );
60 182
61 - 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>';
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 + }
62 199
63 - echo '<span>';
200 + $dashboard_links['uwp_profile'][] = array(
201 + 'optgroup' => 'close',
202 + );
203 +
204 + $dashboard_links = apply_filters( 'uwp_dashboard_links',$dashboard_links,$args);
64 205
65 - printf(__( '<a href="%1$s">Log out</a>', 'userswp'), esc_url( $logout_url ));
206 + $args['template_args']= array(
207 + 'dashboard_links' => $dashboard_links
208 + );
209 +
210 + $template = $design_style ? $design_style."/dashboard.php" : "dashboard.php";
211 + }
66 212
67 - echo '</span>';
68 -
69 - echo '</p>';
70 -
71 - echo '</div>';
72 -
73 213 } else {
214 + $template = $design_style ? $design_style."/login.php" : "login.php";
215 + }
74 216
75 - $temp_obj = new UsersWP_Templates();
76 - $template = $temp_obj->uwp_locate_template('login');
217 + echo '<div class="uwp_page">';
77 218
78 - echo '<div class="uwp_page">';
219 + uwp_get_template($template, $args);
79 220
80 - if ($template) {
81 - include($template);
82 - }
83 -
84 - echo '</div>';
85 -
86 - }
87 -
88 221 echo '</div>';
89 222
90 - $output = ob_get_contents();
223 + return ob_get_clean();
91 224
92 - ob_end_clean();
93 -
94 - return trim($output);
95 -
96 225 }
226 +
97 227 }