@@ -13,9 +13,9 @@ discard block |
||
| 13 | 13 | |
| 14 | 14 | |
| 15 | 15 | function wpinv_get_default_country() { |
| 16 | - $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 16 | + $country = wpinv_get_option( 'default_country', 'UK' ); |
|
| 17 | 17 | |
| 18 | - return apply_filters( 'wpinv_default_country', $country ); |
|
| 18 | + return apply_filters( 'wpinv_default_country', $country ); |
|
| 19 | 19 | } |
| 20 | 20 | |
| 21 | 21 | function wpinv_is_base_country( $country ) { |
@@ -40,9 +40,9 @@ discard block |
||
| 40 | 40 | } |
| 41 | 41 | |
| 42 | 42 | function wpinv_get_default_state() { |
| 43 | - $state = wpinv_get_option( 'default_state', false ); |
|
| 43 | + $state = wpinv_get_option( 'default_state', false ); |
|
| 44 | 44 | |
| 45 | - return apply_filters( 'wpinv_default_state', $state ); |
|
| 45 | + return apply_filters( 'wpinv_default_state', $state ); |
|
| 46 | 46 | } |
| 47 | 47 | |
| 48 | 48 | function wpinv_state_name( $state_code = '', $country_code = '' ) { |
@@ -115,260 +115,260 @@ discard block |
||
| 115 | 115 | } |
| 116 | 116 | |
| 117 | 117 | function wpinv_get_country_list( $first_empty = false ) { |
| 118 | - $countries = array( |
|
| 119 | - 'US' => __('United States', 'invoicing'), |
|
| 120 | - 'CA' => __('Canada', 'invoicing'), |
|
| 121 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
| 122 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
| 123 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
| 124 | - 'AL' => __('Albania', 'invoicing'), |
|
| 125 | - 'DZ' => __('Algeria', 'invoicing'), |
|
| 126 | - 'AS' => __('American Samoa', 'invoicing'), |
|
| 127 | - 'AD' => __('Andorra', 'invoicing'), |
|
| 128 | - 'AO' => __('Angola', 'invoicing'), |
|
| 129 | - 'AI' => __('Anguilla', 'invoicing'), |
|
| 130 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
| 131 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
| 132 | - 'AR' => __('Argentina', 'invoicing'), |
|
| 133 | - 'AM' => __('Armenia', 'invoicing'), |
|
| 134 | - 'AW' => __('Aruba', 'invoicing'), |
|
| 135 | - 'AU' => __('Australia', 'invoicing'), |
|
| 136 | - 'AT' => __('Austria', 'invoicing'), |
|
| 137 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
| 138 | - 'BS' => __('Bahamas', 'invoicing'), |
|
| 139 | - 'BH' => __('Bahrain', 'invoicing'), |
|
| 140 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
| 141 | - 'BB' => __('Barbados', 'invoicing'), |
|
| 142 | - 'BY' => __('Belarus', 'invoicing'), |
|
| 143 | - 'BE' => __('Belgium', 'invoicing'), |
|
| 144 | - 'BZ' => __('Belize', 'invoicing'), |
|
| 145 | - 'BJ' => __('Benin', 'invoicing'), |
|
| 146 | - 'BM' => __('Bermuda', 'invoicing'), |
|
| 147 | - 'BT' => __('Bhutan', 'invoicing'), |
|
| 148 | - 'BO' => __('Bolivia', 'invoicing'), |
|
| 149 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
| 150 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
| 151 | - 'BW' => __('Botswana', 'invoicing'), |
|
| 152 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
| 153 | - 'BR' => __('Brazil', 'invoicing'), |
|
| 154 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
| 155 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
| 156 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
| 157 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
| 158 | - 'BI' => __('Burundi', 'invoicing'), |
|
| 159 | - 'KH' => __('Cambodia', 'invoicing'), |
|
| 160 | - 'CM' => __('Cameroon', 'invoicing'), |
|
| 161 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
| 162 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
| 163 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
| 164 | - 'TD' => __('Chad', 'invoicing'), |
|
| 165 | - 'CL' => __('Chile', 'invoicing'), |
|
| 166 | - 'CN' => __('China', 'invoicing'), |
|
| 167 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
| 168 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
| 169 | - 'CO' => __('Colombia', 'invoicing'), |
|
| 170 | - 'KM' => __('Comoros', 'invoicing'), |
|
| 171 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
| 172 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
| 173 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
| 174 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
| 175 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
| 176 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
| 177 | - 'CU' => __('Cuba', 'invoicing'), |
|
| 178 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
| 179 | - 'CY' => __('Cyprus', 'invoicing'), |
|
| 180 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
| 181 | - 'DK' => __('Denmark', 'invoicing'), |
|
| 182 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
| 183 | - 'DM' => __('Dominica', 'invoicing'), |
|
| 184 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
| 185 | - 'TP' => __('East Timor', 'invoicing'), |
|
| 186 | - 'EC' => __('Ecuador', 'invoicing'), |
|
| 187 | - 'EG' => __('Egypt', 'invoicing'), |
|
| 188 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
| 189 | - 'SV' => __('El Salvador', 'invoicing'), |
|
| 190 | - 'ER' => __('Eritrea', 'invoicing'), |
|
| 191 | - 'EE' => __('Estonia', 'invoicing'), |
|
| 192 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
| 193 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
| 194 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
| 195 | - 'FJ' => __('Fiji', 'invoicing'), |
|
| 196 | - 'FI' => __('Finland', 'invoicing'), |
|
| 197 | - 'FR' => __('France', 'invoicing'), |
|
| 198 | - 'GF' => __('French Guiana', 'invoicing'), |
|
| 199 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
| 200 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
| 201 | - 'GA' => __('Gabon', 'invoicing'), |
|
| 202 | - 'GM' => __('Gambia', 'invoicing'), |
|
| 203 | - 'GE' => __('Georgia', 'invoicing'), |
|
| 204 | - 'DE' => __('Germany', 'invoicing'), |
|
| 205 | - 'GR' => __('Greece', 'invoicing'), |
|
| 206 | - 'GH' => __('Ghana', 'invoicing'), |
|
| 207 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
| 208 | - 'GL' => __('Greenland', 'invoicing'), |
|
| 209 | - 'GD' => __('Grenada', 'invoicing'), |
|
| 210 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
| 211 | - 'GU' => __('Guam', 'invoicing'), |
|
| 212 | - 'GT' => __('Guatemala', 'invoicing'), |
|
| 213 | - 'GG' => __('Guernsey', 'invoicing'), |
|
| 214 | - 'GN' => __('Guinea', 'invoicing'), |
|
| 215 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
| 216 | - 'GY' => __('Guyana', 'invoicing'), |
|
| 217 | - 'HT' => __('Haiti', 'invoicing'), |
|
| 218 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
| 219 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
| 220 | - 'HN' => __('Honduras', 'invoicing'), |
|
| 221 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
| 222 | - 'HU' => __('Hungary', 'invoicing'), |
|
| 223 | - 'IS' => __('Iceland', 'invoicing'), |
|
| 224 | - 'IN' => __('India', 'invoicing'), |
|
| 225 | - 'ID' => __('Indonesia', 'invoicing'), |
|
| 226 | - 'IR' => __('Iran', 'invoicing'), |
|
| 227 | - 'IQ' => __('Iraq', 'invoicing'), |
|
| 228 | - 'IE' => __('Ireland', 'invoicing'), |
|
| 229 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
| 230 | - 'IL' => __('Israel', 'invoicing'), |
|
| 231 | - 'IT' => __('Italy', 'invoicing'), |
|
| 232 | - 'JM' => __('Jamaica', 'invoicing'), |
|
| 233 | - 'JP' => __('Japan', 'invoicing'), |
|
| 234 | - 'JE' => __('Jersey', 'invoicing'), |
|
| 235 | - 'JO' => __('Jordan', 'invoicing'), |
|
| 236 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
| 237 | - 'KE' => __('Kenya', 'invoicing'), |
|
| 238 | - 'KI' => __('Kiribati', 'invoicing'), |
|
| 239 | - 'KW' => __('Kuwait', 'invoicing'), |
|
| 240 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
| 241 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
| 242 | - 'LV' => __('Latvia', 'invoicing'), |
|
| 243 | - 'LB' => __('Lebanon', 'invoicing'), |
|
| 244 | - 'LS' => __('Lesotho', 'invoicing'), |
|
| 245 | - 'LR' => __('Liberia', 'invoicing'), |
|
| 246 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
| 247 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
| 248 | - 'LT' => __('Lithuania', 'invoicing'), |
|
| 249 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
| 250 | - 'MO' => __('Macau', 'invoicing'), |
|
| 251 | - 'MK' => __('Macedonia', 'invoicing'), |
|
| 252 | - 'MG' => __('Madagascar', 'invoicing'), |
|
| 253 | - 'MW' => __('Malawi', 'invoicing'), |
|
| 254 | - 'MY' => __('Malaysia', 'invoicing'), |
|
| 255 | - 'MV' => __('Maldives', 'invoicing'), |
|
| 256 | - 'ML' => __('Mali', 'invoicing'), |
|
| 257 | - 'MT' => __('Malta', 'invoicing'), |
|
| 258 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 259 | - 'MQ' => __('Martinique', 'invoicing'), |
|
| 260 | - 'MR' => __('Mauritania', 'invoicing'), |
|
| 261 | - 'MU' => __('Mauritius', 'invoicing'), |
|
| 262 | - 'YT' => __('Mayotte', 'invoicing'), |
|
| 263 | - 'MX' => __('Mexico', 'invoicing'), |
|
| 264 | - 'FM' => __('Micronesia', 'invoicing'), |
|
| 265 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
| 266 | - 'MC' => __('Monaco', 'invoicing'), |
|
| 267 | - 'MN' => __('Mongolia', 'invoicing'), |
|
| 268 | - 'ME' => __('Montenegro', 'invoicing'), |
|
| 269 | - 'MS' => __('Montserrat', 'invoicing'), |
|
| 270 | - 'MA' => __('Morocco', 'invoicing'), |
|
| 271 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
| 272 | - 'MM' => __('Myanmar', 'invoicing'), |
|
| 273 | - 'NA' => __('Namibia', 'invoicing'), |
|
| 274 | - 'NR' => __('Nauru', 'invoicing'), |
|
| 275 | - 'NP' => __('Nepal', 'invoicing'), |
|
| 276 | - 'NL' => __('Netherlands', 'invoicing'), |
|
| 277 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
| 278 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
| 279 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
| 280 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
| 281 | - 'NE' => __('Niger', 'invoicing'), |
|
| 282 | - 'NG' => __('Nigeria', 'invoicing'), |
|
| 283 | - 'NU' => __('Niue', 'invoicing'), |
|
| 284 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
| 285 | - 'KP' => __('North Korea', 'invoicing'), |
|
| 286 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 287 | - 'NO' => __('Norway', 'invoicing'), |
|
| 288 | - 'OM' => __('Oman', 'invoicing'), |
|
| 289 | - 'PK' => __('Pakistan', 'invoicing'), |
|
| 290 | - 'PW' => __('Palau', 'invoicing'), |
|
| 291 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
| 292 | - 'PA' => __('Panama', 'invoicing'), |
|
| 293 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
| 294 | - 'PY' => __('Paraguay', 'invoicing'), |
|
| 295 | - 'PE' => __('Peru', 'invoicing'), |
|
| 296 | - 'PH' => __('Phillipines', 'invoicing'), |
|
| 297 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
| 298 | - 'PL' => __('Poland', 'invoicing'), |
|
| 299 | - 'PT' => __('Portugal', 'invoicing'), |
|
| 300 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 301 | - 'QA' => __('Qatar', 'invoicing'), |
|
| 302 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
| 303 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
| 304 | - 'RO' => __('Romania', 'invoicing'), |
|
| 305 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
| 306 | - 'RW' => __('Rwanda', 'invoicing'), |
|
| 307 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
| 308 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
| 309 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
| 310 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
| 311 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
| 312 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
| 313 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
| 314 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
| 315 | - 'SM' => __('San Marino', 'invoicing'), |
|
| 316 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
| 317 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
| 318 | - 'SN' => __('Senegal', 'invoicing'), |
|
| 319 | - 'RS' => __('Serbia', 'invoicing'), |
|
| 320 | - 'SC' => __('Seychelles', 'invoicing'), |
|
| 321 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
| 322 | - 'SG' => __('Singapore', 'invoicing'), |
|
| 323 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
| 324 | - 'SI' => __('Slovenia', 'invoicing'), |
|
| 325 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
| 326 | - 'SO' => __('Somalia', 'invoicing'), |
|
| 327 | - 'ZA' => __('South Africa', 'invoicing'), |
|
| 328 | - 'GS' => __('South Georgia', 'invoicing'), |
|
| 329 | - 'KR' => __('South Korea', 'invoicing'), |
|
| 330 | - 'SS' => __('South Sudan', 'invoicing'), |
|
| 331 | - 'ES' => __('Spain', 'invoicing'), |
|
| 332 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
| 333 | - 'SD' => __('Sudan', 'invoicing'), |
|
| 334 | - 'SR' => __('Suriname', 'invoicing'), |
|
| 335 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
| 336 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
| 337 | - 'SE' => __('Sweden', 'invoicing'), |
|
| 338 | - 'CH' => __('Switzerland', 'invoicing'), |
|
| 339 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
| 340 | - 'TW' => __('Taiwan', 'invoicing'), |
|
| 341 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
| 342 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
| 343 | - 'TH' => __('Thailand', 'invoicing'), |
|
| 344 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
| 345 | - 'TG' => __('Togo', 'invoicing'), |
|
| 346 | - 'TK' => __('Tokelau', 'invoicing'), |
|
| 347 | - 'TO' => __('Tonga', 'invoicing'), |
|
| 348 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
| 349 | - 'TN' => __('Tunisia', 'invoicing'), |
|
| 350 | - 'TR' => __('Turkey', 'invoicing'), |
|
| 351 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
| 352 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
| 353 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
| 354 | - 'UG' => __('Uganda', 'invoicing'), |
|
| 355 | - 'UA' => __('Ukraine', 'invoicing'), |
|
| 356 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
| 357 | - 'UY' => __('Uruguay', 'invoicing'), |
|
| 358 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
| 359 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
| 360 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
| 361 | - 'VE' => __('Venezuela', 'invoicing'), |
|
| 362 | - 'VN' => __('Vietnam', 'invoicing'), |
|
| 363 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
| 364 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
| 365 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
| 366 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
| 367 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
| 368 | - 'YE' => __('Yemen', 'invoicing'), |
|
| 369 | - 'ZM' => __('Zambia', 'invoicing'), |
|
| 370 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
| 371 | - ); |
|
| 118 | + $countries = array( |
|
| 119 | + 'US' => __('United States', 'invoicing'), |
|
| 120 | + 'CA' => __('Canada', 'invoicing'), |
|
| 121 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
| 122 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
| 123 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
| 124 | + 'AL' => __('Albania', 'invoicing'), |
|
| 125 | + 'DZ' => __('Algeria', 'invoicing'), |
|
| 126 | + 'AS' => __('American Samoa', 'invoicing'), |
|
| 127 | + 'AD' => __('Andorra', 'invoicing'), |
|
| 128 | + 'AO' => __('Angola', 'invoicing'), |
|
| 129 | + 'AI' => __('Anguilla', 'invoicing'), |
|
| 130 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
| 131 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
| 132 | + 'AR' => __('Argentina', 'invoicing'), |
|
| 133 | + 'AM' => __('Armenia', 'invoicing'), |
|
| 134 | + 'AW' => __('Aruba', 'invoicing'), |
|
| 135 | + 'AU' => __('Australia', 'invoicing'), |
|
| 136 | + 'AT' => __('Austria', 'invoicing'), |
|
| 137 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
| 138 | + 'BS' => __('Bahamas', 'invoicing'), |
|
| 139 | + 'BH' => __('Bahrain', 'invoicing'), |
|
| 140 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
| 141 | + 'BB' => __('Barbados', 'invoicing'), |
|
| 142 | + 'BY' => __('Belarus', 'invoicing'), |
|
| 143 | + 'BE' => __('Belgium', 'invoicing'), |
|
| 144 | + 'BZ' => __('Belize', 'invoicing'), |
|
| 145 | + 'BJ' => __('Benin', 'invoicing'), |
|
| 146 | + 'BM' => __('Bermuda', 'invoicing'), |
|
| 147 | + 'BT' => __('Bhutan', 'invoicing'), |
|
| 148 | + 'BO' => __('Bolivia', 'invoicing'), |
|
| 149 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
| 150 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
| 151 | + 'BW' => __('Botswana', 'invoicing'), |
|
| 152 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
| 153 | + 'BR' => __('Brazil', 'invoicing'), |
|
| 154 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
| 155 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
| 156 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
| 157 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
| 158 | + 'BI' => __('Burundi', 'invoicing'), |
|
| 159 | + 'KH' => __('Cambodia', 'invoicing'), |
|
| 160 | + 'CM' => __('Cameroon', 'invoicing'), |
|
| 161 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
| 162 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
| 163 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
| 164 | + 'TD' => __('Chad', 'invoicing'), |
|
| 165 | + 'CL' => __('Chile', 'invoicing'), |
|
| 166 | + 'CN' => __('China', 'invoicing'), |
|
| 167 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
| 168 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
| 169 | + 'CO' => __('Colombia', 'invoicing'), |
|
| 170 | + 'KM' => __('Comoros', 'invoicing'), |
|
| 171 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
| 172 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
| 173 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
| 174 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
| 175 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
| 176 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
| 177 | + 'CU' => __('Cuba', 'invoicing'), |
|
| 178 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
| 179 | + 'CY' => __('Cyprus', 'invoicing'), |
|
| 180 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
| 181 | + 'DK' => __('Denmark', 'invoicing'), |
|
| 182 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
| 183 | + 'DM' => __('Dominica', 'invoicing'), |
|
| 184 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
| 185 | + 'TP' => __('East Timor', 'invoicing'), |
|
| 186 | + 'EC' => __('Ecuador', 'invoicing'), |
|
| 187 | + 'EG' => __('Egypt', 'invoicing'), |
|
| 188 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
| 189 | + 'SV' => __('El Salvador', 'invoicing'), |
|
| 190 | + 'ER' => __('Eritrea', 'invoicing'), |
|
| 191 | + 'EE' => __('Estonia', 'invoicing'), |
|
| 192 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
| 193 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
| 194 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
| 195 | + 'FJ' => __('Fiji', 'invoicing'), |
|
| 196 | + 'FI' => __('Finland', 'invoicing'), |
|
| 197 | + 'FR' => __('France', 'invoicing'), |
|
| 198 | + 'GF' => __('French Guiana', 'invoicing'), |
|
| 199 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
| 200 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
| 201 | + 'GA' => __('Gabon', 'invoicing'), |
|
| 202 | + 'GM' => __('Gambia', 'invoicing'), |
|
| 203 | + 'GE' => __('Georgia', 'invoicing'), |
|
| 204 | + 'DE' => __('Germany', 'invoicing'), |
|
| 205 | + 'GR' => __('Greece', 'invoicing'), |
|
| 206 | + 'GH' => __('Ghana', 'invoicing'), |
|
| 207 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
| 208 | + 'GL' => __('Greenland', 'invoicing'), |
|
| 209 | + 'GD' => __('Grenada', 'invoicing'), |
|
| 210 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
| 211 | + 'GU' => __('Guam', 'invoicing'), |
|
| 212 | + 'GT' => __('Guatemala', 'invoicing'), |
|
| 213 | + 'GG' => __('Guernsey', 'invoicing'), |
|
| 214 | + 'GN' => __('Guinea', 'invoicing'), |
|
| 215 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
| 216 | + 'GY' => __('Guyana', 'invoicing'), |
|
| 217 | + 'HT' => __('Haiti', 'invoicing'), |
|
| 218 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
| 219 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
| 220 | + 'HN' => __('Honduras', 'invoicing'), |
|
| 221 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
| 222 | + 'HU' => __('Hungary', 'invoicing'), |
|
| 223 | + 'IS' => __('Iceland', 'invoicing'), |
|
| 224 | + 'IN' => __('India', 'invoicing'), |
|
| 225 | + 'ID' => __('Indonesia', 'invoicing'), |
|
| 226 | + 'IR' => __('Iran', 'invoicing'), |
|
| 227 | + 'IQ' => __('Iraq', 'invoicing'), |
|
| 228 | + 'IE' => __('Ireland', 'invoicing'), |
|
| 229 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
| 230 | + 'IL' => __('Israel', 'invoicing'), |
|
| 231 | + 'IT' => __('Italy', 'invoicing'), |
|
| 232 | + 'JM' => __('Jamaica', 'invoicing'), |
|
| 233 | + 'JP' => __('Japan', 'invoicing'), |
|
| 234 | + 'JE' => __('Jersey', 'invoicing'), |
|
| 235 | + 'JO' => __('Jordan', 'invoicing'), |
|
| 236 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
| 237 | + 'KE' => __('Kenya', 'invoicing'), |
|
| 238 | + 'KI' => __('Kiribati', 'invoicing'), |
|
| 239 | + 'KW' => __('Kuwait', 'invoicing'), |
|
| 240 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
| 241 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
| 242 | + 'LV' => __('Latvia', 'invoicing'), |
|
| 243 | + 'LB' => __('Lebanon', 'invoicing'), |
|
| 244 | + 'LS' => __('Lesotho', 'invoicing'), |
|
| 245 | + 'LR' => __('Liberia', 'invoicing'), |
|
| 246 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
| 247 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
| 248 | + 'LT' => __('Lithuania', 'invoicing'), |
|
| 249 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
| 250 | + 'MO' => __('Macau', 'invoicing'), |
|
| 251 | + 'MK' => __('Macedonia', 'invoicing'), |
|
| 252 | + 'MG' => __('Madagascar', 'invoicing'), |
|
| 253 | + 'MW' => __('Malawi', 'invoicing'), |
|
| 254 | + 'MY' => __('Malaysia', 'invoicing'), |
|
| 255 | + 'MV' => __('Maldives', 'invoicing'), |
|
| 256 | + 'ML' => __('Mali', 'invoicing'), |
|
| 257 | + 'MT' => __('Malta', 'invoicing'), |
|
| 258 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
| 259 | + 'MQ' => __('Martinique', 'invoicing'), |
|
| 260 | + 'MR' => __('Mauritania', 'invoicing'), |
|
| 261 | + 'MU' => __('Mauritius', 'invoicing'), |
|
| 262 | + 'YT' => __('Mayotte', 'invoicing'), |
|
| 263 | + 'MX' => __('Mexico', 'invoicing'), |
|
| 264 | + 'FM' => __('Micronesia', 'invoicing'), |
|
| 265 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
| 266 | + 'MC' => __('Monaco', 'invoicing'), |
|
| 267 | + 'MN' => __('Mongolia', 'invoicing'), |
|
| 268 | + 'ME' => __('Montenegro', 'invoicing'), |
|
| 269 | + 'MS' => __('Montserrat', 'invoicing'), |
|
| 270 | + 'MA' => __('Morocco', 'invoicing'), |
|
| 271 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
| 272 | + 'MM' => __('Myanmar', 'invoicing'), |
|
| 273 | + 'NA' => __('Namibia', 'invoicing'), |
|
| 274 | + 'NR' => __('Nauru', 'invoicing'), |
|
| 275 | + 'NP' => __('Nepal', 'invoicing'), |
|
| 276 | + 'NL' => __('Netherlands', 'invoicing'), |
|
| 277 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
| 278 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
| 279 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
| 280 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
| 281 | + 'NE' => __('Niger', 'invoicing'), |
|
| 282 | + 'NG' => __('Nigeria', 'invoicing'), |
|
| 283 | + 'NU' => __('Niue', 'invoicing'), |
|
| 284 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
| 285 | + 'KP' => __('North Korea', 'invoicing'), |
|
| 286 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
| 287 | + 'NO' => __('Norway', 'invoicing'), |
|
| 288 | + 'OM' => __('Oman', 'invoicing'), |
|
| 289 | + 'PK' => __('Pakistan', 'invoicing'), |
|
| 290 | + 'PW' => __('Palau', 'invoicing'), |
|
| 291 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
| 292 | + 'PA' => __('Panama', 'invoicing'), |
|
| 293 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
| 294 | + 'PY' => __('Paraguay', 'invoicing'), |
|
| 295 | + 'PE' => __('Peru', 'invoicing'), |
|
| 296 | + 'PH' => __('Phillipines', 'invoicing'), |
|
| 297 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
| 298 | + 'PL' => __('Poland', 'invoicing'), |
|
| 299 | + 'PT' => __('Portugal', 'invoicing'), |
|
| 300 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
| 301 | + 'QA' => __('Qatar', 'invoicing'), |
|
| 302 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
| 303 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
| 304 | + 'RO' => __('Romania', 'invoicing'), |
|
| 305 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
| 306 | + 'RW' => __('Rwanda', 'invoicing'), |
|
| 307 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
| 308 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
| 309 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
| 310 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
| 311 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
| 312 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
| 313 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
| 314 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
| 315 | + 'SM' => __('San Marino', 'invoicing'), |
|
| 316 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
| 317 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
| 318 | + 'SN' => __('Senegal', 'invoicing'), |
|
| 319 | + 'RS' => __('Serbia', 'invoicing'), |
|
| 320 | + 'SC' => __('Seychelles', 'invoicing'), |
|
| 321 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
| 322 | + 'SG' => __('Singapore', 'invoicing'), |
|
| 323 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
| 324 | + 'SI' => __('Slovenia', 'invoicing'), |
|
| 325 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
| 326 | + 'SO' => __('Somalia', 'invoicing'), |
|
| 327 | + 'ZA' => __('South Africa', 'invoicing'), |
|
| 328 | + 'GS' => __('South Georgia', 'invoicing'), |
|
| 329 | + 'KR' => __('South Korea', 'invoicing'), |
|
| 330 | + 'SS' => __('South Sudan', 'invoicing'), |
|
| 331 | + 'ES' => __('Spain', 'invoicing'), |
|
| 332 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
| 333 | + 'SD' => __('Sudan', 'invoicing'), |
|
| 334 | + 'SR' => __('Suriname', 'invoicing'), |
|
| 335 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
| 336 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
| 337 | + 'SE' => __('Sweden', 'invoicing'), |
|
| 338 | + 'CH' => __('Switzerland', 'invoicing'), |
|
| 339 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
| 340 | + 'TW' => __('Taiwan', 'invoicing'), |
|
| 341 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
| 342 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
| 343 | + 'TH' => __('Thailand', 'invoicing'), |
|
| 344 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
| 345 | + 'TG' => __('Togo', 'invoicing'), |
|
| 346 | + 'TK' => __('Tokelau', 'invoicing'), |
|
| 347 | + 'TO' => __('Tonga', 'invoicing'), |
|
| 348 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
| 349 | + 'TN' => __('Tunisia', 'invoicing'), |
|
| 350 | + 'TR' => __('Turkey', 'invoicing'), |
|
| 351 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
| 352 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
| 353 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
| 354 | + 'UG' => __('Uganda', 'invoicing'), |
|
| 355 | + 'UA' => __('Ukraine', 'invoicing'), |
|
| 356 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
| 357 | + 'UY' => __('Uruguay', 'invoicing'), |
|
| 358 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
| 359 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
| 360 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
| 361 | + 'VE' => __('Venezuela', 'invoicing'), |
|
| 362 | + 'VN' => __('Vietnam', 'invoicing'), |
|
| 363 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
| 364 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
| 365 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
| 366 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
| 367 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
| 368 | + 'YE' => __('Yemen', 'invoicing'), |
|
| 369 | + 'ZM' => __('Zambia', 'invoicing'), |
|
| 370 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
| 371 | + ); |
|
| 372 | 372 | |
| 373 | 373 | if ( $first_empty ) { |
| 374 | 374 | $countries = array_merge( array( '' => '' ), $countries ); |
@@ -1537,30 +1537,30 @@ discard block |
||
| 1537 | 1537 | } |
| 1538 | 1538 | |
| 1539 | 1539 | function wpinv_get_states_field() { |
| 1540 | - if( empty( $_POST['country'] ) ) { |
|
| 1541 | - $_POST['country'] = wpinv_get_default_country(); |
|
| 1542 | - } |
|
| 1543 | - $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1540 | + if( empty( $_POST['country'] ) ) { |
|
| 1541 | + $_POST['country'] = wpinv_get_default_country(); |
|
| 1542 | + } |
|
| 1543 | + $states = wpinv_get_country_states( sanitize_text_field( $_POST['country'] ) ); |
|
| 1544 | 1544 | |
| 1545 | - if( !empty( $states ) ) { |
|
| 1546 | - $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1545 | + if( !empty( $states ) ) { |
|
| 1546 | + $sanitized_field_name = sanitize_text_field( $_POST['field_name'] ); |
|
| 1547 | 1547 | |
| 1548 | 1548 | $args = array( |
| 1549 | - 'name' => $sanitized_field_name, |
|
| 1550 | - 'id' => $sanitized_field_name, |
|
| 1551 | - 'class' => $sanitized_field_name . ' wpinv-select', |
|
| 1552 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1553 | - 'show_option_all' => false, |
|
| 1554 | - 'show_option_none' => false |
|
| 1555 | - ); |
|
| 1556 | - |
|
| 1557 | - $response = wpinv_html_select( $args ); |
|
| 1558 | - |
|
| 1559 | - } else { |
|
| 1560 | - $response = 'nostates'; |
|
| 1561 | - } |
|
| 1549 | + 'name' => $sanitized_field_name, |
|
| 1550 | + 'id' => $sanitized_field_name, |
|
| 1551 | + 'class' => $sanitized_field_name . ' wpinv-select', |
|
| 1552 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1553 | + 'show_option_all' => false, |
|
| 1554 | + 'show_option_none' => false |
|
| 1555 | + ); |
|
| 1556 | + |
|
| 1557 | + $response = wpinv_html_select( $args ); |
|
| 1558 | + |
|
| 1559 | + } else { |
|
| 1560 | + $response = 'nostates'; |
|
| 1561 | + } |
|
| 1562 | 1562 | |
| 1563 | - return $response; |
|
| 1563 | + return $response; |
|
| 1564 | 1564 | } |
| 1565 | 1565 | |
| 1566 | 1566 | function wpinv_default_billing_country( $country = '', $user_id = 0 ) { |
@@ -121,29 +121,29 @@ discard block |
||
| 121 | 121 | |
| 122 | 122 | function wpinv_get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 123 | 123 | if ( ! empty( $args ) && is_array( $args ) ) { |
| 124 | - extract( $args ); |
|
| 125 | - } |
|
| 124 | + extract( $args ); |
|
| 125 | + } |
|
| 126 | 126 | |
| 127 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 128 | - // Allow 3rd party plugin filter template file from their plugin. |
|
| 129 | - $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 127 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
| 128 | + // Allow 3rd party plugin filter template file from their plugin. |
|
| 129 | + $located = apply_filters( 'wpinv_get_template', $located, $template_name, $args, $template_path, $default_path ); |
|
| 130 | 130 | |
| 131 | - if ( ! file_exists( $located ) ) { |
|
| 131 | + if ( ! file_exists( $located ) ) { |
|
| 132 | 132 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
| 133 | - return; |
|
| 134 | - } |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | 135 | |
| 136 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 136 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
| 137 | 137 | |
| 138 | - include( $located ); |
|
| 138 | + include( $located ); |
|
| 139 | 139 | |
| 140 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 140 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
| 144 | - ob_start(); |
|
| 145 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 146 | - return ob_get_clean(); |
|
| 144 | + ob_start(); |
|
| 145 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
| 146 | + return ob_get_clean(); |
|
| 147 | 147 | } |
| 148 | 148 | |
| 149 | 149 | function wpinv_locate_template( $template_name, $template_path = '', $default_path = '' ) { |
@@ -173,120 +173,120 @@ discard block |
||
| 173 | 173 | } |
| 174 | 174 | |
| 175 | 175 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
| 176 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 176 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
| 177 | 177 | |
| 178 | - // Setup possible parts |
|
| 179 | - $templates = array(); |
|
| 180 | - if ( isset( $name ) ) |
|
| 181 | - $templates[] = $slug . '-' . $name . '.php'; |
|
| 182 | - $templates[] = $slug . '.php'; |
|
| 178 | + // Setup possible parts |
|
| 179 | + $templates = array(); |
|
| 180 | + if ( isset( $name ) ) |
|
| 181 | + $templates[] = $slug . '-' . $name . '.php'; |
|
| 182 | + $templates[] = $slug . '.php'; |
|
| 183 | 183 | |
| 184 | - // Allow template parts to be filtered |
|
| 185 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 184 | + // Allow template parts to be filtered |
|
| 185 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
| 186 | 186 | |
| 187 | - // Return the part that is found |
|
| 188 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 187 | + // Return the part that is found |
|
| 188 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
| 189 | 189 | } |
| 190 | 190 | |
| 191 | 191 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
| 192 | - // No file found yet |
|
| 193 | - $located = false; |
|
| 192 | + // No file found yet |
|
| 193 | + $located = false; |
|
| 194 | 194 | |
| 195 | - // Try to find a template file |
|
| 196 | - foreach ( (array)$template_names as $template_name ) { |
|
| 195 | + // Try to find a template file |
|
| 196 | + foreach ( (array)$template_names as $template_name ) { |
|
| 197 | 197 | |
| 198 | - // Continue if template is empty |
|
| 199 | - if ( empty( $template_name ) ) |
|
| 200 | - continue; |
|
| 198 | + // Continue if template is empty |
|
| 199 | + if ( empty( $template_name ) ) |
|
| 200 | + continue; |
|
| 201 | 201 | |
| 202 | - // Trim off any slashes from the template name |
|
| 203 | - $template_name = ltrim( $template_name, '/' ); |
|
| 202 | + // Trim off any slashes from the template name |
|
| 203 | + $template_name = ltrim( $template_name, '/' ); |
|
| 204 | 204 | |
| 205 | - // try locating this template file by looping through the template paths |
|
| 206 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 205 | + // try locating this template file by looping through the template paths |
|
| 206 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
| 207 | 207 | |
| 208 | - if( file_exists( $template_path . $template_name ) ) { |
|
| 209 | - $located = $template_path . $template_name; |
|
| 210 | - break; |
|
| 211 | - } |
|
| 212 | - } |
|
| 208 | + if( file_exists( $template_path . $template_name ) ) { |
|
| 209 | + $located = $template_path . $template_name; |
|
| 210 | + break; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | 213 | |
| 214 | - if( !empty( $located ) ) { |
|
| 215 | - break; |
|
| 216 | - } |
|
| 217 | - } |
|
| 214 | + if( !empty( $located ) ) { |
|
| 215 | + break; |
|
| 216 | + } |
|
| 217 | + } |
|
| 218 | 218 | |
| 219 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | - load_template( $located, $require_once ); |
|
| 219 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
| 220 | + load_template( $located, $require_once ); |
|
| 221 | 221 | |
| 222 | - return $located; |
|
| 222 | + return $located; |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | function wpinv_get_theme_template_paths() { |
| 226 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 226 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
| 227 | 227 | |
| 228 | - $file_paths = array( |
|
| 229 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 230 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | - 100 => wpinv_get_templates_dir() |
|
| 232 | - ); |
|
| 228 | + $file_paths = array( |
|
| 229 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
| 230 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
| 231 | + 100 => wpinv_get_templates_dir() |
|
| 232 | + ); |
|
| 233 | 233 | |
| 234 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 234 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
| 235 | 235 | |
| 236 | - // sort the file paths based on priority |
|
| 237 | - ksort( $file_paths, SORT_NUMERIC ); |
|
| 236 | + // sort the file paths based on priority |
|
| 237 | + ksort( $file_paths, SORT_NUMERIC ); |
|
| 238 | 238 | |
| 239 | - return array_map( 'trailingslashit', $file_paths ); |
|
| 239 | + return array_map( 'trailingslashit', $file_paths ); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | function wpinv_get_theme_template_dir_name() { |
| 243 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 243 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'wpinv_templates' ) ); |
|
| 244 | 244 | } |
| 245 | 245 | |
| 246 | 246 | function wpinv_checkout_meta_tags() { |
| 247 | 247 | |
| 248 | - $pages = array(); |
|
| 249 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
| 250 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 251 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 248 | + $pages = array(); |
|
| 249 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
| 250 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
| 251 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
| 252 | 252 | |
| 253 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 254 | - return; |
|
| 255 | - } |
|
| 253 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
| 254 | + return; |
|
| 255 | + } |
|
| 256 | 256 | |
| 257 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 257 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
| 258 | 258 | } |
| 259 | 259 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
| 260 | 260 | |
| 261 | 261 | function wpinv_add_body_classes( $class ) { |
| 262 | - $classes = (array)$class; |
|
| 262 | + $classes = (array)$class; |
|
| 263 | 263 | |
| 264 | - if( wpinv_is_checkout() ) { |
|
| 265 | - $classes[] = 'wpinv-checkout'; |
|
| 266 | - $classes[] = 'wpinv-page'; |
|
| 267 | - } |
|
| 264 | + if( wpinv_is_checkout() ) { |
|
| 265 | + $classes[] = 'wpinv-checkout'; |
|
| 266 | + $classes[] = 'wpinv-page'; |
|
| 267 | + } |
|
| 268 | 268 | |
| 269 | - if( wpinv_is_success_page() ) { |
|
| 270 | - $classes[] = 'wpinv-success'; |
|
| 271 | - $classes[] = 'wpinv-page'; |
|
| 272 | - } |
|
| 269 | + if( wpinv_is_success_page() ) { |
|
| 270 | + $classes[] = 'wpinv-success'; |
|
| 271 | + $classes[] = 'wpinv-page'; |
|
| 272 | + } |
|
| 273 | 273 | |
| 274 | - if( wpinv_is_failed_transaction_page() ) { |
|
| 275 | - $classes[] = 'wpinv-failed-transaction'; |
|
| 276 | - $classes[] = 'wpinv-page'; |
|
| 277 | - } |
|
| 274 | + if( wpinv_is_failed_transaction_page() ) { |
|
| 275 | + $classes[] = 'wpinv-failed-transaction'; |
|
| 276 | + $classes[] = 'wpinv-page'; |
|
| 277 | + } |
|
| 278 | 278 | |
| 279 | - if( wpinv_is_invoice_history_page() ) { |
|
| 280 | - $classes[] = 'wpinv-history'; |
|
| 281 | - $classes[] = 'wpinv-page'; |
|
| 282 | - } |
|
| 279 | + if( wpinv_is_invoice_history_page() ) { |
|
| 280 | + $classes[] = 'wpinv-history'; |
|
| 281 | + $classes[] = 'wpinv-page'; |
|
| 282 | + } |
|
| 283 | 283 | |
| 284 | - if( wpinv_is_test_mode() ) { |
|
| 285 | - $classes[] = 'wpinv-test-mode'; |
|
| 286 | - $classes[] = 'wpinv-page'; |
|
| 287 | - } |
|
| 284 | + if( wpinv_is_test_mode() ) { |
|
| 285 | + $classes[] = 'wpinv-test-mode'; |
|
| 286 | + $classes[] = 'wpinv-page'; |
|
| 287 | + } |
|
| 288 | 288 | |
| 289 | - return array_unique( $classes ); |
|
| 289 | + return array_unique( $classes ); |
|
| 290 | 290 | } |
| 291 | 291 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
| 292 | 292 | |
@@ -1451,7 +1451,7 @@ discard block |
||
| 1451 | 1451 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
| 1452 | 1452 | |
| 1453 | 1453 | function wpinv_empty_cart_message() { |
| 1454 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1454 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
| 1455 | 1455 | } |
| 1456 | 1456 | |
| 1457 | 1457 | /** |
@@ -1461,7 +1461,7 @@ discard block |
||
| 1461 | 1461 | * @return void |
| 1462 | 1462 | */ |
| 1463 | 1463 | function wpinv_empty_checkout_cart() { |
| 1464 | - echo wpinv_empty_cart_message(); |
|
| 1464 | + echo wpinv_empty_cart_message(); |
|
| 1465 | 1465 | } |
| 1466 | 1466 | add_action( 'wpinv_cart_empty', 'wpinv_empty_checkout_cart' ); |
| 1467 | 1467 | |
@@ -1598,11 +1598,11 @@ discard block |
||
| 1598 | 1598 | do_action( 'wpinv_payment_mode_before_gateways' ); |
| 1599 | 1599 | |
| 1600 | 1600 | if(!empty($gateways)){ |
| 1601 | - foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1602 | - $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1603 | - $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1604 | - $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1605 | - ?> |
|
| 1601 | + foreach ( $gateways as $gateway_id => $gateway ) { |
|
| 1602 | + $checked = checked( $gateway_id, $chosen_gateway, false ); |
|
| 1603 | + $button_label = wpinv_get_gateway_button_label( $gateway_id ); |
|
| 1604 | + $description = wpinv_get_gateway_description( $gateway_id ); |
|
| 1605 | + ?> |
|
| 1606 | 1606 | <div class="list-group-item"> |
| 1607 | 1607 | <div class="radio"> |
| 1608 | 1608 | <label><input type="radio" data-button-text="<?php echo esc_attr( $button_label );?>" value="<?php echo esc_attr( $gateway_id ) ;?>" <?php echo $checked ;?> id="wpi_gateway_<?php echo esc_attr( $gateway_id );?>" name="wpi-gateway" class="wpi-pmethod"><?php echo esc_html( $gateway['checkout_label'] ); ?></label> |
@@ -1615,9 +1615,9 @@ discard block |
||
| 1615 | 1615 | </div> |
| 1616 | 1616 | </div> |
| 1617 | 1617 | <?php |
| 1618 | - } |
|
| 1618 | + } |
|
| 1619 | 1619 | }else{ |
| 1620 | - echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1620 | + echo '<div class="alert alert-warning">'. __('No payment gateway active','invoicing') .'</div>'; |
|
| 1621 | 1621 | } |
| 1622 | 1622 | |
| 1623 | 1623 | do_action( 'wpinv_payment_mode_after_gateways' ); |
@@ -831,328 +831,328 @@ discard block |
||
| 831 | 831 | } |
| 832 | 832 | |
| 833 | 833 | function wpinv_get_pages( $with_slug = false, $default_label = NULL ) { |
| 834 | - $pages_options = array(); |
|
| 834 | + $pages_options = array(); |
|
| 835 | 835 | |
| 836 | - if( $default_label !== NULL && $default_label !== false ) { |
|
| 837 | - $pages_options = array( '' => $default_label ); // Blank option |
|
| 838 | - } |
|
| 836 | + if( $default_label !== NULL && $default_label !== false ) { |
|
| 837 | + $pages_options = array( '' => $default_label ); // Blank option |
|
| 838 | + } |
|
| 839 | 839 | |
| 840 | - $pages = get_pages(); |
|
| 841 | - if ( $pages ) { |
|
| 842 | - foreach ( $pages as $page ) { |
|
| 843 | - $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 840 | + $pages = get_pages(); |
|
| 841 | + if ( $pages ) { |
|
| 842 | + foreach ( $pages as $page ) { |
|
| 843 | + $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title; |
|
| 844 | 844 | $pages_options[ $page->ID ] = $title; |
| 845 | - } |
|
| 846 | - } |
|
| 845 | + } |
|
| 846 | + } |
|
| 847 | 847 | |
| 848 | - return $pages_options; |
|
| 848 | + return $pages_options; |
|
| 849 | 849 | } |
| 850 | 850 | |
| 851 | 851 | function wpinv_header_callback( $args ) { |
| 852 | - if ( !empty( $args['desc'] ) ) { |
|
| 852 | + if ( !empty( $args['desc'] ) ) { |
|
| 853 | 853 | echo $args['desc']; |
| 854 | 854 | } |
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | function wpinv_hidden_callback( $args ) { |
| 858 | - global $wpinv_options; |
|
| 859 | - |
|
| 860 | - if ( isset( $args['set_value'] ) ) { |
|
| 861 | - $value = $args['set_value']; |
|
| 862 | - } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 863 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 864 | - } else { |
|
| 865 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 869 | - $args['readonly'] = true; |
|
| 870 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 871 | - $name = ''; |
|
| 872 | - } else { |
|
| 873 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 874 | - } |
|
| 875 | - |
|
| 876 | - $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 858 | + global $wpinv_options; |
|
| 859 | + |
|
| 860 | + if ( isset( $args['set_value'] ) ) { |
|
| 861 | + $value = $args['set_value']; |
|
| 862 | + } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 863 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 864 | + } else { |
|
| 865 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 869 | + $args['readonly'] = true; |
|
| 870 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 871 | + $name = ''; |
|
| 872 | + } else { |
|
| 873 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 874 | + } |
|
| 875 | + |
|
| 876 | + $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />'; |
|
| 877 | 877 | |
| 878 | - echo $html; |
|
| 878 | + echo $html; |
|
| 879 | 879 | } |
| 880 | 880 | |
| 881 | 881 | function wpinv_checkbox_callback( $args ) { |
| 882 | - global $wpinv_options; |
|
| 882 | + global $wpinv_options; |
|
| 883 | 883 | |
| 884 | 884 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 885 | 885 | |
| 886 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 887 | - $name = ''; |
|
| 888 | - } else { |
|
| 889 | - $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 890 | - } |
|
| 886 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 887 | + $name = ''; |
|
| 888 | + } else { |
|
| 889 | + $name = 'name="wpinv_settings[' . $sanitize_id . ']"'; |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | - $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 893 | - $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 894 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 892 | + $checked = isset( $wpinv_options[ $args['id'] ] ) ? checked( 1, $wpinv_options[ $args['id'] ], false ) : ''; |
|
| 893 | + $html = '<input type="checkbox" id="wpinv_settings[' . $sanitize_id . ']"' . $name . ' value="1" ' . $checked . '/>'; |
|
| 894 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 895 | 895 | |
| 896 | - echo $html; |
|
| 896 | + echo $html; |
|
| 897 | 897 | } |
| 898 | 898 | |
| 899 | 899 | function wpinv_multicheck_callback( $args ) { |
| 900 | - global $wpinv_options; |
|
| 900 | + global $wpinv_options; |
|
| 901 | 901 | |
| 902 | - $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 902 | + $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
|
| 903 | 903 | |
| 904 | - if ( ! empty( $args['options'] ) ) { |
|
| 905 | - foreach( $args['options'] as $key => $option ): |
|
| 906 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 907 | - if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 908 | - $enabled = $sanitize_key; |
|
| 909 | - } else { |
|
| 910 | - $enabled = NULL; |
|
| 911 | - } |
|
| 912 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 913 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 914 | - endforeach; |
|
| 915 | - echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 916 | - } |
|
| 904 | + if ( ! empty( $args['options'] ) ) { |
|
| 905 | + foreach( $args['options'] as $key => $option ): |
|
| 906 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 907 | + if ( isset( $wpinv_options[$args['id']][$sanitize_key] ) ) { |
|
| 908 | + $enabled = $sanitize_key; |
|
| 909 | + } else { |
|
| 910 | + $enabled = NULL; |
|
| 911 | + } |
|
| 912 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/> '; |
|
| 913 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label><br/>'; |
|
| 914 | + endforeach; |
|
| 915 | + echo '<p class="description">' . $args['desc'] . '</p>'; |
|
| 916 | + } |
|
| 917 | 917 | } |
| 918 | 918 | |
| 919 | 919 | function wpinv_payment_icons_callback( $args ) { |
| 920 | - global $wpinv_options; |
|
| 920 | + global $wpinv_options; |
|
| 921 | 921 | |
| 922 | 922 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 923 | 923 | |
| 924 | - if ( ! empty( $args['options'] ) ) { |
|
| 925 | - foreach( $args['options'] as $key => $option ) { |
|
| 924 | + if ( ! empty( $args['options'] ) ) { |
|
| 925 | + foreach( $args['options'] as $key => $option ) { |
|
| 926 | 926 | $sanitize_key = wpinv_sanitize_key( $key ); |
| 927 | 927 | |
| 928 | - if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 929 | - $enabled = $option; |
|
| 930 | - } else { |
|
| 931 | - $enabled = NULL; |
|
| 932 | - } |
|
| 933 | - |
|
| 934 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 935 | - |
|
| 936 | - echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 937 | - |
|
| 938 | - if ( wpinv_string_is_image_url( $key ) ) { |
|
| 939 | - echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 940 | - } else { |
|
| 941 | - $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 942 | - |
|
| 943 | - if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 944 | - $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 945 | - } else { |
|
| 946 | - $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 947 | - $content_dir = WP_CONTENT_DIR; |
|
| 948 | - |
|
| 949 | - if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 950 | - // Replaces backslashes with forward slashes for Windows systems |
|
| 951 | - $image = wp_normalize_path( $image ); |
|
| 952 | - $content_dir = wp_normalize_path( $content_dir ); |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - $image = str_replace( $content_dir, content_url(), $image ); |
|
| 956 | - } |
|
| 957 | - |
|
| 958 | - echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 959 | - } |
|
| 960 | - echo $option . '</label>'; |
|
| 961 | - } |
|
| 962 | - echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 963 | - } |
|
| 928 | + if( isset( $wpinv_options[$args['id']][$key] ) ) { |
|
| 929 | + $enabled = $option; |
|
| 930 | + } else { |
|
| 931 | + $enabled = NULL; |
|
| 932 | + } |
|
| 933 | + |
|
| 934 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">'; |
|
| 935 | + |
|
| 936 | + echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/> '; |
|
| 937 | + |
|
| 938 | + if ( wpinv_string_is_image_url( $key ) ) { |
|
| 939 | + echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 940 | + } else { |
|
| 941 | + $card = strtolower( str_replace( ' ', '', $option ) ); |
|
| 942 | + |
|
| 943 | + if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) { |
|
| 944 | + $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' ); |
|
| 945 | + } else { |
|
| 946 | + $image = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false ); |
|
| 947 | + $content_dir = WP_CONTENT_DIR; |
|
| 948 | + |
|
| 949 | + if ( function_exists( 'wp_normalize_path' ) ) { |
|
| 950 | + // Replaces backslashes with forward slashes for Windows systems |
|
| 951 | + $image = wp_normalize_path( $image ); |
|
| 952 | + $content_dir = wp_normalize_path( $content_dir ); |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + $image = str_replace( $content_dir, content_url(), $image ); |
|
| 956 | + } |
|
| 957 | + |
|
| 958 | + echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>'; |
|
| 959 | + } |
|
| 960 | + echo $option . '</label>'; |
|
| 961 | + } |
|
| 962 | + echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 963 | + } |
|
| 964 | 964 | } |
| 965 | 965 | |
| 966 | 966 | function wpinv_radio_callback( $args ) { |
| 967 | - global $wpinv_options; |
|
| 967 | + global $wpinv_options; |
|
| 968 | 968 | |
| 969 | 969 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 970 | 970 | |
| 971 | 971 | foreach ( $args['options'] as $key => $option ) : |
| 972 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 972 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 973 | 973 | |
| 974 | 974 | $checked = false; |
| 975 | 975 | |
| 976 | - if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 977 | - $checked = true; |
|
| 978 | - elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 979 | - $checked = true; |
|
| 976 | + if ( isset( $wpinv_options[ $args['id'] ] ) && $wpinv_options[ $args['id'] ] == $key ) |
|
| 977 | + $checked = true; |
|
| 978 | + elseif( isset( $args['std'] ) && $args['std'] == $key && ! isset( $wpinv_options[ $args['id'] ] ) ) |
|
| 979 | + $checked = true; |
|
| 980 | 980 | |
| 981 | - echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 982 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 983 | - endforeach; |
|
| 981 | + echo '<input name="wpinv_settings[' . $sanitize_id . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="radio" value="' . $sanitize_key . '" ' . checked(true, $checked, false) . '/> '; |
|
| 982 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option ) . '</label><br/>'; |
|
| 983 | + endforeach; |
|
| 984 | 984 | |
| 985 | - echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 985 | + echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>'; |
|
| 986 | 986 | } |
| 987 | 987 | |
| 988 | 988 | function wpinv_gateways_callback( $args ) { |
| 989 | - global $wpinv_options; |
|
| 989 | + global $wpinv_options; |
|
| 990 | 990 | |
| 991 | 991 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 992 | 992 | |
| 993 | - foreach ( $args['options'] as $key => $option ) : |
|
| 994 | - $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 993 | + foreach ( $args['options'] as $key => $option ) : |
|
| 994 | + $sanitize_key = wpinv_sanitize_key( $key ); |
|
| 995 | 995 | |
| 996 | 996 | if ( isset( $wpinv_options['gateways'][ $key ] ) ) |
| 997 | - $enabled = '1'; |
|
| 998 | - else |
|
| 999 | - $enabled = null; |
|
| 997 | + $enabled = '1'; |
|
| 998 | + else |
|
| 999 | + $enabled = null; |
|
| 1000 | 1000 | |
| 1001 | - echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1002 | - echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 1003 | - endforeach; |
|
| 1001 | + echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/> '; |
|
| 1002 | + echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>'; |
|
| 1003 | + endforeach; |
|
| 1004 | 1004 | } |
| 1005 | 1005 | |
| 1006 | 1006 | function wpinv_gateway_select_callback($args) { |
| 1007 | - global $wpinv_options; |
|
| 1007 | + global $wpinv_options; |
|
| 1008 | 1008 | |
| 1009 | 1009 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1010 | 1010 | |
| 1011 | - echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
| 1011 | + echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']">'; |
|
| 1012 | 1012 | |
| 1013 | - foreach ( $args['options'] as $key => $option ) : |
|
| 1014 | - if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1013 | + foreach ( $args['options'] as $key => $option ) : |
|
| 1014 | + if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
|
| 1015 | 1015 | $selected = selected( $key, $args['selected'], false ); |
| 1016 | 1016 | } else { |
| 1017 | 1017 | $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : ''; |
| 1018 | 1018 | } |
| 1019 | - echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1020 | - endforeach; |
|
| 1019 | + echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>'; |
|
| 1020 | + endforeach; |
|
| 1021 | 1021 | |
| 1022 | - echo '</select>'; |
|
| 1023 | - echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1022 | + echo '</select>'; |
|
| 1023 | + echo '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | 1026 | function wpinv_text_callback( $args ) { |
| 1027 | - global $wpinv_options; |
|
| 1027 | + global $wpinv_options; |
|
| 1028 | 1028 | |
| 1029 | 1029 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1030 | 1030 | |
| 1031 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1032 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1033 | - } else { |
|
| 1034 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1035 | - } |
|
| 1036 | - |
|
| 1037 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1038 | - $args['readonly'] = true; |
|
| 1039 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1040 | - $name = ''; |
|
| 1041 | - } else { |
|
| 1042 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1043 | - } |
|
| 1044 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1045 | - |
|
| 1046 | - $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 1047 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1048 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1049 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1050 | - |
|
| 1051 | - echo $html; |
|
| 1031 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1032 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1033 | + } else { |
|
| 1034 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1035 | + } |
|
| 1036 | + |
|
| 1037 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1038 | + $args['readonly'] = true; |
|
| 1039 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1040 | + $name = ''; |
|
| 1041 | + } else { |
|
| 1042 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1043 | + } |
|
| 1044 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1045 | + |
|
| 1046 | + $readonly = $args['readonly'] === true ? ' readonly="readonly"' : ''; |
|
| 1047 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1048 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>'; |
|
| 1049 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1050 | + |
|
| 1051 | + echo $html; |
|
| 1052 | 1052 | } |
| 1053 | 1053 | |
| 1054 | 1054 | function wpinv_number_callback( $args ) { |
| 1055 | - global $wpinv_options; |
|
| 1055 | + global $wpinv_options; |
|
| 1056 | 1056 | |
| 1057 | 1057 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1058 | 1058 | |
| 1059 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1060 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1061 | - } else { |
|
| 1062 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1063 | - } |
|
| 1064 | - |
|
| 1065 | - if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1066 | - $args['readonly'] = true; |
|
| 1067 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1068 | - $name = ''; |
|
| 1069 | - } else { |
|
| 1070 | - $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1071 | - } |
|
| 1072 | - |
|
| 1073 | - $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1074 | - $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1075 | - $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1076 | - $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1077 | - |
|
| 1078 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1079 | - $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1080 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1081 | - |
|
| 1082 | - echo $html; |
|
| 1059 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1060 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1061 | + } else { |
|
| 1062 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1063 | + } |
|
| 1064 | + |
|
| 1065 | + if ( isset( $args['faux'] ) && true === $args['faux'] ) { |
|
| 1066 | + $args['readonly'] = true; |
|
| 1067 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1068 | + $name = ''; |
|
| 1069 | + } else { |
|
| 1070 | + $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"'; |
|
| 1071 | + } |
|
| 1072 | + |
|
| 1073 | + $max = isset( $args['max'] ) ? $args['max'] : 999999; |
|
| 1074 | + $min = isset( $args['min'] ) ? $args['min'] : 0; |
|
| 1075 | + $step = isset( $args['step'] ) ? $args['step'] : 1; |
|
| 1076 | + $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : ''; |
|
| 1077 | + |
|
| 1078 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1079 | + $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1080 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1081 | + |
|
| 1082 | + echo $html; |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | function wpinv_textarea_callback( $args ) { |
| 1086 | - global $wpinv_options; |
|
| 1086 | + global $wpinv_options; |
|
| 1087 | 1087 | |
| 1088 | 1088 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1089 | 1089 | |
| 1090 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1091 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1092 | - } else { |
|
| 1093 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1094 | - } |
|
| 1090 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1091 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1092 | + } else { |
|
| 1093 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1094 | + } |
|
| 1095 | 1095 | |
| 1096 | 1096 | $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
| 1097 | 1097 | $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text'; |
| 1098 | 1098 | |
| 1099 | - $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1100 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1099 | + $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1100 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1101 | 1101 | |
| 1102 | - echo $html; |
|
| 1102 | + echo $html; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | |
| 1105 | 1105 | function wpinv_password_callback( $args ) { |
| 1106 | - global $wpinv_options; |
|
| 1106 | + global $wpinv_options; |
|
| 1107 | 1107 | |
| 1108 | 1108 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1109 | 1109 | |
| 1110 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1111 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1112 | - } else { |
|
| 1113 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1114 | - } |
|
| 1110 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1111 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1112 | + } else { |
|
| 1113 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1114 | + } |
|
| 1115 | 1115 | |
| 1116 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1117 | - $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1118 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1116 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1117 | + $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>'; |
|
| 1118 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1119 | 1119 | |
| 1120 | - echo $html; |
|
| 1120 | + echo $html; |
|
| 1121 | 1121 | } |
| 1122 | 1122 | |
| 1123 | 1123 | function wpinv_missing_callback($args) { |
| 1124 | - printf( |
|
| 1125 | - __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1126 | - '<strong>' . $args['id'] . '</strong>' |
|
| 1127 | - ); |
|
| 1124 | + printf( |
|
| 1125 | + __( 'The callback function used for the %s setting is missing.', 'invoicing' ), |
|
| 1126 | + '<strong>' . $args['id'] . '</strong>' |
|
| 1127 | + ); |
|
| 1128 | 1128 | } |
| 1129 | 1129 | |
| 1130 | 1130 | function wpinv_select_callback($args) { |
| 1131 | - global $wpinv_options; |
|
| 1131 | + global $wpinv_options; |
|
| 1132 | 1132 | |
| 1133 | 1133 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1134 | 1134 | |
| 1135 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1136 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1137 | - } else { |
|
| 1138 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1139 | - } |
|
| 1135 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1136 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1137 | + } else { |
|
| 1138 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1139 | + } |
|
| 1140 | 1140 | |
| 1141 | 1141 | if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) { |
| 1142 | 1142 | $value = $args['selected']; |
| 1143 | 1143 | } |
| 1144 | 1144 | |
| 1145 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1146 | - $placeholder = $args['placeholder']; |
|
| 1147 | - } else { |
|
| 1148 | - $placeholder = ''; |
|
| 1149 | - } |
|
| 1150 | - |
|
| 1151 | - if ( isset( $args['chosen'] ) ) { |
|
| 1152 | - $chosen = 'class="wpinv-chosen"'; |
|
| 1153 | - } else { |
|
| 1154 | - $chosen = ''; |
|
| 1155 | - } |
|
| 1145 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1146 | + $placeholder = $args['placeholder']; |
|
| 1147 | + } else { |
|
| 1148 | + $placeholder = ''; |
|
| 1149 | + } |
|
| 1150 | + |
|
| 1151 | + if ( isset( $args['chosen'] ) ) { |
|
| 1152 | + $chosen = 'class="wpinv-chosen"'; |
|
| 1153 | + } else { |
|
| 1154 | + $chosen = ''; |
|
| 1155 | + } |
|
| 1156 | 1156 | |
| 1157 | 1157 | if( !empty( $args['onchange'] ) ) { |
| 1158 | 1158 | $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"'; |
@@ -1160,143 +1160,143 @@ discard block |
||
| 1160 | 1160 | $onchange = ''; |
| 1161 | 1161 | } |
| 1162 | 1162 | |
| 1163 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1163 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" ' . $chosen . 'data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />'; |
|
| 1164 | 1164 | |
| 1165 | - foreach ( $args['options'] as $option => $name ) { |
|
| 1166 | - $selected = selected( $option, $value, false ); |
|
| 1167 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1168 | - } |
|
| 1165 | + foreach ( $args['options'] as $option => $name ) { |
|
| 1166 | + $selected = selected( $option, $value, false ); |
|
| 1167 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1168 | + } |
|
| 1169 | 1169 | |
| 1170 | - $html .= '</select>'; |
|
| 1171 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1170 | + $html .= '</select>'; |
|
| 1171 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1172 | 1172 | |
| 1173 | - echo $html; |
|
| 1173 | + echo $html; |
|
| 1174 | 1174 | } |
| 1175 | 1175 | |
| 1176 | 1176 | function wpinv_color_select_callback( $args ) { |
| 1177 | - global $wpinv_options; |
|
| 1177 | + global $wpinv_options; |
|
| 1178 | 1178 | |
| 1179 | 1179 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1180 | 1180 | |
| 1181 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1182 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1183 | - } else { |
|
| 1184 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1185 | - } |
|
| 1181 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1182 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1183 | + } else { |
|
| 1184 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1185 | + } |
|
| 1186 | 1186 | |
| 1187 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1187 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>'; |
|
| 1188 | 1188 | |
| 1189 | - foreach ( $args['options'] as $option => $color ) { |
|
| 1190 | - $selected = selected( $option, $value, false ); |
|
| 1191 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1192 | - } |
|
| 1189 | + foreach ( $args['options'] as $option => $color ) { |
|
| 1190 | + $selected = selected( $option, $value, false ); |
|
| 1191 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>'; |
|
| 1192 | + } |
|
| 1193 | 1193 | |
| 1194 | - $html .= '</select>'; |
|
| 1195 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1194 | + $html .= '</select>'; |
|
| 1195 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1196 | 1196 | |
| 1197 | - echo $html; |
|
| 1197 | + echo $html; |
|
| 1198 | 1198 | } |
| 1199 | 1199 | |
| 1200 | 1200 | function wpinv_rich_editor_callback( $args ) { |
| 1201 | - global $wpinv_options, $wp_version; |
|
| 1201 | + global $wpinv_options, $wp_version; |
|
| 1202 | 1202 | |
| 1203 | 1203 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1204 | 1204 | |
| 1205 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1206 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1205 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1206 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1207 | 1207 | |
| 1208 | - if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1209 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1210 | - } |
|
| 1211 | - } else { |
|
| 1212 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1213 | - } |
|
| 1208 | + if( empty( $args['allow_blank'] ) && empty( $value ) ) { |
|
| 1209 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1210 | + } |
|
| 1211 | + } else { |
|
| 1212 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1213 | + } |
|
| 1214 | 1214 | |
| 1215 | - $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1215 | + $rows = isset( $args['size'] ) ? $args['size'] : 20; |
|
| 1216 | 1216 | |
| 1217 | - if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1218 | - ob_start(); |
|
| 1219 | - wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1220 | - $html = ob_get_clean(); |
|
| 1221 | - } else { |
|
| 1222 | - $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1223 | - } |
|
| 1217 | + if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) { |
|
| 1218 | + ob_start(); |
|
| 1219 | + wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ) ) ); |
|
| 1220 | + $html = ob_get_clean(); |
|
| 1221 | + } else { |
|
| 1222 | + $html = '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>'; |
|
| 1223 | + } |
|
| 1224 | 1224 | |
| 1225 | - $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1225 | + $html .= '<br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1226 | 1226 | |
| 1227 | - echo $html; |
|
| 1227 | + echo $html; |
|
| 1228 | 1228 | } |
| 1229 | 1229 | |
| 1230 | 1230 | function wpinv_upload_callback( $args ) { |
| 1231 | - global $wpinv_options; |
|
| 1231 | + global $wpinv_options; |
|
| 1232 | 1232 | |
| 1233 | 1233 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1234 | 1234 | |
| 1235 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1236 | - $value = $wpinv_options[$args['id']]; |
|
| 1237 | - } else { |
|
| 1238 | - $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1239 | - } |
|
| 1235 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1236 | + $value = $wpinv_options[$args['id']]; |
|
| 1237 | + } else { |
|
| 1238 | + $value = isset($args['std']) ? $args['std'] : ''; |
|
| 1239 | + } |
|
| 1240 | 1240 | |
| 1241 | - $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1242 | - $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1243 | - $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1244 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1241 | + $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular'; |
|
| 1242 | + $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>'; |
|
| 1243 | + $html .= '<span> <input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>'; |
|
| 1244 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1245 | 1245 | |
| 1246 | - echo $html; |
|
| 1246 | + echo $html; |
|
| 1247 | 1247 | } |
| 1248 | 1248 | |
| 1249 | 1249 | function wpinv_color_callback( $args ) { |
| 1250 | - global $wpinv_options; |
|
| 1250 | + global $wpinv_options; |
|
| 1251 | 1251 | |
| 1252 | 1252 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1253 | 1253 | |
| 1254 | - if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1255 | - $value = $wpinv_options[ $args['id'] ]; |
|
| 1256 | - } else { |
|
| 1257 | - $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1258 | - } |
|
| 1254 | + if ( isset( $wpinv_options[ $args['id'] ] ) ) { |
|
| 1255 | + $value = $wpinv_options[ $args['id'] ]; |
|
| 1256 | + } else { |
|
| 1257 | + $value = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1258 | + } |
|
| 1259 | 1259 | |
| 1260 | - $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1260 | + $default = isset( $args['std'] ) ? $args['std'] : ''; |
|
| 1261 | 1261 | |
| 1262 | - $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1263 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1262 | + $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />'; |
|
| 1263 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1264 | 1264 | |
| 1265 | - echo $html; |
|
| 1265 | + echo $html; |
|
| 1266 | 1266 | } |
| 1267 | 1267 | |
| 1268 | 1268 | function wpinv_country_states_callback($args) { |
| 1269 | - global $wpinv_options; |
|
| 1269 | + global $wpinv_options; |
|
| 1270 | 1270 | |
| 1271 | 1271 | $sanitize_id = wpinv_sanitize_key( $args['id'] ); |
| 1272 | 1272 | |
| 1273 | - if ( isset( $args['placeholder'] ) ) { |
|
| 1274 | - $placeholder = $args['placeholder']; |
|
| 1275 | - } else { |
|
| 1276 | - $placeholder = ''; |
|
| 1277 | - } |
|
| 1273 | + if ( isset( $args['placeholder'] ) ) { |
|
| 1274 | + $placeholder = $args['placeholder']; |
|
| 1275 | + } else { |
|
| 1276 | + $placeholder = ''; |
|
| 1277 | + } |
|
| 1278 | 1278 | |
| 1279 | - $states = wpinv_get_country_states(); |
|
| 1279 | + $states = wpinv_get_country_states(); |
|
| 1280 | 1280 | |
| 1281 | - $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1282 | - $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1283 | - $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1281 | + $chosen = ( $args['chosen'] ? ' wpinv-chosen' : '' ); |
|
| 1282 | + $class = empty( $states ) ? ' class="wpinv-no-states' . $chosen . '"' : 'class="' . $chosen . '"'; |
|
| 1283 | + $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>'; |
|
| 1284 | 1284 | |
| 1285 | - foreach ( $states as $option => $name ) { |
|
| 1286 | - $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1287 | - $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1288 | - } |
|
| 1285 | + foreach ( $states as $option => $name ) { |
|
| 1286 | + $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : ''; |
|
| 1287 | + $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>'; |
|
| 1288 | + } |
|
| 1289 | 1289 | |
| 1290 | - $html .= '</select>'; |
|
| 1291 | - $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1290 | + $html .= '</select>'; |
|
| 1291 | + $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>'; |
|
| 1292 | 1292 | |
| 1293 | - echo $html; |
|
| 1293 | + echo $html; |
|
| 1294 | 1294 | } |
| 1295 | 1295 | |
| 1296 | 1296 | function wpinv_tax_rates_callback($args) { |
| 1297 | - global $wpinv_options; |
|
| 1298 | - $rates = wpinv_get_tax_rates(); |
|
| 1299 | - ob_start(); ?> |
|
| 1297 | + global $wpinv_options; |
|
| 1298 | + $rates = wpinv_get_tax_rates(); |
|
| 1299 | + ob_start(); ?> |
|
| 1300 | 1300 | </td><tr> |
| 1301 | 1301 | <td colspan="2" class="wpinv_tax_tdbox"> |
| 1302 | 1302 | <p><?php echo $args['desc']; ?></p> |
@@ -1320,41 +1320,41 @@ discard block |
||
| 1320 | 1320 | <tr> |
| 1321 | 1321 | <td class="wpinv_tax_country"> |
| 1322 | 1322 | <?php |
| 1323 | - echo wpinv_html_select( array( |
|
| 1324 | - 'options' => wpinv_get_country_list( true ), |
|
| 1325 | - 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1323 | + echo wpinv_html_select( array( |
|
| 1324 | + 'options' => wpinv_get_country_list( true ), |
|
| 1325 | + 'name' => 'tax_rates[' . $sanitized_key . '][country]', |
|
| 1326 | 1326 | 'id' => 'tax_rates[' . $sanitized_key . '][country]', |
| 1327 | - 'selected' => $rate['country'], |
|
| 1328 | - 'show_option_all' => false, |
|
| 1329 | - 'show_option_none' => false, |
|
| 1330 | - 'class' => 'wpinv-tax-country', |
|
| 1331 | - 'chosen' => false, |
|
| 1332 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1333 | - ) ); |
|
| 1334 | - ?> |
|
| 1327 | + 'selected' => $rate['country'], |
|
| 1328 | + 'show_option_all' => false, |
|
| 1329 | + 'show_option_none' => false, |
|
| 1330 | + 'class' => 'wpinv-tax-country', |
|
| 1331 | + 'chosen' => false, |
|
| 1332 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1333 | + ) ); |
|
| 1334 | + ?> |
|
| 1335 | 1335 | </td> |
| 1336 | 1336 | <td class="wpinv_tax_state"> |
| 1337 | 1337 | <?php |
| 1338 | - $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1339 | - if( !empty( $states ) ) { |
|
| 1340 | - echo wpinv_html_select( array( |
|
| 1341 | - 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1342 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1338 | + $states = wpinv_get_country_states( $rate['country'] ); |
|
| 1339 | + if( !empty( $states ) ) { |
|
| 1340 | + echo wpinv_html_select( array( |
|
| 1341 | + 'options' => array_merge( array( '' => '' ), $states ), |
|
| 1342 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', |
|
| 1343 | 1343 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1344 | - 'selected' => $rate['state'], |
|
| 1345 | - 'show_option_all' => false, |
|
| 1346 | - 'show_option_none' => false, |
|
| 1347 | - 'chosen' => false, |
|
| 1348 | - 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1349 | - ) ); |
|
| 1350 | - } else { |
|
| 1351 | - echo wpinv_html_text( array( |
|
| 1352 | - 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1353 | - 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1344 | + 'selected' => $rate['state'], |
|
| 1345 | + 'show_option_all' => false, |
|
| 1346 | + 'show_option_none' => false, |
|
| 1347 | + 'chosen' => false, |
|
| 1348 | + 'placeholder' => __( 'Choose a state', 'invoicing' ) |
|
| 1349 | + ) ); |
|
| 1350 | + } else { |
|
| 1351 | + echo wpinv_html_text( array( |
|
| 1352 | + 'name' => 'tax_rates[' . $sanitized_key . '][state]', $rate['state'], |
|
| 1353 | + 'value' => ! empty( $rate['state'] ) ? $rate['state'] : '', |
|
| 1354 | 1354 | 'id' => 'tax_rates[' . $sanitized_key . '][state]', |
| 1355 | - ) ); |
|
| 1356 | - } |
|
| 1357 | - ?> |
|
| 1355 | + ) ); |
|
| 1356 | + } |
|
| 1357 | + ?> |
|
| 1358 | 1358 | </td> |
| 1359 | 1359 | <td class="wpinv_tax_global"> |
| 1360 | 1360 | <input type="checkbox" name="tax_rates[<?php echo $sanitized_key; ?>][global]" id="tax_rates[<?php echo $sanitized_key; ?>][global]" value="1"<?php checked( true, ! empty( $rate['global'] ) ); ?>/> |
@@ -1369,20 +1369,20 @@ discard block |
||
| 1369 | 1369 | <tr> |
| 1370 | 1370 | <td class="wpinv_tax_country"> |
| 1371 | 1371 | <?php |
| 1372 | - echo wpinv_html_select( array( |
|
| 1373 | - 'options' => wpinv_get_country_list( true ), |
|
| 1374 | - 'name' => 'tax_rates[0][country]', |
|
| 1375 | - 'show_option_all' => false, |
|
| 1376 | - 'show_option_none' => false, |
|
| 1377 | - 'class' => 'wpinv-tax-country', |
|
| 1378 | - 'chosen' => false, |
|
| 1379 | - 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1380 | - ) ); ?> |
|
| 1372 | + echo wpinv_html_select( array( |
|
| 1373 | + 'options' => wpinv_get_country_list( true ), |
|
| 1374 | + 'name' => 'tax_rates[0][country]', |
|
| 1375 | + 'show_option_all' => false, |
|
| 1376 | + 'show_option_none' => false, |
|
| 1377 | + 'class' => 'wpinv-tax-country', |
|
| 1378 | + 'chosen' => false, |
|
| 1379 | + 'placeholder' => __( 'Choose a country', 'invoicing' ) |
|
| 1380 | + ) ); ?> |
|
| 1381 | 1381 | </td> |
| 1382 | 1382 | <td class="wpinv_tax_state"> |
| 1383 | 1383 | <?php echo wpinv_html_text( array( |
| 1384 | - 'name' => 'tax_rates[0][state]' |
|
| 1385 | - ) ); ?> |
|
| 1384 | + 'name' => 'tax_rates[0][state]' |
|
| 1385 | + ) ); ?> |
|
| 1386 | 1386 | </td> |
| 1387 | 1387 | <td class="wpinv_tax_global"> |
| 1388 | 1388 | <input type="checkbox" name="tax_rates[0][global]" id="tax_rates[0][global]" value="1"/> |
@@ -1397,7 +1397,7 @@ discard block |
||
| 1397 | 1397 | <tfoot><tr><td colspan="5"></td><td class="wpinv_tax_action"><span class="button-secondary" id="wpinv_add_tax_rate"><?php _e( 'Add Tax Rate', 'invoicing' ); ?></span></td></tr></tfoot> |
| 1398 | 1398 | </table> |
| 1399 | 1399 | <?php |
| 1400 | - echo ob_get_clean(); |
|
| 1400 | + echo ob_get_clean(); |
|
| 1401 | 1401 | } |
| 1402 | 1402 | |
| 1403 | 1403 | function wpinv_tools_callback($args) { |
@@ -1425,15 +1425,15 @@ discard block |
||
| 1425 | 1425 | } |
| 1426 | 1426 | |
| 1427 | 1427 | function wpinv_descriptive_text_callback( $args ) { |
| 1428 | - echo wp_kses_post( $args['desc'] ); |
|
| 1428 | + echo wp_kses_post( $args['desc'] ); |
|
| 1429 | 1429 | } |
| 1430 | 1430 | |
| 1431 | 1431 | function wpinv_hook_callback( $args ) { |
| 1432 | - do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1432 | + do_action( 'wpinv_' . $args['id'], $args ); |
|
| 1433 | 1433 | } |
| 1434 | 1434 | |
| 1435 | 1435 | function wpinv_set_settings_cap() { |
| 1436 | - return 'manage_options'; |
|
| 1436 | + return 'manage_options'; |
|
| 1437 | 1437 | } |
| 1438 | 1438 | add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' ); |
| 1439 | 1439 | |
@@ -155,65 +155,65 @@ discard block |
||
| 155 | 155 | } |
| 156 | 156 | |
| 157 | 157 | function wpinv_admin_messages() { |
| 158 | - global $wpinv_options, $pagenow, $post; |
|
| 158 | + global $wpinv_options, $pagenow, $post; |
|
| 159 | 159 | |
| 160 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 161 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 162 | - } |
|
| 160 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 161 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-added', __( 'Discount code added.', 'invoicing' ), 'updated' ); |
|
| 162 | + } |
|
| 163 | 163 | |
| 164 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 165 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 166 | - } |
|
| 164 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_add_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 165 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-add-fail', __( 'There was a problem adding your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 166 | + } |
|
| 167 | 167 | |
| 168 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 169 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 170 | - } |
|
| 168 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_exists' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 169 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-exists', __( 'A discount with that code already exists, please use a different code.', 'invoicing' ), 'error' ); |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 173 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 174 | - } |
|
| 172 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 173 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated', __( 'Discount code updated.', 'invoicing' ), 'updated' ); |
|
| 174 | + } |
|
| 175 | 175 | |
| 176 | - if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 177 | - add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 178 | - } |
|
| 176 | + if ( isset( $_GET['wpinv-message'] ) && 'discount_update_failed' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 177 | + add_settings_error( 'wpinv-notices', 'wpinv-discount-updated-fail', __( 'There was a problem updating your discount code, please try again.', 'invoicing' ), 'error' ); |
|
| 178 | + } |
|
| 179 | 179 | |
| 180 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 181 | - add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 182 | - } |
|
| 180 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice_deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 181 | + add_settings_error( 'wpinv-notices', 'wpinv-deleted', __( 'The invoice has been deleted.', 'invoicing' ), 'updated' ); |
|
| 182 | + } |
|
| 183 | 183 | |
| 184 | - if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 185 | - add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 184 | + if ( isset( $_GET['wpinv-message'] ) && 'email_sent' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 185 | + add_settings_error( 'wpinv-notices', 'wpinv-sent', __( 'The email has been sent to customer.', 'invoicing' ), 'updated' ); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | if ( isset( $_GET['wpinv-message'] ) && 'email_fail' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
| 189 | - add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 189 | + add_settings_error( 'wpinv-notices', 'wpinv-sent-fail', __( 'Fail to send email to the customer.', 'invoicing' ), 'error' ); |
|
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | if ( isset( $_GET['wpinv-message'] ) && 'invoice-note-deleted' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
| 193 | 193 | add_settings_error( 'wpinv-notices', 'wpinv-note-deleted', __( 'The invoice note has been deleted.', 'invoicing' ), 'updated' ); |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 197 | - add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 198 | - } |
|
| 196 | + if ( isset( $_GET['wpinv-message'] ) && 'settings-imported' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 197 | + add_settings_error( 'wpinv-notices', 'wpinv-settings-imported', __( 'The settings have been imported.', 'invoicing' ), 'updated' ); |
|
| 198 | + } |
|
| 199 | 199 | |
| 200 | - if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 201 | - add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 202 | - } |
|
| 200 | + if ( isset( $_GET['wpinv-message'] ) && 'note-added' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 201 | + add_settings_error( 'wpinv-notices', 'wpinv-note-added', __( 'The invoice note has been added successfully.', 'invoicing' ), 'updated' ); |
|
| 202 | + } |
|
| 203 | 203 | |
| 204 | - if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 205 | - add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 206 | - } |
|
| 204 | + if ( isset( $_GET['wpinv-message'] ) && 'invoice-updated' == $_GET['wpinv-message'] && current_user_can( 'manage_options' ) ) { |
|
| 205 | + add_settings_error( 'wpinv-notices', 'wpinv-updated', __( 'The invoice has been successfully updated.', 'invoicing' ), 'updated' ); |
|
| 206 | + } |
|
| 207 | 207 | |
| 208 | - if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 209 | - $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 208 | + if ( $pagenow == 'post.php' && !empty( $post->post_type ) && $post->post_type == 'wpi_item' && !wpinv_item_is_editable( $post ) ) { |
|
| 209 | + $message = apply_filters( 'wpinv_item_non_editable_message', __( 'This item in not editable.', 'invoicing' ), $post->ID ); |
|
| 210 | 210 | |
| 211 | - if ( !empty( $message ) ) { |
|
| 212 | - add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 213 | - } |
|
| 214 | - } |
|
| 211 | + if ( !empty( $message ) ) { |
|
| 212 | + add_settings_error( 'wpinv-notices', 'wpinv-edit-n', $message, 'updated' ); |
|
| 213 | + } |
|
| 214 | + } |
|
| 215 | 215 | |
| 216 | - settings_errors( 'wpinv-notices' ); |
|
| 216 | + settings_errors( 'wpinv-notices' ); |
|
| 217 | 217 | } |
| 218 | 218 | add_action( 'admin_notices', 'wpinv_admin_messages' ); |
| 219 | 219 | |
@@ -276,7 +276,7 @@ discard block |
||
| 276 | 276 | break; |
| 277 | 277 | case 'id' : |
| 278 | 278 | echo $post->ID; |
| 279 | - echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 279 | + echo '<div class="hidden" id="wpinv_inline-' . $post->ID . '"> |
|
| 280 | 280 | <div class="price">' . wpinv_get_item_price( $post->ID ) . '</div>'; |
| 281 | 281 | if ( $wpinv_euvat->allow_vat_rules() ) { |
| 282 | 282 | echo '<div class="vat_rule">' . $wpinv_euvat->get_item_rule( $post->ID ) . '</div>'; |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
| 3 | - exit; |
|
| 3 | + exit; |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | if ( !( $user_id = get_current_user_id() ) ) { |
@@ -30,7 +30,7 @@ discard block |
||
| 30 | 30 | |
| 31 | 31 | <tbody> |
| 32 | 32 | <?php foreach ( $user_invoices->invoices as $invoice ) { |
| 33 | - ?> |
|
| 33 | + ?> |
|
| 34 | 34 | <tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>"> |
| 35 | 35 | <?php foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) : ?> |
| 36 | 36 | <td class="<?php echo esc_attr( $column_id ); ?> <?php echo (!empty($column_name['class']) ? $column_name['class'] : '');?>" data-title="<?php echo esc_attr( $column_name['title'] ); ?>"> |
@@ -53,31 +53,31 @@ discard block |
||
| 53 | 53 | |
| 54 | 54 | <?php elseif ( 'invoice-actions' === $column_id ) : ?> |
| 55 | 55 | <?php |
| 56 | - $actions = array( |
|
| 57 | - 'pay' => array( |
|
| 58 | - 'url' => $invoice->get_checkout_payment_url(), |
|
| 59 | - 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 56 | + $actions = array( |
|
| 57 | + 'pay' => array( |
|
| 58 | + 'url' => $invoice->get_checkout_payment_url(), |
|
| 59 | + 'name' => __( 'Pay Now', 'invoicing' ), |
|
| 60 | 60 | 'class' => 'btn-success' |
| 61 | - ), |
|
| 61 | + ), |
|
| 62 | 62 | 'print' => array( |
| 63 | - 'url' => $invoice->get_view_url(), |
|
| 64 | - 'name' => __( 'Print', 'invoicing' ), |
|
| 63 | + 'url' => $invoice->get_view_url(), |
|
| 64 | + 'name' => __( 'Print', 'invoicing' ), |
|
| 65 | 65 | 'class' => 'btn-primary', |
| 66 | 66 | 'attrs' => 'target="_blank"' |
| 67 | - ) |
|
| 68 | - ); |
|
| 67 | + ) |
|
| 68 | + ); |
|
| 69 | 69 | |
| 70 | - if ( ! $invoice->needs_payment() ) { |
|
| 71 | - unset( $actions['pay'] ); |
|
| 72 | - } |
|
| 70 | + if ( ! $invoice->needs_payment() ) { |
|
| 71 | + unset( $actions['pay'] ); |
|
| 72 | + } |
|
| 73 | 73 | |
| 74 | - if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | - foreach ( $actions as $key => $action ) { |
|
| 76 | - $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 74 | + if ( $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice ) ) { |
|
| 75 | + foreach ( $actions as $key => $action ) { |
|
| 76 | + $class = !empty($action['class']) ? sanitize_html_class($action['class']) : ''; |
|
| 77 | 77 | echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>'; |
| 78 | - } |
|
| 79 | - } |
|
| 80 | - ?> |
|
| 78 | + } |
|
| 79 | + } |
|
| 80 | + ?> |
|
| 81 | 81 | <?php endif; ?> |
| 82 | 82 | </td> |
| 83 | 83 | <?php endforeach; ?> |
@@ -91,22 +91,22 @@ discard block |
||
| 91 | 91 | <?php if ( 1 < $user_invoices->max_num_pages ) : ?> |
| 92 | 92 | <div class="invoicing-Pagination"> |
| 93 | 93 | <?php |
| 94 | - $big = 999999; |
|
| 95 | - |
|
| 96 | - if (get_query_var('paged')) |
|
| 97 | - $current_page = get_query_var('paged'); |
|
| 98 | - elseif (get_query_var('page')) |
|
| 99 | - $current_page = get_query_var('page'); |
|
| 100 | - else |
|
| 101 | - $current_page = 1; |
|
| 102 | - |
|
| 103 | - echo paginate_links( array( |
|
| 104 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 105 | - 'format' => '?paged=%#%', |
|
| 106 | - 'current' => max( 1, $current_page ), |
|
| 107 | - 'total' => $user_invoices->max_num_pages, |
|
| 108 | - ) ); |
|
| 109 | - ?> |
|
| 94 | + $big = 999999; |
|
| 95 | + |
|
| 96 | + if (get_query_var('paged')) |
|
| 97 | + $current_page = get_query_var('paged'); |
|
| 98 | + elseif (get_query_var('page')) |
|
| 99 | + $current_page = get_query_var('page'); |
|
| 100 | + else |
|
| 101 | + $current_page = 1; |
|
| 102 | + |
|
| 103 | + echo paginate_links( array( |
|
| 104 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 105 | + 'format' => '?paged=%#%', |
|
| 106 | + 'current' => max( 1, $current_page ), |
|
| 107 | + 'total' => $user_invoices->max_num_pages, |
|
| 108 | + ) ); |
|
| 109 | + ?> |
|
| 110 | 110 | </div> |
| 111 | 111 | <?php endif; ?> |
| 112 | 112 | |
@@ -664,7 +664,7 @@ discard block |
||
| 664 | 664 | } |
| 665 | 665 | |
| 666 | 666 | function wpinv_get_payment_key( $invoice_id = 0 ) { |
| 667 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 667 | + $invoice = new WPInv_Invoice( $invoice_id ); |
|
| 668 | 668 | return $invoice->get_key(); |
| 669 | 669 | } |
| 670 | 670 | |
@@ -1197,20 +1197,20 @@ discard block |
||
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | function wpinv_checkout_get_cc_info() { |
| 1200 | - $cc_info = array(); |
|
| 1201 | - $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1202 | - $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1203 | - $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1204 | - $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1205 | - $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1206 | - $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1207 | - $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1208 | - $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1209 | - $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1210 | - $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1211 | - |
|
| 1212 | - // Return cc info |
|
| 1213 | - return $cc_info; |
|
| 1200 | + $cc_info = array(); |
|
| 1201 | + $cc_info['card_name'] = isset( $_POST['card_name'] ) ? sanitize_text_field( $_POST['card_name'] ) : ''; |
|
| 1202 | + $cc_info['card_number'] = isset( $_POST['card_number'] ) ? sanitize_text_field( $_POST['card_number'] ) : ''; |
|
| 1203 | + $cc_info['card_cvc'] = isset( $_POST['card_cvc'] ) ? sanitize_text_field( $_POST['card_cvc'] ) : ''; |
|
| 1204 | + $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] ) ? sanitize_text_field( $_POST['card_exp_month'] ) : ''; |
|
| 1205 | + $cc_info['card_exp_year'] = isset( $_POST['card_exp_year'] ) ? sanitize_text_field( $_POST['card_exp_year'] ) : ''; |
|
| 1206 | + $cc_info['card_address'] = isset( $_POST['wpinv_address'] ) ? sanitize_text_field( $_POST['wpinv_address'] ) : ''; |
|
| 1207 | + $cc_info['card_city'] = isset( $_POST['wpinv_city'] ) ? sanitize_text_field( $_POST['wpinv_city'] ) : ''; |
|
| 1208 | + $cc_info['card_state'] = isset( $_POST['wpinv_state'] ) ? sanitize_text_field( $_POST['wpinv_state'] ) : ''; |
|
| 1209 | + $cc_info['card_country'] = isset( $_POST['wpinv_country'] ) ? sanitize_text_field( $_POST['wpinv_country'] ) : ''; |
|
| 1210 | + $cc_info['card_zip'] = isset( $_POST['wpinv_zip'] ) ? sanitize_text_field( $_POST['wpinv_zip'] ) : ''; |
|
| 1211 | + |
|
| 1212 | + // Return cc info |
|
| 1213 | + return $cc_info; |
|
| 1214 | 1214 | } |
| 1215 | 1215 | |
| 1216 | 1216 | function wpinv_checkout_validate_cc_zip( $zip = 0, $country_code = '' ) { |
@@ -1407,7 +1407,7 @@ discard block |
||
| 1407 | 1407 | $required_fields = wpinv_checkout_required_fields(); |
| 1408 | 1408 | |
| 1409 | 1409 | // Loop through required fields and show error messages |
| 1410 | - if ( !empty( $required_fields ) ) { |
|
| 1410 | + if ( !empty( $required_fields ) ) { |
|
| 1411 | 1411 | foreach ( $required_fields as $field_name => $value ) { |
| 1412 | 1412 | if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) { |
| 1413 | 1413 | wpinv_set_error( $value['error_id'], $value['error_message'] ); |
@@ -1513,7 +1513,7 @@ discard block |
||
| 1513 | 1513 | } |
| 1514 | 1514 | |
| 1515 | 1515 | function wpinv_get_checkout_session() { |
| 1516 | - global $wpi_session; |
|
| 1516 | + global $wpi_session; |
|
| 1517 | 1517 | |
| 1518 | 1518 | return $wpi_session->get( 'wpinv_checkout' ); |
| 1519 | 1519 | } |
@@ -1865,57 +1865,57 @@ discard block |
||
| 1865 | 1865 | } |
| 1866 | 1866 | |
| 1867 | 1867 | function wpinv_get_invoice_id_by_key( $key ) { |
| 1868 | - global $wpdb; |
|
| 1868 | + global $wpdb; |
|
| 1869 | 1869 | |
| 1870 | - $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1870 | + $invoice_id = $wpdb->get_var( $wpdb->prepare( "SELECT post_id FROM $wpdb->postmeta WHERE meta_key = '_wpinv_key' AND meta_value = %s LIMIT 1", $key ) ); |
|
| 1871 | 1871 | |
| 1872 | - if ( $invoice_id != NULL ) |
|
| 1873 | - return $invoice_id; |
|
| 1872 | + if ( $invoice_id != NULL ) |
|
| 1873 | + return $invoice_id; |
|
| 1874 | 1874 | |
| 1875 | - return 0; |
|
| 1875 | + return 0; |
|
| 1876 | 1876 | } |
| 1877 | 1877 | |
| 1878 | 1878 | function wpinv_can_view_receipt( $invoice_key = '' ) { |
| 1879 | - $return = false; |
|
| 1880 | - |
|
| 1881 | - if ( empty( $invoice_key ) ) { |
|
| 1882 | - return $return; |
|
| 1883 | - } |
|
| 1884 | - |
|
| 1885 | - global $wpinv_receipt_args; |
|
| 1886 | - |
|
| 1887 | - $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1888 | - if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1889 | - $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1890 | - } |
|
| 1891 | - |
|
| 1892 | - if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 1893 | - return $return; |
|
| 1894 | - } |
|
| 1895 | - |
|
| 1896 | - $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 1897 | - if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 1898 | - return $return; |
|
| 1899 | - } |
|
| 1900 | - |
|
| 1901 | - if ( is_user_logged_in() ) { |
|
| 1902 | - if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 1903 | - $return = true; |
|
| 1904 | - } |
|
| 1905 | - } |
|
| 1906 | - |
|
| 1907 | - $session = wpinv_get_checkout_session(); |
|
| 1908 | - if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 1909 | - $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 1910 | - |
|
| 1911 | - if ( wpinv_require_login_to_checkout() ) { |
|
| 1912 | - $return = $return && $check_key === $invoice_key; |
|
| 1913 | - } else { |
|
| 1914 | - $return = $check_key === $invoice_key; |
|
| 1915 | - } |
|
| 1916 | - } |
|
| 1917 | - |
|
| 1918 | - return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1879 | + $return = false; |
|
| 1880 | + |
|
| 1881 | + if ( empty( $invoice_key ) ) { |
|
| 1882 | + return $return; |
|
| 1883 | + } |
|
| 1884 | + |
|
| 1885 | + global $wpinv_receipt_args; |
|
| 1886 | + |
|
| 1887 | + $wpinv_receipt_args['id'] = wpinv_get_invoice_id_by_key( $invoice_key ); |
|
| 1888 | + if ( isset( $_GET['invoice-id'] ) ) { |
|
| 1889 | + $wpinv_receipt_args['id'] = $invoice_key == wpinv_get_payment_key( (int)$_GET['invoice-id'] ) ? (int)$_GET['invoice-id'] : 0; |
|
| 1890 | + } |
|
| 1891 | + |
|
| 1892 | + if ( empty( $wpinv_receipt_args['id'] ) ) { |
|
| 1893 | + return $return; |
|
| 1894 | + } |
|
| 1895 | + |
|
| 1896 | + $invoice = wpinv_get_invoice( $wpinv_receipt_args['id'] ); |
|
| 1897 | + if ( !( !empty( $invoice->ID ) && $invoice->get_key() === $invoice_key ) ) { |
|
| 1898 | + return $return; |
|
| 1899 | + } |
|
| 1900 | + |
|
| 1901 | + if ( is_user_logged_in() ) { |
|
| 1902 | + if ( (int)$invoice->get_user_id() === (int) get_current_user_id() ) { |
|
| 1903 | + $return = true; |
|
| 1904 | + } |
|
| 1905 | + } |
|
| 1906 | + |
|
| 1907 | + $session = wpinv_get_checkout_session(); |
|
| 1908 | + if ( isset( $_GET['invoice_key'] ) || ( $session && isset( $session['invoice_key'] ) ) ) { |
|
| 1909 | + $check_key = isset( $_GET['invoice_key'] ) ? $_GET['invoice_key'] : $session['invoice_key']; |
|
| 1910 | + |
|
| 1911 | + if ( wpinv_require_login_to_checkout() ) { |
|
| 1912 | + $return = $return && $check_key === $invoice_key; |
|
| 1913 | + } else { |
|
| 1914 | + $return = $check_key === $invoice_key; |
|
| 1915 | + } |
|
| 1916 | + } |
|
| 1917 | + |
|
| 1918 | + return (bool) apply_filters( 'wpinv_can_view_receipt', $return, $invoice_key ); |
|
| 1919 | 1919 | } |
| 1920 | 1920 | |
| 1921 | 1921 | function wpinv_pay_for_invoice() { |
@@ -218,261 +218,261 @@ discard block |
||
| 218 | 218 | add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 ); |
| 219 | 219 | |
| 220 | 220 | function wpinv_process_paypal_ipn() { |
| 221 | - // Check the request method is POST |
|
| 222 | - if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 223 | - return; |
|
| 224 | - } |
|
| 225 | - |
|
| 226 | - // Set initial post data to empty string |
|
| 227 | - $post_data = ''; |
|
| 228 | - |
|
| 229 | - // Fallback just in case post_max_size is lower than needed |
|
| 230 | - if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 231 | - $post_data = file_get_contents( 'php://input' ); |
|
| 232 | - } else { |
|
| 233 | - // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
|
| 234 | - ini_set( 'post_max_size', '12M' ); |
|
| 235 | - } |
|
| 236 | - // Start the encoded data collection with notification command |
|
| 237 | - $encoded_data = 'cmd=_notify-validate'; |
|
| 238 | - |
|
| 239 | - // Get current arg separator |
|
| 240 | - $arg_separator = wpinv_get_php_arg_separator_output(); |
|
| 241 | - |
|
| 242 | - // Verify there is a post_data |
|
| 243 | - if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 244 | - // Append the data |
|
| 245 | - $encoded_data .= $arg_separator.$post_data; |
|
| 246 | - } else { |
|
| 247 | - // Check if POST is empty |
|
| 248 | - if ( empty( $_POST ) ) { |
|
| 249 | - // Nothing to do |
|
| 250 | - return; |
|
| 251 | - } else { |
|
| 252 | - // Loop through each POST |
|
| 253 | - foreach ( $_POST as $key => $value ) { |
|
| 254 | - // Encode the value and append the data |
|
| 255 | - $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
| 256 | - } |
|
| 257 | - } |
|
| 258 | - } |
|
| 259 | - |
|
| 260 | - // Convert collected post data to an array |
|
| 261 | - parse_str( $encoded_data, $encoded_data_array ); |
|
| 262 | - |
|
| 263 | - foreach ( $encoded_data_array as $key => $value ) { |
|
| 264 | - if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 265 | - $new_key = str_replace( '&', '&', $key ); |
|
| 266 | - $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
| 267 | - |
|
| 268 | - unset( $encoded_data_array[ $key ] ); |
|
| 269 | - $encoded_data_array[ $new_key ] = $value; |
|
| 270 | - } |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - // Get the PayPal redirect uri |
|
| 274 | - $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
| 275 | - |
|
| 276 | - if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
| 277 | - // Validate the IPN |
|
| 278 | - |
|
| 279 | - $remote_post_vars = array( |
|
| 280 | - 'method' => 'POST', |
|
| 281 | - 'timeout' => 45, |
|
| 282 | - 'redirection' => 5, |
|
| 283 | - 'httpversion' => '1.1', |
|
| 284 | - 'blocking' => true, |
|
| 285 | - 'headers' => array( |
|
| 286 | - 'host' => 'www.paypal.com', |
|
| 287 | - 'connection' => 'close', |
|
| 288 | - 'content-type' => 'application/x-www-form-urlencoded', |
|
| 289 | - 'post' => '/cgi-bin/webscr HTTP/1.1', |
|
| 290 | - |
|
| 291 | - ), |
|
| 292 | - 'sslverify' => false, |
|
| 293 | - 'body' => $encoded_data_array |
|
| 294 | - ); |
|
| 295 | - |
|
| 296 | - // Get response |
|
| 297 | - $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
| 298 | - |
|
| 299 | - if ( is_wp_error( $api_response ) ) { |
|
| 300 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
| 301 | - return; // Something went wrong |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
| 305 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
| 306 | - return; // Response not okay |
|
| 307 | - } |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - // Check if $post_data_array has been populated |
|
| 311 | - if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
| 312 | - return; |
|
| 313 | - |
|
| 314 | - $defaults = array( |
|
| 315 | - 'txn_type' => '', |
|
| 316 | - 'payment_status' => '' |
|
| 317 | - ); |
|
| 318 | - |
|
| 319 | - $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 320 | - |
|
| 321 | - $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 221 | + // Check the request method is POST |
|
| 222 | + if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) { |
|
| 223 | + return; |
|
| 224 | + } |
|
| 225 | + |
|
| 226 | + // Set initial post data to empty string |
|
| 227 | + $post_data = ''; |
|
| 228 | + |
|
| 229 | + // Fallback just in case post_max_size is lower than needed |
|
| 230 | + if ( ini_get( 'allow_url_fopen' ) ) { |
|
| 231 | + $post_data = file_get_contents( 'php://input' ); |
|
| 232 | + } else { |
|
| 233 | + // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough |
|
| 234 | + ini_set( 'post_max_size', '12M' ); |
|
| 235 | + } |
|
| 236 | + // Start the encoded data collection with notification command |
|
| 237 | + $encoded_data = 'cmd=_notify-validate'; |
|
| 238 | + |
|
| 239 | + // Get current arg separator |
|
| 240 | + $arg_separator = wpinv_get_php_arg_separator_output(); |
|
| 241 | + |
|
| 242 | + // Verify there is a post_data |
|
| 243 | + if ( $post_data || strlen( $post_data ) > 0 ) { |
|
| 244 | + // Append the data |
|
| 245 | + $encoded_data .= $arg_separator.$post_data; |
|
| 246 | + } else { |
|
| 247 | + // Check if POST is empty |
|
| 248 | + if ( empty( $_POST ) ) { |
|
| 249 | + // Nothing to do |
|
| 250 | + return; |
|
| 251 | + } else { |
|
| 252 | + // Loop through each POST |
|
| 253 | + foreach ( $_POST as $key => $value ) { |
|
| 254 | + // Encode the value and append the data |
|
| 255 | + $encoded_data .= $arg_separator."$key=" . urlencode( $value ); |
|
| 256 | + } |
|
| 257 | + } |
|
| 258 | + } |
|
| 259 | + |
|
| 260 | + // Convert collected post data to an array |
|
| 261 | + parse_str( $encoded_data, $encoded_data_array ); |
|
| 262 | + |
|
| 263 | + foreach ( $encoded_data_array as $key => $value ) { |
|
| 264 | + if ( false !== strpos( $key, 'amp;' ) ) { |
|
| 265 | + $new_key = str_replace( '&', '&', $key ); |
|
| 266 | + $new_key = str_replace( 'amp;', '&' , $new_key ); |
|
| 267 | + |
|
| 268 | + unset( $encoded_data_array[ $key ] ); |
|
| 269 | + $encoded_data_array[ $new_key ] = $value; |
|
| 270 | + } |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + // Get the PayPal redirect uri |
|
| 274 | + $paypal_redirect = wpinv_get_paypal_redirect( true ); |
|
| 275 | + |
|
| 276 | + if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
| 277 | + // Validate the IPN |
|
| 278 | + |
|
| 279 | + $remote_post_vars = array( |
|
| 280 | + 'method' => 'POST', |
|
| 281 | + 'timeout' => 45, |
|
| 282 | + 'redirection' => 5, |
|
| 283 | + 'httpversion' => '1.1', |
|
| 284 | + 'blocking' => true, |
|
| 285 | + 'headers' => array( |
|
| 286 | + 'host' => 'www.paypal.com', |
|
| 287 | + 'connection' => 'close', |
|
| 288 | + 'content-type' => 'application/x-www-form-urlencoded', |
|
| 289 | + 'post' => '/cgi-bin/webscr HTTP/1.1', |
|
| 290 | + |
|
| 291 | + ), |
|
| 292 | + 'sslverify' => false, |
|
| 293 | + 'body' => $encoded_data_array |
|
| 294 | + ); |
|
| 295 | + |
|
| 296 | + // Get response |
|
| 297 | + $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars ); |
|
| 298 | + |
|
| 299 | + if ( is_wp_error( $api_response ) ) { |
|
| 300 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
| 301 | + return; // Something went wrong |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) { |
|
| 305 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) ); |
|
| 306 | + return; // Response not okay |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + // Check if $post_data_array has been populated |
|
| 311 | + if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) ) |
|
| 312 | + return; |
|
| 313 | + |
|
| 314 | + $defaults = array( |
|
| 315 | + 'txn_type' => '', |
|
| 316 | + 'payment_status' => '' |
|
| 317 | + ); |
|
| 318 | + |
|
| 319 | + $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults ); |
|
| 320 | + |
|
| 321 | + $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0; |
|
| 322 | 322 | |
| 323 | - wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
| 324 | - |
|
| 325 | - if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
| 326 | - // Allow PayPal IPN types to be processed separately |
|
| 327 | - do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
| 328 | - } else { |
|
| 329 | - // Fallback to web accept just in case the txn_type isn't present |
|
| 330 | - do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id ); |
|
| 331 | - } |
|
| 332 | - exit; |
|
| 323 | + wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ ); |
|
| 324 | + |
|
| 325 | + if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) { |
|
| 326 | + // Allow PayPal IPN types to be processed separately |
|
| 327 | + do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id ); |
|
| 328 | + } else { |
|
| 329 | + // Fallback to web accept just in case the txn_type isn't present |
|
| 330 | + do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id ); |
|
| 331 | + } |
|
| 332 | + exit; |
|
| 333 | 333 | } |
| 334 | 334 | add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' ); |
| 335 | 335 | |
| 336 | 336 | function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) { |
| 337 | - if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
| 338 | - return; |
|
| 339 | - } |
|
| 340 | - |
|
| 341 | - if( empty( $invoice_id ) ) { |
|
| 342 | - return; |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - // Collect payment details |
|
| 346 | - $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
| 347 | - $paypal_amount = $data['mc_gross']; |
|
| 348 | - $payment_status = strtolower( $data['payment_status'] ); |
|
| 349 | - $currency_code = strtolower( $data['mc_currency'] ); |
|
| 350 | - $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 351 | - $payment_meta = wpinv_get_invoice_meta( $invoice_id ); |
|
| 352 | - |
|
| 353 | - if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
| 354 | - return; // this isn't a PayPal standard IPN |
|
| 355 | - } |
|
| 356 | - |
|
| 357 | - // Verify payment recipient |
|
| 358 | - if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) { |
|
| 359 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 360 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 361 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
| 362 | - return; |
|
| 363 | - } |
|
| 364 | - |
|
| 365 | - // Verify payment currency |
|
| 366 | - if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 367 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 368 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 369 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
| 370 | - return; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
| 374 | - // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
|
| 375 | - // No email associated with purchase, so store from PayPal |
|
| 376 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
| 377 | - |
|
| 378 | - // Setup and store the customer's details |
|
| 379 | - $user_info = array( |
|
| 380 | - 'user_id' => '-1', |
|
| 381 | - 'email' => sanitize_text_field( $data['payer_email'] ), |
|
| 382 | - 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
| 383 | - 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
| 384 | - 'discount' => '', |
|
| 385 | - ); |
|
| 386 | - $user_info['address'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
| 387 | - $user_info['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
| 388 | - $user_info['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
| 389 | - $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
| 390 | - $user_info['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
| 391 | - |
|
| 392 | - $payment_meta['user_info'] = $user_info; |
|
| 393 | - wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 397 | - // Process a refund |
|
| 398 | - wpinv_process_paypal_refund( $data, $invoice_id ); |
|
| 399 | - } else { |
|
| 400 | - if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
| 401 | - return; // Only paid payments once |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - // Retrieve the total purchase amount (before PayPal) |
|
| 405 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
| 406 | - |
|
| 407 | - if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 408 | - // The prices don't match |
|
| 409 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 410 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 411 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
| 412 | - return; |
|
| 413 | - } |
|
| 414 | - if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
| 415 | - // Purchase keys don't match |
|
| 416 | - wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 417 | - wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 418 | - wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
| 419 | - return; |
|
| 420 | - } |
|
| 421 | - |
|
| 422 | - if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) { |
|
| 423 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) ); |
|
| 424 | - wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] ); |
|
| 425 | - wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
| 426 | - } else if ( 'wpi-pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 427 | - // Look for possible pending reasons, such as an echeck |
|
| 428 | - $note = ''; |
|
| 429 | - |
|
| 430 | - switch( strtolower( $data['pending_reason'] ) ) { |
|
| 431 | - case 'echeck' : |
|
| 432 | - $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
| 433 | - break; |
|
| 337 | + if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) { |
|
| 338 | + return; |
|
| 339 | + } |
|
| 340 | + |
|
| 341 | + if( empty( $invoice_id ) ) { |
|
| 342 | + return; |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + // Collect payment details |
|
| 346 | + $purchase_key = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number']; |
|
| 347 | + $paypal_amount = $data['mc_gross']; |
|
| 348 | + $payment_status = strtolower( $data['payment_status'] ); |
|
| 349 | + $currency_code = strtolower( $data['mc_currency'] ); |
|
| 350 | + $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] ); |
|
| 351 | + $payment_meta = wpinv_get_invoice_meta( $invoice_id ); |
|
| 352 | + |
|
| 353 | + if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) { |
|
| 354 | + return; // this isn't a PayPal standard IPN |
|
| 355 | + } |
|
| 356 | + |
|
| 357 | + // Verify payment recipient |
|
| 358 | + if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) { |
|
| 359 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 360 | + wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 361 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ) ); |
|
| 362 | + return; |
|
| 363 | + } |
|
| 364 | + |
|
| 365 | + // Verify payment currency |
|
| 366 | + if ( $currency_code != strtolower( $payment_meta['currency'] ) ) { |
|
| 367 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 368 | + wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 369 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ) ); |
|
| 370 | + return; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + if ( !wpinv_get_payment_user_email( $invoice_id ) ) { |
|
| 374 | + // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal |
|
| 375 | + // No email associated with purchase, so store from PayPal |
|
| 376 | + wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] ); |
|
| 377 | + |
|
| 378 | + // Setup and store the customer's details |
|
| 379 | + $user_info = array( |
|
| 380 | + 'user_id' => '-1', |
|
| 381 | + 'email' => sanitize_text_field( $data['payer_email'] ), |
|
| 382 | + 'first_name' => sanitize_text_field( $data['first_name'] ), |
|
| 383 | + 'last_name' => sanitize_text_field( $data['last_name'] ), |
|
| 384 | + 'discount' => '', |
|
| 385 | + ); |
|
| 386 | + $user_info['address'] = ! empty( $data['address_street'] ) ? sanitize_text_field( $data['address_street'] ) : false; |
|
| 387 | + $user_info['city'] = ! empty( $data['address_city'] ) ? sanitize_text_field( $data['address_city'] ) : false; |
|
| 388 | + $user_info['state'] = ! empty( $data['address_state'] ) ? sanitize_text_field( $data['address_state'] ) : false; |
|
| 389 | + $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false; |
|
| 390 | + $user_info['zip'] = ! empty( $data['address_zip'] ) ? sanitize_text_field( $data['address_zip'] ) : false; |
|
| 391 | + |
|
| 392 | + $payment_meta['user_info'] = $user_info; |
|
| 393 | + wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta ); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) { |
|
| 397 | + // Process a refund |
|
| 398 | + wpinv_process_paypal_refund( $data, $invoice_id ); |
|
| 399 | + } else { |
|
| 400 | + if ( get_post_status( $invoice_id ) == 'publish' ) { |
|
| 401 | + return; // Only paid payments once |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + // Retrieve the total purchase amount (before PayPal) |
|
| 405 | + $payment_amount = wpinv_payment_total( $invoice_id ); |
|
| 406 | + |
|
| 407 | + if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 408 | + // The prices don't match |
|
| 409 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 410 | + wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 411 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ) ); |
|
| 412 | + return; |
|
| 413 | + } |
|
| 414 | + if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) { |
|
| 415 | + // Purchase keys don't match |
|
| 416 | + wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id ); |
|
| 417 | + wpinv_update_payment_status( $invoice_id, 'wpi-failed' ); |
|
| 418 | + wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ) ); |
|
| 419 | + return; |
|
| 420 | + } |
|
| 421 | + |
|
| 422 | + if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) { |
|
| 423 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ) ); |
|
| 424 | + wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] ); |
|
| 425 | + wpinv_update_payment_status( $invoice_id, 'publish' ); |
|
| 426 | + } else if ( 'wpi-pending' == $payment_status && isset( $data['pending_reason'] ) ) { |
|
| 427 | + // Look for possible pending reasons, such as an echeck |
|
| 428 | + $note = ''; |
|
| 429 | + |
|
| 430 | + switch( strtolower( $data['pending_reason'] ) ) { |
|
| 431 | + case 'echeck' : |
|
| 432 | + $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' ); |
|
| 433 | + break; |
|
| 434 | 434 | |
| 435 | 435 | case 'address' : |
| 436 | - $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
| 437 | - break; |
|
| 436 | + $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' ); |
|
| 437 | + break; |
|
| 438 | 438 | |
| 439 | 439 | case 'intl' : |
| 440 | - $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
| 441 | - break; |
|
| 440 | + $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' ); |
|
| 441 | + break; |
|
| 442 | 442 | |
| 443 | 443 | case 'multi-currency' : |
| 444 | - $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
| 445 | - break; |
|
| 444 | + $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' ); |
|
| 445 | + break; |
|
| 446 | 446 | |
| 447 | 447 | case 'paymentreview' : |
| 448 | 448 | case 'regulatory_review' : |
| 449 | - $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
| 450 | - break; |
|
| 449 | + $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' ); |
|
| 450 | + break; |
|
| 451 | 451 | |
| 452 | 452 | case 'unilateral' : |
| 453 | - $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
| 454 | - break; |
|
| 453 | + $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' ); |
|
| 454 | + break; |
|
| 455 | 455 | |
| 456 | 456 | case 'upgrade' : |
| 457 | - $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
| 458 | - break; |
|
| 457 | + $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' ); |
|
| 458 | + break; |
|
| 459 | 459 | |
| 460 | 460 | case 'verify' : |
| 461 | - $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
| 462 | - break; |
|
| 463 | - |
|
| 464 | - case 'other' : |
|
| 465 | - $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
| 466 | - break; |
|
| 467 | - } |
|
| 468 | - |
|
| 469 | - if ( ! empty( $note ) ) { |
|
| 470 | - wpinv_insert_payment_note( $invoice_id, $note ); |
|
| 471 | - } |
|
| 472 | - } else { |
|
| 473 | - wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
| 474 | - } |
|
| 475 | - } |
|
| 461 | + $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' ); |
|
| 462 | + break; |
|
| 463 | + |
|
| 464 | + case 'other' : |
|
| 465 | + $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' ); |
|
| 466 | + break; |
|
| 467 | + } |
|
| 468 | + |
|
| 469 | + if ( ! empty( $note ) ) { |
|
| 470 | + wpinv_insert_payment_note( $invoice_id, $note ); |
|
| 471 | + } |
|
| 472 | + } else { |
|
| 473 | + wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ) ); |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | 476 | } |
| 477 | 477 | add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 ); |
| 478 | 478 | |
@@ -687,27 +687,27 @@ discard block |
||
| 687 | 687 | } |
| 688 | 688 | |
| 689 | 689 | function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) { |
| 690 | - // Collect payment details |
|
| 690 | + // Collect payment details |
|
| 691 | 691 | |
| 692 | - if( empty( $invoice_id ) ) { |
|
| 693 | - return; |
|
| 694 | - } |
|
| 692 | + if( empty( $invoice_id ) ) { |
|
| 693 | + return; |
|
| 694 | + } |
|
| 695 | 695 | |
| 696 | - if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) { |
|
| 697 | - return; // Only refund payments once |
|
| 698 | - } |
|
| 696 | + if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) { |
|
| 697 | + return; // Only refund payments once |
|
| 698 | + } |
|
| 699 | 699 | |
| 700 | - $payment_amount = wpinv_payment_total( $invoice_id ); |
|
| 701 | - $refund_amount = $data['mc_gross'] * -1; |
|
| 700 | + $payment_amount = wpinv_payment_total( $invoice_id ); |
|
| 701 | + $refund_amount = $data['mc_gross'] * -1; |
|
| 702 | 702 | |
| 703 | - if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 704 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) ); |
|
| 705 | - return; // This is a partial refund |
|
| 706 | - } |
|
| 703 | + if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) { |
|
| 704 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'Partial PayPal refund processed: %s', 'invoicing' ), $data['parent_txn_id'] ) ); |
|
| 705 | + return; // This is a partial refund |
|
| 706 | + } |
|
| 707 | 707 | |
| 708 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
| 709 | - wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) ); |
|
| 710 | - wpinv_update_payment_status( $invoice_id, 'wpi-refunded' ); |
|
| 708 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ) ); |
|
| 709 | + wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ) ); |
|
| 710 | + wpinv_update_payment_status( $invoice_id, 'wpi-refunded' ); |
|
| 711 | 711 | } |
| 712 | 712 | |
| 713 | 713 | function wpinv_get_paypal_redirect( $ssl_check = false ) { |