Making WordPress.org


Ignore:
Timestamp:
04/05/2016 04:05:02 PM (10 years ago)
Author:
kovshenin
Message:

WordCamp.org: Reintegrate application-tracking branch into trunk.

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.org2783-2897
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wcpt/wcpt-functions.php

    r171 r2898  
    4444 */
    4545function wcpt_has_access () {
    46 
    4746        if ( is_super_admin () )
    4847                $has_access = true;
     
    8685}
    8786
    88 ?>
     87/**
     88 * Render the Log metabox
     89 *
     90 * @param WP_Post $post
     91 */
     92function 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 */
     105function 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 */
     134function 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 */
     148function 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.