Преглед на файлове

:recycle: going back to old style p2p

tags/0.9.0
J преди 4 години
родител
ревизия
99cafd3342
променени са 1 файла, в които са добавени 79 реда и са изтрити 31 реда
  1. 79
    31
      plugins/cia-post-types/includes/p2p-mappings.php

+ 79
- 31
plugins/cia-post-types/includes/p2p-mappings.php Целия файл

@@ -6,40 +6,88 @@ $admin_box = [
6 6
     'context' => 'side'
7 7
 ];
8 8
 
9
-function _make_p2p_connection($post_type, $to) {
10
-    foreach($to as $type) {
11
-        p2p_register_connection_type([
12
-            'name' => $post_type . 's_to_' . $type . 's',
13
-            'to' => $post_type,
14
-            'from' => $type,
15
-            'reciprocal' => true,
16
-            'admin_box' => $admin_box
17
-        ]);
18
-    }
19
-}
20
-
21 9
 function all_connection_types() {
22
-    $_from = ['post', 'exhibition', 'event', 'episode', 'artist'];
23
-    
24
-     /**
25
-     * Register p2p connections without
26
-     * overlap, since they're bidirecitonal
27
-     * 
28
-     * Purposefully obtuse
29
-     */
30
-    _make_p2p_connection('artist', $_from);
31
-    $_from.pop();
32
-    $_from.pop();
33
-    
34
-    _make_p2p_connection('episode', $_from);
35
-    $_from.pop();
36
-    
37
-    _make_p2p_connection('event', $_from);
38
-    $_from.pop();
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
+    ]);
24
+    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
+
46
+    p2p_register_connection_type([
47
+        'name' => 'episodes_to_exhibitions',
48
+        'to' => 'episode',
49
+        'from' => 'exhibition',
50
+        'reciprocal' => true,
51
+        'admin_box' => $admin_box
52
+    ]);
53
+    p2p_register_connection_type([
54
+        'name' => 'episodes_to_events',
55
+        'to' => 'episode',
56
+        'from' => 'event',
57
+        'reciprocal' => true,
58
+        'admin_box' => $admin_box
59
+    ]);
60
+    p2p_register_connection_type([
61
+        'name' => 'episodes_to_posts',
62
+        'to' => 'episode',
63
+        'from' => 'post',
64
+        'reciprocal' => true,
65
+        'admin_box' => $admin_box
66
+    ]);
67
+
68
+    p2p_register_connection_type([
69
+        'name' => 'events_to_exhibitions',
70
+        'to' => 'event',
71
+        'from' => 'exhibition',
72
+        'reciprocal' => true,
73
+        'admin_box' => $admin_box
74
+    ]);
75
+    p2p_register_connection_type([
76
+        'name' => 'events_to_posts',
77
+        'to' => 'event',
78
+        'from' => 'post',
79
+        'reciprocal' => true,
80
+        'admin_box' => $admin_box
81
+    ]);
39 82
     
40
-    _make_p2p_connection('exhibition', $_from);
83
+    p2p_register_connection_type([
84
+        'name' => 'exhibitions_to_posts',
85
+        'to' => 'exhibition',
86
+        'from' => 'post',
87
+        'reciprocal' => true,
88
+        'admin_box' => $admin_box
89
+    ]);
41 90
 }
42
-
43 91
 add_action( 'p2p_init', 'all_connection_types' );
44 92
 
45 93
 ?>

Loading…
Отказ
Запис