Making WordPress.org

Changeset 4363


Ignore:
Timestamp:
11/15/2016 08:49:18 PM (10 years ago)
Author:
iandunn
Message:

CampTix Badge Generator: Convert multiple choice answers to a string in CSV

If they're left as arrays, then Array will be printed to the CSV instead of the actual values.

File:
1 edited

Legend:

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

    r4362 r4363  
    254254
    255255        foreach ( $questions as $question ) {
    256                 $row[ "question-{$question->ID}" ] = isset( $answers[ $question->ID ] ) ? $answers[ $question->ID ] : '';
     256                $row[ "question-{$question->ID}" ] = get_answer( $question, $answers );
    257257        }
    258258
     
    325325
    326326/**
     327 * Get an attendee's answer to a question
     328 *
     329 * @param \WP_Post $question
     330 * @param array    $answers
     331 *
     332 * @return string
     333 */
     334function get_answer( $question, $answers ) {
     335        if ( ! isset( $answers[ $question->ID ] ) ) {
     336                return '';
     337        }
     338
     339        $answer = $answers[ $question->ID ];
     340
     341        if ( is_array( $answer ) ) {
     342                $answer = implode( ', ', $answer );
     343        }
     344
     345        return $answer;
     346}
     347
     348/**
    327349 * Create a Zip file with all of the assets
    328350 *
Note: See TracChangeset for help on using the changeset viewer.