Browse code

編集画面:予約登録時メッセージ追加

nita authored on 2015/10/14 01:21:16
Showing 2 changed files
... ...
@@ -199,4 +199,37 @@ class Class_Rucy_Editer {
199 199
             wp_clear_scheduled_hook(RC_CRON_HOOK, array($post_id));
200 200
         }
201 201
     }
202
+    
203
+    // add update message
204
+    public function add_reservation_message( $messages ) {
205
+        global $post, $post_ID;
206
+        $component = new Class_Rucy_Component();
207
+        $accept_post_types = $component->get_support_post_type();
208
+        $post_type = get_post_type( $post );
209
+        
210
+        if ( !in_array( $post_type, $accept_post_types ) ) {
211
+            return $messages;
212
+        }
213
+        
214
+        $post_metas = $component->get_post_rc_meta( $post_ID );
215
+        if ( $post_metas->accept != "1" ) {
216
+            return $messages;
217
+        }
218
+        
219
+        $add_message_date = date_i18n( 'Y/m/d @ H:i', strtotime( $post_metas->date ) );
220
+        $base_str = __( 'registered reservation update content _RC_DATETIME_', RC_TXT_DOMAIN );
221
+        $add_message = '<br>' . strtr( $base_str, array( '_RC_DATETIME_' => $add_message_date ) );
222
+        // published
223
+        $messages[$post_type][1] .= $add_message;
224
+        $messages[$post_type][4] .= $add_message;
225
+        $messages[$post_type][6] .= $add_message;
226
+        // saved
227
+        $messages[$post_type][7] .= $add_message;
228
+        // submited
229
+        $messages[$post_type][8] .= $add_message;
230
+        // scheduled
231
+        $messages[$post_type][9] .= $add_message;
232
+        
233
+        return $messages;
234
+    }
202 235
 }
... ...
@@ -35,6 +35,7 @@ class Rucy_Class {
35 35
         $editor = new Class_Rucy_Editer();
36 36
         add_action( 'admin_menu', array( $editor, 'add_rucy_metabox' ) );
37 37
         add_action( 'save_post', array( $editor, 'save_rc_post_meta' ) );
38
+        add_filter( 'post_updated_messages', array( $editor, 'add_reservation_message' ) );
38 39
     }
39 40
     
40 41
     public function activate_plugin() {