Making WordPress.org

Changeset 8605


Ignore:
Timestamp:
04/08/2019 04:39:52 AM (7 years ago)
Author:
dd32
Message:

WordCamp Attendance UI: Allow organisers to select additional Ticket Questions to be shown on the Check in UI.

For example, This allows a WordCamp to show the answer to the 'T Shirt Size' question to help the registration team find the correct swag for the attendee.

This also includes any Attendee Flags set (eg 'Speaker' or 'Food Allergy') to help the registration team find badges or give them any extra relevant information required.

Screenshot example: https://cloudup.com/ckqnh2PVeI8

See https://github.com/WordPress/wordcamp.org/pull/61.

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins
Files:
6 edited

Legend:

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

    r8309 r8605  
    6464        add_filter( 'shortcode_atts_camptix_attendees', array( $this, 'shortcode_attendees_atts' ), 10, 3 );
    6565        add_filter( 'camptix_attendees_shortcode_query_args', array( $this, 'shortcode_attendees_query' ), 10, 2 );
     66
     67        // Add the Flags to the Attendance UI.
     68        add_filter( 'camptix_attendance_ui_extras', array( $this, 'attendance_ui_extras' ), 10, 2 );
    6669    }
    6770
     
    410413        );
    411414    }
     415
     416    /**
     417     * Register Admin flags to be shown in the Attendance UI.
     418     *
     419     * @param array   $extras   List of 'Extra fields' to show.
     420     * @param WP_Post $attendee The Attendee WP_Post being displayed.
     421     */
     422    public function attendance_ui_extras( $extras, $attendee ) {
     423        $attendee_flags = (array) get_post_meta( $attendee->ID, 'camptix-admin-flag' );
     424
     425        $flags = array();
     426        foreach ( $attendee_flags as $flag ) {
     427            if ( isset( $this->flags[ $flag ] ) ) {
     428                $flags[] = $this->flags[ $flag ];
     429            }
     430        }
     431
     432        if ( $flags ) {
     433            array_unshift(
     434                $extras,
     435                array( implode( ', ', $flags ) )
     436            );
     437        }
     438
     439        return $extras;
     440    }
     441
    412442
    413443    /**
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/assets/attendance-ui.css

    r1690 r8605  
    293293    display: block;
    294294    width: 200px;
    295     margin: 40px auto 0 auto; }
     295    margin: 40px auto 40px auto; }
    296296  .attendee-toggle-wrap a.yes,
    297297  .attendee-toggle-wrap a.no {
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/assets/attendance-ui.js

    r7472 r8605  
    2020                avatar: '',
    2121                firstName: '',
    22                 lastName: ''
     22                lastName: '',
     23                extras: []
    2324            }
    2425        },
     
    177178            this.$el.addClass( 'camptix-loading' );
    178179        },
    179        
     180
    180181        /**
    181182         * Hide the spinner.
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/assets/attendance-ui.scss

    r1690 r8605  
    373373        display: block;
    374374        width: 200px;
    375         margin: 40px auto 0 auto;
     375        margin: 40px auto 40px auto;
    376376    }
    377377
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance-ui.php

    r7472 r8605  
    4444            <a href="#" class="yes">Yes</a>
    4545            <a href="#" class="no">No</a>
     46        </div>
     47
     48        <div class="extras">
     49             <# for ( var i in data.extras ) {
     50                var item = data.extras[i];
     51                if ( item.length > 1 ) { #>
     52                    <strong>{{ item[0] }}:</strong> {{ item[1] }}<br>
     53                <# } else { #>
     54                    {{ item[0] }}<br>
     55                <# } #>
     56             <# } #>
    4657        </div>
    4758
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/camptix-attendance/addons/attendance.php

    r7472 r8605  
    44 */
    55class CampTix_Attendance extends CampTix_Addon {
     6    public $secret    = '';
     7    public $questions = array();
    68    /**
    79     * Runs during CampTix init.
     
    2224
    2325        $this->secret = $camptix_options['attendance-secret'];
     26
     27        if ( isset( $camptix_options['attendance-questions'] ) ) {
     28            $this->questions = $camptix_options['attendance-questions'];
     29        }
    2430
    2531        if ( empty( $camptix_options['attendance-enabled'] ) )
     
    202208        $status = (bool) get_post_meta( $attendee->ID, 'tix_attended', true );
    203209
     210        $extras = array();
     211
     212        // By default, allow certain questions to be included.
     213        $questions = get_post_meta( $attendee->ID, 'tix_questions', true );
     214        foreach ( $this->questions as $question_id ) {
     215            if ( ! isset( $questions[ $question_id ] ) ) {
     216                continue;
     217            }
     218
     219            $question_post = get_post( $question_id );
     220            $extras[] = [
     221                html_entity_decode( apply_filters( 'the_title', $question_post->post_title ) ), // Escaped on display
     222                // The attendees selection, which may be an array.
     223                is_array( $questions[ $question_id ] ) ? implode( ', ', $questions[ $question_id ] ) : $questions[ $question_id ],
     224            ];
     225        }
     226
     227        /**
     228         * Allow other plugins/Camptix Addons to register extra fields.
     229         */
     230        $extras = apply_filters( 'camptix_attendance_ui_extras', $extras, $attendee );
     231
    204232        return array(
    205             'id' => $attendee->ID,
     233            'id'        => $attendee->ID,
    206234            'firstName' => $first_name,
    207             'lastName' => $last_name,
    208             'avatar' => esc_url_raw( $avatar_url ),
    209             'status' => $status,
     235            'lastName'  => $last_name,
     236            'avatar'    => esc_url_raw( $avatar_url ),
     237            'status'    => $status,
     238            'extras'    => $extras,
    210239        );
    211240    }
     
    292321            esc_html__( "Don't forget to disable the UI after the event is over.", 'wordcamporg' )
    293322        );
     323
     324        add_settings_field( 'attendance-questions', esc_html__( 'Questions', 'wordcamporg' ), array( $this, 'field_questions' ), 'camptix_options', 'general', esc_html__( 'Show these additional ticket questions in the UI.', 'wordcamporg' ) );
    294325
    295326        add_settings_field( 'attendance-secret', esc_html__( 'Secret Link', 'wordcamporg' ), array( $this, 'field_secret' ), 'camptix_options', 'general' );
     
    314345
    315346    /**
     347     * Ticket Questions Field
     348     *
     349     * This is a field that allows selection of any of the Ticket Questions specified
     350     * to be output into the Attendance UI.
     351     */
     352    public function field_questions() {
     353        global $camptix;
     354        $questions = $camptix->get_all_questions();
     355
     356        echo '<p>' . esc_html__( 'Show the following ticket questions in the Attendance UI.', 'wordcamporg' ) . '</p>';
     357
     358        foreach ( $questions as $question ) {
     359            $selections = get_post_meta( $question->ID, 'tix_values', true );
     360            printf(
     361                '<label><input type="checkbox" name="camptix_options[attendance-questions][]" value="%s" %s> %s %s</label><br>',
     362                esc_attr( $question->ID ),
     363                checked( in_array( $question->ID, $this->questions, true ), true, false ),
     364                esc_html( apply_filters( 'the_title', $question->post_title ) ),
     365                $selections ? '<em>' . esc_html( implode( ', ', $selections ) ) . '</em>' : ''
     366            );
     367        }
     368
     369    }
     370
     371    /**
    316372     * Setup section description.
    317373     */
     
    333389        if ( ! empty( $input['attendance-generate'] ) )
    334390            $output['attendance-secret'] = wp_generate_password( 32, false, false );
     391
     392        if ( ! empty( $input['attendance-questions'] ) ) {
     393            $output['attendance-questions'] = array_map( 'intval', $input['attendance-questions'] );
     394        } elseif ( isset( $input['attendance-enabled'] ) ) {
     395            $output['attendance-questions'] = array();
     396        }
    335397
    336398        return $output;
Note: See TracChangeset for help on using the changeset viewer.