- Timestamp:
- 04/05/2016 04:05:02 PM (8 years ago)
- Location:
- sites/trunk/wordcamp.org
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org
-
Property
svn:mergeinfo
set to
/sites/branches/application-tracking/wordcamp.org merged eligible
-
Property
svn:mergeinfo
set to
-
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-functions.php
r171 r2898 44 44 */ 45 45 function wcpt_has_access () { 46 47 46 if ( is_super_admin () ) 48 47 $has_access = true; … … 86 85 } 87 86 88 ?> 87 /** 88 * Render the Log metabox 89 * 90 * @param WP_Post $post 91 */ 92 function wcpt_log_metabox( $post ) { 93 $entries = wcpt_get_log_entries( $post->ID ); 94 95 require_once( __DIR__ . '/views/common/metabox-log.php' ); 96 } 97 98 /** 99 * Get all the the entries 100 * 101 * @param int $wordcamp_id 102 * 103 * @return array 104 */ 105 function wcpt_get_log_entries( $wordcamp_id ) { 106 $entries = array(); 107 $notes = get_post_meta( $wordcamp_id, '_note' ); 108 $status_changes = get_post_meta( $wordcamp_id, '_status_change' ); 109 110 foreach ( array( 'note' => $notes, 'status_change' => $status_changes ) as $entry_type => $raw_entries ) { 111 foreach ( $raw_entries as $entry ) { 112 $user = get_user_by( 'id', $entry['user_id'] ); 113 114 $entry['type'] = $entry_type; 115 $entry['user_display_name'] = $user->display_name; 116 117 $entries[] = $entry; 118 } 119 } 120 121 usort( $entries, 'wcpt_sort_log_entries' ); 122 123 return $entries; 124 } 125 126 /** 127 * Sort the log entries in reverse-chronological order 128 * 129 * @param array $a 130 * @param array $b 131 * 132 * @return int 133 */ 134 function wcpt_sort_log_entries( $a, $b ) { 135 // If a status change and a note occur at the same time, show the change before the note 136 if ( $a['timestamp'] == $b['timestamp'] ) { 137 return ( 'status_change' == $a['type'] ) ? 1 : -1; 138 } 139 140 return ( $a['timestamp'] > $b['timestamp'] ) ? -1 : 1; 141 } 142 143 /** 144 * Render the Notes metabox 145 * 146 * @param WP_Post $post 147 */ 148 function wcpt_add_note_metabox( $post ) { 149 wp_nonce_field( 'wcpt_notes', 'wcpt_notes_nonce' ); 150 151 require_once( __DIR__ . '/views/common/metabox-notes.php' ); 152 }
Note: See TracChangeset
for help on using the changeset viewer.