-
Notifications
You must be signed in to change notification settings - Fork 0
/
single.php
397 lines (379 loc) · 12.2 KB
/
single.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
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
<?php
/*
* single post page
*/
include('includes/php/ufc-api.php');
get_header();
?>
<?php while ( have_posts() ) : the_post(); ?>
<?php //the_title(); ?>
<?php the_content(); ?>
<?php
// get list of events
// $events = file_get_contents('http://ufc-data-api.ufc.com/api/v3/events');
// $events = json_decode($events);
$events = UfcAPI::getAllEvents();
$feature_image = '';
$fight_url = '';
$event_id = 0;
//$post_start_event = get_field("event_start_date", get_the_id());
$post_start_event = get_field("event_start_date");
$post_event_name = get_field("event_title");
foreach($events as $obj){
$event_date_time = $obj->event_date;
$format_date = new DateTime($event_date_time);
$simple_event_date = $format_date->format('Y-m-d');
if (($obj->base_title == $post_event_name) && ($simple_event_date == $post_start_event)) {
$feature_image = $obj->feature_image;
$event_date = date('F j, Y', strtotime($obj->event_date));
$fight_url = $obj->url_name;
$event_id = $obj->id;
?>
<div class="ufc-event">
<div class="row">
<div class="col-md-12">
<div id="event-title">
<?php echo $obj->base_title; ?>
</div>
<div id="event-tagline">
<?php echo $obj->title_tag_line; ?>
</div>
</div>
</div>
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-3">
<div class="event-when">
<div id="event-date">
<?php echo $event_date; ?>
</div>
<div id="event-time">
<?php echo $obj->event_time_text; ?>
</div>
</div>
</div>
<div class="col-md-3">
<div class="event-where">
<div id="event-arena">
<?php echo $obj->arena; ?>
</div>
<div id="event-location">
<?php echo $obj->location; ?>
</div>
</div>
<div class="col-md-3">
</div>
</div>
</div>
<?php if (is_user_logged_in()) { ?>
<div class="row">
<div class="col-md-3">
</div>
<div class="col-md-3 make-your-selections">
<a href="<?php echo esc_url( add_query_arg( array('ufc_event_id' => $event_id, 'title' => $post_event_name,), site_url( '/betting/' ) ) )?>">
<!-- <a href="betting?ufc_event_id=<?php echo $event_id ?>&title=<?php echo get_the_title(); ?>"> -->
<div class="selections-button">
Make your selections
</div>
</a>
</div>
<div class="col-md-3 event-ldr">
<a href="event-leaderboard?ufc_event_id=<?php echo $event_id ?>&title=<?php echo $post_event_name; ?>">
<div class="ldr-button">
View the event leaderboard
</div>
</a>
</div>
<div class="col-md-3">
</div>
</div>
<?php } ?>
</div>
<?php if (($obj->trailer_url != null) && ($obj->trailer_url != "http://pdvid.ufc.tv")) { ?>
<div id="event-trailer">
<div class="container">
<div class="row">
<div class="col-md-12">
<video controls>
<source src="<?php echo $obj->trailer_url ?>" type="video/mp4">
</video>
</div>
</div>
</div>
</div>
<?php } ?>
<?php
}
}
// get fights for event
// $ufc_event_url = 'http://ufc-data-api.ufc.com/api/v3/events/' . $event_id . '/fights';
// $ufc_event = file_get_contents($ufc_event_url);
// $ufc_event = json_decode($ufc_event);
$ufc_event = UfcAPI::getEventByID($event_id);
// get fights
// ***************************************************
// use this instead of array_slice
// ***************************************************
$fights_table = $wpdb->prefix . 'ufcBet_fights';
$fights = $wpdb->get_results($wpdb->prepare("SELECT * FROM $fights_table WHERE ufc_event_id = %s AND is_betting_enabled = 1", $event_id));
// ***************************************************
// use fights table instead of this
// ***************************************************
//$main_card = array_slice($ufc_event, 0, 6);
//$main_card_order = array_reverse($main_card);
$main_card_order = array_reverse($ufc_event);
// loop through each fight
foreach ($main_card_order as $obj) {
$is_betting_enabled = $wpdb->get_var($wpdb->prepare("SELECT is_betting_enabled FROM $fights_table WHERE ufc_event_id = %s AND ufc_fight_id = %s", $event_id, $obj->id));
if ($is_betting_enabled > 0) {
?>
<div class="fighter-background">
<div class="row">
<div class="col-md-5 fighter-title">
<div class="fighter-title-text">
<?php if ($obj->is_title_fight) { ?>
<div class="championship-fight">
<?php echo $obj->fight_description; ?>
</div>
<?php }
echo $obj->fighter1_first_name . ' ' . $obj->fighter1_last_name . ' ';
if (isset($obj->fighter1_rank)) { ?>
<sup<?php if ($obj->fighter1_rank == 'C') { echo ' class="champ"';} ?>>
<?php echo $obj->fighter1_rank; ?>
</sup>
<?php
}
?>
<br />
vs
<br />
<?php echo $obj->fighter2_first_name . ' ' . $obj->fighter2_last_name . ' ';
if (isset($obj->fighter2_rank)) { ?>
<sup<?php if ($obj->fighter2_rank == 'C') { echo ' class="champ"';} ?>>
<?php echo $obj->fighter2_rank; ?>
</sup>
<?php
}
?>
</div>
</div>
<div class="col-md-7">
<div class="row">
<div class="col-md-3" style="text-align: right;">
<img src="<?php echo $obj->fighter1_full_body_image; ?>" class="hidden-sm hidden-xs" />
</div>
<div class="col-md-6">
<table class="fighter-names">
<tr>
<td width="50%">
<?php echo $obj->fighter1_first_name . ' ' . $obj->fighter1_last_name; ?>
</td>
<td width="50%">
<?php echo $obj->fighter2_first_name . ' ' . $obj->fighter2_last_name; ?>
</td>
</tr>
<tr>
<td class="nickname">
<?php
if ($obj->fighter1_nickname != ""){
echo '"' . $obj->fighter1_nickname . '"';
}
?>
</td>
<td class="nickname">
<?php
if ($obj->fighter2_nickname != ""){
echo '"' . $obj->fighter2_nickname . '"';
}
?>
</td>
</tr>
</table>
<table class="fighter-tale">
<tr>
<td class="left-column" width="20%">
<?php echo $obj->fighter1record; ?>
</td>
<td class="center-column" width="60%">
Record
</td>
<td class="right-column" width="20%">
<?php echo $obj->fighter2record; ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php
$feet = $obj->fighter1height / 12;
$f1_feet = (int)$feet;
$f1_inches = round(($feet - $f1_feet)*12);
echo $f1_feet . "'" . $f1_inches . '"';
?>
</td>
<td class="center-column">
Height
</td>
<td class="right-column">
<?php
$feet = $obj->fighter2height / 12;
$f2_feet = (int)$feet;
$f2_inches = round(($feet - $f2_feet)*12);
echo $f2_feet . "'" . $f2_inches . '"';
?>
</td>
</tr>
<tr>
<td class="left-column">
<?php echo $obj->fighter1weight . ' lbs'; ?>
</td>
<td class="center-column">
Weight
</td>
<td class="right-column">
<?php echo $obj->fighter2weight . ' lbs'; ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1reach)){ echo $obj->fighter1reach . '"'; } ?>
</td>
<td class="center-column">
Reach
</td>
<td class="right-column">
<?php if(isset($obj->fighter2reach)){ echo $obj->fighter2reach . '"'; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_averagefighttime)){ echo $obj->fighter1_averagefighttime; } ?>
</td>
<td class="center-column">
Average Fight Time
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_averagefighttime)){ echo $obj->fighter2_averagefighttime; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_kdaverage)){ echo $obj->fighter1_kdaverage; } ?>
</td>
<td class="center-column">
Knockdown Average
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_kdaverage)){ echo $obj->fighter2_kdaverage; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_slpm)){ echo $obj->fighter1_slpm; } ?>
</td>
<td class="center-column">
Strikes Landed P/M
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_slpm)){ echo $obj->fighter2_slpm; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_strikingaccuracy)){ echo $obj->fighter1_strikingaccuracy . '%'; } ?>
</td>
<td class="center-column">
Striking Accuracy
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_strikingaccuracy)){ echo $obj->fighter2_strikingaccuracy . '%'; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_sapm)){ echo $obj->fighter1_sapm; } ?>
</td>
<td class="center-column">
Strikes Absorbed P/M
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_sapm)){ echo $obj->fighter2_sapm; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_strikingdefense)){ echo $obj->fighter1_strikingdefense . '%'; } ?>
</td>
<td class="center-column">
Striking Defense
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_strikingdefense)){ echo $obj->fighter2_strikingdefense . '%'; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_takedownaverage)){ echo $obj->fighter1_takedownaverage; } ?>
</td>
<td class="center-column">
Takedown Average
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_takedownaverage)){ echo $obj->fighter2_takedownaverage; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_takedownaccuracy)){ echo $obj->fighter1_takedownaccuracy . '%'; } ?>
</td>
<td class="center-column">
Takedown Accuracy
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_takedownaccuracy)){ echo $obj->fighter2_takedownaccuracy . '%'; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_takedowndefense)){ echo $obj->fighter1_takedowndefense . '%'; } ?>
</td>
<td class="center-column">
Takedown Defense
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_takedowndefense)){ echo $obj->fighter2_takedowndefense . '%'; } ?>
</td>
</tr>
<tr>
<td class="left-column">
<?php if(isset($obj->fighter1_submissionsaverage)){ echo $obj->fighter1_submissionsaverage; } ?>
</td>
<td class="center-column">
Submission Average
</td>
<td class="right-column">
<?php if(isset($obj->fighter2_submissionsaverage)){ echo $obj->fighter2_submissionsaverage; } ?>
</td>
</tr>
</table>
</div>
<div class="col-md-3">
<img src="<?php echo $obj->fighter2_full_body_image; ?>" class="hidden-sm hidden-xs" />
</div>
</div>
</div>
</div>
</div>
<?php
}
}
?>
<div id="ufc-link">
<div class="row">
<div class="col-md-12">
For additional event information and fighter statistics, visit the <a href="http://ufc.com/event/<?php echo $fight_url ?>" target="_blank">UFC event website</a>.
</div>
</div>
</div>
<?php endwhile; ?>
<?php get_footer(); ?>