|
|
@@ -6,14 +6,19 @@ $admin_box = [
|
|
6
|
6
|
'context' => 'side'
|
|
7
|
7
|
];
|
|
8
|
8
|
|
|
9
|
|
-function all_connection_types() {
|
|
10
|
|
- p2p_register_connection_type([
|
|
11
|
|
- 'name' => 'artists_to_episodes',
|
|
12
|
|
- 'to' => 'artist',
|
|
13
|
|
- 'from' => 'episode',
|
|
14
|
|
- 'reciprocal' => true,
|
|
15
|
|
- 'admin_box' => $admin_box
|
|
16
|
|
- ]);
|
|
|
9
|
+function register_connections_for($type, $from_types) {
|
|
|
10
|
+ foreach($from_types as $f_type) {
|
|
|
11
|
+ $name = $type . 's_to_' . $f_type . 's';
|
|
|
12
|
+ p2p_register_connection_type([
|
|
|
13
|
+ 'name' => $name,
|
|
|
14
|
+ 'to' => $type,
|
|
|
15
|
+ 'from' => $f_type,
|
|
|
16
|
+ 'reciprocal' => true,
|
|
|
17
|
+ 'admin_box' => $admin_box
|
|
|
18
|
+ ]);
|
|
|
19
|
+ }
|
|
|
20
|
+}
|
|
|
21
|
+function register_all_one_offs() {
|
|
17
|
22
|
p2p_register_connection_type([
|
|
18
|
23
|
'name' => 'artists_to_artists',
|
|
19
|
24
|
'to' => 'artist',
|
|
|
@@ -22,107 +27,44 @@ function all_connection_types() {
|
|
22
|
27
|
'admin_box' => $admin_box
|
|
23
|
28
|
]);
|
|
24
|
29
|
p2p_register_connection_type([
|
|
25
|
|
- 'name' => 'artists_to_exhibitions',
|
|
26
|
|
- 'to' => 'artist',
|
|
27
|
|
- 'from' => 'exhibition',
|
|
28
|
|
- 'reciprocal' => true,
|
|
29
|
|
- 'admin_box' => $admin_box
|
|
30
|
|
- ]);
|
|
31
|
|
- p2p_register_connection_type([
|
|
32
|
|
- 'name' => 'artists_to_events',
|
|
33
|
|
- 'to' => 'artist',
|
|
34
|
|
- 'from' => 'event',
|
|
35
|
|
- 'reciprocal' => true,
|
|
36
|
|
- 'admin_box' => $admin_box
|
|
37
|
|
- ]);
|
|
38
|
|
- p2p_register_connection_type([
|
|
39
|
|
- 'name' => 'artists_to_posts',
|
|
40
|
|
- 'to' => 'artist',
|
|
41
|
|
- 'from' => 'post',
|
|
42
|
|
- 'reciprocal' => true,
|
|
43
|
|
- 'admin_box' => $admin_box
|
|
44
|
|
- ]);
|
|
45
|
|
- p2p_register_connection_type([
|
|
46
|
|
- 'name' => 'artists_to_shorts',
|
|
47
|
|
- 'to' => 'artist',
|
|
48
|
|
- 'from' => 'short',
|
|
49
|
|
- 'reciprocal' => true,
|
|
50
|
|
- 'admin_box' => $admin_box
|
|
51
|
|
- ]);
|
|
52
|
|
- p2p_register_connection_type([
|
|
53
|
|
- 'name' => 'artists_to_techniques',
|
|
54
|
|
- 'to' => 'artist',
|
|
|
30
|
+ 'name' => 'shorts_to_techniques',
|
|
|
31
|
+ 'to' => 'short',
|
|
55
|
32
|
'from' => 'technique',
|
|
56
|
33
|
'reciprocal' => true,
|
|
57
|
34
|
'admin_box' => $admin_box
|
|
58
|
35
|
]);
|
|
|
36
|
+}
|
|
59
|
37
|
|
|
60
|
|
- p2p_register_connection_type([
|
|
61
|
|
- 'name' => 'episodes_to_exhibitions',
|
|
62
|
|
- 'to' => 'episode',
|
|
63
|
|
- 'from' => 'exhibition',
|
|
64
|
|
- 'reciprocal' => true,
|
|
65
|
|
- 'admin_box' => $admin_box
|
|
66
|
|
- ]);
|
|
67
|
|
- p2p_register_connection_type([
|
|
68
|
|
- 'name' => 'episodes_to_events',
|
|
69
|
|
- 'to' => 'episode',
|
|
70
|
|
- 'from' => 'event',
|
|
71
|
|
- 'reciprocal' => true,
|
|
72
|
|
- 'admin_box' => $admin_box
|
|
73
|
|
- ]);
|
|
74
|
|
- p2p_register_connection_type([
|
|
75
|
|
- 'name' => 'episodes_to_posts',
|
|
76
|
|
- 'to' => 'episode',
|
|
77
|
|
- 'from' => 'post',
|
|
78
|
|
- 'reciprocal' => true,
|
|
79
|
|
- 'admin_box' => $admin_box
|
|
80
|
|
- ]);
|
|
81
|
|
- p2p_register_connection_type([
|
|
82
|
|
- 'name' => 'episodes_to_shorts',
|
|
83
|
|
- 'to' => 'episode',
|
|
84
|
|
- 'from' => 'short',
|
|
85
|
|
- 'reciprocal' => true,
|
|
86
|
|
- 'admin_box' => $admin_box
|
|
87
|
|
- ]);
|
|
88
|
|
- p2p_register_connection_type([
|
|
89
|
|
- 'name' => 'episodes_to_techniques',
|
|
90
|
|
- 'to' => 'episode',
|
|
91
|
|
- 'from' => 'technique',
|
|
92
|
|
- 'reciprocal' => true,
|
|
93
|
|
- 'admin_box' => $admin_box
|
|
94
|
|
- ]);
|
|
|
38
|
+function all_connection_types() {
|
|
|
39
|
+ $connection_stack = [
|
|
|
40
|
+ 'artist',
|
|
|
41
|
+ 'episode',
|
|
|
42
|
+ 'event',
|
|
|
43
|
+ 'exhibition',
|
|
|
44
|
+ 'post',
|
|
|
45
|
+ 'guide',
|
|
|
46
|
+ 'short',
|
|
|
47
|
+ 'technique',
|
|
|
48
|
+ ];
|
|
95
|
49
|
|
|
96
|
|
- p2p_register_connection_type([
|
|
97
|
|
- 'name' => 'events_to_exhibitions',
|
|
98
|
|
- 'to' => 'event',
|
|
99
|
|
- 'from' => 'exhibition',
|
|
100
|
|
- 'reciprocal' => true,
|
|
101
|
|
- 'admin_box' => $admin_box
|
|
102
|
|
- ]);
|
|
103
|
|
- p2p_register_connection_type([
|
|
104
|
|
- 'name' => 'events_to_posts',
|
|
105
|
|
- 'to' => 'event',
|
|
106
|
|
- 'from' => 'post',
|
|
107
|
|
- 'reciprocal' => true,
|
|
108
|
|
- 'admin_box' => $admin_box
|
|
109
|
|
- ]);
|
|
|
50
|
+ // Kick-off by assigning to artist
|
|
|
51
|
+ $artist = array_shift($connection_stack);
|
|
|
52
|
+ register_connections_for($artist, $connection_stack);
|
|
|
53
|
+ $episode = array_shift($connection_stack);
|
|
|
54
|
+ register_connections_for($episode, $connection_stack);
|
|
110
|
55
|
|
|
111
|
|
- p2p_register_connection_type([
|
|
112
|
|
- 'name' => 'exhibitions_to_posts',
|
|
113
|
|
- 'to' => 'exhibition',
|
|
114
|
|
- 'from' => 'post',
|
|
115
|
|
- 'reciprocal' => true,
|
|
116
|
|
- 'admin_box' => $admin_box
|
|
117
|
|
- ]);
|
|
118
|
|
-
|
|
119
|
|
- p2p_register_connection_type([
|
|
120
|
|
- 'name' => 'shorts_to_techniques',
|
|
121
|
|
- 'to' => 'short',
|
|
122
|
|
- 'from' => 'technique',
|
|
123
|
|
- 'reciprocal' => true,
|
|
124
|
|
- 'admin_box' => $admin_box
|
|
125
|
|
- ]);
|
|
|
56
|
+ /** Pop the end for now... */
|
|
|
57
|
+ $technique = array_pop($connection_stack);
|
|
|
58
|
+ $short = array_pop($connection_stack);
|
|
|
59
|
+ $guide = array_pop($connection_stack);
|
|
|
60
|
+
|
|
|
61
|
+ // Remaining: ['event', 'exhibition', 'post']
|
|
|
62
|
+ $event = array_shift($connection_stack);
|
|
|
63
|
+ register_connections_for($event, $connection_stack);
|
|
|
64
|
+ $exhibition = array_shift($connection_stack);
|
|
|
65
|
+ register_connections_for($exhibition, $connection_stack);
|
|
|
66
|
+
|
|
|
67
|
+ register_all_one_offs();
|
|
126
|
68
|
}
|
|
127
|
69
|
add_action( 'p2p_init', 'all_connection_types' );
|
|
128
|
70
|
|