Ticket #558: patch_558_meta.diff
File patch_558_meta.diff, 6.5 KB (added by , 10 years ago) |
---|
-
addons/field-country.php
1 <?php 2 /** 3 * Country Field Addon for CampTix 4 * 5 * @see field-twitter.php 6 */ 7 class CampTix_Addon_Country_Field extends CampTix_Addon { 8 9 /** 10 * Runs during camptix_init, @see CampTix_Addon 11 */ 12 function camptix_init() { 13 global $camptix; 14 add_filter( 'camptix_question_field_types', array( $this, 'question_field_types' ) ); 15 add_action( 'camptix_attendees_shortcode_init', array( $this, 'attendees_shortcode_init' ) ); 16 add_action( 'camptix_question_field_country', array( $camptix, 'question_field_country' ), 10, 3 ); 17 add_action( 'camptix_attendees_shortcode_item', array( $this, 'attendees_shortcode_item' ), 10, 1 ); 18 } 19 20 function question_field_types( $types ) { 21 return array_merge( $types, array( 22 'country' => 'Country', 23 ) ); 24 } 25 26 27 function attendees_shortcode_init() { 28 global $camptix; 29 $this->questions = $camptix->get_all_questions(); 30 } 31 32 function attendees_shortcode_item( $attendee_id ) { 33 foreach ( $this->questions as $question ) { 34 if ( get_post_meta( $question->ID, 'tix_type', true ) != 'country' ) 35 continue; 36 37 $answers = (array) get_post_meta( $attendee_id, 'tix_questions', true ); 38 if ( ! isset( $answers[ $question->ID ] ) ) 39 continue; 40 41 $country = esc_html( trim( $answers[ $question->ID ] ) ); 42 // echo $country; 43 if ( $country ) { 44 45 printf( '<span class="tix-field tix-attendee-country">%s</span>', $country ); 46 } 47 } 48 } 49 } 50 51 // Register this class as a CampTix Addon. 52 camptix_register_addon( 'CampTix_Addon_Country_Field' ); -
admin.js
186 186 var value = this.$type.val(); 187 187 var $row = this.$( '.tix-add-question-values-row' ); 188 188 189 if ( value && value.match( /radio|checkbox|select/ ) ) 189 if ( value && value.match( /radio|checkbox|select|country/ ) ) { 190 190 191 $row.show(); 192 193 if ( value === 'country' ) { 194 var $all_countries = "Afghanistan ,Albania ,Algeria ,American Samoa ,Andorra ,Angola ,Anguilla ,Antigua & Barbuda ,Argentina ,Armenia ,Aruba ,Australia ,Austria ,Azerbaijan ,Bahamas,The ,Bahrain ,Bangladesh ,Barbados ,Belarus ,Belgium ,Belize ,Benin ,Bermuda ,Bhutan ,Bolivia ,Bosnia & Herzegovina ,Botswana ,Brazil ,British Virgin Is. ,Brunei ,Bulgaria ,Burkina Faso ,Burma ,Burundi ,Cambodia ,Cameroon ,Canada ,Cape Verde ,Cayman Islands ,Central African Rep. ,Chad ,Chile ,China ,Colombia ,Comoros ,Congo,Dem. Rep. ,Congo,Repub. of the ,Cook Islands ,Costa Rica ,Cote d'Ivoire ,Croatia ,Cuba ,Cyprus ,Czech Republic ,Denmark ,Djibouti ,Dominica ,Dominican Republic ,East Timor ,Ecuador ,Egypt ,El Salvador ,Equatorial Guinea ,Eritrea ,Estonia ,Ethiopia ,Faroe Islands ,Fiji ,Finland ,France ,French Guiana ,French Polynesia ,Gabon ,Gambia,The ,Gaza Strip ,Georgia ,Germany ,Ghana ,Gibraltar ,Greece ,Greenland ,Grenada ,Guadeloupe ,Guam ,Guatemala ,Guernsey ,Guinea ,Guinea-Bissau ,Guyana ,Haiti ,Honduras ,Hong Kong ,Hungary ,Iceland ,India ,Indonesia ,Iran ,Iraq ,Ireland ,Isle of Man ,Israel ,Italy ,Jamaica ,Japan ,Jersey ,Jordan ,Kazakhstan ,Kenya ,Kiribati ,Korea,North ,Korea,South ,Kuwait ,Kyrgyzstan ,Laos ,Latvia ,Lebanon ,Lesotho ,Liberia ,Libya ,Liechtenstein ,Lithuania ,Luxembourg ,Macau ,Macedonia ,Madagascar ,Malawi ,Malaysia ,Maldives ,Mali ,Malta ,Marshall Islands ,Martinique ,Mauritania ,Mauritius ,Mayotte ,Mexico ,Micronesia,Fed. St. ,Moldova ,Monaco ,Mongolia ,Montserrat ,Morocco ,Mozambique ,Namibia ,Nauru ,Nepal ,Netherlands ,Netherlands Antilles ,New Caledonia ,New Zealand ,Nicaragua ,Niger ,Nigeria ,N. Mariana Islands ,Norway ,Oman ,Pakistan ,Palau ,Panama ,Papua New Guinea ,Paraguay ,Peru ,Philippines ,Poland ,Portugal ,Puerto Rico ,Qatar ,Reunion ,Romania ,Russia ,Rwanda ,Saint Helena ,Saint Kitts & Nevis ,Saint Lucia ,St Pierre & Miquelon ,Saint Vincent and the Grenadines ,Samoa ,San Marino ,Sao Tome & Principe ,Saudi Arabia ,Senegal ,Serbia ,Seychelles ,Sierra Leone ,Singapore ,Slovakia ,Slovenia ,Solomon Islands ,Somalia ,South Africa ,Spain ,Sri Lanka ,Sudan ,Suriname ,Swaziland ,Sweden ,Switzerland ,Syria ,Taiwan ,Tajikistan ,Tanzania ,Thailand ,Togo ,Tonga ,Trinidad & Tobago ,Tunisia ,Turkey ,Turkmenistan ,Turks & Caicos Is ,Tuvalu ,Uganda ,Ukraine ,United Arab Emirates ,United Kingdom ,United States ,Uruguay ,Uzbekistan ,Vanuatu ,Venezuela ,Vietnam ,Virgin Islands ,Wallis and Futuna ,West Bank ,Western Sahara ,Yemen ,Zambia ,Zimbabwe"; 195 196 this.$( '#tix-add-question-values' ).val( $all_countries ); 197 198 this.$( '#tix-add-question-values' ).prop("readOnly","true"); 199 200 } 201 } 191 202 else 192 203 $row.hide(); 193 204 -
camptix.php
3568 3568 'select' => __( 'Dropdown select', 'camptix' ), 3569 3569 'radio' => __( 'Radio select', 'camptix' ), 3570 3570 'checkbox' => __( 'Checkbox', 'camptix' ), 3571 'country' => __( 'Country' , 'camptix' ), 3571 3572 ) ); 3572 3573 } 3573 3574 … … 3606 3607 } 3607 3608 3608 3609 /** 3610 * A drop-down Country Select for a question. 3611 */ 3612 function question_field_country( $name, $user_value, $question ) { 3613 $values = get_post_meta( $question->ID, 'tix_values', true ); 3614 ?> 3615 <select name="<?php echo esc_attr( $name ); ?>" /> 3616 <?php foreach ( (array) $values as $question_value ) : ?> 3617 <option <?php selected( $question_value, $user_value ); ?> value="<?php echo esc_attr( $question_value ); ?>"><?php echo esc_html( $question_value ); ?></option> 3618 <?php endforeach; ?> 3619 </select> 3620 <?php 3621 } 3622 3623 /** 3609 3624 * A single or multiple checkbox for a question. 3610 3625 */ 3611 3626 function question_field_checkbox( $name, $user_value, $question ) { … … 3621 3636 <?php 3622 3637 } 3623 3638 3639 3624 3640 /** 3625 3641 * A textarea input for questions. 3626 3642 */ … … 6914 6930 $default_addons = apply_filters( 'camptix_default_addons', array( 6915 6931 'field-twitter' => $this->get_default_addon_path( 'field-twitter.php' ), 6916 6932 'field-url' => $this->get_default_addon_path( 'field-url.php' ), 6933 'field-country' => $this->get_default_addon_path( 'field-country.php' ), 6917 6934 'shortcodes' => $this->get_default_addon_path( 'shortcodes.php' ), 6918 6935 'payment-paypal' => $this->get_default_addon_path( 'payment-paypal.php' ), 6919 6936 'logging-meta' => $this->get_default_addon_path( 'logging-meta.php' ),