-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCustomUpcomingDealsApi.php
More file actions
106 lines (92 loc) · 3.07 KB
/
CustomUpcomingDealsApi.php
File metadata and controls
106 lines (92 loc) · 3.07 KB
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
<?php
/**
* Class CustomOptionCardsApi
*/
class CustomUpcomingDealsApi
{
/**
* Return error
*
* @todo Log this error?
*
* @param string $message Error message
* @param int $statusCode HTTP response status code
*/
public function error(string $message = '', int $statusCode = 500)
{
$data = json_encode([
'message' => $message
]);
http_response_code($statusCode);
header('Content-Type: application/json');
echo $data;
exit;
}
/**
* Get call to action data from Wordpress
*
* @return array
*/
public function get_upcoming_deals()
{
$upcomingDealsInfo = [];
$upcomingDealsInfo['file'] = get_field('pipeline_report', 'option');
if (have_rows('upcoming_deals', 'option')):
while (have_rows('upcoming_deals', 'option')): the_row();
$upcomingDealsInfo['title'] = get_sub_field('title');
$upcomingDealsInfo['page_description'] = get_sub_field('page_description');
endwhile;
endif;
$table0 = [];
if (have_rows('table_0', 'option')):
while (have_rows('table_0', 'option')): the_row();
$table0['title'] = get_sub_field('title');
$table0['caption'] = get_sub_field('caption');
endwhile;
endif;
$table1 = [];
if (have_rows('table_1', 'option')):
while (have_rows('table_1', 'option')): the_row();
$table1['title'] = get_sub_field('title');
$table1['caption'] = get_sub_field('caption');
endwhile;
endif;
$table2 = [];
if (have_rows('table_2', 'option')):
while (have_rows('table_2', 'option')): the_row();
$table2['title'] = get_sub_field('title');
$table2['caption'] = get_sub_field('caption');
endwhile;
endif;
$table3 = [];
if (have_rows('table_3', 'option')):
while (have_rows('table_3', 'option')): the_row();
$table3['title'] = get_sub_field('title');
$table3['caption'] = get_sub_field('caption');
endwhile;
endif;
$table4 = [];
if (have_rows('table_4', 'option')):
while (have_rows('table_4', 'option')): the_row();
$table4['title'] = get_sub_field('title');
$table4['caption'] = get_sub_field('caption');
endwhile;
endif;
$table5 = [];
if (have_rows('table_5', 'option')):
while (have_rows('table_5', 'option')): the_row();
$table5['title'] = get_sub_field('title');
$table5['caption'] = get_sub_field('caption');
endwhile;
endif;
return [
'upcomingDealsInfo' => $upcomingDealsInfo,
'table_0' => $table0,
'table_1' => $table1,
'table_2' => $table2,
'table_3' => $table3,
'table_4' => $table4,
'table_5' => $table5,
];
}
}