Kaynağa Gözat

Rearranged formatting for Admin Custom Columns

tags/0.9.0
Alej 4 yıl önce
ebeveyn
işleme
71634ce031
1 değiştirilmiş dosya ile 40 ekleme ve 42 silme
  1. 40
    42
      vue-theme/functions.php

+ 40
- 42
vue-theme/functions.php Dosyayı Görüntüle

@@ -169,6 +169,34 @@ add_action( 'after_setup_theme', 'craft_post_thumbnails' );
169 169
 add_theme_support('editor-styles');
170 170
 add_editor_style( 'editor-style.css' );
171 171
 
172
+// ADMIN CUSTOM COLUMNS
173
+// Add the custom columns for ARTIST:
174
+add_filter( 'manage_artist_posts_columns', 'set_custom_edit_artist_columns' );
175
+function set_custom_edit_artist_columns($columns) {
176
+    $date = $columns['date'];
177
+    unset( $columns['date'] );
178
+    $columns['artist_type'] = __('Artist Type', 'my-text-domain' );
179
+    $columns['material'] = __('Material', 'my-text-xx' );
180
+    $columns['date'] = $date;
181
+    return $columns;
182
+}
183
+// Add the data to the custom columns for ARTIST:
184
+add_action( 'manage_artist_posts_custom_column' , 'custom_artist_column', 10, 2 );
185
+function custom_artist_column( $column, $post_id ) {
186
+    switch ( $column ) {
187
+        // display a list of artist_type terms assigned to the post 
188
+        case 'artist_type' :
189
+            $terms = get_the_term_list( $post_id , 'artist_type' , '' , ', ' , '' );
190
+            echo is_string( $terms ) ? $terms : '—';
191
+            break;
192
+            // display a list of material terms assigned to the post 
193
+        case 'material' :
194
+            $terms = get_the_term_list( $post_id , 'material' , '' , ', ' , '' );
195
+            echo is_string( $terms ) ? $terms : '—';
196
+            break;
197
+    }
198
+}
199
+
172 200
 // Add the custom columns for EVENT:
173 201
 add_filter( 'manage_event_posts_columns', 'set_custom_edit_event_columns' );
174 202
 function set_custom_edit_event_columns($columns) {
@@ -189,24 +217,19 @@ function custom_event_column( $column, $post_id ) {
189 217
     }
190 218
 }
191 219
 
192
-// Add the custom columns for ARTIST:
193
-add_filter( 'manage_artist_posts_columns', 'set_custom_edit_artist_columns' );
194
-function set_custom_edit_artist_columns($columns) {
220
+// Add the custom columns for SHORT:
221
+add_filter( 'manage_short_posts_columns', 'set_custom_edit_short_columns' );
222
+function set_custom_edit_short_columns($columns) {
195 223
     $date = $columns['date'];
196 224
     unset( $columns['date'] );
197
-    $columns['artist_type'] = __('Artist Type');
198 225
     $columns['material'] = __('Material');
199 226
     $columns['date'] = $date;
200 227
     return $columns;
201 228
 }
202
-// Add the data to the custom columns for ARTIST:
203
-add_action( 'manage_artist_posts_custom_column' , 'custom_artist_column', 10, 2 );
204
-function custom_artist_column( $column, $post_id ) {
229
+// Add the data to the custom columns for SHORT:
230
+add_action( 'manage_short_posts_custom_column' , 'custom_short_column', 10, 2 );
231
+function custom_short_column( $column, $post_id ) {
205 232
     switch ( $column ) {
206
-        case 'artist_type' :
207
-            $terms = get_the_term_list( $post_id , 'artist_type' , '' , ',' , '' );
208
-            echo is_string( $terms ) ? $terms : '—';
209
-            break;
210 233
         case 'material' :
211 234
             $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
212 235
             echo is_string( $terms ) ? $terms : '—';
@@ -214,18 +237,18 @@ function custom_artist_column( $column, $post_id ) {
214 237
     }
215 238
 }
216 239
 
217
-// Add the custom columns for SHORT:
218
-add_filter( 'manage_short_posts_columns', 'set_custom_edit_short_columns' );
219
-function set_custom_edit_short_columns($columns) {
240
+// Add the custom columns for TECHNIQUE:
241
+add_filter( 'manage_technique_posts_columns', 'set_custom_edit_technique_columns' );
242
+function set_custom_edit_technique_columns($columns) {
220 243
     $date = $columns['date'];
221 244
     unset( $columns['date'] );
222 245
     $columns['material'] = __('Material');
223 246
     $columns['date'] = $date;
224 247
     return $columns;
225 248
 }
226
-// Add the data to the custom columns for SHORT:
227
-add_action( 'manage_short_posts_custom_column' , 'custom_short_column', 10, 2 );
228
-function custom_short_column( $column, $post_id ) {
249
+// Add the data to the custom columns for TECHNIQUE:
250
+add_action( 'manage_technique_posts_custom_column' , 'custom_technique_column', 10, 2 );
251
+function custom_technique_column( $column, $post_id ) {
229 252
     switch ( $column ) {
230 253
         case 'material' :
231 254
             $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
@@ -293,28 +316,3 @@ function custom_publication_column( $column, $post_id ) {
293 316
             break;
294 317
     }
295 318
 }
296
-
297
-// Add the custom columns for TECHNIQUE:
298
-add_filter( 'manage_technique_posts_columns', 'set_custom_edit_technique_columns' );
299
-function set_custom_edit_technique_columns($columns) {
300
-    $date = $columns['date'];
301
-    unset( $columns['date'] );
302
-    $columns['material'] = __('Material');
303
-    $columns['date'] = $date;
304
-    return $columns;
305
-}
306
-// Add the data to the custom columns for TECHNIQUE:
307
-add_action( 'manage_technique_posts_custom_column' , 'custom_technique_column', 10, 2 );
308
-function custom_technique_column( $column, $post_id ) {
309
-    switch ( $column ) {
310
-        case 'material' :
311
-            $terms = get_the_term_list( $post_id , 'material' , '' , ',' , '' );
312
-            echo is_string( $terms ) ? $terms : '—';
313
-            break;
314
-    }
315
-}
316
-
317
-
318
-
319
-
320
-

Loading…
İptal
Kaydet