-
Notifications
You must be signed in to change notification settings - Fork 0
/
user_dashboard_favorites.php
90 lines (78 loc) · 3.23 KB
/
user_dashboard_favorites.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
/**
* Template Name: User Dashboard Favorite Properties
* Created by PhpStorm.
* User: waqasriaz
* Date: 11/01/16
* Time: 4:35 PM
*/
/*if ( !is_user_logged_in() ) {
wp_redirect( home_url() );
}*/
global $houzez_local, $current_user;
wp_get_current_user();
$userID = $current_user->ID;
$user_login = $current_user->user_login;
$fav_ids = 'houzez_favorites-'.$userID;
$fav_ids = get_option( $fav_ids );
if ( !is_user_logged_in() ) {
$fav_ids = isset($_COOKIE['houzez_favorite_listings']) ? explode(',', $_COOKIE['houzez_favorite_listings']) : '';
if( empty( $fav_ids[0] ) ) {
$fav_ids = isset( $_GET['ids'] ) ? $_GET['ids'] : '';
$fav_ids = explode(',', $fav_ids);
}
}
get_header();
?>
<header class="header-main-wrap dashboard-header-main-wrap">
<div class="dashboard-header-wrap">
<div class="d-flex align-items-center">
<div class="dashboard-header-left flex-grow-1">
<h1><?php echo houzez_option('dsh_favorite', 'Favorites'); ?></h1>
</div><!-- dashboard-header-left -->
<div class="dashboard-header-right">
</div><!-- dashboard-header-right -->
</div><!-- d-flex -->
</div><!-- dashboard-header-wrap -->
</header><!-- .header-main-wrap -->
<section class="dashboard-content-wrap">
<div class="dashboard-content-inner-wrap">
<div class="dashboard-content-block-wrap">
<?php
if( empty( $fav_ids ) ) { ?>
<div class="dashboard-content-block">
<?php echo esc_html__("You don't have any favorite listings yet!", 'houzez'); ?>
</div>
<?php
} else {
?>
<table class="dashboard-table dashboard-table-properties table-lined responsive-table">
<thead>
<tr>
<th><?php echo esc_html__('Thumbnail', 'houzez'); ?></th>
<th><?php echo esc_html__('Title', 'houzez'); ?></th>
<th><?php echo esc_html__('Type', 'houzez'); ?></th>
<th><?php echo esc_html__('Status', 'houzez'); ?></th>
<th><?php echo esc_html__('Price', 'houzez'); ?></th>
<th class="action-col"><?php echo esc_html__('Actions', 'houzez'); ?></th>
</tr>
</thead>
<tbody>
<?php
$args = array('post_type' => 'property', 'post__in' => $fav_ids, 'numberposts' => -1 );
$myposts = get_posts($args);
foreach ($myposts as $post) : setup_postdata($post);
get_template_part('template-parts/dashboard/property/favorite-item');
endforeach;
wp_reset_postdata();
?>
</tbody>
</table><!-- dashboard-table -->
<?php } ?>
</div><!-- dashboard-content-block-wrap -->
</div><!-- dashboard-content-inner-wrap -->
</section><!-- dashboard-content-wrap -->
<section class="dashboard-side-wrap">
<?php get_template_part('template-parts/dashboard/side-wrap'); ?>
</section>
<?php get_footer(); ?>