Changeset 2083 for sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/classes/payment-request.php
- Timestamp:
- 11/16/2015 01:16:20 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/classes/payment-request.php
r2060 r2083 20 20 add_action( 'save_post', array( $this, 'save_payment' ), 10, 2 ); 21 21 add_filter( 'map_meta_cap', array( $this, 'modify_capabilities' ), 10, 4 ); 22 add_action( 'transition_post_status', array( $this, 'transition_post_status' ), 10, 3 ); 22 23 23 24 // Columns … … 165 166 'high' 166 167 ); 168 169 add_meta_box( 'wcp_log', __( 'Log', 'wordcamporg' ), array( $this, 'render_log_metabox' ), 170 self::POST_TYPE, 'normal', 'high' ); 167 171 } 168 172 … … 248 252 249 253 require_once( dirname( __DIR__ ) . '/views/payment-request/metabox-files.php' ); 254 } 255 256 /** 257 * Render the Log metabox 258 * 259 * @param WP_Post $post 260 */ 261 public function render_log_metabox( $post ) { 262 $log = get_post_meta( $post->ID, '_wcp_log', true ); 263 if ( empty( $log ) ) 264 $log = '[]'; 265 266 $log = json_decode( $log, true ); 267 268 // I wish I had a spaceship. 269 uasort( $log, function( $a, $b ) { 270 if ( $b['timestamp'] == $a ) 271 return 0; 272 273 return ( $a['timestamp'] < $b['timestamp'] ) ? -1 : 1; 274 }); 275 276 require_once( dirname( __DIR__ ) . '/views/payment-request/metabox-log.php' ); 250 277 } 251 278 … … 658 685 $post_data['post_status'] = 'incomplete'; 659 686 $this->notify_requester_request_incomplete( $post_data_raw['ID'], $post_data, $post_data_raw ); 687 688 update_post_meta( $post_data_raw['ID'], '_wcp_incomplete_notes', sanitize_text_field( $post_data_raw['wcp_mark_incomplete_notes'] ) ); 660 689 } else { 661 690 $previous_status = $post_data['post_status']; … … 901 930 } 902 931 932 public function transition_post_status( $new, $old, $post ) { 933 if ( $post->post_type != self::POST_TYPE ) 934 return; 935 936 $user = get_user_by( 'id', get_current_user_id() ); 937 if ( $new == 'auto-draft' ) 938 return; 939 940 if ( $new == 'incomplete' && $old != 'incomplete' ) { 941 $incomplete_text = get_post_meta( $post->ID, '_wcp_incomplete_notes', true ); 942 $incomplete_text = preg_replace( '#\.$#', '', $incomplete_text ); // trailing-undot-it. 943 WordCamp_Payments::log( $post->ID, sprintf( 'Marked as incomplete by %s: %s.', $user->display_name, $incomplete_text ), array( 944 'user_id' => $user->ID, 945 'action' => 'marked-incomplete', 946 'reason' => 'maybe notes', 947 ) ); 948 } elseif ( $new == 'paid' && $old != 'paid' ) { 949 WordCamp_Payments::log( $post->ID, sprintf( 'Marked as paid by %s.', $user->display_name ), array( 950 'user_id' => $user->ID, 951 'action' => 'marked-paid', 952 ) ); 953 } elseif ( $old == 'auto-draft' && $new != 'auto-draft' ) { 954 WordCamp_Payments::log( $post->ID, sprintf( 'Request created by %s.', $user->display_name ), array( 955 'user_id' => $user->ID, 956 'action' => 'updated', 957 ) ); 958 } else { 959 WordCamp_Payments::log( $post->ID, sprintf( 'Request updated by %s.', $user->display_name ), array( 960 'user_id' => $user->ID, 961 'action' => 'updated', 962 ) ); 963 } 964 } 965 903 966 /** 904 967 * Attach unattached files to the payment request post
Note: See TracChangeset
for help on using the changeset viewer.