This repository has been archived by the owner on Mar 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
auction-feeder-page.php
262 lines (226 loc) · 9.11 KB
/
auction-feeder-page.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
<?php
//auction listing page - pagination
$page_num = get_option('wdm_auc_num_per_page');
$page_num = (!empty($page_num) && $page_num > 0) ? $page_num : 20;
function auction_pagination($pages = '', $range = 2, $paged)
{
$showitems = ($range * 2)+1;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class='pagination'>";
printf('<span>'.__('Page %1$s of %2$s', 'wdm-ultimate-auction').'</span>', $paged, $pages);
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
echo "</div>\n";
}
}
$wdm_auction_array=array();
if (get_query_var('paged')) { $paged = get_query_var('paged'); }
elseif (get_query_var('page')) { $paged = get_query_var('page'); }
else { $paged = 1; }
$args = array(
'posts_per_page'=> $page_num,
'post_type' => 'ultimate-auction',
'auction-status' => 'live',
'post_status' => 'publish',
'paged' => $paged,
'suppress_filters' => false
);
$arg_data_c = array(
'posts_per_page'=> -1,
'post_type' => 'ultimate-auction',
'auction-status' => 'live',
'post_status' => 'publish',
'paged' => $paged,
'suppress_filters' => false
);
do_action('wdm_ua_before_get_auctions');
$wdm_auction_array = get_posts($args);
$count_pages = count(get_posts($arg_data_c));
do_action('wdm_ua_after_get_auctions');
$show_content = '';
$show_content = apply_filters('wdm_ua_before_auctions_listing', $show_content);
echo $show_content;
?>
<div class="wdm-auction-listing-container">
<ul class="wdm_auctions_list">
<li class="auction-list-menus">
<ul>
<li class="wdm-apn auc_single_list"><strong><?php _e('Product', 'wdm-ultimate-auction');?></strong></li>
<li class="wdm-apt auc_single_list"><strong></strong></li>
<li class="wdm-app auc_single_list"><strong><?php _e('Current Price', 'wdm-ultimate-auction');?></strong></li>
<li class="wdm-apb auc_single_list"><strong><?php _e('Bids Placed', 'wdm-ultimate-auction');?></strong></li>
<li class="wdm-ape auc_single_list"><strong><?php _e('Ending', 'wdm-ultimate-auction');?></strong></li>
</ul>
</li>
<?php
//auction listing page container
foreach($wdm_auction_array as $wdm_single_auction){
global $wpdb;
$query="SELECT MAX(bid) FROM ".$wpdb->prefix."wdm_bidders WHERE auction_id =".$wdm_single_auction->ID;
$curr_price = $wpdb->get_var($query);
?>
<li class="wdm-auction-single-item">
<a href="<?php echo get_permalink().$set_char."ult_auc_id=".$wdm_single_auction->ID; ?>" class="wdm-auction-list-link">
<ul>
<li class="wdm-apn auc_single_list">
<div class="wdm_single_auction_thumb">
<?php $vid_arr = array('mpg', 'mpeg', 'avi', 'mov', 'wmv', 'wma', 'mp4', '3gp', 'ogm', 'mkv', 'flv');
$auc_thumb = get_post_meta($wdm_single_auction->ID, 'wdm_auction_thumb', true);
$imgMime = wdm_get_mime_type($auc_thumb);
$img_ext = explode(".",$auc_thumb);
$img_ext = end($img_ext);
if(strpos($img_ext, '?') !== false)
$img_ext = strtolower(strstr($img_ext, '?', true));
if(strstr($imgMime, "video/") || in_array($img_ext, $vid_arr) || strstr($auc_thumb, "youtube.com") || strstr($auc_thumb, "vimeo.com")){
$auc_thumb = plugins_url('img/film.png', __FILE__);
}
if(empty($auc_thumb)){$auc_thumb = plugins_url('img/no-pic.jpg', __FILE__);}
?>
<img src="<?php echo $auc_thumb; ?>" alt="<?php echo $wdm_single_auction->post_title; ?>" />
</div>
</li>
<li class="wdm-apt auc_single_list">
<div class="wdm-auction-title"><?php echo $wdm_single_auction->post_title; ?></div>
</li>
<li class="wdm-app auc_single_list auc_list_center">
<span class="wdm-auction-price wdm-mark-green">
<?php
$cc = substr(get_option('wdm_currency'), -3);
$ob = get_post_meta($wdm_single_auction->ID, 'wdm_opening_bid', true);
$bnp = get_post_meta($wdm_single_auction->ID, 'wdm_buy_it_now', true);
if((!empty($curr_price) || $curr_price > 0) && !empty($ob))
echo $currency_symbol. number_format($curr_price, 2, '.', ',')." ".$currency_code_display;
elseif(!empty($ob))
echo $currency_symbol.number_format($ob, 2, '.', ',')." ".$currency_code_display;
elseif(empty($ob) && !empty($bnp))
printf(__('Buy at %s%s %s', 'wdm-ultimate-auction'), $currency_symbol, number_format($bnp, 2, '.', ','), $currency_code_display);
?>
</span>
</li>
<li class="wdm-apb auc_single_list auc_list_center">
<?php
$get_bids = "SELECT COUNT(bid) FROM ".$wpdb->prefix."wdm_bidders WHERE auction_id =".$wdm_single_auction->ID;
$bids_placed = $wpdb->get_var($get_bids);
if(!empty($bids_placed) || $bids_placed > 0)
echo "<span class='wdm-bids-avail wdm-mark-normal'>".$bids_placed."</span>";
else
echo "<span class='wdm-no-bids-avail wdm-mark-red'>".__('No bids placed', 'wdm-ultimate-auction')."</span>";
?>
</li>
<li class="wdm-ape auc_single_list auc_list_center">
<?php
$now = time();
$ending_date = strtotime(get_post_meta($wdm_single_auction->ID, 'wdm_listing_ends', true));
$act_trm = wp_get_post_terms($wdm_single_auction->ID, 'auction-status',array("fields" => "names"));
$seconds = $ending_date - $now;
if(in_array('expired',$act_trm))
{
echo "<span class='wdm-mark-red'>".__('Expired', 'wdm-ultimate-auction')."</span>";
}
elseif($seconds > 0 && !in_array('expired',$act_trm))
{
$days = floor($seconds / 86400);
$seconds %= 86400;
$hours = floor($seconds / 3600);
$seconds %= 3600;
$minutes = floor($seconds / 60);
$seconds %= 60;
if($days > 1)
echo "<span class='wdm-mark-normal'>". $days ." ".__('days', 'wdm-ultimate-auction')."</span>";
elseif($days == 1)
echo "<span class='wdm-mark-normal'>". $days ." ".__('day', 'wdm-ultimate-auction')."</span>";
elseif($days < 1)
{
if($hours > 1)
echo "<span class='wdm-mark-normal'>". $hours ." ".__('hours', 'wdm-ultimate-auction')."</span>";
elseif($hours == 1)
echo "<span class='wdm-mark-normal'>". $hours ." ".__('hour', 'wdm-ultimate-auction')."</span>";
elseif($hours < 1)
{
if($minutes > 1)
echo "<span class='wdm-mark-normal'>". $minutes ." ".__('minutes', 'wdm-ultimate-auction')."</span>";
elseif($minutes == 1)
echo "<span class='wdm-mark-normal'>". $minutes ." ".__('minute', 'wdm-ultimate-auction')."</span>";
elseif($minutes < 1)
{
if($seconds > 1)
echo "<span class='wdm-mark-normal'>". $seconds ." ".__('seconds', 'wdm-ultimate-auction')."</span>";
elseif($seconds == 1)
echo "<span class='wdm-mark-normal'>". $seconds ." ".__('second', 'wdm-ultimate-auction')."</span>";
else
echo "<span class='wdm-mark-red'>".__('Expired', 'wdm-ultimate-auction')."</span>";
}
}
}
}
else
{
echo "<span class='wdm-mark-red'>".__('Expired', 'wdm-ultimate-auction')."</span>";
}
?>
<br/>
</li>
<li class="wdm-apbid auc_single_list auc_list_center">
<input class="wdm_bid_now_btn" type="button" value="<?php _e('Bid Now', 'wdm-ultimate-auction');?>" />
</li>
<li><div class="wdm-apd"><?php echo $wdm_single_auction->post_excerpt ; ?> </div></li>
</ul>
</a>
</li>
<?php
}
//global $wpdb;
//
//$live_posts = array();
//
//$comm_query = "SELECT object_id
//FROM ".$wpdb->prefix."term_relationships
//WHERE term_taxonomy_id = (SELECT term_id
//FROM ".$wpdb->prefix."terms
//WHERE slug = 'live')";
//
//$comm_query = apply_filters('wdm_ua_filtered_auctions', $comm_query);
//
//$live_posts = $wpdb->get_col($comm_query);
//
//if(!empty($live_posts)){
// $live_posts = implode("," , $live_posts);
//
// $count_query = "SELECT count(ID)
// FROM ".$wpdb->prefix."posts
// WHERE post_type = 'ultimate-auction'
// AND ID IN($live_posts)
// AND post_status = 'publish'";
//
// $count_query = apply_filters('wdm_ua_filtered_counts', $count_query);
//
// $count_pages = $wpdb->get_var($count_query);
if(!empty($count_pages)){
echo '<input type="hidden" id="wdm_ua_auc_avail" value="'.$count_pages.'" />';
$c=ceil($count_pages/$page_num);
auction_pagination($c, 1, $paged);
}
//}
?>
</ul>
</div>