PluginProbe
Pie Register – User Registration, Profiles & Content Restriction / 3.8
Pie Register – User Registration, Profiles & Content Restriction v3.8
3.8.4.13 3.8.4.12 3.8.4.11 3.7.4.2 3.7.4.3 3.7.4.4 3.7.4.5 3.7.4.6 3.7.5 3.7.5.1 3.8 3.8.0.1 3.8.0.2 3.8.1 3.8.1.1 3.8.1.2 3.8.1.3 3.8.1.4 3.8.2 3.8.2.1 3.8.2.2 3.8.2.3 3.8.2.4 3.8.2.5 3.8.2.6 All 179 releases
pie-register / widget.php

widget.php in Pie Register – User Registration, Profiles & Content Restriction 3.8, at widget.php

321 lines 14.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if( file_exists( PIEREG_DIR_NAME . '/classes/registration_form.php') )
3 require_once('classes/registration_form.php');
4
5 class Pie_Register_Widget extends WP_Widget
6 {
7 function __construct()
8 {
9 parent::__construct(
10 'pie_widget', // Base ID
11 __('Pie Register - Registration Form', 'pie-register'), // Name
12 array( 'description' => __( 'Display the Pie Register registration form on sidebar', 'pie-register' ), ) // Args
13 );
14 }
15 public function widget( $args, $instance ){
16 $option = get_option(OPTION_PIE_REGISTER);
17 global $piereg_post_array;
18 $this->pie_post_array = $piereg_post_array;
19
20 $pie_register = new PieRegister();
21 $pie_register->piereg_ssl_template_redirect();
22 if(is_user_logged_in() && !is_admin() && $option['redirect_user']==1 ){
23 //do nothing here
24 }elseif( (isset($instance['form_id']) && $instance['form_id'] != $pie_register->regFormForFreeVers()) ) {
25 //do nothing here
26
27 }else{
28 global $errors;
29 $form_on_free = get_option("piereg_form_free_id");
30
31 $success = $error = '' ;
32 $title = isset($instance['title']) ? apply_filters( 'widget_title', $instance['title'] ) : '';
33 $form_id = isset($instance['form_id']) ? $instance['form_id'] : $form_on_free;
34 $form_title = isset($instance['form_title']) ? $instance['form_title'] : '';
35 $form_desc = isset($instance['form_desc']) ? $instance['form_desc'] : true;
36
37 echo $args['before_widget'];
38
39 echo('<div class="piereg_container pieregWrapper">');
40 if(isset($this->pie_post_array['success']) && $this->pie_post_array['success'] != "")
41 echo('<p class="piereg_message">'.apply_filters('piereg_messages',__($this->pie_post_array['success'],"pie-register")).'</p>');
42
43 if(isset($this->pie_post_array['error']) && $this->pie_post_array['error'] != "")
44 echo('<p class="piereg_login_error">'.apply_filters('piereg_messages',__($this->pie_post_array['error'],"pie-register")).'</p>');
45
46 if(isset($this->pie_post_array['registration_success']) && $this->pie_post_array['registration_success'] != ""){
47 echo('<p class="piereg_message">'.apply_filters('piereg_messages',__($this->pie_post_array['registration_success'],"pie-register")).'</p>');
48 unset($_POST);
49 }
50
51 if(isset($errors->errors) && sizeof($errors->errors) > 0)
52 {
53 foreach($errors->errors as $key=>$err)
54 {
55 if($key != "login-error")
56 $error .= $err[0] . "<br />";
57 }
58 if(isset($error) && !empty($error))
59 echo('<p class="piereg_login_error">'.apply_filters('piereg_messages',__($error,"pie-register")).'</p>');
60 }
61 echo wp_kses($pie_register->outputRegForm(true,$form_id,$form_title,$form_desc), $pie_register->piereg_forms_get_allowed_tags());
62 echo('</div>');
63 echo $args['after_widget'];
64 set_pr_stats("register","view");
65
66 }
67 }
68 // Widget Backend
69 public function form( $instance ) {
70 $base = new PieReg_Base();
71
72 if ( isset( $instance[ 'title' ] ) ) {
73 $title = $instance[ 'title' ];
74 }
75 else {
76 $title = __( 'Pie Registration Form', 'pie_forgot' );
77 }
78 $form_id = ((isset($instance['form_id']))?$instance['form_id']:"");
79 $form_title = ((isset($instance['form_title']))?$instance['form_title']:"true");
80 $form_desc = ((isset($instance['form_desc']))?$instance['form_desc']:"true");
81 // Widget admin form
82 ?>
83 <p>
84 <label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php esc_html_e( 'Title:' ); ?></label>
85 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
86 </p>
87 <p>
88 <label for="<?php echo esc_attr($this->get_field_id( 'form_id' )); ?>"><?php esc_html_e( 'Form:' );?></label>
89 <select class="widefat" id="<?php echo esc_attr($this->get_field_id( 'form_id' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'form_id' )); ?>">
90 <?php
91 $fields_id = get_option("piereg_form_fields_id");
92 for($a=1;$a<=$fields_id;$a++)
93 {
94 $option = get_option("piereg_form_field_option_".$a);
95 if($option != "" && (!isset($option['IsDeleted']) || trim($option['IsDeleted']) != 1) )
96 {
97 echo '<option '.selected( (!empty($form_id) && $form_id == $option['Id']), true).' value="'.esc_attr($option['Id']).'" >'.esc_html($option['Title']).'</option>';
98
99 if(!$base->piereg_pro_is_activate){
100 break;
101 }
102 }
103 }?>
104 </select>
105 </p>
106 <p>
107 <label for="<?php echo esc_attr($this->get_field_id( 'form_title' )); ?>"><?php esc_html_e( 'Form Title:' );?></label>
108 <select class="widefat" id="<?php echo esc_attr($this->get_field_id( 'form_title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'form_title' )); ?>">
109 <?php
110 echo '<option '.selected((!empty($form_title) && $form_title == "true"), true).' value="true" >Show</option>';
111 echo '<option '.selected((!empty($form_title) && $form_title == "false"), true).' value="false" >Hide</option>';
112 ?>
113 </select>
114 </p>
115 <p>
116 <label for="<?php echo esc_attr($this->get_field_id( 'form_desc' )); ?>"><?php esc_html_e( 'Form Description:' );?></label>
117 <select class="widefat" id="<?php echo esc_attr($this->get_field_id( 'form_desc' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'form_desc' )); ?>">
118 <?php
119 echo '<option '.selected((!empty($form_desc) && $form_desc == "true"), true).' value="true" >Show</option>';
120 echo '<option '.selected((!empty($form_desc) && $form_desc == "false"), true).' value="false" >Hide</option>';
121 ?>
122 </select>
123 </p>
124 <?php
125 }
126 // Updating widget replacing old instances with new
127 public function update( $new_instance, $old_instance ) {
128 $instance = array();
129 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
130 $instance['form_id'] = ( ! empty( $new_instance['form_id'] ) ) ? wp_strip_all_tags( $new_instance['form_id'] ) : '';
131 $instance['form_title'] = ( ! empty( $new_instance['form_title'] ) ) ? wp_strip_all_tags( $new_instance['form_title'] ) : '';
132 $instance['form_desc'] = ( ! empty( $new_instance['form_desc'] ) ) ? wp_strip_all_tags( $new_instance['form_desc'] ) : '';
133 return $instance;
134 }
135 }
136
137
138
139
140 /*
141 * Pie Register Login Widgets
142 */
143 class Pie_Login_Widget extends WP_Widget {
144 /**
145 * Register widget with WordPress.
146 */
147 function __construct()
148 {
149 parent::__construct(
150 'pie_login_widget', // Base ID
151 __('Pie Register - Login Form', 'pie_login'), // Name
152 array( 'description' => __( 'Display Pie Register Login Form on Sidebar', 'pie-register' ), ) // Args
153 );
154 }
155 public function widget( $args, $instance ){
156 $option = get_option(OPTION_PIE_REGISTER);
157 $pie_register = new PieRegister();
158 $pie_register->piereg_ssl_template_redirect();
159
160 echo $args['before_widget'];
161 $before_title = isset($instance['before_title']) ? apply_filters( 'widget_title', $instance['before_title'] ) : '';
162 $after_title = isset($instance['after_title']) ? apply_filters( 'widget_title', $instance['after_title'] ) : '';
163 $social_login = ( (isset($instance['social_login'])) ? apply_filters( 'widget_title', $instance['social_login'] ) : 0 );
164 if ( !is_user_logged_in() )
165 {
166 if ( ! empty( $before_title ) )
167 echo $args['before_title'] . $before_title . $args['after_title'];
168 set_pr_stats("login","view");
169 if( file_exists(PIEREG_DIR_NAME . "/login_form.php") )
170 include_once("login_form.php");
171 echo wp_kses(pieOutputLoginForm(true), $pie_register->piereg_forms_get_allowed_tags());
172 if(intval($social_login) > 0 )
173 {
174 $social_site_data = "";
175 $social_site_data .= apply_filters("get_enable_social_sites_button_widgets",$social_site_data);
176 echo wp_kses($social_site_data, $pie_register->piereg_forms_get_allowed_tags());
177 }
178 }else{
179
180 $current_user = wp_get_current_user();
181 if ( ! empty( $after_title ) )
182 echo $args['before_title'] . $after_title . $args['after_title'];
183 $profile_pic_array = get_user_meta($current_user->ID);
184 $profile_pic = "";
185 foreach($profile_pic_array as $key=>$val)
186 {
187 if(strpos($key,'profile_pic') !== false){
188 $profile_pic = trim($val[0]);
189 }
190 }
191
192 $profile_pic = apply_filters("piereg_profile_image_url",$profile_pic,$current_user);
193 echo '<div class="logged-In">';
194 $user_avater = get_avatar(get_current_user_id(),75);
195 $profile_link = get_permalink($option['alternate_profilepage']);
196 $profile_avatar = ((!empty($profile_pic))?('<img src="'.esc_url($profile_pic).'" style="max-width:75px;max-height:75px;"/>'):$user_avater);
197 $profile_image_html = '<a href="'.esc_url($profile_link).'">'.$profile_avatar.'</a>';
198 echo wp_kses_post(apply_filters('pie_profile_image_frontend_widget',$profile_image_html,$profile_link,$profile_pic));
199 ////////////////////////////
200 $first_name = get_user_meta($current_user->ID,"first_name",true);
201 $last_name = get_user_meta($current_user->ID,"last_name",true);
202 if( !empty($first_name) && !empty($last_name) )
203 $profile_text = $first_name . "&nbsp;" . $last_name;
204 elseif( !empty($current_user->display_name) )
205 $profile_text = $current_user->display_name;
206 else
207 $profile_text = $current_user->user_login;
208
209 $profile_text_html = '<a href="'.esc_url($profile_link) .'">' . esc_html($profile_text) . '</a>';
210 echo '';
211 echo '<div class="member_div"><h4>';
212 echo wp_kses_post(apply_filters('pie_profile_username_frontend_widget',$profile_text_html,$profile_link,$profile_text));
213 echo '</h4>';
214 echo '<a href="'.esc_url(wp_logout_url()).'" class="logout-link" title="Logout">'.__("Logout","pie-register").'</a></div></div>';
215 }
216 echo $args['after_widget'];
217 }
218 // Widget Backend
219 public function form( $instance ) {
220 if ( isset( $instance[ 'before_title' ] ) ) {
221 $before_title = $instance[ 'before_title' ];
222 }
223 else {
224 $before_title = __( 'Pie Login', 'pie_login' );
225 }
226 if ( isset( $instance[ 'after_title' ] ) ) {
227 $after_title = $instance[ 'after_title' ];
228 }
229 else {
230 $after_title = __( 'Welcome User', 'pie_login' );
231 }
232 if ( isset( $instance[ 'social_login' ] ) ) {
233 $social_login = $instance[ 'social_login' ];
234 }
235 else {
236 $social_login = 0;
237 }
238 // Widget admin form
239 ?>
240 <p>
241 <label for="<?php echo esc_attr($this->get_field_id( 'before_title' )); ?>"><?php esc_html_e( 'Before Login Title:' ); ?></label>
242 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'before_title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'before_title' )); ?>" type="text" value="<?php echo esc_attr( $before_title ); ?>" />
243 <label for="<?php echo esc_attr($this->get_field_id( 'after_title' )); ?>"><?php esc_html_e( 'After Login Title:' ); ?></label>
244 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'after_title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'after_title' )); ?>" type="text" value="<?php echo esc_attr( $after_title ); ?>" />
245 <?php
246 if(is_plugin_active('pie-register-social-site/pie-register-social-site.php')):
247 ?>
248 <label for="<?php echo esc_attr($this->get_field_id( 'social_login' )); ?>"><?php esc_html_e( 'Social Login:' ); ?></label>
249 <select class="widefat" name="<?php echo esc_attr($this->get_field_name( 'social_login' )); ?>" id="<?php echo esc_attr($this->get_field_id( 'social_login' )); ?>">
250 <option value="0" <?php selected( $social_login == 0, true); ?>><?php esc_html_e("Disable","pie-register"); ?></option>
251 <option value="1" <?php selected( $social_login == 1, true); ?>><?php esc_html_e("Enable","pie-register"); ?></option>
252 </select>
253 <?php
254 endif;
255 ?>
256 </p>
257 <?php
258 }
259 // Updating widget replacing old instances with new
260 public function update( $new_instance, $old_instance ) {
261 $instance = array();
262 $instance['before_title'] = ( ! empty( $new_instance['before_title'] ) ) ? wp_strip_all_tags( $new_instance['before_title'] ) : '';
263 $instance['after_title'] = ( ! empty( $new_instance['after_title'] ) ) ? wp_strip_all_tags( $new_instance['after_title'] ) : '';
264 $instance['social_login'] = ( isset( $new_instance['social_login'] ) && ! empty( $new_instance['social_login'] ) ) ? intval( $new_instance['social_login'] ) : '';
265 return $instance;
266 }
267 }
268
269 class Pie_Forgot_Widget extends WP_Widget
270 {
271 function __construct()
272 {
273 parent::__construct(
274 'pie_forgot_widget', // Base ID
275 __('Pie Register - Forgot Password Form', 'pie-register'), // Name
276 array( 'description' => __( 'Forgot Password Form', 'pie-register' ), ) // Args
277 );
278
279 }
280 public function widget( $args, $instance )
281 {
282 $option = get_option(OPTION_PIE_REGISTER);
283 $pie_register = new PieRegister();
284 $pie_register->piereg_ssl_template_redirect();
285 if(is_user_logged_in() && !is_admin() && $option['redirect_user']==1 ){
286 //do nothing here
287 }else{
288 $title = (isset($instance['title']) && $instance['title']) ? $instance['title'] : __( 'Forgot password', 'pie-register' );
289 echo $args['before_widget'];
290 if ( ! empty( $title ) )
291 echo $args['before_title'] . esc_html($title) . $args['after_title'];
292 if( file_exists(PIEREG_DIR_NAME . "/forgot_password.php") )
293 include_once("forgot_password.php");
294 set_pr_stats("forgot","view");
295 echo wp_kses(pieResetFormOutput(true), $pie_register->piereg_forms_get_allowed_tags());
296 echo $args['after_widget'];
297 }
298 }
299 // Widget Backend
300 public function form( $instance ) {
301 if ( isset( $instance[ 'title' ] ) ) {
302 $title = $instance[ 'title' ];
303 }
304 else {
305 $title = __( 'Forgot password', 'pie-register' );
306 }
307 // Widget admin form
308 ?>
309 <p>
310 <label for="<?php echo esc_attr($this->get_field_id( 'title' )); ?>"><?php echo esc_html( 'Title:' ); ?></label>
311 <input class="widefat" id="<?php echo esc_attr($this->get_field_id( 'title' )); ?>" name="<?php echo esc_attr($this->get_field_name( 'title' )); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" />
312 </p>
313 <?php
314 }
315 // Updating widget replacing old instances with new
316 public function update( $new_instance, $old_instance ) {
317 $instance = array();
318 $instance['title'] = ( ! empty( $new_instance['title'] ) ) ? wp_strip_all_tags( $new_instance['title'] ) : '';
319 return $instance;
320 }
321 }