Making WordPress.org


Ignore:
Timestamp:
07/17/2018 07:24:58 PM (6 years ago)
Author:
coreymckrill
Message:

CampTix Attendance: Add sorting options to attendance UI.

Update the Attendance UI filters with the ability to sort Attendees by First
Name, Last Name and Order Date.

Also:

  • Assure defaults for model and filter settings (id was missing from model).
  • Fix console error about viewport tag using semicolons instead of commas.

Fixes #1097
Props dryanpress

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance.php

    r5531 r7472  
    7171
    7272    /**
    73      * Synchronize an attendee model.
     73     * Synchronize a single attendee model.
    7474     *
    7575     * Sets are removes the attended flag for a given camptix_id.
     
    114114
    115115        $query_args = array(
    116             'post_type' => 'tix_attendee',
    117             'post_status' => 'publish',
    118             'orderby' => 'title',
    119             'order' => 'ASC',
    120             'paged' => $paged,
     116            'post_type'      => 'tix_attendee',
     117            'post_status'    => 'publish',
     118            'orderby'        => 'title',
     119            'order'          => 'ASC',
     120            'paged'          => $paged,
    121121            'posts_per_page' => 50,
    122             'meta_query' => '',
     122            'meta_query'     => '',
    123123        );
     124
     125        /**
     126         * Sort Attendee Posts
     127         */
     128        if ( ! empty( $_REQUEST['camptix_filters']['sort'] ) ) {
     129            switch ( $_REQUEST['camptix_filters']['sort'] ) {
     130                case 'lastName':
     131                    $query_args['orderby']  = 'meta_value';
     132                    $query_args['meta_key'] = 'tix_last_name';
     133                    break;
     134                case 'orderDate':
     135                    $query_args['orderby'] = 'date';
     136                    $query_args['order']   = 'DESC';
     137                    break;
     138                case 'firstName':
     139                default:
     140                    // each $attendee->post_title is already First Lastname
     141                    break;
     142            }
     143
     144            unset( $_REQUEST['camptix_filters']['sort'] );
     145        }
    124146
    125147        $filters = array();
     
    174196
    175197        $first_name = get_post_meta( $attendee->ID, 'tix_first_name', true );
    176         $last_name = get_post_meta( $attendee->ID, 'tix_last_name', true );
     198        $last_name  = get_post_meta( $attendee->ID, 'tix_last_name', true );
    177199        $avatar_url = sprintf( 'https://secure.gravatar.com/avatar/%s?s=160', md5( get_post_meta( $attendee->ID, 'tix_email', true ) ) );
    178200        $avatar_url = add_query_arg( 'd', 'https://secure.gravatar.com/avatar/ad516503a11cd5ca435acc9bb6523536?s=160', $avatar_url );
     
    182204        return array(
    183205            'id' => $attendee->ID,
    184             'name' => sprintf( '%s %s', $first_name, $last_name ),
     206            'firstName' => $first_name,
     207            'lastName' => $last_name,
    185208            'avatar' => esc_url_raw( $avatar_url ),
    186209            'status' => $status,
     
    250273    public function setup_sections( $sections ) {
    251274        $sections['attendance-ui'] = esc_html__( 'Attendance UI', 'wordcamporg' );
     275
    252276        return $sections;
    253277    }
     
    314338
    315339    /**
    316      * Get CampTix Tickets
     340     * Get CampTix Tickets (not to be confused with Attendees)
    317341     *
    318342     * Returns an array of published tickets registered with CampTix.
Note: See TracChangeset for help on using the changeset viewer.