Bladeren bron

:recycle: tweaking p2p mappings to match old data

tags/0.9.0
j 5 jaren geleden
bovenliggende
commit
c3c083b3db
3 gewijzigde bestanden met toevoegingen van 36 en 30 verwijderingen
  1. 1
    0
      docker-compose.yml
  2. 35
    21
      plugins/cia-post-types/includes/p2p-mappings.php
  3. 0
    9
      vue-theme/functions.php

+ 1
- 0
docker-compose.yml Bestand weergeven

47
             - 8181:8080
47
             - 8181:8080
48
         environment:
48
         environment:
49
             ADMINER_DEFAULT_SERVER: craft-db
49
             ADMINER_DEFAULT_SERVER: craft-db
50
+            ADMINER_DESIGN: pepa-linha-dark
50
         volumes:
51
         volumes:
51
            - ./adminer.ini:/usr/local/etc/php/conf.d/uploads.ini
52
            - ./adminer.ini:/usr/local/etc/php/conf.d/uploads.ini
52
 
53
 

+ 35
- 21
plugins/cia-post-types/includes/p2p-mappings.php Bestand weergeven

1
 <?php
1
 <?php
2
 include('/custom-types.php');
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
 ?>

+ 0
- 9
vue-theme/functions.php Bestand weergeven

170
 // Add featured image support
170
 // Add featured image support
171
 function craft_post_thumbnails() { add_theme_support( 'post-thumbnails' ); }
171
 function craft_post_thumbnails() { add_theme_support( 'post-thumbnails' ); }
172
 add_action( 'after_setup_theme', 'craft_post_thumbnails' );
172
 add_action( 'after_setup_theme', 'craft_post_thumbnails' );
173
-
174
-// function artists_types() {
175
-//     p2p_register_connection_type( array(
176
-//         'name' => 'artists_to_episodes',
177
-//         'from' => 'artist',
178
-//         'to' => 'episode'
179
-//     ) );
180
-// }
181
-// add_action( 'p2p_init', 'artists_types' );

Laden…
Annuleren
Opslaan