PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / trunk
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP vtrunk
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 trunk, at widgets/login.php

227 lines 8.0 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 if ( $this->is_preview() ) {
148 return;
149 }
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
213 } else {
214 $template = $design_style ? $design_style."/login.php" : "login.php";
215 }
216
217 echo '<div class="uwp_page">';
218
219 uwp_get_template($template, $args);
220
221 echo '</div>';
222
223 return ob_get_clean();
224
225 }
226
227 }