Changeset 2899
- Timestamp:
- 04/05/2016 06:40:48 PM (9 years ago)
- Location:
- sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/applications/tracker.php
r2894 r2899 15 15 $statuses = \WordCamp_Loader::get_post_statuses(); 16 16 $milestones = \WordCamp_Loader::map_statuses_to_milestones(); 17 $posts = get_active_wordcamps( $statuses ); 18 19 require_once( dirname( __DIR__ ) . '/wcpt-wordcamp/wordcamp-admin.php' ); 20 require( dirname( __DIR__ ) . '/views/applications/tracker/shortcode-application-tracker.php' ); 21 } 22 23 /** 24 * Get camps that are active enough to be shown on the tracker 25 * 26 * @param array $statuses 27 * 28 * @return array 29 */ 30 function get_active_wordcamps( $statuses ) { 31 $inactive_timestamp = strtotime( '60 days ago' ); 17 32 18 33 $shown_statuses = $statuses; … … 20 35 $shown_statuses = array_keys( $shown_statuses ); 21 36 22 $ posts = get_posts( array(37 $wordcamps = get_posts( array( 23 38 'post_type' => WCPT_POST_TYPE_ID, 24 39 'post_status' => $shown_statuses, … … 28 43 ) ); 29 44 30 require_once( dirname( __DIR__ ) . '/wcpt-wordcamp/wordcamp-admin.php' ); 31 require( dirname( __DIR__ ) . '/views/applications/tracker/shortcode-application-tracker.php' ); 45 foreach ( $wordcamps as $key => $wordcamp ) { 46 $wordcamp->last_update_timestamp = get_last_update_timestamp( $wordcamp->ID ); 47 48 if ( $wordcamp->last_update_timestamp <= $inactive_timestamp ) { 49 unset( $wordcamps[ $key ] ); 50 } 51 } 52 53 return $wordcamps; 32 54 } 33 55 34 56 /** 35 * Get the time difference between now and the last status update.57 * Get the timestamp of the last time the post status changed 36 58 * 37 * @param $post_id59 * @param int $post_id 38 60 * 39 * @return string61 * @return int 40 62 */ 41 function get_last_ status_update_time_diff( $post_id ) {42 $ time_diff = '';43 $status_changes = get_post_meta( $post_id, '_status_change' );63 function get_last_update_timestamp( $post_id ) { 64 $last_update_timestamp = 0; 65 $status_changes = get_post_meta( $post_id, '_status_change' ); 44 66 45 67 if ( $status_changes ) { 46 68 usort( $status_changes, 'wcpt_sort_log_entries' ); 47 $ time_diff = human_time_diff( time(), $status_changes[0]['timestamp'] ) . ' ago';69 $last_update_timestamp = $status_changes[0]['timestamp']; 48 70 } 49 71 50 return $ time_diff;72 return $last_update_timestamp; 51 73 } 52 74 -
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/views/applications/tracker/shortcode-application-tracker.php
r2869 r2899 24 24 <td class="milestone" ><?php echo esc_html( $milestones[ $post->post_status ] ); ?></td> 25 25 <td class="status" ><?php echo esc_html( $statuses[ $post->post_status ] ); ?></td> 26 <td class="last-update"><?php echo esc_html( get_last_status_update_time_diff( $post->ID ) ); ?></td> 26 <td class="last-update"><?php echo esc_html( human_time_diff( time(), $post->last_update_timestamp ) . ' ago' ); ?></td> 27 <!-- todo realign --> 27 28 </tr> 28 29 <?php endforeach; ?>
Note: See TracChangeset
for help on using the changeset viewer.