Making WordPress.org

Changeset 5575


Ignore:
Timestamp:
06/15/2017 02:17:54 PM (9 years ago)
Author:
coreymckrill
Message:

WordCamp Post Types: Make sponsor invoice province field optional

Some regions don't have a state or province as part of their official
address format. However, some banks always require that field on
invoices, regardless of the country. The solution in this patch is to
make the state/province field optional, but add the string
"Not applicable" if the field is left blank when the form data is
saved.

Props davidmosterd
Fixes #2711

Location:
sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/views/sponsors/metabox-sponsor-info.php

    r5509 r5575  
    142142
    143143<ul class="wcpt-form">
    144         <li class="wcpt-form-header">
    145                 <?php _e( 'Address', 'wordcamporg' ); ?>
    146         </li>
    147 
    148         <li>
    149                 <label for="_wcpt_sponsor_street_address1">
    150                         <?php _e( 'Street Address 1:', 'wordcamporg' ); ?>
    151                 </label>
    152 
    153                 <input
    154                         type="text"
    155                         class="regular-text"
    156                         id="_wcpt_sponsor_street_address1"
    157                         name="_wcpt_sponsor_street_address1"
    158                         value="<?php echo esc_attr( $street_address1 ); ?>"
    159                     required
    160                 />
    161 
    162                 <?php $this->render_form_field_required_indicator(); ?>
    163         </li>
    164 
    165         <li>
    166                 <label for="_wcpt_sponsor_street_address2">
    167                         <?php _e( 'Street Address 2:', 'wordcamporg' ); ?>
    168                 </label>
    169 
    170                 <input
    171                         type="text"
    172                         class="regular-text"
    173                         id="_wcpt_sponsor_street_address2"
    174                         name="_wcpt_sponsor_street_address2"
    175                         value="<?php echo esc_attr( $street_address2 ); ?>"
    176                 />
    177         </li>
    178 
    179         <li>
    180                 <label for="_wcpt_sponsor_city">
    181                         <?php _e( 'City:', 'wordcamporg' ); ?>
    182                 </label>
    183 
    184                 <input
    185                         type="text"
    186                         class="regular-text"
    187                         id="_wcpt_sponsor_city"
    188                         name="_wcpt_sponsor_city"
    189                         value="<?php echo esc_attr( $city ); ?>"
    190                     required
    191                 />
    192 
    193                 <?php $this->render_form_field_required_indicator(); ?>
    194         </li>
    195 
    196         <li>
    197                 <label for="_wcpt_sponsor_state">
    198                         <?php _e( 'State / Province:', 'wordcamporg' ); ?>
    199                 </label>
    200 
    201                 <input
    202                         type="text"
    203                         class="regular-text"
    204                         id="_wcpt_sponsor_state"
    205                         name="_wcpt_sponsor_state"
    206                         value="<?php echo esc_attr( $state ); ?>"
    207                     required
    208                 />
    209 
    210                 <?php $this->render_form_field_required_indicator(); ?>
    211         </li>
    212 
    213         <li>
    214                 <label for="_wcpt_sponsor_zip_code">
    215                         <?php _e( 'ZIP / Postal Code:', 'wordcamporg' ); ?>
    216                 </label>
    217 
    218                 <input
    219                         type="text"
    220                         class="regular-text"
    221                         id="_wcpt_sponsor_zip_code"
    222                         name="_wcpt_sponsor_zip_code"
    223                         value="<?php echo esc_attr( $zip_code ); ?>"
    224                         maxlength="30"
    225                     required
    226                 />
    227 
    228                 <?php $this->render_form_field_required_indicator(); ?>
    229         </li>
    230 
    231144        <li>
    232145                <label for="_wcpt_sponsor_country">
     
    249162                <?php $this->render_form_field_required_indicator(); ?>
    250163        </li>
     164
     165        <li class="wcpt-form-header">
     166                <?php _e( 'Address', 'wordcamporg' ); ?>
     167        </li>
     168
     169        <li>
     170                <label for="_wcpt_sponsor_street_address1">
     171                        <?php _e( 'Street Address 1:', 'wordcamporg' ); ?>
     172                </label>
     173
     174                <input
     175                        type="text"
     176                        class="regular-text"
     177                        id="_wcpt_sponsor_street_address1"
     178                        name="_wcpt_sponsor_street_address1"
     179                        value="<?php echo esc_attr( $street_address1 ); ?>"
     180                    required
     181                />
     182
     183                <?php $this->render_form_field_required_indicator(); ?>
     184        </li>
     185
     186        <li>
     187                <label for="_wcpt_sponsor_street_address2">
     188                        <?php _e( 'Street Address 2:', 'wordcamporg' ); ?>
     189                </label>
     190
     191                <input
     192                        type="text"
     193                        class="regular-text"
     194                        id="_wcpt_sponsor_street_address2"
     195                        name="_wcpt_sponsor_street_address2"
     196                        value="<?php echo esc_attr( $street_address2 ); ?>"
     197                />
     198        </li>
     199
     200        <li>
     201                <label for="_wcpt_sponsor_city">
     202                        <?php _e( 'City:', 'wordcamporg' ); ?>
     203                </label>
     204
     205                <input
     206                        type="text"
     207                        class="regular-text"
     208                        id="_wcpt_sponsor_city"
     209                        name="_wcpt_sponsor_city"
     210                        value="<?php echo esc_attr( $city ); ?>"
     211                    required
     212                />
     213
     214                <?php $this->render_form_field_required_indicator(); ?>
     215        </li>
     216
     217        <li>
     218                <label for="_wcpt_sponsor_state">
     219                        <?php _e( 'State / Province:', 'wordcamporg' ); ?>
     220                </label>
     221
     222                <input
     223                        type="text"
     224                        class="regular-text"
     225                        id="_wcpt_sponsor_state"
     226                        name="_wcpt_sponsor_state"
     227                        value="<?php echo esc_attr( $state ); ?>"
     228                />
     229
     230                <span class="description">
     231                        <?php esc_html_e( 'Only necessary if you want this to be shown on your invoice', 'wordcamporg' ); ?>
     232                </span>
     233        </li>
     234
     235        <li>
     236                <label for="_wcpt_sponsor_zip_code">
     237                        <?php _e( 'ZIP / Postal Code:', 'wordcamporg' ); ?>
     238                </label>
     239
     240                <input
     241                        type="text"
     242                        class="regular-text"
     243                        id="_wcpt_sponsor_zip_code"
     244                        name="_wcpt_sponsor_zip_code"
     245                        value="<?php echo esc_attr( $zip_code ); ?>"
     246                        maxlength="30"
     247                    required
     248                />
     249
     250                <?php $this->render_form_field_required_indicator(); ?>
     251        </li>
    251252</ul>
    252253
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wc-post-types/wc-post-types.php

    r5568 r5575  
    16351635                $country         = get_post_meta( $sponsor->ID, '_wcpt_sponsor_country',           true );
    16361636
     1637                if ( $state === $this->get_sponsor_info_state_default_value() ) {
     1638                        $state = '';
     1639                }
     1640
    16371641                $available_countries = array( 'Abkhazia', 'Afghanistan', 'Aland', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Ascension', 'Ashmore and Cartier Islands', 'Australia', 'Australian Antarctic Territory', 'Austria', 'Azerbaijan', 'Bahamas, The', 'Bahrain', 'Baker Island', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Antarctic Territory', 'British Indian Ocean Territory', 'British Sovereign Base Areas', 'British Virgin Islands', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', "China, People's Republic of", 'China, Republic of (Taiwan)', 'Christmas Island', 'Clipperton Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo, (Congo – Brazzaville)', 'Congo, (Congo – Kinshasa)', 'Cook Islands', 'Coral Sea Islands', 'Costa Rica', "Cote d'Ivoire (Ivory Coast)", 'Croatia', 'Cuba', 'Cyprus', 'Czech Republic', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Islas Malvinas)', 'Faroe Islands', 'Fiji', 'Finland', 'France', 'French Guiana', 'French Polynesia', 'French Southern and Antarctic Lands', 'Gabon', 'Gambia, The', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guernsey', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Heard Island and McDonald Islands', 'Honduras', 'Hong Kong', 'Howland Island', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Isle of Man', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jarvis Island', 'Jersey', 'Johnston Atoll', 'Jordan', 'Kazakhstan', 'Kenya', 'Kingman Reef', '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', 'Midway Islands', 'Moldova', 'Monaco', 'Mongolia', 'Montenegro', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar (Burma)', 'Nagorno-Karabakh', 'Namibia', 'Nauru', 'Navassa Island', 'Nepal', 'Netherlands', 'Netherlands Antilles', 'New Caledonia', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Niue', 'Norfolk Island', 'Northern Cyprus', 'Northern Mariana Islands', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palmyra Atoll', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Peter I Island', 'Philippines', 'Pitcairn Islands', 'Poland', 'Portugal', 'Pridnestrovie (Transnistria)', 'Puerto Rico', 'Qatar', 'Queen Maud Land', 'Reunion', 'Romania', 'Ross Dependency', 'Russia', 'Rwanda', 'Saint Barthelemy', 'Saint Helena', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Martin', 'Saint Pierre and Miquelon', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'Somaliland', 'South Africa', 'South Georgia & South Sandwich Islands', 'South Ossetia', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Svalbard', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Tajikistan', 'Tanzania', 'Thailand', 'Timor-Leste (East Timor)', 'Togo', 'Tokelau', 'Tonga', 'Trinidad and Tobago', 'Tristan da Cunha', 'Tunisia', 'Turkey', 'Turkmenistan', 'Turks and Caicos Islands', 'Tuvalu', 'U.S. Virgin Islands', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Wake Island', 'Wallis and Futuna', 'Yemen', 'Zambia', 'Zimbabwe' );
    16381642                // todo use WordCamp_Budgets::get_valid_countries_iso3166() instead. need to switch multi-event sponsors at same time.
     
    16411645
    16421646                require_once( __DIR__ . '/views/sponsors/metabox-sponsor-info.php' );
     1647        }
     1648
     1649        /**
     1650         * Returns the default value for the state input when it's empty
     1651         *
     1652         * @return string
     1653         */
     1654        protected function get_sponsor_info_state_default_value() {
     1655                return 'Not Applicable';
    16431656        }
    16441657
     
    18351848                        foreach ( $text_values as $id ) {
    18361849                                $values[ $id ] = sanitize_text_field( filter_input( INPUT_POST, '_wcpt_sponsor_' . $id ) );
     1850                        }
     1851
     1852                        if ( empty( $values['state'] ) ) {
     1853                                $values['state'] = $this->get_sponsor_info_state_default_value();
    18371854                        }
    18381855
Note: See TracChangeset for help on using the changeset viewer.