|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace GeminiLabs\SiteReviews\Controllers\Api\Version1\Parameters; |
|
4
|
|
|
|
|
5
|
|
|
use GeminiLabs\SiteReviews\Modules\Rating; |
|
6
|
|
|
|
|
7
|
|
|
class ReviewParameters |
|
8
|
|
|
{ |
|
9
|
|
|
public function parameters(array $context) |
|
10
|
|
|
{ |
|
11
|
|
|
$parameters = [ |
|
12
|
|
|
'after' => [ |
|
13
|
|
|
'description' => _x('Limit result set to reviews published after a given ISO8601 compliant date.', 'admin-text', 'site-reviews'), |
|
14
|
|
|
'format' => 'date-time', |
|
15
|
|
|
'type' => 'string', |
|
16
|
|
|
], |
|
17
|
|
|
'assigned_posts' => [ |
|
18
|
|
|
'default' => [], |
|
19
|
|
|
'description' => _x('Limit result set to reviews assigned to specific posts of any public post type.', 'admin-text', 'site-reviews'), |
|
20
|
|
|
'items' => [ |
|
21
|
|
|
'type' => ['integer', 'string'], |
|
22
|
|
|
], |
|
23
|
|
|
'type' => 'array', |
|
24
|
|
|
], |
|
25
|
|
|
'assigned_terms' => [ |
|
26
|
|
|
'default' => [], |
|
27
|
|
|
'description' => sprintf(_x('Limit result set to reviews assigned to specific terms in the %s taxonomy.', 'admin-text', 'site-reviews'), glsr()->taxonomy), |
|
28
|
|
|
'items' => [ |
|
29
|
|
|
'type' => ['integer', 'string'], |
|
30
|
|
|
], |
|
31
|
|
|
'type' => 'array', |
|
32
|
|
|
], |
|
33
|
|
|
'assigned_users' => [ |
|
34
|
|
|
'default' => [], |
|
35
|
|
|
'description' => _x('Limit result set to reviews assigned to specific users.', 'admin-text', 'site-reviews'), |
|
36
|
|
|
'items' => [ |
|
37
|
|
|
'type' => ['integer', 'string'], |
|
38
|
|
|
], |
|
39
|
|
|
'type' => 'array', |
|
40
|
|
|
], |
|
41
|
|
|
'before' => [ |
|
42
|
|
|
'description' => _x('Limit result set to reviews published before a given ISO8601 compliant date.', 'admin-text', 'site-reviews'), |
|
43
|
|
|
'format' => 'date-time', |
|
44
|
|
|
'type' => 'string', |
|
45
|
|
|
], |
|
46
|
|
|
'date' => [ |
|
47
|
|
|
'description' => _x('Limit result set to reviews published on a given ISO8601 compliant date.', 'admin-text', 'site-reviews'), |
|
48
|
|
|
'format' => 'date-time', |
|
49
|
|
|
'type' => 'string', |
|
50
|
|
|
], |
|
51
|
|
|
'email' => [ |
|
52
|
|
|
'description' => _x('Limit result set to reviews containing a given email address.', 'admin-text', 'site-reviews'), |
|
53
|
|
|
'format' => 'email', |
|
54
|
|
|
'type' => 'string', |
|
55
|
|
|
], |
|
56
|
|
|
'exclude' => [ |
|
57
|
|
|
'default' => [], |
|
58
|
|
|
'description' => _x('Ensure result set excludes specific review IDs.', 'admin-text', 'site-reviews'), |
|
59
|
|
|
'items' => ['type' => 'integer'], |
|
60
|
|
|
'type' => 'array', |
|
61
|
|
|
], |
|
62
|
|
|
'include' => [ |
|
63
|
|
|
'default' => [], |
|
64
|
|
|
'description' => _x('Limit result set to specific review IDs.', 'admin-text', 'site-reviews'), |
|
65
|
|
|
'items' => ['type' => 'integer'], |
|
66
|
|
|
'type' => 'array', |
|
67
|
|
|
], |
|
68
|
|
|
'ip_address' => [ |
|
69
|
|
|
'description' => _x('Limit result set to reviews submitted from a given IP address.', 'admin-text', 'site-reviews'), |
|
70
|
|
|
'format' => 'ip', |
|
71
|
|
|
'type' => 'string', |
|
72
|
|
|
], |
|
73
|
|
|
'offset' => [ |
|
74
|
|
|
'description' => _x('Offset the result set by a specific number of items.', 'admin-text', 'site-reviews'), |
|
75
|
|
|
'type' => 'integer', |
|
76
|
|
|
], |
|
77
|
|
|
'order' => [ |
|
78
|
|
|
'default' => 'desc', |
|
79
|
|
|
'description' => _x('Order sort attribute ascending or descending.', 'admin-text', 'site-reviews'), |
|
80
|
|
|
'enum' => ['asc', 'desc'], |
|
81
|
|
|
'type' => 'string', |
|
82
|
|
|
], |
|
83
|
|
|
'orderby' => [ |
|
84
|
|
|
'default' => 'date', |
|
85
|
|
|
'description' => _x('Sort collection by object attribute.', 'admin-text', 'site-reviews'), |
|
86
|
|
|
'enum' => ['author', 'comment_count', 'date', 'date_gmt', 'id', 'menu_order', 'none', 'random', 'rating'], |
|
87
|
|
|
'type' => 'string', |
|
88
|
|
|
], |
|
89
|
|
|
'page' => [ |
|
90
|
|
|
'default' => 1, |
|
91
|
|
|
'description' => _x('Current page of the collection.', 'admin-text', 'site-reviews'), |
|
92
|
|
|
'minimum' => 1, |
|
93
|
|
|
'sanitize_callback' => 'absint', |
|
94
|
|
|
'type' => 'integer', |
|
95
|
|
|
], |
|
96
|
|
|
'per_page' => [ |
|
97
|
|
|
'default' => 10, |
|
98
|
|
|
'description' => _x('Maximum number of items to be returned in result set.', 'admin-text', 'site-reviews'), |
|
99
|
|
|
'maximum' => 100, |
|
100
|
|
|
'minimum' => 1, |
|
101
|
|
|
'sanitize_callback' => 'absint', |
|
102
|
|
|
'type' => 'integer', |
|
103
|
|
|
], |
|
104
|
|
|
'rating' => [ |
|
105
|
|
|
'description' => _x('Limit result set to reviews containing a given minimum rating.', 'admin-text', 'site-reviews'), |
|
106
|
|
|
'maximum' => Rating::max(), |
|
107
|
|
|
'minimum' => Rating::min(), |
|
108
|
|
|
'sanitize_callback' => 'absint', |
|
109
|
|
|
'type' => 'integer', |
|
110
|
|
|
], |
|
111
|
|
|
'status' => [ |
|
112
|
|
|
'description' => _x('Limit result set to reviews containing a given status.', 'admin-text', 'site-reviews'), |
|
113
|
|
|
'enum' => ['all', 'approved', 'pending', 'publish', 'unapproved'], |
|
114
|
|
|
'type' => 'string', |
|
115
|
|
|
], |
|
116
|
|
|
'terms' => [ |
|
117
|
|
|
'description' => _x('Limit result set to reviews submitted with terms accepted.', 'admin-text', 'site-reviews'), |
|
118
|
|
|
'type' => 'boolean', |
|
119
|
|
|
], |
|
120
|
|
|
'type' => [ |
|
121
|
|
|
'description' => _x('Limit result set to reviews containing a given review type.', 'admin-text', 'site-reviews'), |
|
122
|
|
|
'enum' => glsr()->retrieveAs('array', 'review_types', []), |
|
123
|
|
|
'type' => 'string', |
|
124
|
|
|
], |
|
125
|
|
|
'user__in' => [ |
|
126
|
|
|
'default' => [], |
|
127
|
|
|
'description' => _x('Limit result set to reviews authored by specific users.', 'admin-text', 'site-reviews'), |
|
128
|
|
|
'items' => [ |
|
129
|
|
|
'type' => ['integer', 'string'], |
|
130
|
|
|
], |
|
131
|
|
|
'type' => 'array', |
|
132
|
|
|
], |
|
133
|
|
|
'user__not_in' => [ |
|
134
|
|
|
'default' => [], |
|
135
|
|
|
'description' => _x('Ensure result set excludes reviews authored by specific users.', 'admin-text', 'site-reviews'), |
|
136
|
|
|
'items' => [ |
|
137
|
|
|
'type' => ['integer', 'string'], |
|
138
|
|
|
], |
|
139
|
|
|
'type' => 'array', |
|
140
|
|
|
], |
|
141
|
|
|
]; |
|
142
|
|
|
$parameters = glsr()->filterArray('rest-api/reviews/parameters', $parameters); |
|
143
|
|
|
$parameters['context'] = $context; |
|
144
|
|
|
ksort($parameters); |
|
145
|
|
|
return $parameters; |
|
146
|
|
|
} |
|
147
|
|
|
} |
|
148
|
|
|
|