PluginProbe
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder / 1.4.3
Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder v1.4.3
3.6.0 3.5.0 trunk 1.0.10 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.6.1 1.0.7 1.0.8 1.0.9 1.1 1.1.1 1.2 1.3 1.4 1.4.1 1.4.2 1.4.3 1.4.4 1.4.5 1.5 1.5.1 All 110 releases
buttonizer-multifunctional-button / freemius / templates / account / billing.php

billing.php in Buttonizer – Floating Menus, Sticky Buttons, & Popup Builder 1.4.3, at freemius/templates/account/billing.php

431 lines 13.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * @package Freemius
4 * @copyright Copyright (c) 2016, Freemius, Inc.
5 * @license https://www.gnu.org/licenses/gpl-3.0.html GNU General Public License Version 3
6 * @since 1.2.0
7 */
8
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 /**
14 * @var array $VARS
15 * @var Freemius $fs
16 */
17 $fs = freemius( $VARS['id'] );
18
19 $slug = $fs->get_slug();
20
21 $payments = $fs->_fetch_payments();
22
23 $show_billing = ( is_array( $payments ) && 0 < count( $payments ) );
24
25 if ( $show_billing ) :
26
27 $edit_text = fs_text_x_inline( 'Edit', 'verb', 'edit', $slug );
28 $update_text = fs_text_x_inline( 'Update', 'verb', 'update', $slug );
29
30 $billing = $fs->_fetch_billing();
31 $has_billing = ( $billing instanceof FS_Billing );
32 if ( ! $has_billing ) {
33 $billing = new FS_Billing();
34 }
35 ?>
36 <!-- Billing -->
37 <div class="postbox">
38 <div id="fs_billing">
39 <h3><span class="dashicons dashicons-portfolio"></span> <?php fs_esc_html_echo_inline( 'Billing', 'billing', $slug ) ?></h3>
40 <table id="fs_billing_address"<?php if ( $has_billing ) {
41 echo ' class="fs-read-mode"';
42 } ?>>
43 <tr>
44 <td><label><span><?php fs_esc_html_echo_inline( 'Business name', 'business-name', $slug ) ?>:</span> <input id="business_name" value="<?php echo $billing->business_name ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Business name', 'business-name', $slug ) ?>"></label></td>
45 <td><label><span><?php fs_esc_html_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>:</span> <input id="tax_id" value="<?php echo $billing->tax_id ?>" placeholder="<?php fs_esc_attr_echo_inline( 'Tax / VAT ID', 'tax-vat-id', $slug ) ?>"></label></td>
46 </tr>
47 <tr>
48 <td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>:</span> <input id="address_street" value="<?php echo $billing->address_street ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 1 ) ?>"></label></td>
49 <td><label><span><?php printf( fs_esc_html_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>:</span> <input id="address_apt" value="<?php echo $billing->address_apt ?>" placeholder="<?php printf( fs_esc_attr_inline( 'Address Line %d', 'address-line-n', $slug ), 2 ) ?>"></label></td>
50 </tr>
51 <tr>
52 <td><label><span><?php fs_esc_html_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Town', 'town', $slug ) ?>:</span> <input id="address_city" value="<?php echo $billing->address_city ?>" placeholder="<?php fs_esc_attr_echo_inline( 'City', 'city', $slug ) ?> / <?php fs_esc_attr_echo_inline( 'Town', 'town', $slug ) ?>"></label></td>
53 <td><label><span><?php fs_esc_html_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>:</span> <input id="address_zip" value="<?php echo $billing->address_zip ?>" placeholder="<?php fs_esc_attr_echo_inline( 'ZIP / Postal Code', 'zip-postal-code', $slug ) ?>"></label></td>
54 </tr>
55 <tr>
56 <?php $countries = array(
57 'AF' => 'Afghanistan',
58 'AX' => 'Aland Islands',
59 'AL' => 'Albania',
60 'DZ' => 'Algeria',
61 'AS' => 'American Samoa',
62 'AD' => 'Andorra',
63 'AO' => 'Angola',
64 'AI' => 'Anguilla',
65 'AQ' => 'Antarctica',
66 'AG' => 'Antigua and Barbuda',
67 'AR' => 'Argentina',
68 'AM' => 'Armenia',
69 'AW' => 'Aruba',
70 'AU' => 'Australia',
71 'AT' => 'Austria',
72 'AZ' => 'Azerbaijan',
73 'BS' => 'Bahamas',
74 'BH' => 'Bahrain',
75 'BD' => 'Bangladesh',
76 'BB' => 'Barbados',
77 'BY' => 'Belarus',
78 'BE' => 'Belgium',
79 'BZ' => 'Belize',
80 'BJ' => 'Benin',
81 'BM' => 'Bermuda',
82 'BT' => 'Bhutan',
83 'BO' => 'Bolivia',
84 'BQ' => 'Bonaire, Saint Eustatius and Saba',
85 'BA' => 'Bosnia and Herzegovina',
86 'BW' => 'Botswana',
87 'BV' => 'Bouvet Island',
88 'BR' => 'Brazil',
89 'IO' => 'British Indian Ocean Territory',
90 'VG' => 'British Virgin Islands',
91 'BN' => 'Brunei',
92 'BG' => 'Bulgaria',
93 'BF' => 'Burkina Faso',
94 'BI' => 'Burundi',
95 'KH' => 'Cambodia',
96 'CM' => 'Cameroon',
97 'CA' => 'Canada',
98 'CV' => 'Cape Verde',
99 'KY' => 'Cayman Islands',
100 'CF' => 'Central African Republic',
101 'TD' => 'Chad',
102 'CL' => 'Chile',
103 'CN' => 'China',
104 'CX' => 'Christmas Island',
105 'CC' => 'Cocos Islands',
106 'CO' => 'Colombia',
107 'KM' => 'Comoros',
108 'CK' => 'Cook Islands',
109 'CR' => 'Costa Rica',
110 'HR' => 'Croatia',
111 'CU' => 'Cuba',
112 'CW' => 'Curacao',
113 'CY' => 'Cyprus',
114 'CZ' => 'Czech Republic',
115 'CD' => 'Democratic Republic of the Congo',
116 'DK' => 'Denmark',
117 'DJ' => 'Djibouti',
118 'DM' => 'Dominica',
119 'DO' => 'Dominican Republic',
120 'TL' => 'East Timor',
121 'EC' => 'Ecuador',
122 'EG' => 'Egypt',
123 'SV' => 'El Salvador',
124 'GQ' => 'Equatorial Guinea',
125 'ER' => 'Eritrea',
126 'EE' => 'Estonia',
127 'ET' => 'Ethiopia',
128 'FK' => 'Falkland Islands',
129 'FO' => 'Faroe Islands',
130 'FJ' => 'Fiji',
131 'FI' => 'Finland',
132 'FR' => 'France',
133 'GF' => 'French Guiana',
134 'PF' => 'French Polynesia',
135 'TF' => 'French Southern Territories',
136 'GA' => 'Gabon',
137 'GM' => 'Gambia',
138 'GE' => 'Georgia',
139 'DE' => 'Germany',
140 'GH' => 'Ghana',
141 'GI' => 'Gibraltar',
142 'GR' => 'Greece',
143 'GL' => 'Greenland',
144 'GD' => 'Grenada',
145 'GP' => 'Guadeloupe',
146 'GU' => 'Guam',
147 'GT' => 'Guatemala',
148 'GG' => 'Guernsey',
149 'GN' => 'Guinea',
150 'GW' => 'Guinea-Bissau',
151 'GY' => 'Guyana',
152 'HT' => 'Haiti',
153 'HM' => 'Heard Island and McDonald Islands',
154 'HN' => 'Honduras',
155 'HK' => 'Hong Kong',
156 'HU' => 'Hungary',
157 'IS' => 'Iceland',
158 'IN' => 'India',
159 'ID' => 'Indonesia',
160 'IR' => 'Iran',
161 'IQ' => 'Iraq',
162 'IE' => 'Ireland',
163 'IM' => 'Isle of Man',
164 'IL' => 'Israel',
165 'IT' => 'Italy',
166 'CI' => 'Ivory Coast',
167 'JM' => 'Jamaica',
168 'JP' => 'Japan',
169 'JE' => 'Jersey',
170 'JO' => 'Jordan',
171 'KZ' => 'Kazakhstan',
172 'KE' => 'Kenya',
173 'KI' => 'Kiribati',
174 'XK' => 'Kosovo',
175 'KW' => 'Kuwait',
176 'KG' => 'Kyrgyzstan',
177 'LA' => 'Laos',
178 'LV' => 'Latvia',
179 'LB' => 'Lebanon',
180 'LS' => 'Lesotho',
181 'LR' => 'Liberia',
182 'LY' => 'Libya',
183 'LI' => 'Liechtenstein',
184 'LT' => 'Lithuania',
185 'LU' => 'Luxembourg',
186 'MO' => 'Macao',
187 'MK' => 'Macedonia',
188 'MG' => 'Madagascar',
189 'MW' => 'Malawi',
190 'MY' => 'Malaysia',
191 'MV' => 'Maldives',
192 'ML' => 'Mali',
193 'MT' => 'Malta',
194 'MH' => 'Marshall Islands',
195 'MQ' => 'Martinique',
196 'MR' => 'Mauritania',
197 'MU' => 'Mauritius',
198 'YT' => 'Mayotte',
199 'MX' => 'Mexico',
200 'FM' => 'Micronesia',
201 'MD' => 'Moldova',
202 'MC' => 'Monaco',
203 'MN' => 'Mongolia',
204 'ME' => 'Montenegro',
205 'MS' => 'Montserrat',
206 'MA' => 'Morocco',
207 'MZ' => 'Mozambique',
208 'MM' => 'Myanmar',
209 'NA' => 'Namibia',
210 'NR' => 'Nauru',
211 'NP' => 'Nepal',
212 'NL' => 'Netherlands',
213 'NC' => 'New Caledonia',
214 'NZ' => 'New Zealand',
215 'NI' => 'Nicaragua',
216 'NE' => 'Niger',
217 'NG' => 'Nigeria',
218 'NU' => 'Niue',
219 'NF' => 'Norfolk Island',
220 'KP' => 'North Korea',
221 'MP' => 'Northern Mariana Islands',
222 'NO' => 'Norway',
223 'OM' => 'Oman',
224 'PK' => 'Pakistan',
225 'PW' => 'Palau',
226 'PS' => 'Palestinian Territory',
227 'PA' => 'Panama',
228 'PG' => 'Papua New Guinea',
229 'PY' => 'Paraguay',
230 'PE' => 'Peru',
231 'PH' => 'Philippines',
232 'PN' => 'Pitcairn',
233 'PL' => 'Poland',
234 'PT' => 'Portugal',
235 'PR' => 'Puerto Rico',
236 'QA' => 'Qatar',
237 'CG' => 'Republic of the Congo',
238 'RE' => 'Reunion',
239 'RO' => 'Romania',
240 'RU' => 'Russia',
241 'RW' => 'Rwanda',
242 'BL' => 'Saint Barthelemy',
243 'SH' => 'Saint Helena',
244 'KN' => 'Saint Kitts and Nevis',
245 'LC' => 'Saint Lucia',
246 'MF' => 'Saint Martin',
247 'PM' => 'Saint Pierre and Miquelon',
248 'VC' => 'Saint Vincent and the Grenadines',
249 'WS' => 'Samoa',
250 'SM' => 'San Marino',
251 'ST' => 'Sao Tome and Principe',
252 'SA' => 'Saudi Arabia',
253 'SN' => 'Senegal',
254 'RS' => 'Serbia',
255 'SC' => 'Seychelles',
256 'SL' => 'Sierra Leone',
257 'SG' => 'Singapore',
258 'SX' => 'Sint Maarten',
259 'SK' => 'Slovakia',
260 'SI' => 'Slovenia',
261 'SB' => 'Solomon Islands',
262 'SO' => 'Somalia',
263 'ZA' => 'South Africa',
264 'GS' => 'South Georgia and the South Sandwich Islands',
265 'KR' => 'South Korea',
266 'SS' => 'South Sudan',
267 'ES' => 'Spain',
268 'LK' => 'Sri Lanka',
269 'SD' => 'Sudan',
270 'SR' => 'Suriname',
271 'SJ' => 'Svalbard and Jan Mayen',
272 'SZ' => 'Swaziland',
273 'SE' => 'Sweden',
274 'CH' => 'Switzerland',
275 'SY' => 'Syria',
276 'TW' => 'Taiwan',
277 'TJ' => 'Tajikistan',
278 'TZ' => 'Tanzania',
279 'TH' => 'Thailand',
280 'TG' => 'Togo',
281 'TK' => 'Tokelau',
282 'TO' => 'Tonga',
283 'TT' => 'Trinidad and Tobago',
284 'TN' => 'Tunisia',
285 'TR' => 'Turkey',
286 'TM' => 'Turkmenistan',
287 'TC' => 'Turks and Caicos Islands',
288 'TV' => 'Tuvalu',
289 'VI' => 'U.S. Virgin Islands',
290 'UG' => 'Uganda',
291 'UA' => 'Ukraine',
292 'AE' => 'United Arab Emirates',
293 'GB' => 'United Kingdom',
294 'US' => 'United States',
295 'UM' => 'United States Minor Outlying Islands',
296 'UY' => 'Uruguay',
297 'UZ' => 'Uzbekistan',
298 'VU' => 'Vanuatu',
299 'VA' => 'Vatican',
300 'VE' => 'Venezuela',
301 'VN' => 'Vietnam',
302 'WF' => 'Wallis and Futuna',
303 'EH' => 'Western Sahara',
304 'YE' => 'Yemen',
305 'ZM' => 'Zambia',
306 'ZW' => 'Zimbabwe',
307 ) ?>
308 <td><label><span><?php fs_esc_html_echo_inline( 'Country', 'country', $slug ) ?>:</span> <select id="address_country_code">
309 <?php if ( empty( $billing->address_country_code ) ) : ?>
310 <option value="" selected><?php fs_esc_html_echo_inline( 'Select Country', 'select-country', $slug ) ?></option>
311 <?php endif ?>
312 <?php foreach ( $countries as $code => $country ) : ?>
313 <option
314 value="<?php echo $code ?>" <?php selected( $billing->address_country_code, $code ) ?>><?php echo $country ?></option>
315 <?php endforeach ?>
316 </select></label></td>
317 <td><label><span><?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>:</span>
318 <input id="address_state" value="<?php echo $billing->address_state ?>" placeholder="<?php fs_esc_html_echo_inline( 'State', 'state', $slug ) ?> / <?php fs_esc_html_echo_inline( 'Province', 'province', $slug ) ?>"></label></td>
319 </tr>
320 <tr>
321 <td colspan="2">
322 <button
323 class="button"><?php echo esc_html( $has_billing ?
324 $edit_text :
325 $update_text
326 ) ?></button>
327 </td>
328 </tr>
329 </table>
330 </div>
331 </div>
332 <!--/ Billing -->
333 <script type="text/javascript">
334 (function($){
335 var $billingAddress = $('#fs_billing_address'),
336 $billingInputs = $billingAddress.find('input, select');
337
338 var setPrevValues = function () {
339 $billingInputs.each(function () {
340 $(this).attr('data-val', $(this).val());
341 });
342 };
343
344 setPrevValues();
345
346 var hasBillingChanged = function () {
347 for (var i = 0, len = $billingInputs.length; i < len; i++){
348 var $this = $($billingInputs[i]);
349 if ($this.attr('data-val') !== $this.val()) {
350 return true;
351 }
352 }
353
354 return false;
355 };
356
357 var isEditAllFieldsMode = false;
358
359 $billingAddress.find('.button').click(function(){
360 $billingAddress.toggleClass('fs-read-mode');
361
362 var isEditMode = !$billingAddress.hasClass('fs-read-mode');
363
364 $(this)
365 .html(isEditMode ? '<?php echo esc_js( $update_text ) ?>' : '<?php echo esc_js( $edit_text ) ?>')
366 .toggleClass('button-primary');
367
368 if (isEditMode) {
369 $('#business_name').focus().select();
370 isEditAllFieldsMode = true;
371 } else {
372 isEditAllFieldsMode = false;
373
374 if (!hasBillingChanged())
375 return;
376
377 var billing = {};
378
379 $billingInputs.each(function(){
380 if ($(this).attr('data-val') !== $(this).val()) {
381 billing[$(this).attr('id')] = $(this).val();
382 }
383 });
384
385 $.ajax({
386 url : ajaxurl,
387 method : 'POST',
388 data : {
389 action : '<?php echo $fs->get_ajax_action( 'update_billing' ) ?>',
390 security : '<?php echo $fs->get_ajax_security( 'update_billing' ) ?>',
391 module_id: '<?php echo $fs->get_id() ?>',
392 billing : billing
393 },
394 success: function (resultObj) {
395 if (resultObj.success) {
396 setPrevValues();
397 } else {
398 alert(resultObj.error);
399 }
400 }
401 });
402 }
403 });
404
405 $billingInputs
406 // Get into edit mode upon selection.
407 .focus(function () {
408 var isEditMode = !$billingAddress.hasClass('fs-read-mode');
409
410 if (isEditMode) {
411 return;
412 }
413
414 $billingAddress.toggleClass('fs-read-mode');
415 $billingAddress.find('.button')
416 .html('<?php echo esc_js( $update_text ) ?>')
417 .toggleClass('button-primary');
418 })
419 // If blured after editing only one field without changes, exit edit mode.
420 .blur(function () {
421 if (!isEditAllFieldsMode && !hasBillingChanged()) {
422 $billingAddress.toggleClass('fs-read-mode');
423 $billingAddress.find('.button')
424 .html('<?php echo esc_js( $edit_text ) ?>')
425 .toggleClass('button-primary');
426 }
427 });
428 })(jQuery);
429 </script>
430 <?php
431 endif;