Making WordPress.org

Changeset 4360


Ignore:
Timestamp:
11/15/2016 07:51:09 PM (10 years ago)
Author:
iandunn
Message:

CampTix Badge Generator: Add options to reduce the attendees being fetched.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/common.php

    r4358 r4360  
    6666 * Get the attendees
    6767 *
     68 * @param string|array $ticket_ids        Reduce fetched attendees by the ticket they purchased. The string 'all'
     69 *                                        will result in all attendees being fetched, regardless of their
     70 *                                        ticket. An array of ticket IDs will result in only the attendees for
     71 *                                        those tickets being fetched.
     72 * @param string $registered_after        Reduce fetched attendees by their registration date. Any value parseable
     73 *                                        by strtotime().
     74 *
     75 * @todo Maybe optimize this by looking at post_date rather than tix_timestamp
     76 *
    6877 * @return array
    6978 */
    70 function get_attendees() {
    71         $attendees = get_posts( array(
     79function get_attendees( $ticket_ids = 'all', $registered_after = '' ) {
     80        $params = array(
    7281                'post_type'      => 'tix_attendee',
    7382                'posts_per_page' => 12000,
     83                'order'          => 'ASC',
    7484                'orderby'        => 'title',
    75         ) );
     85                'meta_query'     => array(),
     86        );
     87
     88        if ( 'all' !== $ticket_ids ) {
     89                $params['meta_query'][] = array(
     90                        'key'     => 'tix_ticket_id',
     91                        'value'   => $ticket_ids,
     92                        'compare' => 'IN',
     93                );
     94        }
     95
     96        if ( ! empty( $registered_after ) ) {
     97                $params['meta_query'][] = array(
     98                        'key'     => 'tix_timestamp',
     99                        'value'   => strtotime( $registered_after ),
     100                        'compare' => '>=',
     101                );
     102        }
     103
     104        $attendees = get_posts( $params );
    76105
    77106        return $attendees;
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/html-badges.php

    r4316 r4360  
    214214        );
    215215
    216         $attendees = Badge_Generator\get_attendees();
     216        $attendees = Badge_Generator\get_attendees( 'all' );
    217217
    218218        require( dirname( __DIR__ ) . '/views/html-badges/template-badges.php' );
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-badge-generator/includes/indesign-badges.php

    r4359 r4360  
    2525/**
    2626 * Build the badge assets for InDesign
    27  */
    28 function build_assets() {
     27 *
     28 * @param array $options
     29 */
     30function build_assets( $options ) {
     31        $options = shortcode_atts(
     32                array(
     33                        'ticket_ids'       => 'all',
     34                        'registered_after' => ''
     35                ),
     36                $options
     37        );
     38
    2939        try {
    3040                // Security: assets are intentionally saved to a folder outside the web root. See serve_zip_file() for details.
    … …  
    3444                $zip_filename     = get_zip_filename( $assets_folder );
    3545                $zip_local_folder = pathinfo( $zip_filename, PATHINFO_FILENAME );
    36                 $attendees        = Badge_Generator\get_attendees();
     46                $attendees        = Badge_Generator\get_attendees( $options['ticket_ids'], $options['registered_after'] );
    3747
    3848                wp_mkdir_p( $gravatar_folder );
Note: See TracChangeset for help on using the changeset viewer.