Changeset 7253 for sites/trunk/wordcamp.org/public_html/wp-content/mu-plugins/camptix-tweaks/addons/accommodations.php
- Timestamp:
- 05/31/2018 12:38: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
r7228 r7253 20 20 const SLUG = 'accommodations'; 21 21 22 public $label = ''; 23 22 24 public $question = ''; 23 25 … … 28 30 */ 29 31 public function camptix_init() { 32 $this->label = __( 'Accessibility needs', 'wordcamporg' ); 33 30 34 $this->question = __( 'Do you have any accessibility needs, such as a sign language interpreter or wheelchair access, to participate in WordCamp?', 'wordcamporg' ); 31 35 … … 49 53 // Metabox 50 54 add_filter( 'camptix_metabox_attendee_info_additional_rows', array( $this, 'add_metabox_row' ), 12, 2 ); 55 56 // Reporting 57 add_filter( 'camptix_summary_fields', array( $this, 'add_summary_field' ) ); 58 add_action( 'camptix_summarize_by_' . self::SLUG, array( $this, 'summarize' ), 10, 2 ); 59 add_filter( 'camptix_attendee_report_extra_columns', array( $this, 'add_export_column' ) ); 60 add_filter( 'camptix_attendee_report_column_value_' . self::SLUG, array( $this, 'add_export_column_value' ), 10, 2 ); 51 61 52 62 // Privacy … … 343 353 344 354 /** 355 * Add an option to the `Summarize by` dropdown. 356 * 357 * @param array $fields 358 * 359 * @return array 360 */ 361 public function add_summary_field( $fields ) { 362 $fields[ self::SLUG ] = $this->label; 363 364 return $fields; 365 } 366 367 /** 368 * Callback to summarize the answers for this field. 369 * 370 * @param array $summary 371 * @param WP_Post $attendee 372 */ 373 public function summarize( &$summary, $attendee ) { 374 /** @var $camptix CampTix_Plugin */ 375 global $camptix; 376 377 $answer = get_post_meta( $attendee->ID, 'tix_' . self::SLUG, true ); 378 379 if ( isset( $this->options[ $answer ] ) ) { 380 $camptix->increment_summary( $summary, $this->options[ $answer ] ); 381 } else { 382 $camptix->increment_summary( $summary, __( 'No answer', 'wordcamporg' ) ); 383 } 384 } 385 386 /** 387 * Add a column to the CSV export. 388 * 389 * @param array $columns 390 * 391 * @return array 392 */ 393 public function add_export_column( $columns ) { 394 $columns[ self::SLUG ] = $this->label; 395 396 return $columns; 397 } 398 399 /** 400 * Add the human-readable value of the field to the CSV export. 401 * 402 * @param string $value 403 * @param WP_Post $attendee 404 * 405 * @return string 406 */ 407 public function add_export_column_value( $value, $attendee ) { 408 $value = get_post_meta( $attendee->ID, 'tix_' . self::SLUG, true ); 409 410 if ( isset( $this->options[ $value ] ) ) { 411 return $this->options[ $value ]; 412 } 413 414 return ''; 415 } 416 417 /** 345 418 * Include the new field in the personal data exporter. 346 419 *
Note: See TracChangeset
for help on using the changeset viewer.