PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.0.16
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.0.16
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
userswp / includes / libraries / class-geodirectory-plugin.php

class-geodirectory-plugin.php in UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP 1.0.16, at includes/libraries/class-geodirectory-plugin.php

1,273 lines 55.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * GeoDirectory plugin related functions
4 *
5 * This class defines all code necessary for GeoDirectory plugin.
6 *
7 * @since 1.0.0
8 * @author GeoDirectory Team <info@wpgeodirectory.com>
9 */
10 class UsersWP_GeoDirectory_Plugin {
11 private static $instance;
12
13 public static function get_instance() {
14 if ( ! isset( self::$instance ) && ! ( self::$instance instanceof UsersWP_GeoDirectory_Plugin ) ) {
15 self::$instance = new UsersWP_GeoDirectory_Plugin;
16 self::$instance->setup_globals();
17 self::$instance->includes();
18 self::$instance->setup_actions();
19 }
20
21 return self::$instance;
22 }
23
24 private function __construct() {
25 self::$instance = $this;
26 }
27
28 private function setup_globals() {
29
30 }
31
32 private function setup_actions() {
33 if ( is_admin() ) {
34 add_filter( 'uwp_display_form_title', array( $this, 'display_form_title' ), 10, 3 );
35 add_action( 'uwp_geodirectory_settings_main_tab_content', array( $this, 'main_tab_content' ), 10, 1 );
36 add_action( 'uwp_admin_sub_menus', array( $this, 'add_admin_gd_sub_menu' ), 10, 1 );
37 add_filter( 'uwp_settings_tabs', array( $this, 'add_gd_tab' ) );
38 add_filter( 'uwp_registered_settings', array( $this, 'add_gd_settings' ) );
39 add_filter( 'uwp_available_tab_items', array( $this, 'available_tab_items' ) );
40 } else {
41 add_filter( 'uwp_profile_tabs', array( $this, 'add_profile_gd_tabs' ), 10, 3 );
42 add_action( 'uwp_profile_listings_tab_content', array( $this, 'add_profile_listings_tab_content' ) );
43 add_action( 'uwp_profile_reviews_tab_content', array( $this, 'add_profile_reviews_tab_content' ) );
44 add_action( 'uwp_profile_favorites_tab_content', array( $this, 'add_profile_favorites_tab_content' ) );
45 add_action( 'uwp_profile_invoices_tab_content', array( $this, 'add_profile_invoices_tab_content' ) );
46 add_action( 'uwp_profile_gd_listings_subtab_content', array( $this, 'gd_get_listings' ), 10, 2 );
47 add_action( 'uwp_profile_gd_reviews_subtab_content', array( $this, 'gd_get_reviews' ), 10, 2 );
48 add_action( 'uwp_profile_gd_favorites_subtab_content', array( $this, 'gd_get_favorites' ), 10, 2 );
49 //add_action( 'geodir_after_edit_post_link_on_listing', array( $this, 'geodir_add_post_status_author_page' ), 11 );
50 }
51 add_filter( 'geodir_login_url', array( $this, 'get_gd_login_url' ), 10, 2 );
52 add_action( 'wp', array( $this, 'geodir_uwp_author_redirect' ) );
53 add_filter( 'geodir_post_status_is_author_page', array( $this, 'geodir_post_status_is_author_page' ) );
54 add_filter( 'gd_login_wid_login_placeholder', array( $this, 'gd_login_wid_login_placeholder' ) );
55 add_filter( 'gd_login_wid_login_name', array( $this, 'gd_login_wid_login_name' ) );
56 add_filter( 'gd_login_wid_login_pwd', array( $this, 'gd_login_wid_login_pwd' ) );
57 add_action( 'login_form', array( $this, 'gd_login_inject_nonce' ) );
58 add_filter( 'uwp_check_redirect_author_page', array( $this, 'check_redirect_author_page' ), 10, 1 );
59 add_filter( 'uwp_use_author_page_content', array( $this, 'skip_uwp_author_page' ), 10, 1 );
60
61 do_action( 'uwp_gd_setup_actions', $this );
62 }
63
64 private function includes() {
65 do_action( 'uwp_gd_include_files' );
66
67 if ( is_admin() ) {
68 do_action( 'uwp_gd_include_admin_files' );
69 }
70 }
71
72 /**
73 * Modifies the settings form title.
74 *
75 * @since 1.0.0
76 * @package userswp
77 *
78 * @param string $title Original title.
79 * @param string $page admin.php?page=uwp_xxx.
80 * @param string $active_tab active tab in that settings page.
81 *
82 * @return string Form title.
83 */
84 public function display_form_title( $title, $page, $active_tab ) {
85 if ( $page == 'uwp_geodirectory' && $active_tab == 'main' ) {
86 $title = __( 'GeoDirectory Settings', 'userswp' );
87 }
88 return $title;
89 }
90
91 /**
92 * Prints the settings form.
93 *
94 * @since 1.0.0
95 * @package userswp
96 *
97 * @param string $form Setting form html.
98 *
99 * @return void
100 */
101 public function main_tab_content( $form ) {
102 echo $form;
103 }
104
105 /**
106 * Adds the current userswp addon settings page menu as submenu.
107 *
108 * @since 1.0.0
109 * @package userswp
110 *
111 * @param callable $settings_page The function to be called to output the content for this page.
112 *
113 * @return void
114 */
115 public function add_admin_gd_sub_menu( $settings_page ) {
116 add_submenu_page(
117 "userswp",
118 __( 'GeoDirectory', 'userswp' ),
119 __( 'GeoDirectory', 'userswp' ),
120 'manage_options',
121 'uwp_geodirectory',
122 $settings_page
123 );
124 }
125
126 /**
127 * Adds settings tabs for the current userswp addon.
128 *
129 * @since 1.0.0
130 * @package userswp
131 *
132 * @param array $tabs Existing tabs array.
133 *
134 * @return array Tabs array.
135 */
136 public function add_gd_tab( $tabs ) {
137 $tabs['uwp_geodirectory'] = array(
138 'main' => __( 'GeoDirectory', 'userswp' ),
139 );
140 return $tabs;
141 }
142
143 /**
144 * Registers form fields for the current userswp addon settings page.
145 *
146 * @since 1.0.0
147 * @package userswp
148 *
149 * @param array $uwp_settings Existing settings array.
150 *
151 * @return array Settings array.
152 */
153 public function add_gd_settings( $uwp_settings ) {
154 $gd_posttypes = $this->get_gd_posttypes();
155
156 $options = array(
157 'gd_settings_info' => array(
158 'id' => 'woo_settings_info',
159 'name' => __( 'Info', 'userswp' ),
160 'desc' => __( 'You can now add Listings, Reviews and Favorites tabs under UsersWP > Profile > Choose the tabs to display in Profile', 'userswp' ),
161 'type' => 'info',
162 'std' => '1',
163 'class' => 'uwp_label_inline',
164 ),
165 'gd_profile_listings' => array(
166 'id' => 'gd_profile_listings',
167 'name' => __( 'CPT listings in Profile', 'userswp' ),
168 'desc' => __( 'Choose the post types to show listings tab in UsersWP Profile', 'userswp' ),
169 'multiple' => true,
170 'chosen' => true,
171 'type' => 'select',
172 'options' => $gd_posttypes,
173 'placeholder' => __( 'Select Post Types', 'userswp' )
174 ),
175 'gd_profile_reviews' => array(
176 'id' => 'gd_profile_reviews',
177 'name' => __( 'CPT reviews in Profile', 'userswp' ),
178 'desc' => __( 'Choose the post types to show reviews tab in UsersWP Profile', 'userswp' ),
179 'multiple' => true,
180 'chosen' => true,
181 'type' => 'select',
182 'options' => $gd_posttypes,
183 'placeholder' => __( 'Select Post Types', 'userswp' )
184 ),
185 'gd_profile_favorites' => array(
186 'id' => 'gd_profile_favorites',
187 'name' => __( 'CPT favorites in Profile', 'userswp' ),
188 'desc' => __( 'Choose the post types to show favorites tab in UsersWP Profile', 'userswp' ),
189 'multiple' => true,
190 'chosen' => true,
191 'type' => 'select',
192 'options' => $gd_posttypes,
193 'placeholder' => __( 'Select Post Types', 'userswp' )
194 ),
195 'geodir_uwp_link_listing' => array(
196 'id' => 'geodir_uwp_link_listing',
197 'name' => __( 'Redirect my listing link from GD loginbox to UsersWP profile', 'userswp' ),
198 'desc' => __( 'If this option is selected, the my listing link from GD loginbox will redirect to listings tab of UsersWP profile.', 'userswp' ),
199 'type' => 'checkbox',
200 'std' => '0',
201 'class' => 'uwp_label_inline',
202 ),
203 'geodir_uwp_link_favorite' => array(
204 'id' => 'geodir_uwp_link_favorite',
205 'name' => __( 'Redirect favorite link from GD loginbox to UsersWP profile', 'userswp' ),
206 'desc' => __( 'If this option is selected, the favorite link from GD loginbox will redirect to favorites tab of UsersWP profile.', 'userswp' ),
207 'type' => 'checkbox',
208 'std' => '0',
209 'class' => 'uwp_label_inline',
210 ),
211 );
212
213 $uwp_settings['uwp_geodirectory'] = array(
214 'main' => apply_filters( 'uwp_settings_geodirectory', $options ),
215 );
216
217 return $uwp_settings;
218 }
219
220 public function get_gd_posttypes() {
221 $post_type_arr = array();
222 $post_types = geodir_get_posttypes( 'object' );
223
224 foreach ( $post_types as $key => $post_types_obj ) {
225 $post_type_arr[$key] = $post_types_obj->labels->singular_name;
226 }
227 return $post_type_arr;
228 }
229
230 /**
231 * Registers the current addon tab items in "Choose the tabs to display in UsersWP Profile" setting.
232 *
233 * @since 1.0.0
234 * @package userswp
235 *
236 * @param array $tabs_arr Existing tabs array.
237 *
238 * @return array Tabs array.
239 */
240 public function available_tab_items( $tabs_arr ) {
241 $tabs_arr['listings'] = __( 'Listings', 'userswp' );
242 $tabs_arr['reviews'] = __( 'Reviews', 'userswp' );
243 $tabs_arr['favorites'] = __( 'Favorites', 'userswp' );
244
245 if ( class_exists( 'WPInv_Invoice' ) ) {
246 $tabs_arr['invoices'] = __( 'Invoices', 'userswp' );
247 }
248
249 return $tabs_arr;
250 }
251
252 public function geodir_get_reviews_by_user_id($post_type = 'gd_place', $user_id, $count_only = false, $offset = 0, $limit = 20) {
253 global $wpdb;
254
255 if ($count_only) {
256 $results = $wpdb->get_var(
257 $wpdb->prepare(
258 "SELECT COUNT(reviews.overall_rating) FROM " . GEODIR_REVIEW_TABLE . " reviews JOIN " . $wpdb->posts . " posts ON reviews.post_id = posts.id WHERE reviews.user_id = %d AND reviews.post_type = %s AND reviews.status=1 AND reviews.overall_rating>0 AND posts.post_status = 'publish'",
259 array($user_id, $post_type)
260 )
261 );
262 } else {
263 $results = $wpdb->get_results(
264 $wpdb->prepare(
265 "SELECT reviews.* FROM " . GEODIR_REVIEW_TABLE . " reviews JOIN " . $wpdb->posts . " posts ON reviews.post_id = posts.id WHERE reviews.user_id = %d AND reviews.post_type = %s AND reviews.status=1 AND reviews.overall_rating>0 AND posts.post_status = 'publish' LIMIT %d OFFSET %d",
266 array($user_id, $post_type, $limit, $offset )
267 )
268 );
269 }
270
271 if (!empty($results))
272 return $results;
273 else
274 return false;
275 }
276
277 public function geodir_count_favorite( $post_type, $user_id = 0 ) {
278 global $wpdb;
279
280 $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
281 if ( $user_id && $user_id == get_current_user_id() ) {
282 $post_status .= " OR " . $wpdb->posts . ".post_status = 'draft' OR " . $wpdb->posts . ".post_status = 'private'";
283 }
284
285 $user_fav_posts = geodir_get_user_favourites( (int)$user_id );
286 $user_fav_posts = !empty( $user_fav_posts ) ? implode( "','", $user_fav_posts ) : "-1";
287
288 $count = (int)$wpdb->get_var( "SELECT count( ID ) FROM ".$wpdb->posts." WHERE " . $wpdb->posts . ".ID IN ('" . $user_fav_posts . "') AND post_type='" . $post_type . "' AND ( post_status = 'publish' " . $post_status . " )" );
289
290 return apply_filters( 'uwp_geodir_count_favorite', $count, $user_id );
291 }
292
293 public function get_listings_count($post_type, $user_id = 0) {
294 global $wpdb;
295 if (empty($user_id)) {
296 return 0;
297 }
298
299 $post_status = is_super_admin() ? " OR " . $wpdb->posts . ".post_status = 'private'" : '';
300 if ($user_id && $user_id == get_current_user_id()) {
301 $post_status .= " OR " . $wpdb->posts . ".post_status = 'draft' OR " . $wpdb->posts . ".post_status = 'private'";
302 }
303
304 $count = (int)$wpdb->get_var("SELECT count( ID ) FROM " . $wpdb->prefix . "posts WHERE post_author=" . (int)$user_id . " AND post_type='" . $post_type . "' AND ( post_status = 'publish' " . $post_status . " )");
305
306 return apply_filters('geodir_uwp_count_total', $count, $user_id);
307 }
308
309 public function get_total_listings_count($user_id = 0) {
310 if (empty($user_id)) {
311 return 0;
312 }
313
314 $gd_post_types = geodir_get_posttypes('array');
315
316 if (empty($gd_post_types)) {
317 return 0;
318 }
319
320
321 // allowed post types
322 $listing_post_types = uwp_get_option('gd_profile_listings', array());
323
324 if (!is_array($listing_post_types)) {
325 $listing_post_types = array();
326 }
327
328 $count = 0;
329 $total_count = 0;
330 foreach ($listing_post_types as $post_type) {
331 if (array_key_exists($post_type, $gd_post_types)) {
332
333 // get listing count
334 $listing_count = $this->get_listings_count($post_type, $user_id);
335 $total_count += $listing_count;
336
337 $count++;
338 }
339 }
340
341 return $total_count;
342 }
343
344 public function get_total_reviews_count($user_id = 0) {
345 if (empty($user_id)) {
346 return 0;
347 }
348
349 $gd_post_types = geodir_get_posttypes('array');
350
351 if (empty($gd_post_types)) {
352 return 0;
353 }
354
355 // allowed post types
356 $listing_post_types = uwp_get_option('gd_profile_reviews', array());
357
358 if (!is_array($listing_post_types)) {
359 $listing_post_types = array();
360 }
361
362 $count = 0;
363 $total_count = 0;
364 foreach ($listing_post_types as $post_type) {
365 if (array_key_exists($post_type, $gd_post_types)) {
366
367 // get listing count
368 $listing_count = $this->geodir_get_reviews_by_user_id($post_type, $user_id, true);
369 $total_count += $listing_count;
370
371 $count++;
372 }
373 }
374
375 return $total_count;
376 }
377
378 public function get_total_favorites_count($user_id = 0) {
379 if (empty($user_id)) {
380 return 0;
381 }
382
383 $gd_post_types = geodir_get_posttypes('array');
384
385 if (empty($gd_post_types)) {
386 return 0;
387 }
388
389 // allowed post types
390 $listing_post_types = uwp_get_option('gd_profile_favorites', array());
391
392 if (!is_array($listing_post_types)) {
393 $listing_post_types = array();
394 }
395
396 $count = 0;
397 $total_count = 0;
398 foreach ($listing_post_types as $post_type) {
399 if (array_key_exists($post_type, $gd_post_types)) {
400
401 // get listing count
402 $listing_count = $this->geodir_count_favorite($post_type, $user_id);
403 $total_count += $listing_count;
404
405 $count++;
406 }
407 }
408
409 return $total_count;
410 }
411
412 /**
413 * Adds tab in user profile page.
414 *
415 * @since 1.0.0
416 * @package userswp
417 *
418 * @param array $tabs Existing tabs array.
419 * @param object $user User object.
420 * @param array $allowed_tabs Allowed tabs array.
421 *
422 * @return array Tabs array.
423 */
424 function add_profile_gd_tabs($tabs, $user,$allowed_tabs) {
425 // allowed post types
426 $listing_post_types = uwp_get_option('gd_profile_listings', array());
427 if (!empty($listing_post_types) && in_array('listings', $allowed_tabs)) {
428 $tabs['listings'] = array(
429 'title' => __('Listings', 'userswp'),
430 'count' => $this->get_total_listings_count($user->ID)
431 );
432 }
433
434 $listing_post_types = uwp_get_option('gd_profile_reviews', array());
435 if (!empty($listing_post_types) && in_array('reviews', $allowed_tabs)) {
436 $tabs['reviews'] = array(
437 'title' => __('Reviews', 'userswp'),
438 'count' => $this->get_total_reviews_count($user->ID)
439 );
440 }
441
442 $listing_post_types = uwp_get_option('gd_profile_favorites', array());
443 if (!empty($listing_post_types) && in_array('favorites', $allowed_tabs) && (get_current_user_id() == $user->ID)) {
444 $tabs['favorites'] = array(
445 'title' => __('Favorites', 'userswp'),
446 'count' => $this->get_total_favorites_count($user->ID)
447 );
448 }
449
450 if (class_exists('WPInv_Invoice') && in_array('invoices', $allowed_tabs) && (get_current_user_id() == $user->ID)) {
451 $tabs['invoices'] = array(
452 'title' => __('Invoices', 'userswp'),
453 'count' => $this->invoice_count($user->ID)
454 );
455 }
456
457 return $tabs;
458 }
459
460 /**
461 * Adds GD listings tab content.
462 *
463 * @since 1.0.0
464 * @package userswp
465 *
466 * @param object $user User object.
467 *
468 * @return void
469 */
470 public function add_profile_listings_tab_content($user) {
471 $this->profile_gd_subtabs_content($user, 'listings');
472 }
473
474 /**
475 * Adds GD reviews tab content.
476 *
477 * @since 1.0.0
478 * @package userswp
479 *
480 * @param object $user User object.
481 *
482 * @return void
483 */
484 public function add_profile_reviews_tab_content($user) {
485 $this->profile_gd_subtabs_content($user, 'reviews');
486 }
487
488 /**
489 * Adds GD Favorites tab content.
490 *
491 * @since 1.0.0
492 * @package userswp
493 *
494 * @param object $user User object.
495 *
496 * @return void
497 */
498 public function add_profile_favorites_tab_content($user) {
499 $this->profile_gd_subtabs_content($user, 'favorites');
500 }
501
502 /**
503 * Adds GD Invoices tab content.
504 *
505 * @since 1.0.0
506 * @package userswp
507 *
508 * @param object $user User object.
509 *
510 * @return void
511 */
512 public function add_profile_invoices_tab_content($user) {
513 $this->profile_gd_invoices_content($user);
514 }
515
516 public function profile_gd_subtabs($user, $type = 'listings') {
517 $tabs = array();
518
519 $gd_post_types = geodir_get_posttypes('array');
520
521 if (empty($gd_post_types)) {
522 return $tabs;
523 }
524
525 // allowed post types
526 if ($type == 'listings') {
527 $listing_post_types = uwp_get_option('gd_profile_listings', array());
528 } elseif ($type == 'reviews') {
529 $listing_post_types = uwp_get_option('gd_profile_reviews', array());
530 } elseif ($type == 'favorites') {
531 $listing_post_types = uwp_get_option('gd_profile_favorites', array());
532 } else {
533 $listing_post_types = array();
534 }
535
536 if (!is_array($listing_post_types)) {
537 $listing_post_types = array();
538 }
539
540 foreach ($gd_post_types as $post_type_id => $post_type) {
541 if (in_array($post_type_id, $listing_post_types)) {
542 $post_type_slug = $gd_post_types[$post_type_id]['has_archive'];
543
544 if ($type == 'listings') {
545 $count = uwp_post_count($user->ID, $post_type_id);
546 } elseif ($type == 'reviews') {
547 $count = $this->geodir_get_reviews_by_user_id($post_type_id, $user->ID, true);
548 } elseif ($type == 'favorites') {
549 $count = $this->geodir_count_favorite($post_type_id, $user->ID);
550 } else {
551 $count = 0;
552 }
553
554 if (empty($count)) {
555 $count = 0;
556 }
557 $tabs[$post_type_slug] = array(
558 'title' => $gd_post_types[$post_type_id]['labels']['name'],
559 'count' => $count,
560 'ptype' => $post_type_id
561 );
562 }
563 }
564
565 return apply_filters('uwp_profile_gd_tabs', $tabs, $user, $type);
566 }
567
568 public function profile_gd_subtabs_content($user, $type = 'listings') {
569 $subtab = get_query_var('uwp_subtab');
570 $subtabs = $this->profile_gd_subtabs($user, $type);
571 $default_tab = apply_filters('uwp_default_listing_subtab', 'places', $user, $type);
572 $active_tab = !empty($subtab) && array_key_exists($subtab, $subtabs) ? $subtab : $default_tab;
573 if (!empty($subtabs)) {
574 $subtab_keys = array_keys($subtabs);
575 $post_type = $subtabs[$subtab_keys[0]]['ptype'];
576 } else {
577 $post_type = false;
578 }
579 ?>
580 <div class="uwp-profile-subcontent">
581 <div class="uwp-profile-subnav">
582 <?php if ($subtabs) { ?>
583 <ul class="item-list-subtabs-ul">
584 <?php
585 foreach ($this->profile_gd_subtabs($user, $type) as $tab_id => $tab) {
586
587 $tab_url = uwp_build_profile_tab_url($user->ID, $type, $tab_id);
588
589 $active = $active_tab == $tab_id ? ' active' : '';
590 $post_type = $active_tab == $tab_id ? $tab['ptype'] : $post_type;
591 ?>
592 <li id="uwp-profile-gd-<?php echo $tab_id; ?>" class="<?php echo $active; ?>">
593 <a href="<?php echo esc_url($tab_url); ?>">
594 <span class="uwp-profile-tab-label uwp-profile-gd-<?php echo $tab_id; ?>-label "><span
595 class="uwp-profile-tab-sub-ul-count uwp-profile-sub-ul-gd-<?php echo $tab_id; ?>-count"><?php echo $tab['count']; ?></span> <?php echo esc_html($tab['title']); ?></span>
596 </a>
597 </li>
598 <?php
599 }
600 ?>
601 </ul>
602 <?php } ?>
603 </div>
604
605 <div class="uwp-profile-subtab-entries">
606 <?php
607 do_action('uwp_profile_gd_' . $type . '_subtab_content', $user, $post_type);
608 ?>
609 </div>
610 </div>
611 <?php
612 }
613
614 function gd_get_listings($user, $post_type) {
615 $gd_post_types = geodir_get_posttypes('array');
616 ?>
617 <h3><?php echo __($gd_post_types[$post_type]['labels']['name'], 'userswp') ?></h3>
618
619 <div class="uwp-profile-item-block">
620 <?php
621
622 $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
623
624 $args = array(
625 'post_type' => $post_type,
626 'post_status' => array('publish'),
627 'posts_per_page' => uwp_get_option('profile_no_of_items', 10),
628 'author' => $user->ID,
629 'paged' => $paged,
630 );
631
632 if (get_current_user_id() == $user->ID) {
633 $args['post_status'] = array('publish', 'draft', 'private');
634 }
635 // The Query
636 $the_query = new WP_Query($args);
637
638 do_action('uwp_before_profile_listing_items', $user, $post_type);
639 // The Loop
640 if ($the_query->have_posts()) {
641 echo '<ul class="uwp-profile-item-ul">';
642 while ($the_query->have_posts()) {
643 $the_query->the_post();
644 $post_id = get_the_ID();
645 global $post;
646 $post = geodir_get_post_info($post_id);
647 setup_postdata($post);
648 $post_avgratings = geodir_get_post_rating($post->ID);
649 $post_ratings = geodir_get_rating_stars($post_avgratings, $post->ID);
650 ob_start();
651 geodir_comments_number($post->rating_count);
652 $n_comments = ob_get_contents();
653 ob_end_clean();
654
655 do_action('uwp_before_profile_listing_item', $post_id, $user, $post_type);
656 ?>
657 <li class="uwp-profile-item-li uwp-profile-item-clearfix <?php echo 'gd-post-'.$post_type; ?>">
658 <a class="uwp-profile-item-img" href="<?php echo get_the_permalink(); ?>">
659 <?php
660 if (has_post_thumbnail()) {
661 $thumb_url = get_the_post_thumbnail_url(get_the_ID(), array(80, 80));
662 } else {
663 $thumb_url = USERSWP_PLUGIN_URL."/public/assets/images/no_thumb.png";
664 }
665 ?>
666 <img class="uwp-profile-item-alignleft uwp-profile-item-thumb" src="<?php echo $thumb_url; ?>">
667 </a>
668
669 <?php do_action('uwp_before_profile_listing_title', $post_id, $user, $post_type); ?>
670 <h3 class="uwp-profile-item-title">
671 <a href="<?php echo get_the_permalink(); ?>"><?php echo get_the_title(); ?></a>
672 </h3>
673 <?php do_action('uwp_after_profile_listing_title', $post_id, $user, $post_type); ?>
674
675 <div class="uwp-time-ratings-wrap">
676 <?php do_action('uwp_before_profile_listing_ratings', $post_id, $user, $post_type); ?>
677 <time class="uwp-profile-item-time published" datetime="<?php echo get_the_time('c'); ?>">
678 <?php echo get_the_date(); ?>
679 </time>
680 <?php echo '<div class="uwp-ratings">' . $post_ratings . ' <a href="' . get_comments_link() . '" class="uwp-num-comments">' . $n_comments . '</a></div>'; ?>
681 <?php
682 if (!is_user_logged_in()) {
683 do_action( 'geodir_after_favorite_html', $post->ID, 'listing' );
684 }
685 ?>
686 <?php do_action('uwp_after_profile_listing_ratings', $post_id, $user, $post_type); ?>
687 </div>
688 <div class="uwp-item-actions">
689 <?php
690 if (is_user_logged_in()) {
691 do_action( 'geodir_after_favorite_html', $post->ID, 'listing' );
692 }
693 if ($post->post_author == get_current_user_id()) {
694 $addplacelink = get_permalink(geodir_add_listing_page_id());
695 $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false);
696
697 $ajaxlink = geodir_get_ajax_url();
698 $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false);
699 ?>
700
701 <span class="geodir-authorlink clearfix">
702
703 <?php do_action('geodir_before_edit_post_link_on_listing', $post_id, $user, $post_type); ?>
704
705 <a href="<?php echo esc_url($editlink); ?>" class="geodir-edit"
706 title="<?php _e('Edit Listing', 'userswp'); ?>">
707 <?php
708 $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fa fa-edit');
709 echo '<i class="' . $geodir_listing_edit_icon . '"></i>';
710 ?>
711 <?php _e('Edit', 'userswp'); ?>
712 </a>
713 <a href="<?php echo esc_url($deletelink); ?>" class="geodir-delete"
714 title="<?php _e('Delete Listing', 'userswp'); ?>">
715 <?php
716 $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fa fa-close', $post_id, $user, $post_type);
717 echo '<i class="' . $geodir_listing_delete_icon . '"></i>';
718 ?>
719 <?php _e('Delete', 'userswp'); ?>
720 </a>
721
722 <?php do_action('geodir_after_edit_post_link_on_listing', $post_id, $user, $post_type); ?>
723
724 </span>
725
726 <?php } ?>
727 </div>
728
729 <div class="uwp-profile-item-summary">
730 <?php
731 do_action('uwp_before_profile_listing_summary', $post_id, $user, $post_type);
732 $excerpt = strip_shortcodes(wp_trim_words(get_the_excerpt(), 15, '...'));
733 echo $excerpt;
734 if ($excerpt) {
735 ?>
736 <a href="<?php echo get_the_permalink(); ?>" class="more-link"><?php echo __( 'Read More »', 'userswp' ); ?></a>
737 <?php
738 }
739 do_action('uwp_after_profile_listing_summary', $post_id, $user, $post_type);
740 ?>
741 </div>
742 </li>
743 <?php
744 do_action('uwp_after_profile_listing_item', $post_id, $user, $post_type);
745 }
746 echo '</ul>';
747 /* Restore original Post Data */
748 wp_reset_postdata();
749 } else {
750 echo sprintf( __( "No %s found", 'userswp' ), $gd_post_types[$post_type]['labels']['name']);
751 }
752 do_action('uwp_after_profile_listing_items', $user, $post_type);
753
754 do_action('uwp_profile_pagination', $the_query->max_num_pages);
755 ?>
756 </div>
757 <?php
758 }
759
760 public function gd_get_reviews($user, $post_type) {
761 $gd_post_types = geodir_get_posttypes('array');
762 ?>
763 <h3><?php echo __($gd_post_types[$post_type]['labels']['name'], 'userswp') ?></h3>
764
765 <div class="uwp-profile-item-block">
766 <?php
767 $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
768 $limit = uwp_get_option('profile_no_of_items', 10);
769 $offset = ($paged - 1) * $limit;
770
771 $total_reviews = $this->geodir_get_reviews_by_user_id($post_type, $user->ID, true, $offset, $limit);
772 $maximum_pages = ceil($total_reviews / $limit);
773
774 $reviews = $this->geodir_get_reviews_by_user_id($post_type, $user->ID, false, $offset, $limit);
775
776 do_action('uwp_before_profile_reviews_items', $user, $post_type);
777 // The Loop
778 if ($reviews) {
779 echo '<ul class="uwp-profile-item-ul">';
780 foreach ($reviews as $review) {
781 $rating = 0;
782 if (!empty($review))
783 $rating = geodir_get_commentoverall($review->comment_id);
784
785 do_action('uwp_before_profile_reviews_item', $review->comment_id, $user, $post_type);
786 ?>
787 <li class="uwp-profile-item-li uwp-profile-item-clearfix <?php echo 'gd-post-'.$post_type; ?>">
788 <a class="uwp-profile-item-img" href="<?php echo get_comment_link($review->comment_id); ?>">
789 <?php
790 if ( has_post_thumbnail($review->post_id) ) {
791 $thumb_url = get_the_post_thumbnail_url($review->post_id, array(80, 80));
792 } else {
793 $thumb_url = USERSWP_PLUGIN_URL."/public/assets/images/no_thumb.png";
794 }
795 ?>
796 <img class="uwp-profile-item-alignleft uwp-profile-item-thumb" src="<?php echo $thumb_url; ?>">
797 </a>
798
799 <?php do_action('uwp_before_profile_reviews_title', $review->comment_id, $user, $post_type); ?>
800 <h3 class="uwp-profile-item-title">
801 <a href="<?php echo get_comment_link($review->comment_id); ?>"><?php echo get_the_title($review->post_id); ?></a>
802 </h3>
803 <?php do_action('uwp_after_profile_reviews_title', $review->comment_id, $user, $post_type); ?>
804
805 <div class="uwp-time-ratings-wrap">
806 <?php do_action('uwp_before_profile_reviews_ratings', $review->comment_id, $user, $post_type); ?>
807 <time class="uwp-profile-item-time published" datetime="<?php echo get_the_time('c'); ?>">
808 <?php echo date_i18n(get_option('date_format'), strtotime(get_comment_date("", $review->comment_id))); ?>
809 </time>
810 <?php echo '<div class="uwp-ratings">' . geodir_get_rating_stars($rating, $review->comment_id) . '</div>'; ?>
811 <?php do_action('uwp_after_profile_reviews_ratings', $review->comment_id, $user, $post_type); ?>
812 </div>
813 <div class="uwp-profile-item-summary">
814 <?php
815 do_action('uwp_before_profile_reviews_summary', $review->comment_id, $user, $post_type);
816 $excerpt = strip_shortcodes(wp_trim_words($review->comment_content, 15, '...'));
817 echo $excerpt;
818 if ($excerpt) {
819 ?>
820 <a href="<?php echo get_comment_link($review->comment_id); ?>" class="more-link">Read More
821 »</a>
822 <?php
823 }
824 do_action('uwp_after_profile_reviews_summary', $review->comment_id, $user, $post_type);
825 ?>
826 </div>
827 </li>
828 <?php
829 do_action('uwp_after_profile_reviews_item', $review->comment_id, $user, $post_type);
830 }
831 echo '</ul>';
832 /* Restore original Post Data */
833 wp_reset_postdata();
834 } else {
835 echo sprintf( __( "No %s found", 'userswp' ), $gd_post_types[$post_type]['labels']['name']);
836 }
837
838 do_action('uwp_after_profile_reviews_items', $user, $post_type);
839
840 do_action('uwp_profile_pagination', $maximum_pages);
841 ?>
842 </div>
843 <?php
844 }
845
846 public function gd_get_favorites($user, $post_type) {
847 $gd_post_types = geodir_get_posttypes('array');
848 ?>
849 <h3><?php echo __($gd_post_types[$post_type]['labels']['name'], 'userswp') ?></h3>
850
851 <div class="uwp-profile-item-block">
852 <?php
853 $paged = (get_query_var('paged')) ? absint(get_query_var('paged')) : 1;
854
855 $user_fav_posts = geodir_get_user_favourites($user->ID);
856
857 if ($user_fav_posts) {
858 $args = array(
859 'post_type' => $post_type,
860 'post_status' => array('publish'),
861 'posts_per_page' => uwp_get_option('profile_no_of_items', 10),
862 'post__in' => $user_fav_posts,
863 'paged' => $paged,
864 );
865
866 if (get_current_user_id() == $user->ID) {
867 $args['post_status'] = array('publish', 'draft', 'private');
868 }
869
870 // The Query
871 $the_query = new WP_Query($args);
872
873 do_action('uwp_before_profile_favourite_items', $user, $post_type);
874 // The Loop
875 if ($the_query->have_posts()) {
876 echo '<ul class="uwp-profile-item-ul">';
877 while ($the_query->have_posts()) {
878 $the_query->the_post();
879 $post_id = get_the_ID();
880 global $post;
881 $post = geodir_get_post_info($post_id);
882 setup_postdata($post);
883 $post_avgratings = geodir_get_post_rating($post->ID);
884 $post_ratings = geodir_get_rating_stars($post_avgratings, $post->ID);
885 ob_start();
886 geodir_comments_number($post->rating_count);
887 $n_comments = ob_get_contents();
888 ob_end_clean();
889 do_action('uwp_before_profile_favourite_item', $post_id, $user, $post_type);
890 ?>
891 <li class="uwp-profile-item-li uwp-profile-item-clearfix <?php echo 'gd-post-'.$post_type; ?>">
892 <a class="uwp-profile-item-img" href="<?php echo get_the_permalink(); ?>">
893 <?php
894 if (has_post_thumbnail()) {
895 $thumb_url = get_the_post_thumbnail_url(get_the_ID(), array(80, 80));
896 } else {
897 $thumb_url = USERSWP_PLUGIN_URL."/public/assets/images/no_thumb.png";
898 }
899 ?>
900 <img class="uwp-profile-item-alignleft uwp-profile-item-thumb" src="<?php echo $thumb_url; ?>">
901 </a>
902
903 <?php do_action('uwp_before_profile_favourite_title', $post_id, $user, $post_type); ?>
904 <h3 class="uwp-profile-item-title">
905 <a href="<?php echo get_the_permalink(); ?>"><?php echo get_the_title(); ?></a>
906 </h3>
907 <?php do_action('uwp_after_profile_favourite_title', $post_id, $user, $post_type); ?>
908
909 <div class="uwp-time-ratings-wrap">
910 <?php do_action('uwp_before_profile_favourite_ratings', $post_id, $user, $post_type); ?>
911 <time class="uwp-profile-item-time published" datetime="<?php echo get_the_time('c'); ?>">
912 <?php echo get_the_date(); ?>
913 </time>
914 <?php echo '<div class="uwp-ratings">' . $post_ratings . ' <a href="' . get_comments_link() . '" class="uwp-num-comments">' . $n_comments . '</a></div>'; ?>
915 <?php
916 if (!is_user_logged_in()) {
917 do_action( 'geodir_after_favorite_html', $post->ID, 'listing' );
918 }
919 ?>
920 <?php do_action('uwp_after_profile_favourite_ratings', $post_id, $user, $post_type); ?>
921 </div>
922 <div class="uwp-item-actions">
923 <?php
924 if (is_user_logged_in()) {
925 do_action( 'geodir_after_favorite_html', $post->ID, 'listing' );
926 }
927 if ($post->post_author == get_current_user_id()) {
928 $addplacelink = get_permalink(geodir_add_listing_page_id());
929 $editlink = geodir_getlink($addplacelink, array('pid' => $post->ID), false);
930
931 $ajaxlink = geodir_get_ajax_url();
932 $deletelink = geodir_getlink($ajaxlink, array('geodir_ajax' => 'add_listing', 'ajax_action' => 'delete', 'pid' => $post->ID), false);
933 ?>
934
935 <span class="geodir-authorlink clearfix">
936
937 <?php do_action('geodir_before_edit_post_link_on_listing', $post_id, $user, $post_type); ?>
938
939 <a href="<?php echo esc_url($editlink); ?>" class="geodir-edit"
940 title="<?php _e('Edit Listing', 'userswp'); ?>">
941 <?php
942 $geodir_listing_edit_icon = apply_filters('geodir_listing_edit_icon', 'fa fa-edit');
943 echo '<i class="' . $geodir_listing_edit_icon . '"></i>';
944 ?>
945 <?php _e('Edit', 'userswp'); ?>
946 </a>
947 <a href="<?php echo esc_url($deletelink); ?>" class="geodir-delete"
948 title="<?php _e('Delete Listing', 'userswp'); ?>">
949 <?php
950 $geodir_listing_delete_icon = apply_filters('geodir_listing_delete_icon', 'fa fa-close');
951 echo '<i class="' . $geodir_listing_delete_icon . '"></i>';
952 ?>
953 <?php _e('Delete', 'userswp'); ?>
954 </a>
955
956 <?php do_action('geodir_after_edit_post_link_on_listing', $post_id, $user, $post_type); ?>
957
958 </span>
959
960 <?php } ?>
961 </div>
962 <div class="uwp-profile-item-summary">
963 <?php
964 do_action('uwp_before_profile_favourite_summary', $post_id, $user, $post_type);
965 $excerpt = strip_shortcodes(wp_trim_words(get_the_excerpt(), 15, '...'));
966 echo $excerpt;
967 if ($excerpt) {
968 ?>
969 <a href="<?php echo get_the_permalink(); ?>" class="more-link"><?php echo __( 'Read More »', 'userswp' ); ?></a>
970 <?php
971 }
972 do_action('uwp_after_profile_favourite_summary', $post_id, $user, $post_type);
973 ?>
974 </div>
975 </li>
976 <?php
977 do_action('uwp_after_profile_favourite_item', $post_id, $user, $post_type);
978 }
979 echo '</ul>';
980 /* Restore original Post Data */
981 wp_reset_postdata();
982 } else {
983 echo sprintf( __( "No %s found", 'userswp' ), $gd_post_types[$post_type]['labels']['name']);
984 }
985
986 do_action('uwp_after_profile_favourite_items', $user, $post_type);
987
988 do_action('uwp_profile_pagination', $the_query->max_num_pages);
989 } else {
990 echo sprintf( __( "No %s found", 'userswp' ), $gd_post_types[$post_type]['labels']['name']);
991 }
992 ?>
993 </div>
994 <?php
995 }
996
997 public function get_gd_login_url($url, $args) {
998 $register_page = uwp_get_page_id('register_page', false);
999 $login_page = uwp_get_page_id('login_page', false);
1000 $forgot_page = uwp_get_page_id('forgot_page', false);
1001 $reset_page = uwp_get_page_id('reset_page', false);
1002
1003 if (!empty($args)) {
1004 if (isset($args['signup']) && $args['signup']) {
1005 $page_id = $register_page;
1006 } elseif (isset($args['forgot']) && $args['forgot']) {
1007 $page_id = $forgot_page;
1008 } elseif (isset($args['reset']) && $args['reset']) {
1009 $page_id = $reset_page;
1010 } else {
1011 $page_id = $login_page;
1012 }
1013 } else {
1014 $page_id = $login_page;
1015 }
1016 if ($page_id) {
1017 $uwp_url = get_permalink($page_id);
1018
1019 if (strpos($url, 'redirect_add_listing') !== false) {
1020 $parsed = wp_parse_url($url);
1021 parse_str($parsed['query'], $query);
1022 $uwp_url = add_query_arg( array(
1023 'redirect_to' => $query['redirect_add_listing'],
1024 ), $uwp_url );
1025 }
1026
1027 if(isset($args['redirect_to']) && !empty($args['redirect_to'])){
1028 $uwp_url = add_query_arg( array(
1029 'redirect_to' => $args['redirect_to'],
1030 ), $uwp_url );
1031 }
1032
1033 $url = $uwp_url;
1034 }
1035 return $url;
1036 }
1037
1038 public function geodir_uwp_author_redirect() {
1039 if ( ! empty( $_REQUEST['geodir_dashbord'] ) ) {
1040 $author = get_query_var( 'author_name' ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) );
1041
1042 if ( !empty( $author ) && ! empty( $author->ID ) ) {
1043 $favourite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false;
1044 $post_type = isset( $_REQUEST['stype'] ) ? sanitize_text_field( $_REQUEST['stype'] ) : NULL;
1045
1046 $author_id = $author->ID;
1047 $author_link = uwp_build_profile_tab_url( $author_id );
1048 $gd_post_types = geodir_get_posttypes( 'array' );
1049
1050 if ( !empty( $gd_post_types ) && array_key_exists( $post_type, $gd_post_types ) ) {
1051 if ( $favourite ) {
1052 $profile_favorites = uwp_get_option( 'gd_profile_favorites', array() );
1053
1054 if ( uwp_get_option( 'geodir_uwp_link_favorite', '0' ) && ! empty( $profile_favorites ) && in_array( $post_type, $profile_favorites ) ) {
1055 $author_link = uwp_build_profile_tab_url( $author_id, 'favorites', $gd_post_types[ $post_type ]['has_archive'] );
1056 } else {
1057 return; // Do not redirect to dashboard CPT favorites.
1058 }
1059 } else {
1060 $profile_listings = uwp_get_option( 'gd_profile_listings', array() );
1061
1062 if ( uwp_get_option( 'geodir_uwp_link_listing', '0' ) && ! empty( $profile_listings ) && in_array( $post_type, $profile_listings ) ) {
1063 $author_link = uwp_build_profile_tab_url( $author_id, 'listings', $gd_post_types[ $post_type ]['has_archive'] );
1064 } else {
1065 return; // Do not redirect to dashboard CPT listings.
1066 }
1067 }
1068 }
1069
1070 wp_redirect($author_link);
1071 exit;
1072 }
1073 }
1074 return;
1075 }
1076
1077 public function gd_is_listings_tab() {
1078 global $wp_query;
1079 if (is_page() && class_exists('UsersWP')) {
1080 $profile_page = uwp_get_page_id('profile_page', false);
1081 if ($profile_page) {
1082 if (isset($wp_query->query_vars['uwp_profile'])
1083 && isset($wp_query->query_vars['uwp_tab'])
1084 && ($wp_query->query_vars['uwp_tab'] == 'listings' || $wp_query->query_vars['uwp_tab'] == 'favorites')
1085 ) {
1086
1087 return true;
1088
1089 }
1090 }
1091 }
1092 return false;
1093 }
1094
1095 public function geodir_post_status_is_author_page($value) {
1096 return $value || $this->gd_is_listings_tab();
1097 }
1098
1099 public function geodir_add_post_status_author_page() {
1100 global $wpdb, $post;
1101
1102 $html = '';
1103 if (get_current_user_id()) {
1104 if ($this->gd_is_listings_tab() && !empty($post) && isset($post->post_author) && $post->post_author == get_current_user_id()) {
1105
1106 // we need to query real status direct as we dynamically change the status for author on author page so even non author status can view them.
1107 $real_status = $wpdb->get_var("SELECT post_status from $wpdb->posts WHERE ID=$post->ID");
1108 $status = "<strong>(";
1109 $status_icon = '<i class="fa fa-play"></i>';
1110 if ($real_status == 'publish') {
1111 $status .= __('Published', 'userswp');
1112 } else {
1113 $status .= __('Not published', 'userswp');
1114 $status_icon = '<i class="fa fa-pause"></i>';
1115 }
1116 $status .= ")</strong>";
1117
1118 $html = '<span class="geodir-post-status">' . $status_icon . ' <font class="geodir-status-label">' . __('Status: ', 'userswp') . '</font>' . $status . '</span>';
1119 }
1120 }
1121
1122 if ($html != '') {
1123 echo apply_filters('geodir_filter_status_text_on_author_page', $html);
1124 }
1125 }
1126
1127 public function profile_gd_invoices_content($user) {
1128 if (!is_user_logged_in()) {
1129 return;
1130 }
1131
1132 if (get_current_user_id() != $user->ID) {
1133 return;
1134 }
1135 ?>
1136 <h3><?php echo __('Invoices', 'userswp'); ?></h3>
1137
1138 <div class="uwp-profile-item-block">
1139 <?php
1140 $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
1141
1142 $args = array(
1143 'post_type' => 'wpi_invoice',
1144 'post_status' => array_keys(wpinv_get_invoice_statuses()),
1145 'posts_per_page' => uwp_get_option('profile_no_of_items', 10),
1146 'author' => $user->ID,
1147 'paged' => $paged,
1148 );
1149 // The Query
1150 $the_query = new WP_Query($args);
1151
1152 // The Loop
1153 if ($the_query->have_posts()) {
1154 echo '<ul class="uwp-profile-item-ul">';
1155 while ($the_query->have_posts()) {
1156 $the_query->the_post();
1157 $wpi_invoice = new WPInv_Invoice( get_the_ID() );
1158 ?>
1159 <li class="uwp-profile-item-li uwp-profile-item-clearfix">
1160 <h3 class="uwp-profile-item-title">
1161 <a href="<?php echo get_the_permalink(); ?>"><?php _e('Invoice','userswp');?> <?php echo get_the_title(); ?></a>
1162 </h3>
1163 <time class="uwp-profile-item-time published" datetime="<?php echo get_the_time('c'); ?>">
1164 <?php echo get_the_date(); ?>
1165 </time>
1166 <div class="uwp-profile-item-summary">
1167 <div class="uwp-order-status">
1168 <?php
1169 echo __('Invoice Status: ', 'userswp').$wpi_invoice->get_status( true ) . ( $wpi_invoice->is_recurring() && $wpi_invoice->is_parent() ? ' <span class="wpi-suffix">' . __( '(r)', 'invoicing' ) . '</span>' : '' );
1170 ?>
1171 </div>
1172 <div class="uwp-order-total">
1173 <?php
1174 echo __('Invoice Total: ', 'userswp'). $wpi_invoice->get_total( true );
1175 ?>
1176 </div
1177 </div>
1178 </li>
1179 <?php
1180 }
1181 echo '</ul>';
1182 /* Restore original Post Data */
1183 wp_reset_postdata();
1184 } else {
1185 // no posts found
1186 echo "<p>".__('No Invoices Found', 'userswp')."</p>";
1187 }
1188 do_action('uwp_profile_pagination', $the_query->max_num_pages);
1189 ?>
1190 </div>
1191 <?php
1192 }
1193
1194 public function invoice_count($user_id) {
1195 global $wpdb;
1196
1197 $post_status_array = array_keys(wpinv_get_invoice_statuses());
1198 $post_status = "'" . implode("','", $post_status_array) . "'";
1199
1200 $count = $wpdb->get_var('
1201 SELECT COUNT(ID)
1202 FROM ' . $wpdb->posts. '
1203 WHERE post_author = "' . $user_id . '"
1204 AND post_status IN ('.$post_status.')
1205 AND post_type = "wpi_invoice"'
1206 );
1207 return $count;
1208 }
1209
1210 public function gd_login_wid_login_placeholder() {
1211 return __( 'Username', 'userswp' );
1212 }
1213
1214 public function gd_login_wid_login_name() {
1215 return "uwp_login_username";
1216 }
1217
1218 public function gd_login_wid_login_pwd() {
1219 return "uwp_login_password";
1220 }
1221
1222 public function gd_login_inject_nonce() {
1223 ?>
1224 <input type="hidden" name="uwp_login_nonce" value="<?php echo wp_create_nonce( 'uwp-login-nonce' ); ?>" />
1225 <?php
1226 }
1227
1228 public function check_redirect_author_page( $redirect = false ) {
1229 if ( $redirect && ! empty( $_REQUEST['geodir_dashbord'] ) ) {
1230 $author = get_query_var( 'author_name' ) ? get_user_by( 'slug', get_query_var( 'author_name' ) ) : get_userdata( get_query_var( 'author' ) );
1231
1232 if ( !empty( $author ) && ! empty( $author->ID ) ) {
1233 $favourite = isset($_REQUEST['list']) && $_REQUEST['list'] == 'favourite' ? true : false;
1234 $post_type = isset( $_REQUEST['stype'] ) ? sanitize_text_field( $_REQUEST['stype'] ) : NULL;
1235
1236 $author_id = $author->ID;
1237 $author_link = uwp_build_profile_tab_url( $author_id );
1238 $gd_post_types = geodir_get_posttypes( 'array' );
1239
1240 if ( !empty( $gd_post_types ) && array_key_exists( $post_type, $gd_post_types ) ) {
1241 if ( $favourite ) {
1242 $profile_favorites = uwp_get_option( 'gd_profile_favorites', array() );
1243
1244 if ( uwp_get_option( 'geodir_uwp_link_favorite', '0' ) && ! empty( $profile_favorites ) && in_array( $post_type, $profile_favorites ) ) {
1245 // Redirect to dashboard CPT favorites.
1246 } else {
1247 $redirect = false; // Do not redirect to dashboard CPT favorites.
1248 }
1249 } else {
1250 $profile_listings = uwp_get_option( 'gd_profile_listings', array() );
1251
1252 if ( uwp_get_option( 'geodir_uwp_link_listing', '0' ) && ! empty( $profile_listings ) && in_array( $post_type, $profile_listings ) ) {
1253 // Redirect to dashboard CPT listings.
1254 } else {
1255 $redirect =false; // Do not redirect to dashboard CPT listings.
1256 }
1257 }
1258 }
1259 }
1260 }
1261
1262 return $redirect;
1263 }
1264
1265 public function skip_uwp_author_page( $uwp_author = true ) {
1266 if ( geodir_is_page( 'author' ) ) {
1267 $uwp_author = false;
1268 }
1269
1270 return $uwp_author;
1271 }
1272 }
1273 $userswp_geodirectory = UsersWP_GeoDirectory_Plugin::get_instance();