Changeset 2784 for sites/branches/application-tracking/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
- Timestamp:
- 03/23/2016 10:04:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/branches/application-tracking/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-wordcamp/wordcamp-admin.php
r2517 r2784 43 43 // Post status transitions 44 44 add_action( 'transition_post_status', array( $this, 'trigger_schedule_actions' ), 10, 3 ); 45 add_action( 'transition_post_status', array( $this, 'log_status_changes' ), 10, 3 ); 45 46 add_action( 'wcpt_added_to_planning_schedule', array( $this, 'add_organizer_to_central' ), 10 ); 46 47 add_action( 'wcpt_added_to_planning_schedule', array( $this, 'mark_date_added_to_planning_schedule' ), 10 ); … … 51 52 add_action( 'admin_notices', array( $this, 'print_admin_notices' ) ); 52 53 add_filter( 'redirect_post_location', array( $this, 'add_admin_notices_to_redirect_url' ), 10, 2 ); 54 } 55 56 // todo phpdoc 57 public static function get_status_name( $status_slug ) { 58 // todo call get_custom_statuses and map ? 59 60 return '{status name}'; 61 } 62 63 //todo phpdoc 64 public static function get_milestone_from_status( $status_slug ) { 65 // todo just have an array that maps them together? 66 67 return '{milestone name}'; 53 68 } 54 69 … … 87 102 'high' 88 103 ); 104 105 add_meta_box( 106 'wcpt_notes', 107 __( 'Add a Note', 'wordcamporg' ), 108 'wcpt_add_note_metabox', 109 WCPT_POST_TYPE_ID, 110 'side', 111 'low' 112 ); 113 114 add_meta_box( 115 'wcpt_log', 116 'Log', 117 'wcpt_log_metabox', 118 WCPT_POST_TYPE_ID, 119 'advanced', 120 'low' 121 ); 89 122 } 90 123 … … 159 192 } 160 193 } 161 } 194 195 $this->validate_and_add_note( $post_id ); 196 } 197 198 /** 199 * Validate and add a new note 200 * 201 * @param int $post_id 202 */ 203 protected function validate_and_add_note( $post_id ) { 204 // todo make sure edit is actionable - done in caller, but test 205 206 check_admin_referer( 'wcpt_notes', 'wcpt_notes_nonce' ); // todo test working 207 208 $new_note_message = sanitize_text_field( wp_unslash( $_POST['wcpt_new_note'] ) ); 209 210 if ( empty( $new_note_message ) ) { 211 return; 212 } 213 214 add_post_meta( $post_id, '_note', array( 215 'timestamp' => current_time( 'timestamp' ), 216 'user_id' => get_current_user_id(), 217 'message' => $new_note_message, 218 ) ); 219 } 220 162 221 163 222 /** … … 553 612 554 613 /** 614 * Log when the post status changes 615 * 616 * @param string $new_status 617 * @param string $old_status 618 * @param WP_Post $post 619 */ 620 public function log_status_changes( $new_status, $old_status, $post ) { 621 if ( $new_status === $old_status ) { 622 return; 623 } 624 625 add_post_meta( $post->ID, '_status_change', array( 626 'timestamp' => current_time( 'timestamp' ), 627 'user_id' => get_current_user_id(), 628 'message' => sprintf( '%s -> %s', $old_status, $new_status ), /// todo use get_status_name() when it's ready 629 ) ); 630 } 631 632 /** 555 633 * Add the lead organizer to Central when a WordCamp application is accepted. 556 634 *
Note: See TracChangeset
for help on using the changeset viewer.