Making WordPress.org


Ignore:
Timestamp:
04/10/2018 12:50:17 AM (8 years ago)
Author:
coreymckrill
Message:

WordCamp tickets: Wording changes, add rows to Attendee Info table

  • Change the wording from "special accommodations" to "accessibility needs" to avoid confusion. Some interpret "accommodations" as referring to lodging.
  • Add the answers to the allergy, accessibility, and Code of Conduct questions to the Attendee Info metabox table.
  • Add the allergy, accessibility, and Code of Conduct fields to the list of default fields in the Questions metabox.
File:
1 edited

Legend:

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

    r7040 r7071  
    1818    const SLUG = 'allergy';
    1919
     20    public $question = '';
     21
     22    public $options = array();
     23
    2024    /**
    2125     * Hook into WordPress and Camptix.
    2226     */
    2327    public function camptix_init() {
     28        $this->question = __( 'Do you have a life-threatening allergy that would affect your experience at WordCamp?', 'wordcamporg' );
     29
     30        $this->options = array(
     31            'yes' => _x( 'Yes (we will contact you)', 'ticket registration option', 'wordcamporg' ),
     32            'no'  => _x( 'No', 'ticket registration option', 'wordcamporg' ),
     33        );
     34
    2435        // Registration field
    2536        add_action( 'camptix_attendee_form_after_questions', array( $this, 'render_registration_field' ), 11, 2 );
     
    3344        add_action( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'validate_save_ticket_info_field' ), 10, 2 );
    3445        add_action( 'camptix_form_edit_attendee_after_questions', array( $this, 'render_ticket_info_field' ), 11 );
     46
     47        // Metabox
     48        add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 11, 2 );
    3549    }
    3650
     
    5064        <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>">
    5165            <td class="tix-required tix-left">
    52                 <?php esc_html_e( 'Do you have a life-threatening allergy that would affect your experience at WordCamp?', 'wordcamporg' ); ?>
     66                <?php echo esc_html( $this->question ); ?>
    5367                <span class="tix-required-star">*</span>
    5468            </td>
    5569
    5670            <td class="tix-right">
    57                 <label><input name="tix_attendee_info[<?php echo esc_attr( $i ); ?>][<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="yes" <?php checked( 'yes', $current_data[ self::SLUG ] ); ?> /> <?php esc_html( _ex( 'Yes (we will contact you)', 'ticket registration option', 'wordcamporg' ) ); ?></label>
     71                <label><input name="tix_attendee_info[<?php echo esc_attr( $i ); ?>][<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="yes" <?php checked( 'yes', $current_data[ self::SLUG ] ); ?> /> <?php echo esc_html( $this->options['yes'] ); ?></label>
    5872                <br />
    59                 <label><input name="tix_attendee_info[<?php echo esc_attr( $i ); ?>][<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="no" <?php checked( 'no', $current_data[ self::SLUG ] ); ?> /> <?php esc_html( _ex( 'No', 'ticket registration option', 'wordcamporg' ) ); ?></label>
     73                <label><input name="tix_attendee_info[<?php echo esc_attr( $i ); ?>][<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="no" <?php checked( 'no', $current_data[ self::SLUG ] ); ?> /> <?php echo esc_html( $this->options['no'] ); ?></label>
    6074            </td>
    6175        </tr>
     
    168182        <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>">
    169183            <td class="tix-required tix-left">
    170                 <?php esc_html_e( 'Do you have a life-threatening allergy that would affect your experience at WordCamp?', 'wordcamporg' ); ?>
     184                <?php echo esc_html( $this->question ); ?>
    171185                <span class="tix-required-star">*</span>
    172186            </td>
    173187
    174188            <td class="tix-right">
    175                 <label><input name="tix_ticket_info[<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="yes" <?php checked( 'yes', $current_data[ self::SLUG ] ); ?> /> <?php esc_html( _ex( 'Yes (we will contact you)', 'ticket registration option', 'wordcamporg' ) ); ?></label>
     189                <label><input name="tix_ticket_info[<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="yes" <?php checked( 'yes', $current_data[ self::SLUG ] ); ?> /> <?php echo esc_html( $this->options['yes'] ); ?></label>
    176190                <br />
    177                 <label><input name="tix_ticket_info[<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="no" <?php checked( 'no', $current_data[ self::SLUG ] ); ?> /> <?php esc_html( _ex( 'No', 'ticket registration option', 'wordcamporg' ) ); ?></label>
     191                <label><input name="tix_ticket_info[<?php echo esc_attr( self::SLUG ); ?>]" type="radio" value="no" <?php checked( 'no', $current_data[ self::SLUG ] ); ?> /> <?php echo esc_html( $this->options['no'] ); ?></label>
    178192            </td>
    179193        </tr>
    180194
    181195        <?php
     196    }
     197
     198    /**
     199     * Add a row to the Attendee Info metabox table for the new field and value.
     200     *
     201     * @param array   $rows
     202     * @param WP_Post $post
     203     *
     204     * @return mixed
     205     */
     206    public function add_metabox_row( $rows, $post ) {
     207        $value = get_post_meta( $post->ID, 'tix_' . self::SLUG, true ) ?: '';
     208        if ( $value && isset( $this->options[ $value ] ) ) {
     209            $value = $this->options[ $value ];
     210        }
     211        $new_row = array( $this->question, esc_html( $value ) );
     212
     213        add_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
     214
     215        $ticket_row = array_filter( $rows, function( $row ) {
     216            if ( 'Ticket' === $row[0] ) {
     217                return true;
     218            }
     219
     220            return false;
     221        } );
     222
     223        remove_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
     224
     225        if ( ! empty( $ticket_row ) ) {
     226            $ticket_row_key = key( $ticket_row );
     227            $row_indexes    = array_keys( $rows );
     228            $position       = array_search( $ticket_row_key, $row_indexes );
     229
     230            $slice = array_slice( $rows, $position );
     231
     232            array_unshift( $slice, $new_row );
     233            array_splice( $rows, $position, count( $rows ), $slice );
     234        } else {
     235            $rows[] = $new_row;
     236        }
     237
     238        return $rows;
    182239    }
    183240
Note: See TracChangeset for help on using the changeset viewer.