Browse code

記事一覧画面:予約更新日時カラム追加

nita authored on 2015/10/14 01:44:49
Showing 1 changed files
... ...
@@ -37,6 +37,15 @@ class Rucy_Class {
37 37
         add_action( 'admin_menu', array( $editor, 'add_rucy_metabox' ) );
38 38
         add_action( 'save_post', array( $editor, 'save_rc_post_meta' ) );
39 39
         add_filter( 'post_updated_messages', array( $editor, 'add_reservation_message' ) );
40
+        $component = new Class_Rucy_Component();
41
+        $accept_post_types = $component->get_support_post_type();
42
+        foreach ( $accept_post_types as $p ) {
43
+            if ( in_array( $p, array( 'page', 'post' ) ) ) {
44
+                $p .= 's';
45
+            }
46
+            add_filter('manage_'.$p.'_columns', array( $this, 'manage_rucy_cols' ) );
47
+            add_action('manage_'.$p.'_custom_column', array( $this, 'add_rucy_col' ), 10, 2); 
48
+        }
40 49
     }
41 50
     
42 51
     public function activate_plugin() {
... ...
@@ -76,5 +85,22 @@ class Rucy_Class {
76 76
         $links[] = '<a href="' . get_admin_url( null, 'options-general.php?page=rucy' ) . '">' . __('Settings') . '</a>';
77 77
         return $links;
78 78
     }
79
+    
80
+    public function manage_rucy_cols( $columns ) {
81
+        $columns['rucy_reservation_date'] = __( "Reservation Update DateTime", RC_TXT_DOMAIN );
82
+        return $columns;
83
+    }
84
+    
85
+    public function add_rucy_col( $column_name, $post_id ) {
86
+        $component = new Class_Rucy_Component();
87
+        $post_metas = $component->get_post_rc_meta( $post_id );
88
+        if ( $column_name == 'rucy_reservation_date' ) {
89
+            if ( $post_metas->accept == "1" ) {
90
+                echo $post_metas->date;
91
+            } else {
92
+                _e( 'None' );
93
+            }
94
+        }
95
+    }
79 96
 }
80 97
 new Rucy_Class();
81 98
\ No newline at end of file