@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class OxidInstaller extends BaseInstaller |
7 | 7 | { |
8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
9 | 9 | |
10 | 10 | protected $locations = array( |
11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | 'out' => 'out/{$name}/', |
14 | 14 | ); |
15 | 15 | |
16 | - /** |
|
17 | - * getInstallPath |
|
18 | - * |
|
19 | - * @param PackageInterface $package |
|
20 | - * @param string $frameworkType |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | - { |
|
25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | - $type = $this->package->getType(); |
|
27 | - if ($type === 'oxid-module') { |
|
28 | - $this->prepareVendorDirectory($installPath); |
|
29 | - } |
|
30 | - return $installPath; |
|
31 | - } |
|
16 | + /** |
|
17 | + * getInstallPath |
|
18 | + * |
|
19 | + * @param PackageInterface $package |
|
20 | + * @param string $frameworkType |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | + { |
|
25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | + $type = $this->package->getType(); |
|
27 | + if ($type === 'oxid-module') { |
|
28 | + $this->prepareVendorDirectory($installPath); |
|
29 | + } |
|
30 | + return $installPath; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * prepareVendorDirectory |
|
35 | - * |
|
36 | - * Makes sure there is a vendormetadata.php file inside |
|
37 | - * the vendor folder if there is a vendor folder. |
|
38 | - * |
|
39 | - * @param string $installPath |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function prepareVendorDirectory($installPath) |
|
43 | - { |
|
44 | - $matches = ''; |
|
45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | - if (!$hasVendorDirectory) { |
|
47 | - return; |
|
48 | - } |
|
33 | + /** |
|
34 | + * prepareVendorDirectory |
|
35 | + * |
|
36 | + * Makes sure there is a vendormetadata.php file inside |
|
37 | + * the vendor folder if there is a vendor folder. |
|
38 | + * |
|
39 | + * @param string $installPath |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function prepareVendorDirectory($installPath) |
|
43 | + { |
|
44 | + $matches = ''; |
|
45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | + if (!$hasVendorDirectory) { |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $vendorDirectory = $matches['vendor']; |
|
51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | - if (!file_exists($vendorPath)) { |
|
53 | - mkdir($vendorPath, 0755, true); |
|
54 | - } |
|
50 | + $vendorDirectory = $matches['vendor']; |
|
51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | + if (!file_exists($vendorPath)) { |
|
53 | + mkdir($vendorPath, 0755, true); |
|
54 | + } |
|
55 | 55 | |
56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | - touch($vendorMetaDataPath); |
|
58 | - } |
|
56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | + touch($vendorMetaDataPath); |
|
58 | + } |
|
59 | 59 | } |
@@ -9,31 +9,31 @@ |
||
9 | 9 | defined( 'ABSPATH' ) || exit; |
10 | 10 | |
11 | 11 | return array( |
12 | - 'AT', |
|
13 | - 'BE', |
|
14 | - 'BG', |
|
15 | - 'HR', |
|
16 | - 'CY', |
|
17 | - 'CZ', |
|
18 | - 'DK', |
|
19 | - 'EE', |
|
20 | - 'FI', |
|
21 | - 'FR', |
|
22 | - 'DE', |
|
23 | - 'GR', |
|
24 | - 'HU', |
|
25 | - 'IE', |
|
26 | - 'IT', |
|
27 | - 'LV', |
|
28 | - 'LT', |
|
29 | - 'LU', |
|
30 | - 'MT', |
|
31 | - 'NL', |
|
32 | - 'PL', |
|
33 | - 'PT', |
|
34 | - 'RO', |
|
35 | - 'SK', |
|
36 | - 'SI', |
|
37 | - 'ES', |
|
38 | - 'SE' |
|
12 | + 'AT', |
|
13 | + 'BE', |
|
14 | + 'BG', |
|
15 | + 'HR', |
|
16 | + 'CY', |
|
17 | + 'CZ', |
|
18 | + 'DK', |
|
19 | + 'EE', |
|
20 | + 'FI', |
|
21 | + 'FR', |
|
22 | + 'DE', |
|
23 | + 'GR', |
|
24 | + 'HU', |
|
25 | + 'IE', |
|
26 | + 'IT', |
|
27 | + 'LV', |
|
28 | + 'LT', |
|
29 | + 'LU', |
|
30 | + 'MT', |
|
31 | + 'NL', |
|
32 | + 'PL', |
|
33 | + 'PT', |
|
34 | + 'RO', |
|
35 | + 'SK', |
|
36 | + 'SI', |
|
37 | + 'ES', |
|
38 | + 'SE' |
|
39 | 39 | ); |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
38 | - return 'manage_options'; |
|
39 | - }; |
|
37 | + if ( current_user_can( 'manage_options' ) ) { |
|
38 | + return 'manage_options'; |
|
39 | + }; |
|
40 | 40 | |
41 | - return $capalibilty; |
|
41 | + return $capalibilty; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | // Prepare user values. |
63 | 63 | $prefix = preg_replace( '/\s+/', '', $prefix ); |
64 | 64 | $prefix = empty( $prefix ) ? $email : $prefix; |
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | - 'user_pass' => wp_generate_password(), |
|
68 | - 'user_email' => $email, |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | + 'user_pass' => wp_generate_password(), |
|
68 | + 'user_email' => $email, |
|
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | function wpinv_generate_user_name( $prefix = '' ) { |
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
85 | + $prefix = strtok( $prefix, '@' ); |
|
86 | 86 | $prefix = trim( $prefix, '.' ); |
87 | 87 | |
88 | - // Sanitize the username. |
|
89 | - $prefix = sanitize_user( $prefix, true ); |
|
88 | + // Sanitize the username. |
|
89 | + $prefix = sanitize_user( $prefix, true ); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | - } |
|
91 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | + $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
@@ -12,256 +12,256 @@ |
||
12 | 12 | defined( 'ABSPATH' ) || exit; |
13 | 13 | |
14 | 14 | return array( |
15 | - 'US' => __('United States', 'invoicing'), |
|
16 | - 'CA' => __('Canada', 'invoicing'), |
|
17 | - 'GB' => __('United Kingdom', 'invoicing'), |
|
18 | - 'AF' => __('Afghanistan', 'invoicing'), |
|
19 | - 'AX' => __('Aland Islands', 'invoicing'), |
|
20 | - 'AL' => __('Albania', 'invoicing'), |
|
21 | - 'DZ' => __('Algeria', 'invoicing'), |
|
22 | - 'AS' => __('American Samoa', 'invoicing'), |
|
23 | - 'AD' => __('Andorra', 'invoicing'), |
|
24 | - 'AO' => __('Angola', 'invoicing'), |
|
25 | - 'AI' => __('Anguilla', 'invoicing'), |
|
26 | - 'AQ' => __('Antarctica', 'invoicing'), |
|
27 | - 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
28 | - 'AR' => __('Argentina', 'invoicing'), |
|
29 | - 'AM' => __('Armenia', 'invoicing'), |
|
30 | - 'AW' => __('Aruba', 'invoicing'), |
|
31 | - 'AU' => __('Australia', 'invoicing'), |
|
32 | - 'AT' => __('Austria', 'invoicing'), |
|
33 | - 'AZ' => __('Azerbaijan', 'invoicing'), |
|
34 | - 'BS' => __('Bahamas', 'invoicing'), |
|
35 | - 'BH' => __('Bahrain', 'invoicing'), |
|
36 | - 'BD' => __('Bangladesh', 'invoicing'), |
|
37 | - 'BB' => __('Barbados', 'invoicing'), |
|
38 | - 'BY' => __('Belarus', 'invoicing'), |
|
39 | - 'BE' => __('Belgium', 'invoicing'), |
|
40 | - 'BZ' => __('Belize', 'invoicing'), |
|
41 | - 'BJ' => __('Benin', 'invoicing'), |
|
42 | - 'BM' => __('Bermuda', 'invoicing'), |
|
43 | - 'BT' => __('Bhutan', 'invoicing'), |
|
44 | - 'BO' => __('Bolivia', 'invoicing'), |
|
45 | - 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
46 | - 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
47 | - 'BW' => __('Botswana', 'invoicing'), |
|
48 | - 'BV' => __('Bouvet Island', 'invoicing'), |
|
49 | - 'BR' => __('Brazil', 'invoicing'), |
|
50 | - 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
51 | - 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
52 | - 'BG' => __('Bulgaria', 'invoicing'), |
|
53 | - 'BF' => __('Burkina Faso', 'invoicing'), |
|
54 | - 'BI' => __('Burundi', 'invoicing'), |
|
55 | - 'KH' => __('Cambodia', 'invoicing'), |
|
56 | - 'CM' => __('Cameroon', 'invoicing'), |
|
57 | - 'CV' => __('Cape Verde', 'invoicing'), |
|
58 | - 'KY' => __('Cayman Islands', 'invoicing'), |
|
59 | - 'CF' => __('Central African Republic', 'invoicing'), |
|
60 | - 'TD' => __('Chad', 'invoicing'), |
|
61 | - 'CL' => __('Chile', 'invoicing'), |
|
62 | - 'CN' => __('China', 'invoicing'), |
|
63 | - 'CX' => __('Christmas Island', 'invoicing'), |
|
64 | - 'CC' => __('Cocos Islands', 'invoicing'), |
|
65 | - 'CO' => __('Colombia', 'invoicing'), |
|
66 | - 'KM' => __('Comoros', 'invoicing'), |
|
67 | - 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
68 | - 'CG' => __('Congo, Republic of', 'invoicing'), |
|
69 | - 'CK' => __('Cook Islands', 'invoicing'), |
|
70 | - 'CR' => __('Costa Rica', 'invoicing'), |
|
71 | - 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
72 | - 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
73 | - 'CU' => __('Cuba', 'invoicing'), |
|
74 | - 'CW' => __('CuraÇao', 'invoicing'), |
|
75 | - 'CY' => __('Cyprus', 'invoicing'), |
|
76 | - 'CZ' => __('Czech Republic', 'invoicing'), |
|
77 | - 'DK' => __('Denmark', 'invoicing'), |
|
78 | - 'DJ' => __('Djibouti', 'invoicing'), |
|
79 | - 'DM' => __('Dominica', 'invoicing'), |
|
80 | - 'DO' => __('Dominican Republic', 'invoicing'), |
|
81 | - 'TP' => __('East Timor', 'invoicing'), |
|
82 | - 'EC' => __('Ecuador', 'invoicing'), |
|
83 | - 'EG' => __('Egypt', 'invoicing'), |
|
84 | - 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
85 | - 'SV' => __('El Salvador', 'invoicing'), |
|
86 | - 'ER' => __('Eritrea', 'invoicing'), |
|
87 | - 'EE' => __('Estonia', 'invoicing'), |
|
88 | - 'ET' => __('Ethiopia', 'invoicing'), |
|
89 | - 'FK' => __('Falkland Islands', 'invoicing'), |
|
90 | - 'FO' => __('Faroe Islands', 'invoicing'), |
|
91 | - 'FJ' => __('Fiji', 'invoicing'), |
|
92 | - 'FI' => __('Finland', 'invoicing'), |
|
93 | - 'FR' => __('France', 'invoicing'), |
|
94 | - 'GF' => __('French Guiana', 'invoicing'), |
|
95 | - 'PF' => __('French Polynesia', 'invoicing'), |
|
96 | - 'TF' => __('French Southern Territories', 'invoicing'), |
|
97 | - 'GA' => __('Gabon', 'invoicing'), |
|
98 | - 'GM' => __('Gambia', 'invoicing'), |
|
99 | - 'GE' => __('Georgia', 'invoicing'), |
|
100 | - 'DE' => __('Germany', 'invoicing'), |
|
101 | - 'GR' => __('Greece', 'invoicing'), |
|
102 | - 'GH' => __('Ghana', 'invoicing'), |
|
103 | - 'GI' => __('Gibraltar', 'invoicing'), |
|
104 | - 'GL' => __('Greenland', 'invoicing'), |
|
105 | - 'GD' => __('Grenada', 'invoicing'), |
|
106 | - 'GP' => __('Guadeloupe', 'invoicing'), |
|
107 | - 'GU' => __('Guam', 'invoicing'), |
|
108 | - 'GT' => __('Guatemala', 'invoicing'), |
|
109 | - 'GG' => __('Guernsey', 'invoicing'), |
|
110 | - 'GN' => __('Guinea', 'invoicing'), |
|
111 | - 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
112 | - 'GY' => __('Guyana', 'invoicing'), |
|
113 | - 'HT' => __('Haiti', 'invoicing'), |
|
114 | - 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
115 | - 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
116 | - 'HN' => __('Honduras', 'invoicing'), |
|
117 | - 'HK' => __('Hong Kong', 'invoicing'), |
|
118 | - 'HU' => __('Hungary', 'invoicing'), |
|
119 | - 'IS' => __('Iceland', 'invoicing'), |
|
120 | - 'IN' => __('India', 'invoicing'), |
|
121 | - 'ID' => __('Indonesia', 'invoicing'), |
|
122 | - 'IR' => __('Iran', 'invoicing'), |
|
123 | - 'IQ' => __('Iraq', 'invoicing'), |
|
124 | - 'IE' => __('Ireland', 'invoicing'), |
|
125 | - 'IM' => __('Isle of Man', 'invoicing'), |
|
126 | - 'IL' => __('Israel', 'invoicing'), |
|
127 | - 'IT' => __('Italy', 'invoicing'), |
|
128 | - 'JM' => __('Jamaica', 'invoicing'), |
|
129 | - 'JP' => __('Japan', 'invoicing'), |
|
130 | - 'JE' => __('Jersey', 'invoicing'), |
|
131 | - 'JO' => __('Jordan', 'invoicing'), |
|
132 | - 'KZ' => __('Kazakhstan', 'invoicing'), |
|
133 | - 'KE' => __('Kenya', 'invoicing'), |
|
134 | - 'KI' => __('Kiribati', 'invoicing'), |
|
135 | - 'KW' => __('Kuwait', 'invoicing'), |
|
136 | - 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
137 | - 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
138 | - 'LV' => __('Latvia', 'invoicing'), |
|
139 | - 'LB' => __('Lebanon', 'invoicing'), |
|
140 | - 'LS' => __('Lesotho', 'invoicing'), |
|
141 | - 'LR' => __('Liberia', 'invoicing'), |
|
142 | - 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
143 | - 'LI' => __('Liechtenstein', 'invoicing'), |
|
144 | - 'LT' => __('Lithuania', 'invoicing'), |
|
145 | - 'LU' => __('Luxembourg', 'invoicing'), |
|
146 | - 'MO' => __('Macau', 'invoicing'), |
|
147 | - 'MK' => __('Macedonia', 'invoicing'), |
|
148 | - 'MG' => __('Madagascar', 'invoicing'), |
|
149 | - 'MW' => __('Malawi', 'invoicing'), |
|
150 | - 'MY' => __('Malaysia', 'invoicing'), |
|
151 | - 'MV' => __('Maldives', 'invoicing'), |
|
152 | - 'ML' => __('Mali', 'invoicing'), |
|
153 | - 'MT' => __('Malta', 'invoicing'), |
|
154 | - 'MH' => __('Marshall Islands', 'invoicing'), |
|
155 | - 'MQ' => __('Martinique', 'invoicing'), |
|
156 | - 'MR' => __('Mauritania', 'invoicing'), |
|
157 | - 'MU' => __('Mauritius', 'invoicing'), |
|
158 | - 'YT' => __('Mayotte', 'invoicing'), |
|
159 | - 'MX' => __('Mexico', 'invoicing'), |
|
160 | - 'FM' => __('Micronesia', 'invoicing'), |
|
161 | - 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
162 | - 'MC' => __('Monaco', 'invoicing'), |
|
163 | - 'MN' => __('Mongolia', 'invoicing'), |
|
164 | - 'ME' => __('Montenegro', 'invoicing'), |
|
165 | - 'MS' => __('Montserrat', 'invoicing'), |
|
166 | - 'MA' => __('Morocco', 'invoicing'), |
|
167 | - 'MZ' => __('Mozambique', 'invoicing'), |
|
168 | - 'MM' => __('Myanmar', 'invoicing'), |
|
169 | - 'NA' => __('Namibia', 'invoicing'), |
|
170 | - 'NR' => __('Nauru', 'invoicing'), |
|
171 | - 'NP' => __('Nepal', 'invoicing'), |
|
172 | - 'NL' => __('Netherlands', 'invoicing'), |
|
173 | - 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
174 | - 'NC' => __('New Caledonia', 'invoicing'), |
|
175 | - 'NZ' => __('New Zealand', 'invoicing'), |
|
176 | - 'NI' => __('Nicaragua', 'invoicing'), |
|
177 | - 'NE' => __('Niger', 'invoicing'), |
|
178 | - 'NG' => __('Nigeria', 'invoicing'), |
|
179 | - 'NU' => __('Niue', 'invoicing'), |
|
180 | - 'NF' => __('Norfolk Island', 'invoicing'), |
|
181 | - 'KP' => __('North Korea', 'invoicing'), |
|
182 | - 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
183 | - 'NO' => __('Norway', 'invoicing'), |
|
184 | - 'OM' => __('Oman', 'invoicing'), |
|
185 | - 'PK' => __('Pakistan', 'invoicing'), |
|
186 | - 'PW' => __('Palau', 'invoicing'), |
|
187 | - 'PS' => __('Palestinian Territories', 'invoicing'), |
|
188 | - 'PA' => __('Panama', 'invoicing'), |
|
189 | - 'PG' => __('Papua New Guinea', 'invoicing'), |
|
190 | - 'PY' => __('Paraguay', 'invoicing'), |
|
191 | - 'PE' => __('Peru', 'invoicing'), |
|
192 | - 'PH' => __('Philippines', 'invoicing'), |
|
193 | - 'PN' => __('Pitcairn Island', 'invoicing'), |
|
194 | - 'PL' => __('Poland', 'invoicing'), |
|
195 | - 'PT' => __('Portugal', 'invoicing'), |
|
196 | - 'PR' => __('Puerto Rico', 'invoicing'), |
|
197 | - 'QA' => __('Qatar', 'invoicing'), |
|
198 | - 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
199 | - 'RE' => __('Reunion Island', 'invoicing'), |
|
200 | - 'RO' => __('Romania', 'invoicing'), |
|
201 | - 'RU' => __('Russian Federation', 'invoicing'), |
|
202 | - 'RW' => __('Rwanda', 'invoicing'), |
|
203 | - 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
204 | - 'SH' => __('Saint Helena', 'invoicing'), |
|
205 | - 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
206 | - 'LC' => __('Saint Lucia', 'invoicing'), |
|
207 | - 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
208 | - 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
209 | - 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
210 | - 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
211 | - 'SM' => __('San Marino', 'invoicing'), |
|
212 | - 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
213 | - 'SA' => __('Saudi Arabia', 'invoicing'), |
|
214 | - 'SN' => __('Senegal', 'invoicing'), |
|
215 | - 'RS' => __('Serbia', 'invoicing'), |
|
216 | - 'SC' => __('Seychelles', 'invoicing'), |
|
217 | - 'SL' => __('Sierra Leone', 'invoicing'), |
|
218 | - 'SG' => __('Singapore', 'invoicing'), |
|
219 | - 'SK' => __('Slovak Republic', 'invoicing'), |
|
220 | - 'SI' => __('Slovenia', 'invoicing'), |
|
221 | - 'SB' => __('Solomon Islands', 'invoicing'), |
|
222 | - 'SO' => __('Somalia', 'invoicing'), |
|
223 | - 'ZA' => __('South Africa', 'invoicing'), |
|
224 | - 'GS' => __('South Georgia', 'invoicing'), |
|
225 | - 'KR' => __('South Korea', 'invoicing'), |
|
226 | - 'SS' => __('South Sudan', 'invoicing'), |
|
227 | - 'ES' => __('Spain', 'invoicing'), |
|
228 | - 'LK' => __('Sri Lanka', 'invoicing'), |
|
229 | - 'SD' => __('Sudan', 'invoicing'), |
|
230 | - 'SR' => __('Suriname', 'invoicing'), |
|
231 | - 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
232 | - 'SZ' => __('Swaziland', 'invoicing'), |
|
233 | - 'SE' => __('Sweden', 'invoicing'), |
|
234 | - 'CH' => __('Switzerland', 'invoicing'), |
|
235 | - 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
236 | - 'TW' => __('Taiwan', 'invoicing'), |
|
237 | - 'TJ' => __('Tajikistan', 'invoicing'), |
|
238 | - 'TZ' => __('Tanzania', 'invoicing'), |
|
239 | - 'TH' => __('Thailand', 'invoicing'), |
|
240 | - 'TL' => __('Timor-Leste', 'invoicing'), |
|
241 | - 'TG' => __('Togo', 'invoicing'), |
|
242 | - 'TK' => __('Tokelau', 'invoicing'), |
|
243 | - 'TO' => __('Tonga', 'invoicing'), |
|
244 | - 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
245 | - 'TN' => __('Tunisia', 'invoicing'), |
|
246 | - 'TR' => __('Turkey', 'invoicing'), |
|
247 | - 'TM' => __('Turkmenistan', 'invoicing'), |
|
248 | - 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
249 | - 'TV' => __('Tuvalu', 'invoicing'), |
|
250 | - 'UG' => __('Uganda', 'invoicing'), |
|
251 | - 'UA' => __('Ukraine', 'invoicing'), |
|
252 | - 'AE' => __('United Arab Emirates', 'invoicing'), |
|
253 | - 'UY' => __('Uruguay', 'invoicing'), |
|
254 | - 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
255 | - 'UZ' => __('Uzbekistan', 'invoicing'), |
|
256 | - 'VU' => __('Vanuatu', 'invoicing'), |
|
257 | - 'VE' => __('Venezuela', 'invoicing'), |
|
258 | - 'VN' => __('Vietnam', 'invoicing'), |
|
259 | - 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
260 | - 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
261 | - 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
262 | - 'EH' => __('Western Sahara', 'invoicing'), |
|
263 | - 'WS' => __('Western Samoa', 'invoicing'), |
|
264 | - 'YE' => __('Yemen', 'invoicing'), |
|
265 | - 'ZM' => __('Zambia', 'invoicing'), |
|
266 | - 'ZW' => __('Zimbabwe', 'invoicing'), |
|
15 | + 'US' => __('United States', 'invoicing'), |
|
16 | + 'CA' => __('Canada', 'invoicing'), |
|
17 | + 'GB' => __('United Kingdom', 'invoicing'), |
|
18 | + 'AF' => __('Afghanistan', 'invoicing'), |
|
19 | + 'AX' => __('Aland Islands', 'invoicing'), |
|
20 | + 'AL' => __('Albania', 'invoicing'), |
|
21 | + 'DZ' => __('Algeria', 'invoicing'), |
|
22 | + 'AS' => __('American Samoa', 'invoicing'), |
|
23 | + 'AD' => __('Andorra', 'invoicing'), |
|
24 | + 'AO' => __('Angola', 'invoicing'), |
|
25 | + 'AI' => __('Anguilla', 'invoicing'), |
|
26 | + 'AQ' => __('Antarctica', 'invoicing'), |
|
27 | + 'AG' => __('Antigua and Barbuda', 'invoicing'), |
|
28 | + 'AR' => __('Argentina', 'invoicing'), |
|
29 | + 'AM' => __('Armenia', 'invoicing'), |
|
30 | + 'AW' => __('Aruba', 'invoicing'), |
|
31 | + 'AU' => __('Australia', 'invoicing'), |
|
32 | + 'AT' => __('Austria', 'invoicing'), |
|
33 | + 'AZ' => __('Azerbaijan', 'invoicing'), |
|
34 | + 'BS' => __('Bahamas', 'invoicing'), |
|
35 | + 'BH' => __('Bahrain', 'invoicing'), |
|
36 | + 'BD' => __('Bangladesh', 'invoicing'), |
|
37 | + 'BB' => __('Barbados', 'invoicing'), |
|
38 | + 'BY' => __('Belarus', 'invoicing'), |
|
39 | + 'BE' => __('Belgium', 'invoicing'), |
|
40 | + 'BZ' => __('Belize', 'invoicing'), |
|
41 | + 'BJ' => __('Benin', 'invoicing'), |
|
42 | + 'BM' => __('Bermuda', 'invoicing'), |
|
43 | + 'BT' => __('Bhutan', 'invoicing'), |
|
44 | + 'BO' => __('Bolivia', 'invoicing'), |
|
45 | + 'BQ' => __('Bonaire, Saint Eustatius and Saba', 'invoicing'), |
|
46 | + 'BA' => __('Bosnia and Herzegovina', 'invoicing'), |
|
47 | + 'BW' => __('Botswana', 'invoicing'), |
|
48 | + 'BV' => __('Bouvet Island', 'invoicing'), |
|
49 | + 'BR' => __('Brazil', 'invoicing'), |
|
50 | + 'IO' => __('British Indian Ocean Territory', 'invoicing'), |
|
51 | + 'BN' => __('Brunei Darrussalam', 'invoicing'), |
|
52 | + 'BG' => __('Bulgaria', 'invoicing'), |
|
53 | + 'BF' => __('Burkina Faso', 'invoicing'), |
|
54 | + 'BI' => __('Burundi', 'invoicing'), |
|
55 | + 'KH' => __('Cambodia', 'invoicing'), |
|
56 | + 'CM' => __('Cameroon', 'invoicing'), |
|
57 | + 'CV' => __('Cape Verde', 'invoicing'), |
|
58 | + 'KY' => __('Cayman Islands', 'invoicing'), |
|
59 | + 'CF' => __('Central African Republic', 'invoicing'), |
|
60 | + 'TD' => __('Chad', 'invoicing'), |
|
61 | + 'CL' => __('Chile', 'invoicing'), |
|
62 | + 'CN' => __('China', 'invoicing'), |
|
63 | + 'CX' => __('Christmas Island', 'invoicing'), |
|
64 | + 'CC' => __('Cocos Islands', 'invoicing'), |
|
65 | + 'CO' => __('Colombia', 'invoicing'), |
|
66 | + 'KM' => __('Comoros', 'invoicing'), |
|
67 | + 'CD' => __('Congo, Democratic People\'s Republic', 'invoicing'), |
|
68 | + 'CG' => __('Congo, Republic of', 'invoicing'), |
|
69 | + 'CK' => __('Cook Islands', 'invoicing'), |
|
70 | + 'CR' => __('Costa Rica', 'invoicing'), |
|
71 | + 'CI' => __('Cote d\'Ivoire', 'invoicing'), |
|
72 | + 'HR' => __('Croatia/Hrvatska', 'invoicing'), |
|
73 | + 'CU' => __('Cuba', 'invoicing'), |
|
74 | + 'CW' => __('CuraÇao', 'invoicing'), |
|
75 | + 'CY' => __('Cyprus', 'invoicing'), |
|
76 | + 'CZ' => __('Czech Republic', 'invoicing'), |
|
77 | + 'DK' => __('Denmark', 'invoicing'), |
|
78 | + 'DJ' => __('Djibouti', 'invoicing'), |
|
79 | + 'DM' => __('Dominica', 'invoicing'), |
|
80 | + 'DO' => __('Dominican Republic', 'invoicing'), |
|
81 | + 'TP' => __('East Timor', 'invoicing'), |
|
82 | + 'EC' => __('Ecuador', 'invoicing'), |
|
83 | + 'EG' => __('Egypt', 'invoicing'), |
|
84 | + 'GQ' => __('Equatorial Guinea', 'invoicing'), |
|
85 | + 'SV' => __('El Salvador', 'invoicing'), |
|
86 | + 'ER' => __('Eritrea', 'invoicing'), |
|
87 | + 'EE' => __('Estonia', 'invoicing'), |
|
88 | + 'ET' => __('Ethiopia', 'invoicing'), |
|
89 | + 'FK' => __('Falkland Islands', 'invoicing'), |
|
90 | + 'FO' => __('Faroe Islands', 'invoicing'), |
|
91 | + 'FJ' => __('Fiji', 'invoicing'), |
|
92 | + 'FI' => __('Finland', 'invoicing'), |
|
93 | + 'FR' => __('France', 'invoicing'), |
|
94 | + 'GF' => __('French Guiana', 'invoicing'), |
|
95 | + 'PF' => __('French Polynesia', 'invoicing'), |
|
96 | + 'TF' => __('French Southern Territories', 'invoicing'), |
|
97 | + 'GA' => __('Gabon', 'invoicing'), |
|
98 | + 'GM' => __('Gambia', 'invoicing'), |
|
99 | + 'GE' => __('Georgia', 'invoicing'), |
|
100 | + 'DE' => __('Germany', 'invoicing'), |
|
101 | + 'GR' => __('Greece', 'invoicing'), |
|
102 | + 'GH' => __('Ghana', 'invoicing'), |
|
103 | + 'GI' => __('Gibraltar', 'invoicing'), |
|
104 | + 'GL' => __('Greenland', 'invoicing'), |
|
105 | + 'GD' => __('Grenada', 'invoicing'), |
|
106 | + 'GP' => __('Guadeloupe', 'invoicing'), |
|
107 | + 'GU' => __('Guam', 'invoicing'), |
|
108 | + 'GT' => __('Guatemala', 'invoicing'), |
|
109 | + 'GG' => __('Guernsey', 'invoicing'), |
|
110 | + 'GN' => __('Guinea', 'invoicing'), |
|
111 | + 'GW' => __('Guinea-Bissau', 'invoicing'), |
|
112 | + 'GY' => __('Guyana', 'invoicing'), |
|
113 | + 'HT' => __('Haiti', 'invoicing'), |
|
114 | + 'HM' => __('Heard and McDonald Islands', 'invoicing'), |
|
115 | + 'VA' => __('Holy See (City Vatican State)', 'invoicing'), |
|
116 | + 'HN' => __('Honduras', 'invoicing'), |
|
117 | + 'HK' => __('Hong Kong', 'invoicing'), |
|
118 | + 'HU' => __('Hungary', 'invoicing'), |
|
119 | + 'IS' => __('Iceland', 'invoicing'), |
|
120 | + 'IN' => __('India', 'invoicing'), |
|
121 | + 'ID' => __('Indonesia', 'invoicing'), |
|
122 | + 'IR' => __('Iran', 'invoicing'), |
|
123 | + 'IQ' => __('Iraq', 'invoicing'), |
|
124 | + 'IE' => __('Ireland', 'invoicing'), |
|
125 | + 'IM' => __('Isle of Man', 'invoicing'), |
|
126 | + 'IL' => __('Israel', 'invoicing'), |
|
127 | + 'IT' => __('Italy', 'invoicing'), |
|
128 | + 'JM' => __('Jamaica', 'invoicing'), |
|
129 | + 'JP' => __('Japan', 'invoicing'), |
|
130 | + 'JE' => __('Jersey', 'invoicing'), |
|
131 | + 'JO' => __('Jordan', 'invoicing'), |
|
132 | + 'KZ' => __('Kazakhstan', 'invoicing'), |
|
133 | + 'KE' => __('Kenya', 'invoicing'), |
|
134 | + 'KI' => __('Kiribati', 'invoicing'), |
|
135 | + 'KW' => __('Kuwait', 'invoicing'), |
|
136 | + 'KG' => __('Kyrgyzstan', 'invoicing'), |
|
137 | + 'LA' => __('Lao People\'s Democratic Republic', 'invoicing'), |
|
138 | + 'LV' => __('Latvia', 'invoicing'), |
|
139 | + 'LB' => __('Lebanon', 'invoicing'), |
|
140 | + 'LS' => __('Lesotho', 'invoicing'), |
|
141 | + 'LR' => __('Liberia', 'invoicing'), |
|
142 | + 'LY' => __('Libyan Arab Jamahiriya', 'invoicing'), |
|
143 | + 'LI' => __('Liechtenstein', 'invoicing'), |
|
144 | + 'LT' => __('Lithuania', 'invoicing'), |
|
145 | + 'LU' => __('Luxembourg', 'invoicing'), |
|
146 | + 'MO' => __('Macau', 'invoicing'), |
|
147 | + 'MK' => __('Macedonia', 'invoicing'), |
|
148 | + 'MG' => __('Madagascar', 'invoicing'), |
|
149 | + 'MW' => __('Malawi', 'invoicing'), |
|
150 | + 'MY' => __('Malaysia', 'invoicing'), |
|
151 | + 'MV' => __('Maldives', 'invoicing'), |
|
152 | + 'ML' => __('Mali', 'invoicing'), |
|
153 | + 'MT' => __('Malta', 'invoicing'), |
|
154 | + 'MH' => __('Marshall Islands', 'invoicing'), |
|
155 | + 'MQ' => __('Martinique', 'invoicing'), |
|
156 | + 'MR' => __('Mauritania', 'invoicing'), |
|
157 | + 'MU' => __('Mauritius', 'invoicing'), |
|
158 | + 'YT' => __('Mayotte', 'invoicing'), |
|
159 | + 'MX' => __('Mexico', 'invoicing'), |
|
160 | + 'FM' => __('Micronesia', 'invoicing'), |
|
161 | + 'MD' => __('Moldova, Republic of', 'invoicing'), |
|
162 | + 'MC' => __('Monaco', 'invoicing'), |
|
163 | + 'MN' => __('Mongolia', 'invoicing'), |
|
164 | + 'ME' => __('Montenegro', 'invoicing'), |
|
165 | + 'MS' => __('Montserrat', 'invoicing'), |
|
166 | + 'MA' => __('Morocco', 'invoicing'), |
|
167 | + 'MZ' => __('Mozambique', 'invoicing'), |
|
168 | + 'MM' => __('Myanmar', 'invoicing'), |
|
169 | + 'NA' => __('Namibia', 'invoicing'), |
|
170 | + 'NR' => __('Nauru', 'invoicing'), |
|
171 | + 'NP' => __('Nepal', 'invoicing'), |
|
172 | + 'NL' => __('Netherlands', 'invoicing'), |
|
173 | + 'AN' => __('Netherlands Antilles', 'invoicing'), |
|
174 | + 'NC' => __('New Caledonia', 'invoicing'), |
|
175 | + 'NZ' => __('New Zealand', 'invoicing'), |
|
176 | + 'NI' => __('Nicaragua', 'invoicing'), |
|
177 | + 'NE' => __('Niger', 'invoicing'), |
|
178 | + 'NG' => __('Nigeria', 'invoicing'), |
|
179 | + 'NU' => __('Niue', 'invoicing'), |
|
180 | + 'NF' => __('Norfolk Island', 'invoicing'), |
|
181 | + 'KP' => __('North Korea', 'invoicing'), |
|
182 | + 'MP' => __('Northern Mariana Islands', 'invoicing'), |
|
183 | + 'NO' => __('Norway', 'invoicing'), |
|
184 | + 'OM' => __('Oman', 'invoicing'), |
|
185 | + 'PK' => __('Pakistan', 'invoicing'), |
|
186 | + 'PW' => __('Palau', 'invoicing'), |
|
187 | + 'PS' => __('Palestinian Territories', 'invoicing'), |
|
188 | + 'PA' => __('Panama', 'invoicing'), |
|
189 | + 'PG' => __('Papua New Guinea', 'invoicing'), |
|
190 | + 'PY' => __('Paraguay', 'invoicing'), |
|
191 | + 'PE' => __('Peru', 'invoicing'), |
|
192 | + 'PH' => __('Philippines', 'invoicing'), |
|
193 | + 'PN' => __('Pitcairn Island', 'invoicing'), |
|
194 | + 'PL' => __('Poland', 'invoicing'), |
|
195 | + 'PT' => __('Portugal', 'invoicing'), |
|
196 | + 'PR' => __('Puerto Rico', 'invoicing'), |
|
197 | + 'QA' => __('Qatar', 'invoicing'), |
|
198 | + 'XK' => __('Republic of Kosovo', 'invoicing'), |
|
199 | + 'RE' => __('Reunion Island', 'invoicing'), |
|
200 | + 'RO' => __('Romania', 'invoicing'), |
|
201 | + 'RU' => __('Russian Federation', 'invoicing'), |
|
202 | + 'RW' => __('Rwanda', 'invoicing'), |
|
203 | + 'BL' => __('Saint Barthélemy', 'invoicing'), |
|
204 | + 'SH' => __('Saint Helena', 'invoicing'), |
|
205 | + 'KN' => __('Saint Kitts and Nevis', 'invoicing'), |
|
206 | + 'LC' => __('Saint Lucia', 'invoicing'), |
|
207 | + 'MF' => __('Saint Martin (French)', 'invoicing'), |
|
208 | + 'SX' => __('Saint Martin (Dutch)', 'invoicing'), |
|
209 | + 'PM' => __('Saint Pierre and Miquelon', 'invoicing'), |
|
210 | + 'VC' => __('Saint Vincent and the Grenadines', 'invoicing'), |
|
211 | + 'SM' => __('San Marino', 'invoicing'), |
|
212 | + 'ST' => __('São Tomé and Príncipe', 'invoicing'), |
|
213 | + 'SA' => __('Saudi Arabia', 'invoicing'), |
|
214 | + 'SN' => __('Senegal', 'invoicing'), |
|
215 | + 'RS' => __('Serbia', 'invoicing'), |
|
216 | + 'SC' => __('Seychelles', 'invoicing'), |
|
217 | + 'SL' => __('Sierra Leone', 'invoicing'), |
|
218 | + 'SG' => __('Singapore', 'invoicing'), |
|
219 | + 'SK' => __('Slovak Republic', 'invoicing'), |
|
220 | + 'SI' => __('Slovenia', 'invoicing'), |
|
221 | + 'SB' => __('Solomon Islands', 'invoicing'), |
|
222 | + 'SO' => __('Somalia', 'invoicing'), |
|
223 | + 'ZA' => __('South Africa', 'invoicing'), |
|
224 | + 'GS' => __('South Georgia', 'invoicing'), |
|
225 | + 'KR' => __('South Korea', 'invoicing'), |
|
226 | + 'SS' => __('South Sudan', 'invoicing'), |
|
227 | + 'ES' => __('Spain', 'invoicing'), |
|
228 | + 'LK' => __('Sri Lanka', 'invoicing'), |
|
229 | + 'SD' => __('Sudan', 'invoicing'), |
|
230 | + 'SR' => __('Suriname', 'invoicing'), |
|
231 | + 'SJ' => __('Svalbard and Jan Mayen Islands', 'invoicing'), |
|
232 | + 'SZ' => __('Swaziland', 'invoicing'), |
|
233 | + 'SE' => __('Sweden', 'invoicing'), |
|
234 | + 'CH' => __('Switzerland', 'invoicing'), |
|
235 | + 'SY' => __('Syrian Arab Republic', 'invoicing'), |
|
236 | + 'TW' => __('Taiwan', 'invoicing'), |
|
237 | + 'TJ' => __('Tajikistan', 'invoicing'), |
|
238 | + 'TZ' => __('Tanzania', 'invoicing'), |
|
239 | + 'TH' => __('Thailand', 'invoicing'), |
|
240 | + 'TL' => __('Timor-Leste', 'invoicing'), |
|
241 | + 'TG' => __('Togo', 'invoicing'), |
|
242 | + 'TK' => __('Tokelau', 'invoicing'), |
|
243 | + 'TO' => __('Tonga', 'invoicing'), |
|
244 | + 'TT' => __('Trinidad and Tobago', 'invoicing'), |
|
245 | + 'TN' => __('Tunisia', 'invoicing'), |
|
246 | + 'TR' => __('Turkey', 'invoicing'), |
|
247 | + 'TM' => __('Turkmenistan', 'invoicing'), |
|
248 | + 'TC' => __('Turks and Caicos Islands', 'invoicing'), |
|
249 | + 'TV' => __('Tuvalu', 'invoicing'), |
|
250 | + 'UG' => __('Uganda', 'invoicing'), |
|
251 | + 'UA' => __('Ukraine', 'invoicing'), |
|
252 | + 'AE' => __('United Arab Emirates', 'invoicing'), |
|
253 | + 'UY' => __('Uruguay', 'invoicing'), |
|
254 | + 'UM' => __('US Minor Outlying Islands', 'invoicing'), |
|
255 | + 'UZ' => __('Uzbekistan', 'invoicing'), |
|
256 | + 'VU' => __('Vanuatu', 'invoicing'), |
|
257 | + 'VE' => __('Venezuela', 'invoicing'), |
|
258 | + 'VN' => __('Vietnam', 'invoicing'), |
|
259 | + 'VG' => __('Virgin Islands (British)', 'invoicing'), |
|
260 | + 'VI' => __('Virgin Islands (USA)', 'invoicing'), |
|
261 | + 'WF' => __('Wallis and Futuna Islands', 'invoicing'), |
|
262 | + 'EH' => __('Western Sahara', 'invoicing'), |
|
263 | + 'WS' => __('Western Samoa', 'invoicing'), |
|
264 | + 'YE' => __('Yemen', 'invoicing'), |
|
265 | + 'ZM' => __('Zambia', 'invoicing'), |
|
266 | + 'ZW' => __('Zimbabwe', 'invoicing'), |
|
267 | 267 | ); |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | defined( 'ABSPATH' ) || exit; |
11 | 11 | |
12 | 12 | if ( empty( $fields ) ) { |
13 | - return; |
|
13 | + return; |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
@@ -18,12 +18,12 @@ discard block |
||
18 | 18 | |
19 | 19 | // Prepare the user's country. |
20 | 20 | if ( ! empty( $form->invoice ) ) { |
21 | - $country = $form->invoice->get_country(); |
|
21 | + $country = $form->invoice->get_country(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | if ( empty( $country ) ) { |
25 | - $country = empty( $country ) ? getpaid_get_ip_country() : $country; |
|
26 | - $country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
25 | + $country = empty( $country ) ? getpaid_get_ip_country() : $country; |
|
26 | + $country = empty( $country ) ? wpinv_get_default_country() : $country; |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | // A prefix for all ids (so that a form can be included in the same page multiple times). |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | <!-- Start Billing Address --> |
56 | 56 | <div class="getpaid-billing-address-wrapper"> |
57 | 57 | <?php |
58 | - $field_type = 'billing'; |
|
59 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
60 | - do_action( 'getpaid_after_payment_form_billing_fields', $form ); |
|
61 | - ?> |
|
58 | + $field_type = 'billing'; |
|
59 | + include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
60 | + do_action( 'getpaid_after_payment_form_billing_fields', $form ); |
|
61 | + ?> |
|
62 | 62 | </div> |
63 | 63 | <!-- End Billing Address --> |
64 | 64 | |
@@ -70,20 +70,20 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | |
73 | - echo aui()->input( |
|
74 | - array( |
|
75 | - 'type' => 'checkbox', |
|
76 | - 'name' => 'same-shipping-address', |
|
77 | - 'id' => "shipping-toggle$uniqid", |
|
78 | - 'required' => false, |
|
79 | - 'label' => wp_kses_post( $shipping_address_toggle ), |
|
80 | - 'value' => 1, |
|
81 | - 'checked' => true, |
|
82 | - 'class' => 'w-auto', |
|
83 | - ) |
|
84 | - ); |
|
73 | + echo aui()->input( |
|
74 | + array( |
|
75 | + 'type' => 'checkbox', |
|
76 | + 'name' => 'same-shipping-address', |
|
77 | + 'id' => "shipping-toggle$uniqid", |
|
78 | + 'required' => false, |
|
79 | + 'label' => wp_kses_post( $shipping_address_toggle ), |
|
80 | + 'value' => 1, |
|
81 | + 'checked' => true, |
|
82 | + 'class' => 'w-auto', |
|
83 | + ) |
|
84 | + ); |
|
85 | 85 | |
86 | - ?> |
|
86 | + ?> |
|
87 | 87 | |
88 | 88 | |
89 | 89 | <!-- Start Shipping Address Title --> |
@@ -102,10 +102,10 @@ discard block |
||
102 | 102 | <!-- Start Shipping Address --> |
103 | 103 | <div class="getpaid-shipping-address-wrapper"> |
104 | 104 | <?php |
105 | - $field_type = 'shipping'; |
|
106 | - include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
107 | - do_action( 'getpaid_after_payment_form_shipping_fields', $form ); |
|
108 | - ?> |
|
105 | + $field_type = 'shipping'; |
|
106 | + include plugin_dir_path( __FILE__ ) . 'address-fields.php'; |
|
107 | + do_action( 'getpaid_after_payment_form_shipping_fields', $form ); |
|
108 | + ?> |
|
109 | 109 | </div> |
110 | 110 | <!-- End Shipping Address --> |
111 | 111 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -20,29 +20,29 @@ discard block |
||
20 | 20 | public $templates_url; |
21 | 21 | |
22 | 22 | /** |
23 | - * Class constructor. |
|
24 | - * |
|
25 | - * @since 1.0.19 |
|
26 | - */ |
|
27 | - public function __construct() { |
|
23 | + * Class constructor. |
|
24 | + * |
|
25 | + * @since 1.0.19 |
|
26 | + */ |
|
27 | + public function __construct() { |
|
28 | 28 | |
29 | 29 | $this->templates_dir = apply_filters( 'getpaid_default_templates_dir', WPINV_PLUGIN_DIR . 'templates' ); |
30 | 30 | $this->templates_url = apply_filters( 'getpaid_default_templates_url', WPINV_PLUGIN_URL . 'templates' ); |
31 | 31 | |
32 | 32 | // Oxygen plugin |
33 | - if ( defined( 'CT_VERSION' ) ) { |
|
34 | - add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 ); |
|
35 | - } |
|
33 | + if ( defined( 'CT_VERSION' ) ) { |
|
34 | + add_filter( 'wpinv_locate_template', array( $this, 'oxygen_override_template' ), 11, 4 ); |
|
35 | + } |
|
36 | 36 | |
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
40 | - * Checks if this is a preview page |
|
41 | - * |
|
42 | - * @since 1.0.19 |
|
43 | - * @return bool |
|
44 | - */ |
|
45 | - public function is_preview() { |
|
40 | + * Checks if this is a preview page |
|
41 | + * |
|
42 | + * @since 1.0.19 |
|
43 | + * @return bool |
|
44 | + */ |
|
45 | + public function is_preview() { |
|
46 | 46 | return |
47 | 47 | $this->is_divi_preview() || |
48 | 48 | $this->is_elementor_preview() || |
@@ -54,73 +54,73 @@ discard block |
||
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | - * Checks if this is an elementor preview page |
|
58 | - * |
|
59 | - * @since 1.0.19 |
|
60 | - * @return bool |
|
61 | - */ |
|
62 | - public function is_elementor_preview() { |
|
63 | - return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
64 | - } |
|
65 | - |
|
66 | - /** |
|
67 | - * Checks if this is a DIVI preview page |
|
68 | - * |
|
69 | - * @since 1.0.19 |
|
70 | - * @return bool |
|
71 | - */ |
|
72 | - public function is_divi_preview() { |
|
73 | - return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
74 | - } |
|
75 | - |
|
76 | - /** |
|
77 | - * Checks if this is a beaver builder preview page |
|
78 | - * |
|
79 | - * @since 1.0.19 |
|
80 | - * @return bool |
|
81 | - */ |
|
82 | - public function is_beaver_preview() { |
|
83 | - return isset( $_REQUEST['fl_builder'] ); |
|
84 | - } |
|
85 | - |
|
86 | - /** |
|
87 | - * Checks if this is a siteorigin builder preview page |
|
88 | - * |
|
89 | - * @since 1.0.19 |
|
90 | - * @return bool |
|
91 | - */ |
|
92 | - public function is_siteorigin_preview() { |
|
93 | - return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Checks if this is a cornerstone builder preview page |
|
98 | - * |
|
99 | - * @since 1.0.19 |
|
100 | - * @return bool |
|
101 | - */ |
|
102 | - public function is_cornerstone_preview() { |
|
103 | - return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
104 | - } |
|
105 | - |
|
106 | - /** |
|
107 | - * Checks if this is a fusion builder preview page |
|
108 | - * |
|
109 | - * @since 1.0.19 |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function is_fusion_preview() { |
|
113 | - return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Checks if this is an oxygen builder preview page |
|
118 | - * |
|
119 | - * @since 1.0.19 |
|
120 | - * @return bool |
|
121 | - */ |
|
122 | - public function is_oxygen_preview() { |
|
123 | - return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
57 | + * Checks if this is an elementor preview page |
|
58 | + * |
|
59 | + * @since 1.0.19 |
|
60 | + * @return bool |
|
61 | + */ |
|
62 | + public function is_elementor_preview() { |
|
63 | + return isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ); |
|
64 | + } |
|
65 | + |
|
66 | + /** |
|
67 | + * Checks if this is a DIVI preview page |
|
68 | + * |
|
69 | + * @since 1.0.19 |
|
70 | + * @return bool |
|
71 | + */ |
|
72 | + public function is_divi_preview() { |
|
73 | + return isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'et_pb' ); |
|
74 | + } |
|
75 | + |
|
76 | + /** |
|
77 | + * Checks if this is a beaver builder preview page |
|
78 | + * |
|
79 | + * @since 1.0.19 |
|
80 | + * @return bool |
|
81 | + */ |
|
82 | + public function is_beaver_preview() { |
|
83 | + return isset( $_REQUEST['fl_builder'] ); |
|
84 | + } |
|
85 | + |
|
86 | + /** |
|
87 | + * Checks if this is a siteorigin builder preview page |
|
88 | + * |
|
89 | + * @since 1.0.19 |
|
90 | + * @return bool |
|
91 | + */ |
|
92 | + public function is_siteorigin_preview() { |
|
93 | + return ! empty( $_REQUEST['siteorigin_panels_live_editor'] ); |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Checks if this is a cornerstone builder preview page |
|
98 | + * |
|
99 | + * @since 1.0.19 |
|
100 | + * @return bool |
|
101 | + */ |
|
102 | + public function is_cornerstone_preview() { |
|
103 | + return ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint'; |
|
104 | + } |
|
105 | + |
|
106 | + /** |
|
107 | + * Checks if this is a fusion builder preview page |
|
108 | + * |
|
109 | + * @since 1.0.19 |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function is_fusion_preview() { |
|
113 | + return ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ); |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Checks if this is an oxygen builder preview page |
|
118 | + * |
|
119 | + * @since 1.0.19 |
|
120 | + * @return bool |
|
121 | + */ |
|
122 | + public function is_oxygen_preview() { |
|
123 | + return ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * @param string $template_path The template path relative to the theme's root dir. Defaults to 'invoicing'. |
131 | 131 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
132 | 132 | */ |
133 | - public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
133 | + public function locate_template( $template_name, $template_path = '', $default_path = '' ) { |
|
134 | 134 | |
135 | 135 | // Load the defaults for the template path and default path. |
136 | 136 | $template_path = empty( $template_path ) ? 'invoicing' : $template_path; |
@@ -151,22 +151,22 @@ discard block |
||
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
154 | - * Loads a template |
|
155 | - * |
|
156 | - * @since 1.0.19 |
|
157 | - * @return bool |
|
158 | - */ |
|
159 | - protected function load_template( $template_name, $template_path, $args ) { |
|
154 | + * Loads a template |
|
155 | + * |
|
156 | + * @since 1.0.19 |
|
157 | + * @return bool |
|
158 | + */ |
|
159 | + protected function load_template( $template_name, $template_path, $args ) { |
|
160 | 160 | |
161 | 161 | if ( is_array( $args ) ){ |
162 | 162 | extract( $args ); |
163 | 163 | } |
164 | 164 | |
165 | 165 | // Fires before loading a template. |
166 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
166 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $args ); |
|
167 | 167 | |
168 | 168 | // Load the template. |
169 | - include( $template_path ); |
|
169 | + include( $template_path ); |
|
170 | 170 | |
171 | 171 | // Fires after loading a template. |
172 | 172 | do_action( 'wpinv_after_template_part', $template_name, $template_path, $args ); |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
184 | 184 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
185 | 185 | */ |
186 | - public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
186 | + public function display_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
187 | 187 | |
188 | 188 | // Locate the template. |
189 | 189 | $located = $this->locate_template( $template_name, $template_path, $default_path ); |
@@ -208,74 +208,74 @@ discard block |
||
208 | 208 | * @param string $template_path The templates directory relative to the theme's root dir. Defaults to 'invoicing'. |
209 | 209 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
210 | 210 | */ |
211 | - public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
211 | + public function get_template( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
|
212 | 212 | ob_start(); |
213 | 213 | $this->display_template( $template_name, $args, $template_path, $default_path ); |
214 | 214 | return ob_get_clean(); |
215 | 215 | } |
216 | 216 | |
217 | 217 | /** |
218 | - * Get the geodirectory templates theme path. |
|
219 | - * |
|
220 | - * |
|
221 | - * @return string Template path. |
|
222 | - */ |
|
223 | - public static function get_theme_template_path() { |
|
224 | - $template = get_template(); |
|
225 | - $theme_root = get_theme_root( $template ); |
|
226 | - |
|
227 | - return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() ); |
|
228 | - |
|
229 | - } |
|
230 | - |
|
231 | - /** |
|
232 | - * Oxygen locate theme template. |
|
233 | - * |
|
234 | - * @param string $template The template. |
|
235 | - * @return string The theme template. |
|
236 | - */ |
|
237 | - public static function oxygen_locate_template( $template ) { |
|
238 | - |
|
239 | - if ( empty( $template ) ) { |
|
240 | - return ''; |
|
241 | - } |
|
242 | - |
|
243 | - $has_filter = has_filter( 'template', 'ct_oxygen_template_name' ); |
|
244 | - |
|
245 | - // Remove template filter |
|
246 | - if ( $has_filter ) { |
|
247 | - remove_filter( 'template', 'ct_oxygen_template_name' ); |
|
248 | - } |
|
249 | - |
|
250 | - $template = self::get_theme_template_path() . '/' . $template; |
|
251 | - |
|
252 | - if ( ! file_exists( $template ) ) { |
|
253 | - $template = ''; |
|
254 | - } |
|
255 | - |
|
256 | - // Add template filter |
|
257 | - if ( $has_filter ) { |
|
258 | - add_filter( 'template', 'ct_oxygen_template_name' ); |
|
259 | - } |
|
260 | - |
|
261 | - return $template; |
|
262 | - } |
|
263 | - |
|
264 | - /** |
|
265 | - * Oxygen override theme template. |
|
266 | - * |
|
267 | - * @param string $located Located template. |
|
268 | - * @param string $template_name Template name. |
|
269 | - * @return string Located template. |
|
270 | - */ |
|
271 | - public function oxygen_override_template( $located, $template_name ) { |
|
218 | + * Get the geodirectory templates theme path. |
|
219 | + * |
|
220 | + * |
|
221 | + * @return string Template path. |
|
222 | + */ |
|
223 | + public static function get_theme_template_path() { |
|
224 | + $template = get_template(); |
|
225 | + $theme_root = get_theme_root( $template ); |
|
226 | + |
|
227 | + return $theme_root . '/' . $template . '/' . untrailingslashit( wpinv_get_theme_template_dir_name() ); |
|
228 | + |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Oxygen locate theme template. |
|
233 | + * |
|
234 | + * @param string $template The template. |
|
235 | + * @return string The theme template. |
|
236 | + */ |
|
237 | + public static function oxygen_locate_template( $template ) { |
|
238 | + |
|
239 | + if ( empty( $template ) ) { |
|
240 | + return ''; |
|
241 | + } |
|
242 | + |
|
243 | + $has_filter = has_filter( 'template', 'ct_oxygen_template_name' ); |
|
244 | + |
|
245 | + // Remove template filter |
|
246 | + if ( $has_filter ) { |
|
247 | + remove_filter( 'template', 'ct_oxygen_template_name' ); |
|
248 | + } |
|
249 | + |
|
250 | + $template = self::get_theme_template_path() . '/' . $template; |
|
251 | + |
|
252 | + if ( ! file_exists( $template ) ) { |
|
253 | + $template = ''; |
|
254 | + } |
|
255 | + |
|
256 | + // Add template filter |
|
257 | + if ( $has_filter ) { |
|
258 | + add_filter( 'template', 'ct_oxygen_template_name' ); |
|
259 | + } |
|
260 | + |
|
261 | + return $template; |
|
262 | + } |
|
263 | + |
|
264 | + /** |
|
265 | + * Oxygen override theme template. |
|
266 | + * |
|
267 | + * @param string $located Located template. |
|
268 | + * @param string $template_name Template name. |
|
269 | + * @return string Located template. |
|
270 | + */ |
|
271 | + public function oxygen_override_template( $located, $template_name ) { |
|
272 | 272 | |
273 | 273 | $oxygen_overide = self::oxygen_locate_template( $template_name ); |
274 | - if ( ! empty( $oxygen_overide ) ) { |
|
275 | - return $oxygen_overide; |
|
276 | - } |
|
274 | + if ( ! empty( $oxygen_overide ) ) { |
|
275 | + return $oxygen_overide; |
|
276 | + } |
|
277 | 277 | |
278 | - return $located; |
|
279 | - } |
|
278 | + return $located; |
|
279 | + } |
|
280 | 280 | |
281 | 281 | } |
@@ -411,9 +411,9 @@ |
||
411 | 411 | $bill_times = $item->get_recurring_limit(); |
412 | 412 | |
413 | 413 | if ( ! empty( $bill_times ) ) { |
414 | - $bill_times = $item->get_recurring_interval() * $bill_times; |
|
415 | - $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
416 | - } |
|
414 | + $bill_times = $item->get_recurring_interval() * $bill_times; |
|
415 | + $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times ); |
|
416 | + } |
|
417 | 417 | |
418 | 418 | if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) { |
419 | 419 | $initial_price = wpinv_price( $item->get_sub_total(), $currency ); |
@@ -14,51 +14,51 @@ |
||
14 | 14 | */ |
15 | 15 | class GetPaid_Payment_Exception extends Exception { |
16 | 16 | |
17 | - /** |
|
18 | - * Sanitized error code. |
|
19 | - * |
|
20 | - * @var string |
|
21 | - */ |
|
22 | - protected $error_code; |
|
17 | + /** |
|
18 | + * Sanitized error code. |
|
19 | + * |
|
20 | + * @var string |
|
21 | + */ |
|
22 | + protected $error_code; |
|
23 | 23 | |
24 | - /** |
|
25 | - * Error extra data. |
|
26 | - * |
|
27 | - * @var array |
|
28 | - */ |
|
29 | - protected $error_data; |
|
24 | + /** |
|
25 | + * Error extra data. |
|
26 | + * |
|
27 | + * @var array |
|
28 | + */ |
|
29 | + protected $error_data; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Setup exception. |
|
33 | - * |
|
34 | - * @param string $code Machine-readable error code, e.g `getpaid-discount-error`. |
|
35 | - * @param string $message User-friendly translated error message, e.g. 'Discount is invalid'. |
|
36 | - * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. |
|
37 | - * @param array $data Extra error data. |
|
38 | - */ |
|
39 | - public function __construct( $code, $message, $http_status_code = 400, $data = array() ) { |
|
40 | - $this->error_code = $code; |
|
41 | - $this->error_data = array_merge( array( 'status' => $http_status_code ), $data ); |
|
31 | + /** |
|
32 | + * Setup exception. |
|
33 | + * |
|
34 | + * @param string $code Machine-readable error code, e.g `getpaid-discount-error`. |
|
35 | + * @param string $message User-friendly translated error message, e.g. 'Discount is invalid'. |
|
36 | + * @param int $http_status_code Proper HTTP status code to respond with, e.g. 400. |
|
37 | + * @param array $data Extra error data. |
|
38 | + */ |
|
39 | + public function __construct( $code, $message, $http_status_code = 400, $data = array() ) { |
|
40 | + $this->error_code = $code; |
|
41 | + $this->error_data = array_merge( array( 'status' => $http_status_code ), $data ); |
|
42 | 42 | |
43 | - parent::__construct( $message, $http_status_code ); |
|
44 | - } |
|
43 | + parent::__construct( $message, $http_status_code ); |
|
44 | + } |
|
45 | 45 | |
46 | - /** |
|
47 | - * Returns the error code. |
|
48 | - * |
|
49 | - * @return string |
|
50 | - */ |
|
51 | - public function getErrorCode() { |
|
52 | - return $this->error_code; |
|
53 | - } |
|
46 | + /** |
|
47 | + * Returns the error code. |
|
48 | + * |
|
49 | + * @return string |
|
50 | + */ |
|
51 | + public function getErrorCode() { |
|
52 | + return $this->error_code; |
|
53 | + } |
|
54 | 54 | |
55 | - /** |
|
56 | - * Returns error data. |
|
57 | - * |
|
58 | - * @return array |
|
59 | - */ |
|
60 | - public function getErrorData() { |
|
61 | - return $this->error_data; |
|
62 | - } |
|
55 | + /** |
|
56 | + * Returns error data. |
|
57 | + * |
|
58 | + * @return array |
|
59 | + */ |
|
60 | + public function getErrorData() { |
|
61 | + return $this->error_data; |
|
62 | + } |
|
63 | 63 | |
64 | 64 | } |
@@ -12,202 +12,202 @@ |
||
12 | 12 | */ |
13 | 13 | class WPInv_Notes { |
14 | 14 | |
15 | - /** |
|
16 | - * Class constructor. |
|
17 | - */ |
|
18 | - public function __construct() { |
|
19 | - |
|
20 | - // Filter inovice notes. |
|
21 | - add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
22 | - add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 ); |
|
23 | - |
|
24 | - // Delete comments count cache whenever there is a new comment or a comment status changes. |
|
25 | - add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
26 | - add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
27 | - |
|
28 | - // Count comments. |
|
29 | - add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 ); |
|
30 | - |
|
31 | - // Fires after notes are loaded. |
|
32 | - do_action( 'wpinv_notes_init', $this ); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * Filters invoice notes query to only include our notes. |
|
37 | - * |
|
38 | - * @param WP_Comment_Query $query |
|
39 | - */ |
|
40 | - public function set_invoice_note_type( $query ) { |
|
41 | - $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
42 | - |
|
43 | - if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) { |
|
44 | - $query->query_vars['type'] = 'wpinv_note'; |
|
45 | - } else { |
|
46 | - |
|
47 | - if ( empty( $query->query_vars['type__not_in'] ) ) { |
|
48 | - $query->query_vars['type__not_in'] = array(); |
|
49 | - } |
|
50 | - |
|
51 | - $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] ); |
|
52 | - $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] ); |
|
53 | - } |
|
54 | - |
|
55 | - return $query; |
|
56 | - } |
|
57 | - |
|
58 | - /** |
|
59 | - * Exclude notes from the comments feed. |
|
60 | - */ |
|
61 | - function wpinv_comment_feed_where( $where ){ |
|
62 | - return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' "; |
|
63 | - } |
|
64 | - |
|
65 | - /** |
|
66 | - * Delete comments count cache whenever there is |
|
67 | - * new comment or the status of a comment changes. Cache |
|
68 | - * will be regenerated next time WPInv_Notes::wp_count_comments() |
|
69 | - * is called. |
|
70 | - */ |
|
71 | - public function delete_comments_count_cache() { |
|
72 | - delete_transient( 'getpaid_count_comments' ); |
|
73 | - } |
|
74 | - |
|
75 | - /** |
|
76 | - * Remove invoice notes from wp_count_comments(). |
|
77 | - * |
|
78 | - * @since 2.2 |
|
79 | - * @param object $stats Comment stats. |
|
80 | - * @param int $post_id Post ID. |
|
81 | - * @return object |
|
82 | - */ |
|
83 | - public function wp_count_comments( $stats, $post_id ) { |
|
84 | - global $wpdb; |
|
85 | - |
|
86 | - if ( empty( $post_id ) ) { |
|
87 | - $stats = get_transient( 'getpaid_count_comments' ); |
|
88 | - |
|
89 | - if ( ! $stats ) { |
|
90 | - $stats = array( |
|
91 | - 'total_comments' => 0, |
|
92 | - 'all' => 0, |
|
93 | - ); |
|
94 | - |
|
95 | - $count = $wpdb->get_results( |
|
96 | - " |
|
15 | + /** |
|
16 | + * Class constructor. |
|
17 | + */ |
|
18 | + public function __construct() { |
|
19 | + |
|
20 | + // Filter inovice notes. |
|
21 | + add_action( 'pre_get_comments', array( $this, 'set_invoice_note_type' ), 11, 1 ); |
|
22 | + add_action( 'comment_feed_where', array( $this, 'wpinv_comment_feed_where' ), 10, 1 ); |
|
23 | + |
|
24 | + // Delete comments count cache whenever there is a new comment or a comment status changes. |
|
25 | + add_action( 'wp_insert_comment', array( $this, 'delete_comments_count_cache' ) ); |
|
26 | + add_action( 'wp_set_comment_status', array( $this, 'delete_comments_count_cache' ) ); |
|
27 | + |
|
28 | + // Count comments. |
|
29 | + add_filter( 'wp_count_comments', array( $this, 'wp_count_comments' ), 100, 2 ); |
|
30 | + |
|
31 | + // Fires after notes are loaded. |
|
32 | + do_action( 'wpinv_notes_init', $this ); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * Filters invoice notes query to only include our notes. |
|
37 | + * |
|
38 | + * @param WP_Comment_Query $query |
|
39 | + */ |
|
40 | + public function set_invoice_note_type( $query ) { |
|
41 | + $post_id = ! empty( $query->query_vars['post_ID'] ) ? $query->query_vars['post_ID'] : $query->query_vars['post_id']; |
|
42 | + |
|
43 | + if ( $post_id && getpaid_is_invoice_post_type( get_post_type( $post_id ) ) ) { |
|
44 | + $query->query_vars['type'] = 'wpinv_note'; |
|
45 | + } else { |
|
46 | + |
|
47 | + if ( empty( $query->query_vars['type__not_in'] ) ) { |
|
48 | + $query->query_vars['type__not_in'] = array(); |
|
49 | + } |
|
50 | + |
|
51 | + $query->query_vars['type__not_in'] = wpinv_parse_list( $query->query_vars['type__not_in'] ); |
|
52 | + $query->query_vars['type__not_in'] = array_merge( array( 'wpinv_note' ), $query->query_vars['type__not_in'] ); |
|
53 | + } |
|
54 | + |
|
55 | + return $query; |
|
56 | + } |
|
57 | + |
|
58 | + /** |
|
59 | + * Exclude notes from the comments feed. |
|
60 | + */ |
|
61 | + function wpinv_comment_feed_where( $where ){ |
|
62 | + return $where . ( $where ? ' AND ' : '' ) . " comment_type != 'wpinv_note' "; |
|
63 | + } |
|
64 | + |
|
65 | + /** |
|
66 | + * Delete comments count cache whenever there is |
|
67 | + * new comment or the status of a comment changes. Cache |
|
68 | + * will be regenerated next time WPInv_Notes::wp_count_comments() |
|
69 | + * is called. |
|
70 | + */ |
|
71 | + public function delete_comments_count_cache() { |
|
72 | + delete_transient( 'getpaid_count_comments' ); |
|
73 | + } |
|
74 | + |
|
75 | + /** |
|
76 | + * Remove invoice notes from wp_count_comments(). |
|
77 | + * |
|
78 | + * @since 2.2 |
|
79 | + * @param object $stats Comment stats. |
|
80 | + * @param int $post_id Post ID. |
|
81 | + * @return object |
|
82 | + */ |
|
83 | + public function wp_count_comments( $stats, $post_id ) { |
|
84 | + global $wpdb; |
|
85 | + |
|
86 | + if ( empty( $post_id ) ) { |
|
87 | + $stats = get_transient( 'getpaid_count_comments' ); |
|
88 | + |
|
89 | + if ( ! $stats ) { |
|
90 | + $stats = array( |
|
91 | + 'total_comments' => 0, |
|
92 | + 'all' => 0, |
|
93 | + ); |
|
94 | + |
|
95 | + $count = $wpdb->get_results( |
|
96 | + " |
|
97 | 97 | SELECT comment_approved, COUNT(*) AS num_comments |
98 | 98 | FROM {$wpdb->comments} |
99 | 99 | WHERE comment_type NOT IN ('action_log', 'order_note', 'webhook_delivery', 'wpinv_note') |
100 | 100 | GROUP BY comment_approved |
101 | 101 | ", |
102 | - ARRAY_A |
|
103 | - ); |
|
104 | - |
|
105 | - $approved = array( |
|
106 | - '0' => 'moderated', |
|
107 | - '1' => 'approved', |
|
108 | - 'spam' => 'spam', |
|
109 | - 'trash' => 'trash', |
|
110 | - 'post-trashed' => 'post-trashed', |
|
111 | - ); |
|
112 | - |
|
113 | - foreach ( (array) $count as $row ) { |
|
114 | - // Don't count post-trashed toward totals. |
|
115 | - if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { |
|
116 | - $stats['all'] += $row['num_comments']; |
|
117 | - $stats['total_comments'] += $row['num_comments']; |
|
118 | - } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { |
|
119 | - $stats['total_comments'] += $row['num_comments']; |
|
120 | - } |
|
121 | - if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
122 | - $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
123 | - } |
|
124 | - } |
|
125 | - |
|
126 | - foreach ( $approved as $key ) { |
|
127 | - if ( empty( $stats[ $key ] ) ) { |
|
128 | - $stats[ $key ] = 0; |
|
129 | - } |
|
130 | - } |
|
131 | - |
|
132 | - $stats = (object) $stats; |
|
133 | - set_transient( 'getpaid_count_comments', $stats ); |
|
134 | - } |
|
135 | - |
|
136 | - } |
|
137 | - |
|
138 | - return $stats; |
|
139 | - } |
|
140 | - |
|
141 | - /** |
|
142 | - * Returns an array of invoice notes. |
|
143 | - * |
|
144 | - * @param int $invoice_id The invoice ID whose notes to retrieve. |
|
145 | - * @param string $type Optional. Pass in customer to only return customer notes. |
|
146 | - * @return WP_Comment[] |
|
147 | - */ |
|
148 | - public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) { |
|
149 | - |
|
150 | - // Default comment args. |
|
151 | - $args = array( |
|
152 | - 'post_id' => $invoice_id, |
|
153 | - 'orderby' => 'comment_ID', |
|
154 | - 'order' => 'ASC', |
|
155 | - ); |
|
156 | - |
|
157 | - // Maybe only show customer comments. |
|
158 | - if ( $type == 'customer' ) { |
|
159 | - $args['meta_key'] = '_wpi_customer_note'; |
|
160 | - $args['meta_value'] = 1; |
|
161 | - } |
|
162 | - |
|
163 | - $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
164 | - |
|
165 | - return get_comments( $args ); |
|
166 | - } |
|
167 | - |
|
168 | - /** |
|
169 | - * Saves an invoice comment. |
|
170 | - * |
|
171 | - * @param WPInv_Invoice $invoice The invoice to add the comment to. |
|
172 | - * @param string $note The note content. |
|
173 | - * @param string $note_author The name of the author of the note. |
|
174 | - * @param bool $for_customer Whether or not this comment is meant to be sent to the customer. |
|
175 | - * @return int|false The new note's ID on success, false on failure. |
|
176 | - */ |
|
177 | - function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){ |
|
178 | - |
|
179 | - do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer ); |
|
180 | - |
|
181 | - /** |
|
182 | - * Insert the comment. |
|
183 | - */ |
|
184 | - $note_id = wp_insert_comment( |
|
185 | - wp_filter_comment( |
|
186 | - array( |
|
187 | - 'comment_post_ID' => $invoice->get_id(), |
|
188 | - 'comment_content' => $note, |
|
189 | - 'comment_agent' => 'Invoicing', |
|
190 | - 'user_id' => get_current_user_id(), |
|
191 | - 'comment_author' => $note_author, |
|
192 | - 'comment_author_IP' => wpinv_get_ip(), |
|
193 | - 'comment_author_email' => $author_email, |
|
194 | - 'comment_author_url' => $invoice->get_view_url(), |
|
195 | - 'comment_type' => 'wpinv_note', |
|
196 | - ) |
|
197 | - ) |
|
198 | - ); |
|
199 | - |
|
200 | - do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer ); |
|
201 | - |
|
202 | - // Are we notifying the customer? |
|
203 | - if ( empty( $note_id ) || empty( $for_customer ) ) { |
|
204 | - return $note_id; |
|
205 | - } |
|
206 | - |
|
207 | - add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
208 | - do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) ); |
|
209 | - do_action( 'getpaid_new_customer_note', $invoice, $note ); |
|
210 | - return $note_id; |
|
211 | - } |
|
102 | + ARRAY_A |
|
103 | + ); |
|
104 | + |
|
105 | + $approved = array( |
|
106 | + '0' => 'moderated', |
|
107 | + '1' => 'approved', |
|
108 | + 'spam' => 'spam', |
|
109 | + 'trash' => 'trash', |
|
110 | + 'post-trashed' => 'post-trashed', |
|
111 | + ); |
|
112 | + |
|
113 | + foreach ( (array) $count as $row ) { |
|
114 | + // Don't count post-trashed toward totals. |
|
115 | + if ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash', 'spam' ), true ) ) { |
|
116 | + $stats['all'] += $row['num_comments']; |
|
117 | + $stats['total_comments'] += $row['num_comments']; |
|
118 | + } elseif ( ! in_array( $row['comment_approved'], array( 'post-trashed', 'trash' ), true ) ) { |
|
119 | + $stats['total_comments'] += $row['num_comments']; |
|
120 | + } |
|
121 | + if ( isset( $approved[ $row['comment_approved'] ] ) ) { |
|
122 | + $stats[ $approved[ $row['comment_approved'] ] ] = $row['num_comments']; |
|
123 | + } |
|
124 | + } |
|
125 | + |
|
126 | + foreach ( $approved as $key ) { |
|
127 | + if ( empty( $stats[ $key ] ) ) { |
|
128 | + $stats[ $key ] = 0; |
|
129 | + } |
|
130 | + } |
|
131 | + |
|
132 | + $stats = (object) $stats; |
|
133 | + set_transient( 'getpaid_count_comments', $stats ); |
|
134 | + } |
|
135 | + |
|
136 | + } |
|
137 | + |
|
138 | + return $stats; |
|
139 | + } |
|
140 | + |
|
141 | + /** |
|
142 | + * Returns an array of invoice notes. |
|
143 | + * |
|
144 | + * @param int $invoice_id The invoice ID whose notes to retrieve. |
|
145 | + * @param string $type Optional. Pass in customer to only return customer notes. |
|
146 | + * @return WP_Comment[] |
|
147 | + */ |
|
148 | + public function get_invoice_notes( $invoice_id = 0, $type = 'all' ) { |
|
149 | + |
|
150 | + // Default comment args. |
|
151 | + $args = array( |
|
152 | + 'post_id' => $invoice_id, |
|
153 | + 'orderby' => 'comment_ID', |
|
154 | + 'order' => 'ASC', |
|
155 | + ); |
|
156 | + |
|
157 | + // Maybe only show customer comments. |
|
158 | + if ( $type == 'customer' ) { |
|
159 | + $args['meta_key'] = '_wpi_customer_note'; |
|
160 | + $args['meta_value'] = 1; |
|
161 | + } |
|
162 | + |
|
163 | + $args = apply_filters( 'wpinv_invoice_notes_args', $args, $this, $invoice_id, $type ); |
|
164 | + |
|
165 | + return get_comments( $args ); |
|
166 | + } |
|
167 | + |
|
168 | + /** |
|
169 | + * Saves an invoice comment. |
|
170 | + * |
|
171 | + * @param WPInv_Invoice $invoice The invoice to add the comment to. |
|
172 | + * @param string $note The note content. |
|
173 | + * @param string $note_author The name of the author of the note. |
|
174 | + * @param bool $for_customer Whether or not this comment is meant to be sent to the customer. |
|
175 | + * @return int|false The new note's ID on success, false on failure. |
|
176 | + */ |
|
177 | + function add_invoice_note( $invoice, $note, $note_author, $author_email, $for_customer = false ){ |
|
178 | + |
|
179 | + do_action( 'wpinv_pre_insert_invoice_note', $invoice->get_id(), $note, $for_customer ); |
|
180 | + |
|
181 | + /** |
|
182 | + * Insert the comment. |
|
183 | + */ |
|
184 | + $note_id = wp_insert_comment( |
|
185 | + wp_filter_comment( |
|
186 | + array( |
|
187 | + 'comment_post_ID' => $invoice->get_id(), |
|
188 | + 'comment_content' => $note, |
|
189 | + 'comment_agent' => 'Invoicing', |
|
190 | + 'user_id' => get_current_user_id(), |
|
191 | + 'comment_author' => $note_author, |
|
192 | + 'comment_author_IP' => wpinv_get_ip(), |
|
193 | + 'comment_author_email' => $author_email, |
|
194 | + 'comment_author_url' => $invoice->get_view_url(), |
|
195 | + 'comment_type' => 'wpinv_note', |
|
196 | + ) |
|
197 | + ) |
|
198 | + ); |
|
199 | + |
|
200 | + do_action( 'wpinv_insert_payment_note', $note_id, $invoice->get_id(), $note, $for_customer ); |
|
201 | + |
|
202 | + // Are we notifying the customer? |
|
203 | + if ( empty( $note_id ) || empty( $for_customer ) ) { |
|
204 | + return $note_id; |
|
205 | + } |
|
206 | + |
|
207 | + add_comment_meta( $note_id, '_wpi_customer_note', 1 ); |
|
208 | + do_action( 'wpinv_new_customer_note', array( 'invoice_id' => $invoice->get_id(), 'user_note' => $note ) ); |
|
209 | + do_action( 'getpaid_new_customer_note', $invoice, $note ); |
|
210 | + return $note_id; |
|
211 | + } |
|
212 | 212 | |
213 | 213 | } |