Making WordPress.org


Ignore:
Timestamp:
01/29/2016 12:14:20 PM (11 years ago)
Author:
kovshenin
Message:

WordCamp.org: Add more banking fields to the budgets plugin.

  • ISO3166 country code selectors
  • Intermediary bank fields for wires
  • Invoice number
File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordcamp.org/public_html/wp-content/plugins/wordcamp-payments/includes/wordcamp-budgets.php

    r2415 r2420  
    9191                $amount = preg_replace( '#[^\d.-]+#', '', $amount );
    9292                $amount = round( floatval( $amount ), 2 );
    93                
     93
    9494                return $amount;
     95        }
     96
     97        /**
     98         * Return an array of countries where the key is an ISO 3166 code
     99         * and the value is a label.
     100         *
     101         * @see https://gist.github.com/vxnick/380904
     102         *
     103         * @return array
     104         */
     105        public static function get_valid_countries_iso3166() {
     106                $countries = array(
     107                        'AF' => 'Afghanistan',
     108                        'AX' => 'Aland Islands',
     109                        'AL' => 'Albania',
     110                        'DZ' => 'Algeria',
     111                        'AS' => 'American Samoa',
     112                        'AD' => 'Andorra',
     113                        'AO' => 'Angola',
     114                        'AI' => 'Anguilla',
     115                        'AQ' => 'Antarctica',
     116                        'AG' => 'Antigua And Barbuda',
     117                        'AR' => 'Argentina',
     118                        'AM' => 'Armenia',
     119                        'AW' => 'Aruba',
     120                        'AU' => 'Australia',
     121                        'AT' => 'Austria',
     122                        'AZ' => 'Azerbaijan',
     123                        'BS' => 'Bahamas',
     124                        'BH' => 'Bahrain',
     125                        'BD' => 'Bangladesh',
     126                        'BB' => 'Barbados',
     127                        'BY' => 'Belarus',
     128                        'BE' => 'Belgium',
     129                        'BZ' => 'Belize',
     130                        'BJ' => 'Benin',
     131                        'BM' => 'Bermuda',
     132                        'BT' => 'Bhutan',
     133                        'BO' => 'Bolivia',
     134                        'BA' => 'Bosnia And Herzegovina',
     135                        'BW' => 'Botswana',
     136                        'BV' => 'Bouvet Island',
     137                        'BR' => 'Brazil',
     138                        'IO' => 'British Indian Ocean Territory',
     139                        'BN' => 'Brunei Darussalam',
     140                        'BG' => 'Bulgaria',
     141                        'BF' => 'Burkina Faso',
     142                        'BI' => 'Burundi',
     143                        'KH' => 'Cambodia',
     144                        'CM' => 'Cameroon',
     145                        'CA' => 'Canada',
     146                        'CV' => 'Cape Verde',
     147                        'KY' => 'Cayman Islands',
     148                        'CF' => 'Central African Republic',
     149                        'TD' => 'Chad',
     150                        'CL' => 'Chile',
     151                        'CN' => 'China',
     152                        'CX' => 'Christmas Island',
     153                        'CC' => 'Cocos (Keeling) Islands',
     154                        'CO' => 'Colombia',
     155                        'KM' => 'Comoros',
     156                        'CG' => 'Congo',
     157                        'CD' => 'Congo, Democratic Republic',
     158                        'CK' => 'Cook Islands',
     159                        'CR' => 'Costa Rica',
     160                        'CI' => 'Cote D\'Ivoire',
     161                        'HR' => 'Croatia',
     162                        'CU' => 'Cuba',
     163                        'CY' => 'Cyprus',
     164                        'CZ' => 'Czech Republic',
     165                        'DK' => 'Denmark',
     166                        'DJ' => 'Djibouti',
     167                        'DM' => 'Dominica',
     168                        'DO' => 'Dominican Republic',
     169                        'EC' => 'Ecuador',
     170                        'EG' => 'Egypt',
     171                        'SV' => 'El Salvador',
     172                        'GQ' => 'Equatorial Guinea',
     173                        'ER' => 'Eritrea',
     174                        'EE' => 'Estonia',
     175                        'ET' => 'Ethiopia',
     176                        'FK' => 'Falkland Islands (Malvinas)',
     177                        'FO' => 'Faroe Islands',
     178                        'FJ' => 'Fiji',
     179                        'FI' => 'Finland',
     180                        'FR' => 'France',
     181                        'GF' => 'French Guiana',
     182                        'PF' => 'French Polynesia',
     183                        'TF' => 'French Southern Territories',
     184                        'GA' => 'Gabon',
     185                        'GM' => 'Gambia',
     186                        'GE' => 'Georgia',
     187                        'DE' => 'Germany',
     188                        'GH' => 'Ghana',
     189                        'GI' => 'Gibraltar',
     190                        'GR' => 'Greece',
     191                        'GL' => 'Greenland',
     192                        'GD' => 'Grenada',
     193                        'GP' => 'Guadeloupe',
     194                        'GU' => 'Guam',
     195                        'GT' => 'Guatemala',
     196                        'GG' => 'Guernsey',
     197                        'GN' => 'Guinea',
     198                        'GW' => 'Guinea-Bissau',
     199                        'GY' => 'Guyana',
     200                        'HT' => 'Haiti',
     201                        'HM' => 'Heard Island & Mcdonald Islands',
     202                        'VA' => 'Holy See (Vatican City State)',
     203                        'HN' => 'Honduras',
     204                        'HK' => 'Hong Kong',
     205                        'HU' => 'Hungary',
     206                        'IS' => 'Iceland',
     207                        'IN' => 'India',
     208                        'ID' => 'Indonesia',
     209                        'IR' => 'Iran, Islamic Republic Of',
     210                        'IQ' => 'Iraq',
     211                        'IE' => 'Ireland',
     212                        'IM' => 'Isle Of Man',
     213                        'IL' => 'Israel',
     214                        'IT' => 'Italy',
     215                        'JM' => 'Jamaica',
     216                        'JP' => 'Japan',
     217                        'JE' => 'Jersey',
     218                        'JO' => 'Jordan',
     219                        'KZ' => 'Kazakhstan',
     220                        'KE' => 'Kenya',
     221                        'KI' => 'Kiribati',
     222                        'KR' => 'Korea',
     223                        'KW' => 'Kuwait',
     224                        'KG' => 'Kyrgyzstan',
     225                        'LA' => 'Lao People\'s Democratic Republic',
     226                        'LV' => 'Latvia',
     227                        'LB' => 'Lebanon',
     228                        'LS' => 'Lesotho',
     229                        'LR' => 'Liberia',
     230                        'LY' => 'Libyan Arab Jamahiriya',
     231                        'LI' => 'Liechtenstein',
     232                        'LT' => 'Lithuania',
     233                        'LU' => 'Luxembourg',
     234                        'MO' => 'Macao',
     235                        'MK' => 'Macedonia',
     236                        'MG' => 'Madagascar',
     237                        'MW' => 'Malawi',
     238                        'MY' => 'Malaysia',
     239                        'MV' => 'Maldives',
     240                        'ML' => 'Mali',
     241                        'MT' => 'Malta',
     242                        'MH' => 'Marshall Islands',
     243                        'MQ' => 'Martinique',
     244                        'MR' => 'Mauritania',
     245                        'MU' => 'Mauritius',
     246                        'YT' => 'Mayotte',
     247                        'MX' => 'Mexico',
     248                        'FM' => 'Micronesia, Federated States Of',
     249                        'MD' => 'Moldova',
     250                        'MC' => 'Monaco',
     251                        'MN' => 'Mongolia',
     252                        'ME' => 'Montenegro',
     253                        'MS' => 'Montserrat',
     254                        'MA' => 'Morocco',
     255                        'MZ' => 'Mozambique',
     256                        'MM' => 'Myanmar',
     257                        'NA' => 'Namibia',
     258                        'NR' => 'Nauru',
     259                        'NP' => 'Nepal',
     260                        'NL' => 'Netherlands',
     261                        'AN' => 'Netherlands Antilles',
     262                        'NC' => 'New Caledonia',
     263                        'NZ' => 'New Zealand',
     264                        'NI' => 'Nicaragua',
     265                        'NE' => 'Niger',
     266                        'NG' => 'Nigeria',
     267                        'NU' => 'Niue',
     268                        'NF' => 'Norfolk Island',
     269                        'MP' => 'Northern Mariana Islands',
     270                        'NO' => 'Norway',
     271                        'OM' => 'Oman',
     272                        'PK' => 'Pakistan',
     273                        'PW' => 'Palau',
     274                        'PS' => 'Palestinian Territory, Occupied',
     275                        'PA' => 'Panama',
     276                        'PG' => 'Papua New Guinea',
     277                        'PY' => 'Paraguay',
     278                        'PE' => 'Peru',
     279                        'PH' => 'Philippines',
     280                        'PN' => 'Pitcairn',
     281                        'PL' => 'Poland',
     282                        'PT' => 'Portugal',
     283                        'PR' => 'Puerto Rico',
     284                        'QA' => 'Qatar',
     285                        'RE' => 'Reunion',
     286                        'RO' => 'Romania',
     287                        'RU' => 'Russian Federation',
     288                        'RW' => 'Rwanda',
     289                        'BL' => 'Saint Barthelemy',
     290                        'SH' => 'Saint Helena',
     291                        'KN' => 'Saint Kitts And Nevis',
     292                        'LC' => 'Saint Lucia',
     293                        'MF' => 'Saint Martin',
     294                        'PM' => 'Saint Pierre And Miquelon',
     295                        'VC' => 'Saint Vincent And Grenadines',
     296                        'WS' => 'Samoa',
     297                        'SM' => 'San Marino',
     298                        'ST' => 'Sao Tome And Principe',
     299                        'SA' => 'Saudi Arabia',
     300                        'SN' => 'Senegal',
     301                        'RS' => 'Serbia',
     302                        'SC' => 'Seychelles',
     303                        'SL' => 'Sierra Leone',
     304                        'SG' => 'Singapore',
     305                        'SK' => 'Slovakia',
     306                        'SI' => 'Slovenia',
     307                        'SB' => 'Solomon Islands',
     308                        'SO' => 'Somalia',
     309                        'ZA' => 'South Africa',
     310                        'GS' => 'South Georgia And Sandwich Isl.',
     311                        'ES' => 'Spain',
     312                        'LK' => 'Sri Lanka',
     313                        'SD' => 'Sudan',
     314                        'SR' => 'Suriname',
     315                        'SJ' => 'Svalbard And Jan Mayen',
     316                        'SZ' => 'Swaziland',
     317                        'SE' => 'Sweden',
     318                        'CH' => 'Switzerland',
     319                        'SY' => 'Syrian Arab Republic',
     320                        'TW' => 'Taiwan',
     321                        'TJ' => 'Tajikistan',
     322                        'TZ' => 'Tanzania',
     323                        'TH' => 'Thailand',
     324                        'TL' => 'Timor-Leste',
     325                        'TG' => 'Togo',
     326                        'TK' => 'Tokelau',
     327                        'TO' => 'Tonga',
     328                        'TT' => 'Trinidad And Tobago',
     329                        'TN' => 'Tunisia',
     330                        'TR' => 'Turkey',
     331                        'TM' => 'Turkmenistan',
     332                        'TC' => 'Turks And Caicos Islands',
     333                        'TV' => 'Tuvalu',
     334                        'UG' => 'Uganda',
     335                        'UA' => 'Ukraine',
     336                        'AE' => 'United Arab Emirates',
     337                        'GB' => 'United Kingdom',
     338                        'US' => 'United States',
     339                        'UM' => 'United States Outlying Islands',
     340                        'UY' => 'Uruguay',
     341                        'UZ' => 'Uzbekistan',
     342                        'VU' => 'Vanuatu',
     343                        'VE' => 'Venezuela',
     344                        'VN' => 'Viet Nam',
     345                        'VG' => 'Virgin Islands, British',
     346                        'VI' => 'Virgin Islands, U.S.',
     347                        'WF' => 'Wallis And Futuna',
     348                        'EH' => 'Western Sahara',
     349                        'YE' => 'Yemen',
     350                        'ZM' => 'Zambia',
     351                        'ZW' => 'Zimbabwe',
     352                );
     353
     354                return $countries;
    95355        }
    96356
    … …  
    121381                                case 'bank_country':
    122382                                case 'bank_bic':
     383
     384                                case 'interm_bank_name':
     385                                case 'interm_bank_street_address':
     386                                case 'interm_bank_city':
     387                                case 'interm_bank_state':
     388                                case 'interm_bank_zip_code':
     389                                case 'interm_bank_swift':
     390                                case 'interm_bank_account':
     391
    123392                                case 'beneficiary_account_number':
    124393                                case 'beneficiary_name':
    … …  
    140409                                        break;
    141410
     411                                case 'bank_country_iso3166':
     412                                case 'interm_bank_country_iso3166':
     413                                case 'beneficiary_country_iso3166':
     414                                        if ( array_key_exists( $unsafe_value, self::get_valid_countries_iso3166() ) ) {
     415                                                $safe_value = $unsafe_value;
     416                                        }
     417                                        break;
     418
    142419                                default:
    143420                                        $safe_value = null;
    … …  
    176453                        'beneficiary_zip_code',
    177454                        'beneficiary_country',
     455                        'beneficiary_country_iso3166',
    178456                );
    179457        }
Note: See TracChangeset for help on using the changeset viewer.