Changeset 7071
- Timestamp:
- 04/10/2018 12:50:17 AM (7 years ago)
- 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 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 -
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/allergy.php
r7040 r7071 18 18 const SLUG = 'allergy'; 19 19 20 public $question = ''; 21 22 public $options = array(); 23 20 24 /** 21 25 * Hook into WordPress and Camptix. 22 26 */ 23 27 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 24 35 // Registration field 25 36 add_action( 'camptix_attendee_form_after_questions', array( $this, 'render_registration_field' ), 11, 2 ); … … 33 44 add_action( 'camptix_form_edit_attendee_update_post_meta', array( $this, 'validate_save_ticket_info_field' ), 10, 2 ); 34 45 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 ); 35 49 } 36 50 … … 50 64 <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>"> 51 65 <td class="tix-required tix-left"> 52 <?php e sc_html_e( 'Do you have a life-threatening allergy that would affect your experience at WordCamp?', 'wordcamporg'); ?>66 <?php echo esc_html( $this->question ); ?> 53 67 <span class="tix-required-star">*</span> 54 68 </td> 55 69 56 70 <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 e sc_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> 58 72 <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 e sc_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> 60 74 </td> 61 75 </tr> … … 168 182 <tr class="tix-row-<?php echo esc_attr( self::SLUG ); ?>"> 169 183 <td class="tix-required tix-left"> 170 <?php e sc_html_e( 'Do you have a life-threatening allergy that would affect your experience at WordCamp?', 'wordcamporg'); ?>184 <?php echo esc_html( $this->question ); ?> 171 185 <span class="tix-required-star">*</span> 172 186 </td> 173 187 174 188 <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 e sc_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> 176 190 <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 e sc_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> 178 192 </td> 179 193 </tr> 180 194 181 195 <?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; 182 239 } 183 240 -
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/code-of-conduct.php
r7000 r7071 5 5 6 6 use CampTix_Plugin, CampTix_Addon; 7 use WP_Post; 7 8 8 9 /** … … 26 27 add_filter( 'camptix_form_register_complete_attendee_object', array( $this, 'populate_attendee_object' ), 10, 2 ); 27 28 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 ); 28 32 } 29 33 … … 132 136 133 137 /** 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 /** 134 178 * If the Code of Conduct page is still the same one created with the site, get its URL. 135 179 * -
sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/camptix-tweaks.php
r6944 r7071 31 31 add_filter( 'camptix_default_addons', __NAMESPACE__ . '\load_addons' ); 32 32 add_action( 'camptix_load_addons', __NAMESPACE__ . '\load_custom_addons', 11 ); 33 add_filter( 'camptix_metabox_questions_default_fields_list', __NAMESPACE__ . '\modify_default_fields_list' ); 33 34 add_filter( 'camptix_capabilities', __NAMESPACE__ . '\modify_capabilities' ); 34 35 add_filter( 'camptix_default_options', __NAMESPACE__ . '\modify_default_options' ); … … 557 558 558 559 /** 560 * Modify the list of default questions on the ticket registration form. 561 * 562 * @param string $default_fields 563 * 564 * @return string 565 */ 566 function 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 /** 559 571 * Modify CampTix's default capabilities 560 572 */
Note: See TracChangeset
for help on using the changeset viewer.