|
|
@@ -25,9 +25,19 @@ function _unsnake($input) {
|
|
25
|
25
|
return str_replace('_', '-', $input);
|
|
26
|
26
|
}
|
|
27
|
27
|
|
|
|
28
|
+function _make_sorts($post_types, $sorts_types) {
|
|
|
29
|
+ foreach ($sorts_types as $sort) {
|
|
|
30
|
+ $unsnaked = _unsnake($sort);
|
|
|
31
|
+ foreach ($post_types as $type) {
|
|
|
32
|
+ $sort_controller = new Make_Sort_By($type, $sort);
|
|
|
33
|
+ $sort_controller->register_custom_route("$type/$unsnaked");
|
|
|
34
|
+ }
|
|
|
35
|
+ }
|
|
|
36
|
+}
|
|
|
37
|
+
|
|
28
|
38
|
add_action( 'rest_api_init', function () {
|
|
29
|
39
|
/**
|
|
30
|
|
- * Custom endpoints
|
|
|
40
|
+ * Custom post type endpoints
|
|
31
|
41
|
*/
|
|
32
|
42
|
$types = get_all_post_types();
|
|
33
|
43
|
foreach($types as $type) {
|
|
|
@@ -36,7 +46,7 @@ add_action( 'rest_api_init', function () {
|
|
36
|
46
|
}
|
|
37
|
47
|
|
|
38
|
48
|
/**
|
|
39
|
|
- * Sticky Endpoint
|
|
|
49
|
+ * Sticky endpoint
|
|
40
|
50
|
*/
|
|
41
|
51
|
$sticky_controller = new Make_Sticky_Endpoint();
|
|
42
|
52
|
$sticky_controller->register_custom_route('sticky');
|
|
|
@@ -44,32 +54,26 @@ add_action( 'rest_api_init', function () {
|
|
44
|
54
|
/**
|
|
45
|
55
|
* Craft in America custom sort_types
|
|
46
|
56
|
*/
|
|
47
|
|
- $artist_sorts = ['by_alpha', 'by_material', 'by_episode'];
|
|
48
|
|
- foreach ($artist_sorts as $sort) {
|
|
49
|
|
- $unsnaked = _unsnake($sort);
|
|
50
|
|
- $sort_controller = new Make_Sort_By('artist', $sort);
|
|
51
|
|
- $sort_controller->register_custom_route("artist/$unsnaked");
|
|
52
|
|
- }
|
|
53
|
|
-
|
|
|
57
|
+ $artist_sorts = ['by_alpha'];
|
|
|
58
|
+ $by_alpha_types = ['artist'];
|
|
|
59
|
+ _make_sorts($by_alpha_types, $artist_sorts);
|
|
|
60
|
+
|
|
54
|
61
|
$date_sorts = ['by_past', 'by_current_and_upcoming'];
|
|
55
|
|
- $date_types = ['exhibition', 'event'];
|
|
56
|
|
- foreach ($date_sorts as $sort) {
|
|
57
|
|
- $unsnaked = _unsnake($sort);
|
|
58
|
|
- foreach ($date_types as $date_type) {
|
|
59
|
|
- $sort_controller = new Make_Sort_By($date_type, $sort);
|
|
60
|
|
- $sort_controller->register_custom_route("$date_type/$unsnaked");
|
|
61
|
|
- }
|
|
62
|
|
- }
|
|
|
62
|
+ $by_date_types = ['exhibition', 'event'];
|
|
|
63
|
+ _make_sorts($by_date_types, $date_sorts);
|
|
63
|
64
|
|
|
64
|
65
|
$episode_sorts = ['by_episode'];
|
|
65
|
|
- $episode_types = ['artist','exhibition', 'event'];
|
|
66
|
|
- foreach ($episode_sorts as $sort) {
|
|
67
|
|
- $unsnaked = _unsnake($sort);
|
|
68
|
|
- foreach ($episode_types as $episode_type) {
|
|
69
|
|
- $sort_controller = new Make_Sort_By($episode_type, $sort);
|
|
70
|
|
- $sort_controller->register_custom_route("$episode_type/$unsnaked");
|
|
71
|
|
- }
|
|
72
|
|
- }
|
|
|
66
|
+ $by_episode_types = [
|
|
|
67
|
+ 'artist', 'guide', 'short'
|
|
|
68
|
+ ];
|
|
|
69
|
+ _make_sorts($by_episode_types, $episode_sorts);
|
|
|
70
|
+
|
|
|
71
|
+ $material_sorts = ['by_material'];
|
|
|
72
|
+ $by_material_types = [
|
|
|
73
|
+ 'artist', 'guide', 'short',
|
|
|
74
|
+ 'object', 'publication',
|
|
|
75
|
+ ];
|
|
|
76
|
+ _make_sorts($by_material_types, $material_sorts);
|
|
73
|
77
|
});
|
|
74
|
78
|
|
|
75
|
79
|
/**
|