Changeset 7071 for sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php
- Timestamp:
- 04/10/2018 12:50:17 AM (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php
r7040 r7071 13 13 * Add a non-optional attendee field indicating if they require special accommodations. 14 14 * 15 * Note that the user-facing wording has been changed to "accessibility needs" to avoid confusion for attendees and translators. 16 * 15 17 * @package WordCamp\CampTix_Tweaks 16 18 */ … … 18 20 const SLUG = 'accommodations'; 19 21 22 public $question = ''; 23 24 public $options = array(); 25 20 26 /** 21 27 * Hook into WordPress and Camptix. 22 28 */ 23 29 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 24 37 // Registration field 25 38 add_action( 'camptix_attendee_form_after_questions', array( $this, 'render_registration_field' ), 12, 2 ); … … 33 46 add_action( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'validate_save_ticket_info_field' ), 10, 2 ); 34 47 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 ); 35 51 } 36 52 … … 50 66 <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>"> 51 67 <td class="tix-required tix-left"> 52 <?php e sc_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 ); ?> 53 69 <span class="tix-required-star">*</span> 54 70 </td> … … 168 184 <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>"> 169 185 <td class="tix-required tix-left"> 170 <?php e sc_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 ); ?> 171 187 <span class="tix-required-star">*</span> 172 188 </td> … … 180 196 181 197 <?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; 182 241 } 183 242
Note: See TracChangeset
for help on using the changeset viewer.