PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.45
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.45
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 1.0.22 1.0.23 All 172 releases
userswp / widgets / login.php

login.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.2.45, at widgets/login.php

223 lines 7.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) {
4 exit;
5 }
6
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
98 );
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 );
127 }
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 */
138 public function output( $args = array(), $widget_args = array(), $content = '' ) {
139
140 $defaults = array(
141 'form_title' => __('Login','userswp'),
142 'logged_in_show' => '',
143 'css_class' => 'border-0',
144 'redirect_to' => '',
145 );
146
147 /**
148 * Parse incoming $args into an array and merge it with $defaults
149 */
150 $args = wp_parse_args( $args, $defaults );
151
152 // if logged in and set to show nothing then bail.
153 if(is_user_logged_in() && $args['logged_in_show']=='empty'){
154 return '';
155 }
156
157 $design_style = !empty($args['design_style']) ? esc_attr($args['design_style']) : uwp_get_option("design_style",'bootstrap');
158
159 ob_start();
160
161 if(is_user_logged_in()) {
162
163 if($args['logged_in_show']=='simple'){
164 $template = $design_style ? $design_style."/dashboard-simple.php" : "dashboard-simple.php";
165 }else{
166
167 $user_id = get_current_user_id();
168
169 $dashboard_links = array(
170 'placeholder' => array(
171 'url' => '',
172 'text' => __('Select an action','userswp'),
173 'disabled' => true,
174 'selected' => true,
175 'display_none' => true
176 )
177 );
178
179 $dashboard_links['uwp_profile'][] = array(
180 'optgroup' => 'open',
181 'text' => esc_attr( __( 'My Profile', 'userswp' ) )
182 );
183 $dashboard_links['uwp_profile'][] = array(
184 'url' => uwp_build_profile_tab_url( $user_id ),
185 'text' => esc_attr( __( 'View Profile', 'userswp' ) )
186 );
187 $account_page = uwp_get_page_id('account_page', false);
188 $account_link = get_permalink( $account_page );
189 if($account_link){
190 $dashboard_links['uwp_profile'][] = array(
191 'url' => $account_link,
192 'text' => esc_attr( __( 'Edit Profile', 'userswp' ) )
193 );
194 }
195
196 $dashboard_links['uwp_profile'][] = array(
197 'optgroup' => 'close',
198 );
199
200 $dashboard_links = apply_filters( 'uwp_dashboard_links',$dashboard_links,$args);
201
202 $args['template_args']= array(
203 'dashboard_links' => $dashboard_links
204 );
205
206 $template = $design_style ? $design_style."/dashboard.php" : "dashboard.php";
207 }
208
209 } else {
210 $template = $design_style ? $design_style."/login.php" : "login.php";
211 }
212
213 echo '<div class="uwp_page">';
214
215 uwp_get_template($template, $args);
216
217 echo '</div>';
218
219 return ob_get_clean();
220
221 }
222
223 }