Making WordPress.org

Changeset 7071


Ignore:
Timestamp:
04/10/2018 12:50:17 AM (7 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.
Location:
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks
Files:
4 edited

Legend:

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

    r7040 r7071  
    1313 * Add a non-optional attendee field indicating if they require special accommodations.
    1414 *
     15 * Note that the user-facing wording has been changed to "accessibility needs" to avoid confusion for attendees and translators.
     16 *
    1517 * @package WordCamp\CampTix_Tweaks
    1618 */
     
    1820    const SLUG = 'accommodations';
    1921
     22    public $question = '';
     23
     24    public $options = array();
     25
    2026    /**
    2127     * Hook into WordPress and Camptix.
    2228     */
    2329    public function camptix_init() {
     30        $this->question = __( 'Do you have any accessibility needs, such as a sign language interpreter or wheelchair access, to participate in WordCamp?', 'wordcamporg' );
     31
     32        $this->options = array(
     33            'yes' => _x( 'Yes (we will contact you)', 'ticket registration option', 'wordcamporg' ),
     34            'no'  => _x( 'No', 'ticket registration option', 'wordcamporg' ),
     35        );
     36
    2437        // Registration field
    2538        add_action( 'camptix_attendee_form_after_questions', array( $this, 'render_registration_field' ), 12, 2 );
     
    3346        add_action( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'validate_save_ticket_info_field' ), 10, 2 );
    3447        add_action( 'camptix_form_edit_attendee_after_questions', array( $this, 'render_ticket_info_field' ), 12 );
     48
     49        // Metabox
     50        add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 12, 2 );
    3551    }
    3652
     
    5066        <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>">
    5167            <td class="tix-required tix-left">
    52                 <?php esc_html_e( 'Do you require special accommodations, such as a sign language interpreter or wheelchair access, to participate in WordCamp?', 'wordcamporg' ); ?>
     68                <?php echo esc_html( $this->question ); ?>
    5369                <span class="tix-required-star">*</span>
    5470            </td>
     
    168184        <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>">
    169185            <td class="tix-required tix-left">
    170                 <?php esc_html_e( 'Do you require special accommodations, such as a sign language interpreter or wheelchair access, to participate in WordCamp?', 'wordcamporg' ); ?>
     186                <?php echo esc_html( $this->question ); ?>
    171187                <span class="tix-required-star">*</span>
    172188            </td>
     
    180196
    181197        <?php
     198    }
     199
     200    /**
     201     * Add a row to the Attendee Info metabox table for the new field and value.
     202     *
     203     * @param array   $rows
     204     * @param WP_Post $post
     205     *
     206     * @return mixed
     207     */
     208    public function add_metabox_row( $rows, $post ) {
     209        $value = get_post_meta( $post->ID, 'tix_' . self::SLUG, true ) ?: '';
     210        if ( $value && isset( $this->options[ $value ] ) ) {
     211            $value = $this->options[ $value ];
     212        }
     213        $new_row = array( $this->question, esc_html( $value ) );
     214
     215        add_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
     216
     217        $ticket_row = array_filter( $rows, function( $row ) {
     218            if ( 'Ticket' === $row[0] ) {
     219                return true;
     220            }
     221
     222            return false;
     223        } );
     224
     225        remove_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
     226
     227        if ( ! empty( $ticket_row ) ) {
     228            $ticket_row_key = key( $ticket_row );
     229            $row_indexes    = array_keys( $rows );
     230            $position       = array_search( $ticket_row_key, $row_indexes );
     231
     232            $slice = array_slice( $rows, $position );
     233
     234            array_unshift( $slice, $new_row );
     235            array_splice( $rows, $position, count( $rows ), $slice );
     236        } else {
     237            $rows[] = $new_row;
     238        }
     239
     240        return $rows;
    182241    }
    183242
  • 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
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/code-of-conduct.php

    r7000 r7071  
    55
    66use CampTix_Plugin, CampTix_Addon;
     7use WP_Post;
    78
    89/**
     
    2627        add_filter( 'camptix_form_register_complete_attendee_object', array( $this, 'populate_attendee_object' ), 10, 2 );
    2728        add_action( 'camptix_checkout_update_post_meta', array( $this, 'save_registration_field' ), 10, 2 );
     29
     30        // Metabox
     31        add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 15, 2 );
    2832    }
    2933
     
    132136
    133137    /**
     138     * Add a row to the Attendee Info metabox table for the new field and value.
     139     *
     140     * @param array   $rows
     141     * @param WP_Post $post
     142     *
     143     * @return mixed
     144     */
     145    public function add_metabox_row( $rows, $post ) {
     146        $value = get_post_meta( $post->ID, 'tix_' . self::SLUG, true ) ? __( 'Yes', 'wordcamporg' ) : '';
     147        $new_row = array( __( 'Do you agree to follow the event Code of Conduct?', 'camptix' ), esc_html( $value ) );
     148
     149        add_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
     150
     151        $ticket_row = array_filter( $rows, function( $row ) {
     152            if ( 'Ticket' === $row[0] ) {
     153                return true;
     154            }
     155
     156            return false;
     157        } );
     158
     159        remove_filter( 'locale', array( $this, 'set_locale_to_en_US' ) );
     160
     161        if ( ! empty( $ticket_row ) ) {
     162            $ticket_row_key = key( $ticket_row );
     163            $row_indexes    = array_keys( $rows );
     164            $position       = array_search( $ticket_row_key, $row_indexes );
     165
     166            $slice = array_slice( $rows, $position );
     167
     168            array_unshift( $slice, $new_row );
     169            array_splice( $rows, $position, count( $rows ), $slice );
     170        } else {
     171            $rows[] = $new_row;
     172        }
     173
     174        return $rows;
     175    }
     176
     177    /**
    134178     * If the Code of Conduct page is still the same one created with the site, get its URL.
    135179     *
  • sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php

    r6944 r7071  
    3131add_filter( 'camptix_default_addons',                        __NAMESPACE__ . '\load_addons'                         );
    3232add_action( 'camptix_load_addons',                           __NAMESPACE__ . '\load_custom_addons',              11 );
     33add_filter( 'camptix_metabox_questions_default_fields_list', __NAMESPACE__ . '\modify_default_fields_list'          );
    3334add_filter( 'camptix_capabilities',                          __NAMESPACE__ . '\modify_capabilities'                 );
    3435add_filter( 'camptix_default_options',                       __NAMESPACE__ . '\modify_default_options'              );
     
    557558
    558559/**
     560 * Modify the list of default questions on the ticket registration form.
     561 *
     562 * @param string $default_fields
     563 *
     564 * @return string
     565 */
     566function modify_default_fields_list( $default_fields ) {
     567    return __( 'Top three fields: First name, last name, e-mail address.<br />Bottom three fields: Life-threatening allergy, accessibility needs, Code of Conduct agreement.', 'wordcamporg' );
     568}
     569
     570/**
    559571 * Modify CampTix's default capabilities
    560572 */
Note: See TracChangeset for help on using the changeset viewer.