|
|
@@ -1,28 +1,42 @@
|
|
1
|
1
|
<?php
|
|
2
|
2
|
include('/custom-types.php');
|
|
3
|
3
|
|
|
4
|
|
-function register_to_from($to, $from) {
|
|
5
|
|
- p2p_register_connection_type( array(
|
|
6
|
|
- 'name' => $from . 's_to_' . $to . 's',
|
|
7
|
|
- 'from' => $from,
|
|
8
|
|
- 'to' => $to,
|
|
9
|
|
- 'reciprocal' => true
|
|
10
|
|
- ) );
|
|
11
|
|
-}
|
|
|
4
|
+$admin_box = [
|
|
|
5
|
+ 'show' => 'any',
|
|
|
6
|
+ 'context' => 'side'
|
|
|
7
|
+];
|
|
|
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
|
+ ]);
|
|
|
17
|
+ p2p_register_connection_type([
|
|
|
18
|
+ 'name' => 'artists_to_artists',
|
|
|
19
|
+ 'to' => 'artist',
|
|
|
20
|
+ 'from' => 'artist',
|
|
|
21
|
+ 'reciprocal' => true,
|
|
|
22
|
+ 'admin_box' => $admin_box
|
|
|
23
|
+ ]);
|
|
12
|
24
|
|
|
13
|
|
-function register_all_from_type($type_list, $from_type) {
|
|
14
|
|
- foreach ($type_list as $type):
|
|
15
|
|
- register_to_from($type, $from_type);
|
|
16
|
|
- endforeach;
|
|
|
25
|
+ p2p_register_connection_type([
|
|
|
26
|
+ 'name' => 'episodes_to_exhibitions',
|
|
|
27
|
+ 'to' => 'episode',
|
|
|
28
|
+ 'from' => 'exhibition',
|
|
|
29
|
+ 'reciprocal' => true,
|
|
|
30
|
+ 'admin_box' => $admin_box
|
|
|
31
|
+ ]);
|
|
|
32
|
+ p2p_register_connection_type([
|
|
|
33
|
+ 'name' => 'episodes_to_events',
|
|
|
34
|
+ 'to' => 'episode',
|
|
|
35
|
+ 'from' => 'event',
|
|
|
36
|
+ 'reciprocal' => true,
|
|
|
37
|
+ 'admin_box' => $admin_box
|
|
|
38
|
+ ]);
|
|
17
|
39
|
}
|
|
|
40
|
+add_action( 'p2p_init', 'all_connection_types' );
|
|
18
|
41
|
|
|
19
|
|
-add_action( 'p2p_init', function () {
|
|
20
|
|
- $all_types = get_all_custom_types();
|
|
21
|
|
-
|
|
22
|
|
- register_all_from_type($all_types, 'artist');
|
|
23
|
|
- array_splice($all_types, array_search('artist', $all_types), 1);
|
|
24
|
|
-
|
|
25
|
|
- register_all_from_type($all_types, 'episode');
|
|
26
|
|
- array_splice($all_types, array_search('episode', $all_types), 1);
|
|
27
|
|
-} );
|
|
28
|
42
|
?>
|