@@ -8,211 +8,211 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | $getpaid_pages = GetPaid_Installer::get_pages(); |
14 | -$pages = wpinv_get_pages( true ); |
|
14 | +$pages = wpinv_get_pages(true); |
|
15 | 15 | |
16 | 16 | $currencies = wpinv_get_currencies(); |
17 | 17 | |
18 | 18 | $currency_code_options = array(); |
19 | -foreach ( $currencies as $code => $name ) { |
|
20 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
19 | +foreach ($currencies as $code => $name) { |
|
20 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | $invoice_number_padd_options = array(); |
24 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
24 | +for ($i = 0; $i <= 20; $i++) { |
|
25 | 25 | $invoice_number_padd_options[$i] = $i; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $currency_symbol = wpinv_currency_symbol(); |
29 | 29 | |
30 | 30 | $last_number = $reset_number = ''; |
31 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
32 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
31 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
32 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
33 | 33 | |
34 | - if ( !empty( $last_invoice_number ) ) { |
|
35 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
34 | + if (!empty($last_invoice_number)) { |
|
35 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | $nonce = wp_create_nonce('reset_invoice_count'); |
39 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
39 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | $alert_wrapper_start = '<p style="color: #F00">'; |
43 | 43 | $alert_wrapper_close = '</p>'; |
44 | 44 | |
45 | 45 | return array( |
46 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
46 | + 'general' => apply_filters('wpinv_settings_general', |
|
47 | 47 | array( |
48 | 48 | 'main' => array( |
49 | 49 | 'location_settings' => array( |
50 | 50 | 'id' => 'location_settings', |
51 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
51 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
52 | 52 | 'desc' => '', |
53 | 53 | 'type' => 'header', |
54 | 54 | ), |
55 | 55 | 'default_country' => array( |
56 | 56 | 'id' => 'default_country', |
57 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
58 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
57 | + 'name' => __('Default Country', 'invoicing'), |
|
58 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
59 | 59 | 'type' => 'select', |
60 | 60 | 'options' => wpinv_get_country_list(), |
61 | 61 | 'std' => 'GB', |
62 | 62 | 'class' => 'wpi_select2', |
63 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
63 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
64 | 64 | ), |
65 | 65 | 'default_state' => array( |
66 | 66 | 'id' => 'default_state', |
67 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
68 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
67 | + 'name' => __('Default State / Province', 'invoicing'), |
|
68 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
69 | 69 | 'type' => 'country_states', |
70 | 70 | 'class' => 'wpi_select2', |
71 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
71 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
72 | 72 | ), |
73 | 73 | 'store_name' => array( |
74 | 74 | 'id' => 'store_name', |
75 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
76 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
75 | + 'name' => __('Store Name', 'invoicing'), |
|
76 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
77 | 77 | 'std' => get_option('blogname'), |
78 | 78 | 'type' => 'text', |
79 | 79 | ), |
80 | 80 | 'logo' => array( |
81 | 81 | 'id' => 'logo', |
82 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
83 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
82 | + 'name' => __('Logo URL', 'invoicing'), |
|
83 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
84 | 84 | 'type' => 'text', |
85 | 85 | ), |
86 | 86 | 'logo_width' => array( |
87 | 87 | 'id' => 'logo_width', |
88 | - 'name' => __( 'Logo width', 'invoicing' ), |
|
89 | - 'desc' => __( 'Logo width to use in invoice image.', 'invoicing' ), |
|
88 | + 'name' => __('Logo width', 'invoicing'), |
|
89 | + 'desc' => __('Logo width to use in invoice image.', 'invoicing'), |
|
90 | 90 | 'type' => 'number', |
91 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
91 | + 'placeholder' => __('Auto', 'invoicing'), |
|
92 | 92 | ), |
93 | 93 | 'logo_height' => array( |
94 | 94 | 'id' => 'logo_height', |
95 | - 'name' => __( 'Logo height', 'invoicing' ), |
|
96 | - 'desc' => __( 'Logo height to use in invoice image.', 'invoicing' ), |
|
95 | + 'name' => __('Logo height', 'invoicing'), |
|
96 | + 'desc' => __('Logo height to use in invoice image.', 'invoicing'), |
|
97 | 97 | 'type' => 'number', |
98 | - 'placeholder' => __( 'Auto', 'invoicing' ), |
|
98 | + 'placeholder' => __('Auto', 'invoicing'), |
|
99 | 99 | ), |
100 | 100 | 'store_address' => array( |
101 | 101 | 'id' => 'store_address', |
102 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
103 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
102 | + 'name' => __('Store Address', 'invoicing'), |
|
103 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
104 | 104 | 'type' => 'textarea', |
105 | 105 | ), |
106 | 106 | 'page_settings' => array( |
107 | 107 | 'id' => 'page_settings', |
108 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
108 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
109 | 109 | 'desc' => '', |
110 | 110 | 'type' => 'header', |
111 | 111 | ), |
112 | 112 | 'checkout_page' => array( |
113 | 113 | 'id' => 'checkout_page', |
114 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
115 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
114 | + 'name' => __('Checkout Page', 'invoicing'), |
|
115 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
116 | 116 | 'type' => 'select', |
117 | 117 | 'options' => $pages, |
118 | 118 | 'class' => 'wpi_select2', |
119 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
120 | - 'default_content' => empty( $getpaid_pages['checkout_page'] ) ? '' : $getpaid_pages['checkout_page']['content'], |
|
119 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
120 | + 'default_content' => empty($getpaid_pages['checkout_page']) ? '' : $getpaid_pages['checkout_page']['content'], |
|
121 | 121 | 'help-tip' => true, |
122 | 122 | ), |
123 | 123 | 'success_page' => array( |
124 | 124 | 'id' => 'success_page', |
125 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
126 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
125 | + 'name' => __('Success Page', 'invoicing'), |
|
126 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
127 | 127 | 'type' => 'select', |
128 | 128 | 'options' => $pages, |
129 | 129 | 'class' => 'wpi_select2', |
130 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
131 | - 'default_content' => empty( $getpaid_pages['success_page'] ) ? '' : $getpaid_pages['success_page']['content'], |
|
130 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
131 | + 'default_content' => empty($getpaid_pages['success_page']) ? '' : $getpaid_pages['success_page']['content'], |
|
132 | 132 | 'help-tip' => true, |
133 | 133 | ), |
134 | 134 | 'failure_page' => array( |
135 | 135 | 'id' => 'failure_page', |
136 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
137 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
136 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
137 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
138 | 138 | 'type' => 'select', |
139 | 139 | 'options' => $pages, |
140 | 140 | 'class' => 'wpi_select2', |
141 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
142 | - 'default_content' => empty( $getpaid_pages['failure_page'] ) ? '' : $getpaid_pages['failure_page']['content'], |
|
141 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
142 | + 'default_content' => empty($getpaid_pages['failure_page']) ? '' : $getpaid_pages['failure_page']['content'], |
|
143 | 143 | 'help-tip' => true, |
144 | 144 | ), |
145 | 145 | 'invoice_history_page' => array( |
146 | 146 | 'id' => 'invoice_history_page', |
147 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
148 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
147 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
148 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
149 | 149 | 'type' => 'select', |
150 | 150 | 'options' => $pages, |
151 | 151 | 'class' => 'wpi_select2', |
152 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
153 | - 'default_content' => empty( $getpaid_pages['invoice_history_page'] ) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
152 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
153 | + 'default_content' => empty($getpaid_pages['invoice_history_page']) ? '' : $getpaid_pages['invoice_history_page']['content'], |
|
154 | 154 | 'help-tip' => true, |
155 | 155 | ), |
156 | 156 | 'invoice_subscription_page' => array( |
157 | 157 | 'id' => 'invoice_subscription_page', |
158 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
159 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
158 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
159 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
160 | 160 | 'type' => 'select', |
161 | 161 | 'options' => $pages, |
162 | 162 | 'class' => 'wpi_select2', |
163 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
164 | - 'default_content' => empty( $getpaid_pages['invoice_subscription_page'] ) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
163 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
164 | + 'default_content' => empty($getpaid_pages['invoice_subscription_page']) ? '' : $getpaid_pages['invoice_subscription_page']['content'], |
|
165 | 165 | 'help-tip' => true, |
166 | 166 | ), |
167 | 167 | ), |
168 | 168 | 'currency_section' => array( |
169 | 169 | 'currency_settings' => array( |
170 | 170 | 'id' => 'currency_settings', |
171 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
171 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
172 | 172 | 'desc' => '', |
173 | 173 | 'type' => 'header', |
174 | 174 | ), |
175 | 175 | 'currency' => array( |
176 | 176 | 'id' => 'currency', |
177 | - 'name' => __( 'Currency', 'invoicing' ), |
|
178 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
177 | + 'name' => __('Currency', 'invoicing'), |
|
178 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
179 | 179 | 'type' => 'select', |
180 | 180 | 'class' => 'wpi_select2', |
181 | 181 | 'options' => $currency_code_options, |
182 | 182 | ), |
183 | 183 | 'currency_position' => array( |
184 | 184 | 'id' => 'currency_position', |
185 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
186 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
185 | + 'name' => __('Currency Position', 'invoicing'), |
|
186 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
187 | 187 | 'type' => 'select', |
188 | 188 | 'class' => 'wpi_select2', |
189 | 189 | 'options' => array( |
190 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
191 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
192 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
193 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
190 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
191 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
192 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
193 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
194 | 194 | ) |
195 | 195 | ), |
196 | 196 | 'thousands_separator' => array( |
197 | 197 | 'id' => 'thousands_separator', |
198 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
199 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
198 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
199 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
200 | 200 | 'type' => 'text', |
201 | 201 | 'size' => 'small', |
202 | 202 | 'std' => ',', |
203 | 203 | ), |
204 | 204 | 'decimal_separator' => array( |
205 | 205 | 'id' => 'decimal_separator', |
206 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
207 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
206 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
207 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
208 | 208 | 'type' => 'text', |
209 | 209 | 'size' => 'small', |
210 | 210 | 'std' => '.', |
211 | 211 | ), |
212 | 212 | 'decimals' => array( |
213 | 213 | 'id' => 'decimals', |
214 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
215 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
214 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
215 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
216 | 216 | 'type' => 'number', |
217 | 217 | 'size' => 'small', |
218 | 218 | 'std' => '2', |
@@ -224,21 +224,21 @@ discard block |
||
224 | 224 | 'labels' => array( |
225 | 225 | 'labels' => array( |
226 | 226 | 'id' => 'labels_settings', |
227 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
227 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
228 | 228 | 'desc' => '', |
229 | 229 | 'type' => 'header', |
230 | 230 | ), |
231 | 231 | 'vat_invoice_notice_label' => array( |
232 | 232 | 'id' => 'vat_invoice_notice_label', |
233 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
234 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
233 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
234 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
235 | 235 | 'type' => 'text', |
236 | 236 | 'size' => 'regular', |
237 | 237 | ), |
238 | 238 | 'vat_invoice_notice' => array( |
239 | 239 | 'id' => 'vat_invoice_notice', |
240 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
241 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
240 | + 'name' => __('Invoice notice', 'invoicing'), |
|
241 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
242 | 242 | 'type' => 'text', |
243 | 243 | 'size' => 'regular', |
244 | 244 | ), |
@@ -250,22 +250,22 @@ discard block |
||
250 | 250 | 'main' => array( |
251 | 251 | 'gateway_settings' => array( |
252 | 252 | 'id' => 'api_header', |
253 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
253 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
254 | 254 | 'desc' => '', |
255 | 255 | 'type' => 'header', |
256 | 256 | ), |
257 | 257 | 'gateways' => array( |
258 | 258 | 'id' => 'gateways', |
259 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
260 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
259 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
260 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
261 | 261 | 'type' => 'gateways', |
262 | - 'std' => array( 'manual'=>1 ), |
|
262 | + 'std' => array('manual'=>1), |
|
263 | 263 | 'options' => wpinv_get_payment_gateways(), |
264 | 264 | ), |
265 | 265 | 'default_gateway' => array( |
266 | 266 | 'id' => 'default_gateway', |
267 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
268 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
267 | + 'name' => __('Default Gateway', 'invoicing'), |
|
268 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
269 | 269 | 'type' => 'gateway_select', |
270 | 270 | 'std' => 'manual', |
271 | 271 | 'class' => 'wpi_select2', |
@@ -280,32 +280,32 @@ discard block |
||
280 | 280 | 'main' => array( |
281 | 281 | 'tax_settings' => array( |
282 | 282 | 'id' => 'tax_settings', |
283 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
283 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
284 | 284 | 'type' => 'header', |
285 | 285 | ), |
286 | 286 | |
287 | 287 | 'enable_taxes' => array( |
288 | 288 | 'id' => 'enable_taxes', |
289 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
290 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
289 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
290 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
291 | 291 | 'type' => 'checkbox', |
292 | 292 | 'std' => 0, |
293 | 293 | ), |
294 | 294 | |
295 | 295 | 'tax_subtotal_rounding' => array( |
296 | 296 | 'id' => 'tax_subtotal_rounding', |
297 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
298 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
297 | + 'name' => __('Rounding', 'invoicing'), |
|
298 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
299 | 299 | 'type' => 'checkbox', |
300 | 300 | 'std' => 1, |
301 | 301 | ), |
302 | 302 | |
303 | 303 | 'prices_include_tax' => array( |
304 | 304 | 'id' => 'prices_include_tax', |
305 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
305 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
306 | 306 | 'options' => array( |
307 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
308 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
307 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
308 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
309 | 309 | ), |
310 | 310 | 'type' => 'select', |
311 | 311 | 'std' => 'no', |
@@ -313,10 +313,10 @@ discard block |
||
313 | 313 | |
314 | 314 | 'tax_base' => array( |
315 | 315 | 'id' => 'tax_base', |
316 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
316 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
317 | 317 | 'options' => array( |
318 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
319 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
318 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
319 | + 'base' => __('Shop base address', 'invoicing'), |
|
320 | 320 | ), |
321 | 321 | 'type' => 'select', |
322 | 322 | 'std' => 'billing', |
@@ -324,10 +324,10 @@ discard block |
||
324 | 324 | |
325 | 325 | 'tax_display_totals' => array( |
326 | 326 | 'id' => 'tax_display_totals', |
327 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
327 | + 'name' => __('Display tax totals', 'invoicing'), |
|
328 | 328 | 'options' => array( |
329 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
330 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
329 | + 'single' => __('As a single total', 'invoicing'), |
|
330 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
331 | 331 | ), |
332 | 332 | 'type' => 'select', |
333 | 333 | 'std' => 'individual', |
@@ -335,8 +335,8 @@ discard block |
||
335 | 335 | |
336 | 336 | 'tax_rate' => array( |
337 | 337 | 'id' => 'tax_rate', |
338 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
339 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
338 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
339 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
340 | 340 | 'type' => 'number', |
341 | 341 | 'size' => 'small', |
342 | 342 | 'min' => '0', |
@@ -348,8 +348,8 @@ discard block |
||
348 | 348 | 'rates' => array( |
349 | 349 | 'tax_rates' => array( |
350 | 350 | 'id' => 'tax_rates', |
351 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
352 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
351 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
352 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
353 | 353 | 'type' => 'tax_rates', |
354 | 354 | ), |
355 | 355 | ), |
@@ -358,45 +358,45 @@ discard block |
||
358 | 358 | |
359 | 359 | 'vat_company_name' => array( |
360 | 360 | 'id' => 'vat_company_name', |
361 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
362 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
361 | + 'name' => __('Company Name', 'invoicing'), |
|
362 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
363 | 363 | 'type' => 'text', |
364 | 364 | 'size' => 'regular', |
365 | 365 | ), |
366 | 366 | |
367 | 367 | 'vat_number' => array( |
368 | 368 | 'id' => 'vat_number', |
369 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
370 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
369 | + 'name' => __('VAT Number', 'invoicing'), |
|
370 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
371 | 371 | 'type' => 'text', |
372 | 372 | 'size' => 'regular', |
373 | 373 | ), |
374 | 374 | |
375 | 375 | 'vat_prevent_b2c_purchase' => array( |
376 | 376 | 'id' => 'vat_prevent_b2c_purchase', |
377 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
378 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
377 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
378 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
379 | 379 | 'type' => 'checkbox' |
380 | 380 | ), |
381 | 381 | |
382 | 382 | 'validate_vat_number' => array( |
383 | 383 | 'id' => 'validate_vat_number', |
384 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
385 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
384 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
385 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
386 | 386 | 'type' => 'checkbox' |
387 | 387 | ), |
388 | 388 | |
389 | 389 | 'vat_same_country_rule' => array( |
390 | 390 | 'id' => 'vat_same_country_rule', |
391 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
392 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
391 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
392 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
393 | 393 | 'type' => 'select', |
394 | 394 | 'options' => array( |
395 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
396 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
397 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ) |
|
395 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
396 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
397 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing') |
|
398 | 398 | ), |
399 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
399 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
400 | 400 | 'std' => 'vat_too', |
401 | 401 | ), |
402 | 402 | |
@@ -410,66 +410,66 @@ discard block |
||
410 | 410 | 'main' => array( |
411 | 411 | 'email_settings_header' => array( |
412 | 412 | 'id' => 'email_settings_header', |
413 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
413 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
414 | 414 | 'type' => 'header', |
415 | 415 | ), |
416 | 416 | 'email_from_name' => array( |
417 | 417 | 'id' => 'email_from_name', |
418 | - 'name' => __( 'From Name', 'invoicing' ), |
|
419 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
420 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
418 | + 'name' => __('From Name', 'invoicing'), |
|
419 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
420 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
421 | 421 | 'type' => 'text', |
422 | 422 | ), |
423 | 423 | 'email_from' => array( |
424 | 424 | 'id' => 'email_from', |
425 | - 'name' => __( 'From Email', 'invoicing' ), |
|
426 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
427 | - 'std' => get_option( 'admin_email' ), |
|
425 | + 'name' => __('From Email', 'invoicing'), |
|
426 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
427 | + 'std' => get_option('admin_email'), |
|
428 | 428 | 'type' => 'text', |
429 | 429 | ), |
430 | 430 | 'admin_email' => array( |
431 | 431 | 'id' => 'admin_email', |
432 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
433 | - 'desc' => __( 'Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing' ), |
|
434 | - 'std' => get_option( 'admin_email' ), |
|
432 | + 'name' => __('Admin Email', 'invoicing'), |
|
433 | + 'desc' => __('Where should we send admin notifications? This will is also act as the "reply-to" address for invoice emails', 'invoicing'), |
|
434 | + 'std' => get_option('admin_email'), |
|
435 | 435 | 'type' => 'text', |
436 | 436 | ), |
437 | 437 | 'skip_email_free_invoice' => array( |
438 | 438 | 'id' => 'skip_email_free_invoice', |
439 | - 'name' => __( 'Skip Free Invoices', 'invoicing' ), |
|
440 | - 'desc' => __( 'Check this to disable sending emails for free invoices.', 'invoicing' ), |
|
439 | + 'name' => __('Skip Free Invoices', 'invoicing'), |
|
440 | + 'desc' => __('Check this to disable sending emails for free invoices.', 'invoicing'), |
|
441 | 441 | 'type' => 'checkbox', |
442 | 442 | 'std' => false, |
443 | 443 | ), |
444 | 444 | 'overdue_settings_header' => array( |
445 | 445 | 'id' => 'overdue_settings_header', |
446 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
446 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
447 | 447 | 'type' => 'header', |
448 | 448 | ), |
449 | 449 | 'overdue_active' => array( |
450 | 450 | 'id' => 'overdue_active', |
451 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
452 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
451 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
452 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
453 | 453 | 'type' => 'checkbox', |
454 | 454 | 'std' => false, |
455 | 455 | ), |
456 | 456 | 'email_template_header' => array( |
457 | 457 | 'id' => 'email_template_header', |
458 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
458 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
459 | 459 | 'type' => 'header', |
460 | 460 | ), |
461 | 461 | 'email_header_image' => array( |
462 | 462 | 'id' => 'email_header_image', |
463 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
464 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
463 | + 'name' => __('Header Image', 'invoicing'), |
|
464 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
465 | 465 | 'std' => '', |
466 | 466 | 'type' => 'text', |
467 | 467 | ), |
468 | 468 | 'email_footer_text' => array( |
469 | 469 | 'id' => 'email_footer_text', |
470 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
471 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
472 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
470 | + 'name' => __('Footer Text', 'invoicing'), |
|
471 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
472 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
473 | 473 | 'type' => 'textarea', |
474 | 474 | 'class' => 'regular-text', |
475 | 475 | 'rows' => 2, |
@@ -477,29 +477,29 @@ discard block |
||
477 | 477 | ), |
478 | 478 | 'email_base_color' => array( |
479 | 479 | 'id' => 'email_base_color', |
480 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
481 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
480 | + 'name' => __('Base Color', 'invoicing'), |
|
481 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
482 | 482 | 'std' => '#557da2', |
483 | 483 | 'type' => 'color', |
484 | 484 | ), |
485 | 485 | 'email_background_color' => array( |
486 | 486 | 'id' => 'email_background_color', |
487 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
488 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
487 | + 'name' => __('Background Color', 'invoicing'), |
|
488 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
489 | 489 | 'std' => '#f5f5f5', |
490 | 490 | 'type' => 'color', |
491 | 491 | ), |
492 | 492 | 'email_body_background_color' => array( |
493 | 493 | 'id' => 'email_body_background_color', |
494 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
495 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
494 | + 'name' => __('Body Background Color', 'invoicing'), |
|
495 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
496 | 496 | 'std' => '#fdfdfd', |
497 | 497 | 'type' => 'color', |
498 | 498 | ), |
499 | 499 | 'email_text_color' => array( |
500 | 500 | 'id' => 'email_text_color', |
501 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
502 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
501 | + 'name' => __('Body Text Color', 'invoicing'), |
|
502 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
503 | 503 | 'std' => '#505050', |
504 | 504 | 'type' => 'color', |
505 | 505 | ), |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | ), |
515 | 515 | |
516 | 516 | // Integrations. |
517 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
517 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
518 | 518 | |
519 | 519 | /** Privacy Settings */ |
520 | 520 | 'privacy' => apply_filters('wpinv_settings_privacy', |
@@ -522,17 +522,17 @@ discard block |
||
522 | 522 | 'main' => array( |
523 | 523 | 'invoicing_privacy_policy_settings' => array( |
524 | 524 | 'id' => 'invoicing_privacy_policy_settings', |
525 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
525 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
526 | 526 | 'type' => 'header', |
527 | 527 | ), |
528 | 528 | 'privacy_page' => array( |
529 | 529 | 'id' => 'privacy_page', |
530 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
531 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
530 | + 'name' => __('Privacy Page', 'invoicing'), |
|
531 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
532 | 532 | 'type' => 'select', |
533 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
533 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
534 | 534 | 'class' => 'wpi_select2', |
535 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
535 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
536 | 536 | ), |
537 | 537 | ), |
538 | 538 | ) |
@@ -543,19 +543,19 @@ discard block |
||
543 | 543 | 'main' => array( |
544 | 544 | 'invoice_number_format_settings' => array( |
545 | 545 | 'id' => 'invoice_number_format_settings', |
546 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
546 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
547 | 547 | 'type' => 'header', |
548 | 548 | ), |
549 | 549 | 'sequential_invoice_number' => array( |
550 | 550 | 'id' => 'sequential_invoice_number', |
551 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
552 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
551 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
552 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
553 | 553 | 'type' => 'checkbox', |
554 | 554 | ), |
555 | 555 | 'invoice_sequence_start' => array( |
556 | 556 | 'id' => 'invoice_sequence_start', |
557 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
558 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
557 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
558 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
559 | 559 | 'type' => 'number', |
560 | 560 | 'size' => 'small', |
561 | 561 | 'std' => '1', |
@@ -563,8 +563,8 @@ discard block |
||
563 | 563 | ), |
564 | 564 | 'invoice_number_padd' => array( |
565 | 565 | 'id' => 'invoice_number_padd', |
566 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
567 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
566 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
567 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
568 | 568 | 'type' => 'select', |
569 | 569 | 'options' => $invoice_number_padd_options, |
570 | 570 | 'std' => 5, |
@@ -572,8 +572,8 @@ discard block |
||
572 | 572 | ), |
573 | 573 | 'invoice_number_prefix' => array( |
574 | 574 | 'id' => 'invoice_number_prefix', |
575 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
576 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
575 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
576 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
577 | 577 | 'type' => 'text', |
578 | 578 | 'size' => 'regular', |
579 | 579 | 'std' => 'INV-', |
@@ -581,46 +581,46 @@ discard block |
||
581 | 581 | ), |
582 | 582 | 'invoice_number_postfix' => array( |
583 | 583 | 'id' => 'invoice_number_postfix', |
584 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
585 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
584 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
585 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
586 | 586 | 'type' => 'text', |
587 | 587 | 'size' => 'regular', |
588 | 588 | 'std' => '' |
589 | 589 | ), |
590 | 590 | 'checkout_settings' => array( |
591 | 591 | 'id' => 'checkout_settings', |
592 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
592 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
593 | 593 | 'type' => 'header', |
594 | 594 | ), |
595 | 595 | 'disable_new_user_emails' => array( |
596 | 596 | 'id' => 'disable_new_user_emails', |
597 | - 'name' => __( 'Disable new user emails', 'invoicing' ), |
|
598 | - 'desc' => __( 'Do not send an email to customers when a new user account is created for them.', 'invoicing' ), |
|
597 | + 'name' => __('Disable new user emails', 'invoicing'), |
|
598 | + 'desc' => __('Do not send an email to customers when a new user account is created for them.', 'invoicing'), |
|
599 | 599 | 'type' => 'checkbox', |
600 | 600 | ), |
601 | 601 | 'login_to_checkout' => array( |
602 | 602 | 'id' => 'login_to_checkout', |
603 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
604 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
603 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
604 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
605 | 605 | 'type' => 'checkbox', |
606 | 606 | ), |
607 | 607 | 'maxmind_license_key' => array( |
608 | 608 | 'id' => 'maxmind_license_key', |
609 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
609 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
610 | 610 | 'type' => 'text', |
611 | 611 | 'size' => 'regular', |
612 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
612 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
613 | 613 | ), |
614 | 614 | |
615 | 615 | 'uninstall_settings' => array( |
616 | 616 | 'id' => 'uninstall_settings', |
617 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
617 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
618 | 618 | 'type' => 'header', |
619 | 619 | ), |
620 | 620 | 'remove_data_on_unistall' => array( |
621 | 621 | 'id' => 'remove_data_on_unistall', |
622 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
623 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
622 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
623 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
624 | 624 | 'type' => 'checkbox', |
625 | 625 | 'std' => '' |
626 | 626 | ), |
@@ -629,13 +629,13 @@ discard block |
||
629 | 629 | 'custom-css' => array( |
630 | 630 | 'css_settings' => array( |
631 | 631 | 'id' => 'css_settings', |
632 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
632 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
633 | 633 | 'type' => 'header', |
634 | 634 | ), |
635 | 635 | 'template_custom_css' => array( |
636 | 636 | 'id' => 'template_custom_css', |
637 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
638 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
637 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
638 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
639 | 639 | 'type' => 'textarea', |
640 | 640 | 'class'=> 'regular-text', |
641 | 641 | 'rows' => 10, |
@@ -649,8 +649,8 @@ discard block |
||
649 | 649 | 'main' => array( |
650 | 650 | 'tool_settings' => array( |
651 | 651 | 'id' => 'tool_settings', |
652 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
653 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
652 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
653 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
654 | 654 | 'type' => 'tools', |
655 | 655 | ), |
656 | 656 | ), |
@@ -12,474 +12,474 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Invoice_Notification_Emails { |
14 | 14 | |
15 | - /** |
|
16 | - * The array of invoice email actions. |
|
17 | - * |
|
18 | - * @param array |
|
19 | - */ |
|
20 | - public $invoice_actions; |
|
21 | - |
|
22 | - /** |
|
23 | - * Class constructor |
|
24 | - * |
|
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - |
|
28 | - $this->invoice_actions = apply_filters( |
|
29 | - 'getpaid_notification_email_invoice_triggers', |
|
30 | - array( |
|
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
32 | - 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
|
33 | - 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
|
34 | - 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
|
35 | - 'getpaid_invoice_status_wpi-processing' => 'processing_invoice', |
|
36 | - 'getpaid_invoice_status_publish' => 'completed_invoice', |
|
37 | - 'getpaid_invoice_status_wpi-renewal' => 'completed_invoice', |
|
38 | - 'getpaid_invoice_status_wpi-refunded' => 'refunded_invoice', |
|
39 | - 'getpaid_new_customer_note' => 'user_note', |
|
40 | - 'getpaid_daily_maintenance' => 'overdue', |
|
41 | - ) |
|
42 | - ); |
|
43 | - |
|
44 | - $this->init_hooks(); |
|
45 | - |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Registers email hooks. |
|
50 | - */ |
|
51 | - public function init_hooks() { |
|
52 | - |
|
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
55 | - |
|
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
58 | - } |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Registers an email hook for an invoice action. |
|
63 | - * |
|
64 | - * @param string $hook |
|
65 | - * @param string|array $email_type |
|
66 | - */ |
|
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
68 | - |
|
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
70 | - |
|
71 | - foreach ( $email_type as $type ) { |
|
72 | - |
|
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
74 | - |
|
75 | - // Abort if it is not active. |
|
76 | - if ( ! $email->is_active() ) { |
|
77 | - continue; |
|
78 | - } |
|
79 | - |
|
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
82 | - continue; |
|
83 | - } |
|
84 | - |
|
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
86 | - } |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Filters invoice merge tags. |
|
92 | - * |
|
93 | - * @param array $merge_tags |
|
94 | - * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
95 | - */ |
|
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
97 | - |
|
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
99 | - return array_merge( |
|
100 | - $merge_tags, |
|
101 | - $this->get_invoice_merge_tags( $object ) |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
106 | - return array_merge( |
|
107 | - $merge_tags, |
|
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - return $merge_tags; |
|
113 | - |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Generates invoice merge tags. |
|
118 | - * |
|
119 | - * @param WPInv_Invoice $invoice |
|
120 | - * @return array |
|
121 | - */ |
|
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
123 | - |
|
124 | - // Abort if it does not exist. |
|
125 | - if ( ! $invoice->get_id() ) { |
|
126 | - return array(); |
|
127 | - } |
|
128 | - |
|
129 | - $merge_tags = array( |
|
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
148 | - ); |
|
149 | - |
|
150 | - $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
151 | - |
|
152 | - if ( is_array( $payment_form_data ) ) { |
|
153 | - |
|
154 | - foreach ( $payment_form_data as $label => $value ) { |
|
155 | - |
|
156 | - $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | - $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
158 | - |
|
159 | - if ( is_scalar ( $value ) ) { |
|
160 | - $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
161 | - } |
|
162 | - |
|
163 | - } |
|
164 | - |
|
165 | - } |
|
166 | - |
|
167 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
168 | - } |
|
169 | - |
|
170 | - /** |
|
171 | - * Helper function to send an email. |
|
172 | - * |
|
173 | - * @param WPInv_Invoice $invoice |
|
174 | - * @param GetPaid_Notification_Email $email |
|
175 | - * @param string $type |
|
176 | - * @param string|array $recipients |
|
177 | - * @param array $extra_args Extra template args. |
|
178 | - */ |
|
179 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
180 | - |
|
181 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
182 | - |
|
183 | - $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' ); |
|
184 | - if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) { |
|
185 | - return; |
|
186 | - } |
|
187 | - |
|
188 | - $mailer = new GetPaid_Notification_Email_Sender(); |
|
189 | - $merge_tags = $email->get_merge_tags(); |
|
190 | - |
|
191 | - $result = $mailer->send( |
|
192 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
193 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
194 | - $email->get_content( $merge_tags, $extra_args ), |
|
195 | - $email->get_attachments() |
|
196 | - ); |
|
197 | - |
|
198 | - // Maybe send a copy to the admin. |
|
199 | - if ( $email->include_admin_bcc() ) { |
|
200 | - $mailer->send( |
|
201 | - wpinv_get_admin_email(), |
|
202 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
203 | - $email->get_content( $merge_tags ), |
|
204 | - $email->get_attachments() |
|
205 | - ); |
|
206 | - } |
|
207 | - |
|
208 | - if ( $result ) { |
|
209 | - $invoice->add_note( sprintf( __( 'Successfully sent %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
210 | - } else { |
|
211 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
212 | - } |
|
213 | - |
|
214 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
215 | - |
|
216 | - return $result; |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * Also send emails to any cc users. |
|
221 | - * |
|
222 | - * @param array $recipients |
|
223 | - * @param GetPaid_Notification_Email $email |
|
224 | - */ |
|
225 | - public function filter_email_recipients( $recipients, $email ) { |
|
226 | - |
|
227 | - if ( ! $email->is_admin_email() ) { |
|
228 | - $cc = $email->object->get_email_cc(); |
|
229 | - |
|
230 | - if ( ! empty( $cc ) ) { |
|
231 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
232 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
233 | - } |
|
15 | + /** |
|
16 | + * The array of invoice email actions. |
|
17 | + * |
|
18 | + * @param array |
|
19 | + */ |
|
20 | + public $invoice_actions; |
|
21 | + |
|
22 | + /** |
|
23 | + * Class constructor |
|
24 | + * |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + |
|
28 | + $this->invoice_actions = apply_filters( |
|
29 | + 'getpaid_notification_email_invoice_triggers', |
|
30 | + array( |
|
31 | + 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
32 | + 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
|
33 | + 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
|
34 | + 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
|
35 | + 'getpaid_invoice_status_wpi-processing' => 'processing_invoice', |
|
36 | + 'getpaid_invoice_status_publish' => 'completed_invoice', |
|
37 | + 'getpaid_invoice_status_wpi-renewal' => 'completed_invoice', |
|
38 | + 'getpaid_invoice_status_wpi-refunded' => 'refunded_invoice', |
|
39 | + 'getpaid_new_customer_note' => 'user_note', |
|
40 | + 'getpaid_daily_maintenance' => 'overdue', |
|
41 | + ) |
|
42 | + ); |
|
43 | + |
|
44 | + $this->init_hooks(); |
|
45 | + |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Registers email hooks. |
|
50 | + */ |
|
51 | + public function init_hooks() { |
|
52 | + |
|
53 | + add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | + add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
55 | + |
|
56 | + foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | + $this->init_email_type_hook( $hook, $email_type ); |
|
58 | + } |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Registers an email hook for an invoice action. |
|
63 | + * |
|
64 | + * @param string $hook |
|
65 | + * @param string|array $email_type |
|
66 | + */ |
|
67 | + public function init_email_type_hook( $hook, $email_type ) { |
|
68 | + |
|
69 | + $email_type = wpinv_parse_list( $email_type ); |
|
70 | + |
|
71 | + foreach ( $email_type as $type ) { |
|
72 | + |
|
73 | + $email = new GetPaid_Notification_Email( $type ); |
|
74 | + |
|
75 | + // Abort if it is not active. |
|
76 | + if ( ! $email->is_active() ) { |
|
77 | + continue; |
|
78 | + } |
|
79 | + |
|
80 | + if ( method_exists( $this, $type ) ) { |
|
81 | + add_action( $hook, array( $this, $type ), 100, 2 ); |
|
82 | + continue; |
|
83 | + } |
|
84 | + |
|
85 | + do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
86 | + } |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Filters invoice merge tags. |
|
92 | + * |
|
93 | + * @param array $merge_tags |
|
94 | + * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
95 | + */ |
|
96 | + public function invoice_merge_tags( $merge_tags, $object ) { |
|
97 | + |
|
98 | + if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
99 | + return array_merge( |
|
100 | + $merge_tags, |
|
101 | + $this->get_invoice_merge_tags( $object ) |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
106 | + return array_merge( |
|
107 | + $merge_tags, |
|
108 | + $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + return $merge_tags; |
|
113 | + |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Generates invoice merge tags. |
|
118 | + * |
|
119 | + * @param WPInv_Invoice $invoice |
|
120 | + * @return array |
|
121 | + */ |
|
122 | + public function get_invoice_merge_tags( $invoice ) { |
|
123 | + |
|
124 | + // Abort if it does not exist. |
|
125 | + if ( ! $invoice->get_id() ) { |
|
126 | + return array(); |
|
127 | + } |
|
128 | + |
|
129 | + $merge_tags = array( |
|
130 | + '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | + '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | + '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | + '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | + '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | + '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | + '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | + '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | + '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | + '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | + '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | + '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | + '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | + '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | + '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | + '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | + '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
148 | + ); |
|
149 | + |
|
150 | + $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
151 | + |
|
152 | + if ( is_array( $payment_form_data ) ) { |
|
153 | + |
|
154 | + foreach ( $payment_form_data as $label => $value ) { |
|
155 | + |
|
156 | + $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | + $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
158 | + |
|
159 | + if ( is_scalar ( $value ) ) { |
|
160 | + $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
161 | + } |
|
162 | + |
|
163 | + } |
|
164 | + |
|
165 | + } |
|
166 | + |
|
167 | + return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
168 | + } |
|
169 | + |
|
170 | + /** |
|
171 | + * Helper function to send an email. |
|
172 | + * |
|
173 | + * @param WPInv_Invoice $invoice |
|
174 | + * @param GetPaid_Notification_Email $email |
|
175 | + * @param string $type |
|
176 | + * @param string|array $recipients |
|
177 | + * @param array $extra_args Extra template args. |
|
178 | + */ |
|
179 | + public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
180 | + |
|
181 | + do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
182 | + |
|
183 | + $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' ); |
|
184 | + if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) { |
|
185 | + return; |
|
186 | + } |
|
187 | + |
|
188 | + $mailer = new GetPaid_Notification_Email_Sender(); |
|
189 | + $merge_tags = $email->get_merge_tags(); |
|
190 | + |
|
191 | + $result = $mailer->send( |
|
192 | + apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
193 | + $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
194 | + $email->get_content( $merge_tags, $extra_args ), |
|
195 | + $email->get_attachments() |
|
196 | + ); |
|
197 | + |
|
198 | + // Maybe send a copy to the admin. |
|
199 | + if ( $email->include_admin_bcc() ) { |
|
200 | + $mailer->send( |
|
201 | + wpinv_get_admin_email(), |
|
202 | + $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
203 | + $email->get_content( $merge_tags ), |
|
204 | + $email->get_attachments() |
|
205 | + ); |
|
206 | + } |
|
207 | + |
|
208 | + if ( $result ) { |
|
209 | + $invoice->add_note( sprintf( __( 'Successfully sent %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
210 | + } else { |
|
211 | + $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
212 | + } |
|
213 | + |
|
214 | + do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
215 | + |
|
216 | + return $result; |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Also send emails to any cc users. |
|
221 | + * |
|
222 | + * @param array $recipients |
|
223 | + * @param GetPaid_Notification_Email $email |
|
224 | + */ |
|
225 | + public function filter_email_recipients( $recipients, $email ) { |
|
226 | + |
|
227 | + if ( ! $email->is_admin_email() ) { |
|
228 | + $cc = $email->object->get_email_cc(); |
|
229 | + |
|
230 | + if ( ! empty( $cc ) ) { |
|
231 | + $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
232 | + $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
233 | + } |
|
234 | 234 | |
235 | - } |
|
235 | + } |
|
236 | 236 | |
237 | - return $recipients; |
|
237 | + return $recipients; |
|
238 | 238 | |
239 | - } |
|
239 | + } |
|
240 | 240 | |
241 | - /** |
|
242 | - * Sends a new invoice notification. |
|
243 | - * |
|
244 | - * @param WPInv_Invoice $invoice |
|
245 | - */ |
|
246 | - public function new_invoice( $invoice ) { |
|
241 | + /** |
|
242 | + * Sends a new invoice notification. |
|
243 | + * |
|
244 | + * @param WPInv_Invoice $invoice |
|
245 | + */ |
|
246 | + public function new_invoice( $invoice ) { |
|
247 | 247 | |
248 | - // Only send this email for invoices created via the admin page. |
|
249 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
250 | - return; |
|
251 | - } |
|
248 | + // Only send this email for invoices created via the admin page. |
|
249 | + if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
250 | + return; |
|
251 | + } |
|
252 | 252 | |
253 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
254 | - $recipient = wpinv_get_admin_email(); |
|
253 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
254 | + $recipient = wpinv_get_admin_email(); |
|
255 | 255 | |
256 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
256 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
257 | 257 | |
258 | - } |
|
258 | + } |
|
259 | 259 | |
260 | - /** |
|
261 | - * Sends a cancelled invoice notification. |
|
262 | - * |
|
263 | - * @param WPInv_Invoice $invoice |
|
264 | - */ |
|
265 | - public function cancelled_invoice( $invoice ) { |
|
260 | + /** |
|
261 | + * Sends a cancelled invoice notification. |
|
262 | + * |
|
263 | + * @param WPInv_Invoice $invoice |
|
264 | + */ |
|
265 | + public function cancelled_invoice( $invoice ) { |
|
266 | 266 | |
267 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
268 | - $recipient = wpinv_get_admin_email(); |
|
267 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
268 | + $recipient = wpinv_get_admin_email(); |
|
269 | 269 | |
270 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
270 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
271 | 271 | |
272 | - } |
|
272 | + } |
|
273 | 273 | |
274 | - /** |
|
275 | - * Sends a failed invoice notification. |
|
276 | - * |
|
277 | - * @param WPInv_Invoice $invoice |
|
278 | - */ |
|
279 | - public function failed_invoice( $invoice ) { |
|
274 | + /** |
|
275 | + * Sends a failed invoice notification. |
|
276 | + * |
|
277 | + * @param WPInv_Invoice $invoice |
|
278 | + */ |
|
279 | + public function failed_invoice( $invoice ) { |
|
280 | 280 | |
281 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
282 | - $recipient = wpinv_get_admin_email(); |
|
281 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
282 | + $recipient = wpinv_get_admin_email(); |
|
283 | 283 | |
284 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
284 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
285 | 285 | |
286 | - } |
|
286 | + } |
|
287 | 287 | |
288 | - /** |
|
289 | - * Sends a notification whenever an invoice is put on hold. |
|
290 | - * |
|
291 | - * @param WPInv_Invoice $invoice |
|
292 | - */ |
|
293 | - public function onhold_invoice( $invoice ) { |
|
288 | + /** |
|
289 | + * Sends a notification whenever an invoice is put on hold. |
|
290 | + * |
|
291 | + * @param WPInv_Invoice $invoice |
|
292 | + */ |
|
293 | + public function onhold_invoice( $invoice ) { |
|
294 | 294 | |
295 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
296 | - $recipient = $invoice->get_email(); |
|
295 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
296 | + $recipient = $invoice->get_email(); |
|
297 | 297 | |
298 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
298 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
299 | 299 | |
300 | - } |
|
300 | + } |
|
301 | 301 | |
302 | - /** |
|
303 | - * Sends a notification whenever an invoice is marked as processing payment. |
|
304 | - * |
|
305 | - * @param WPInv_Invoice $invoice |
|
306 | - */ |
|
307 | - public function processing_invoice( $invoice ) { |
|
302 | + /** |
|
303 | + * Sends a notification whenever an invoice is marked as processing payment. |
|
304 | + * |
|
305 | + * @param WPInv_Invoice $invoice |
|
306 | + */ |
|
307 | + public function processing_invoice( $invoice ) { |
|
308 | 308 | |
309 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
310 | - $recipient = $invoice->get_email(); |
|
309 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
310 | + $recipient = $invoice->get_email(); |
|
311 | 311 | |
312 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
312 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
313 | 313 | |
314 | - } |
|
314 | + } |
|
315 | 315 | |
316 | - /** |
|
317 | - * Sends a notification whenever an invoice is paid. |
|
318 | - * |
|
319 | - * @param WPInv_Invoice $invoice |
|
320 | - */ |
|
321 | - public function completed_invoice( $invoice ) { |
|
316 | + /** |
|
317 | + * Sends a notification whenever an invoice is paid. |
|
318 | + * |
|
319 | + * @param WPInv_Invoice $invoice |
|
320 | + */ |
|
321 | + public function completed_invoice( $invoice ) { |
|
322 | 322 | |
323 | - // (Maybe) abort if it is a renewal invoice. |
|
324 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
325 | - return; |
|
326 | - } |
|
323 | + // (Maybe) abort if it is a renewal invoice. |
|
324 | + if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
325 | + return; |
|
326 | + } |
|
327 | 327 | |
328 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
329 | - $recipient = $invoice->get_email(); |
|
328 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
329 | + $recipient = $invoice->get_email(); |
|
330 | 330 | |
331 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
331 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
332 | 332 | |
333 | - } |
|
333 | + } |
|
334 | 334 | |
335 | - /** |
|
336 | - * Sends a notification whenever an invoice is refunded. |
|
337 | - * |
|
338 | - * @param WPInv_Invoice $invoice |
|
339 | - */ |
|
340 | - public function refunded_invoice( $invoice ) { |
|
335 | + /** |
|
336 | + * Sends a notification whenever an invoice is refunded. |
|
337 | + * |
|
338 | + * @param WPInv_Invoice $invoice |
|
339 | + */ |
|
340 | + public function refunded_invoice( $invoice ) { |
|
341 | 341 | |
342 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
343 | - $recipient = $invoice->get_email(); |
|
342 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
343 | + $recipient = $invoice->get_email(); |
|
344 | 344 | |
345 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
345 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
346 | 346 | |
347 | - } |
|
347 | + } |
|
348 | 348 | |
349 | - /** |
|
350 | - * Notifies a user about new invoices |
|
351 | - * |
|
352 | - * @param WPInv_Invoice $invoice |
|
353 | - * @param bool $force |
|
354 | - */ |
|
355 | - public function user_invoice( $invoice, $force = false ) { |
|
349 | + /** |
|
350 | + * Notifies a user about new invoices |
|
351 | + * |
|
352 | + * @param WPInv_Invoice $invoice |
|
353 | + * @param bool $force |
|
354 | + */ |
|
355 | + public function user_invoice( $invoice, $force = false ) { |
|
356 | 356 | |
357 | - if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
358 | - return; |
|
359 | - } |
|
360 | - |
|
361 | - // Only send this email for invoices created via the admin page. |
|
362 | - if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) { |
|
363 | - return; |
|
364 | - } |
|
357 | + if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
358 | + return; |
|
359 | + } |
|
360 | + |
|
361 | + // Only send this email for invoices created via the admin page. |
|
362 | + if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) { |
|
363 | + return; |
|
364 | + } |
|
365 | 365 | |
366 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
367 | - $recipient = $invoice->get_email(); |
|
366 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
367 | + $recipient = $invoice->get_email(); |
|
368 | 368 | |
369 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
369 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
370 | 370 | |
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Checks if an invoice is a payment form invoice. |
|
375 | - * |
|
376 | - * @param int $invoice |
|
377 | - * @return bool |
|
378 | - */ |
|
379 | - public function is_payment_form_invoice( $invoice ) { |
|
380 | - $is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
381 | - return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice ); |
|
382 | - } |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Checks if an invoice is a payment form invoice. |
|
375 | + * |
|
376 | + * @param int $invoice |
|
377 | + * @return bool |
|
378 | + */ |
|
379 | + public function is_payment_form_invoice( $invoice ) { |
|
380 | + $is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
381 | + return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice ); |
|
382 | + } |
|
383 | 383 | |
384 | - /** |
|
385 | - * Notifies admin about new invoice notes |
|
386 | - * |
|
387 | - * @param WPInv_Invoice $invoice |
|
388 | - * @param string $note |
|
389 | - */ |
|
390 | - public function user_note( $invoice, $note ) { |
|
391 | - |
|
392 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
393 | - $recipient = $invoice->get_email(); |
|
384 | + /** |
|
385 | + * Notifies admin about new invoice notes |
|
386 | + * |
|
387 | + * @param WPInv_Invoice $invoice |
|
388 | + * @param string $note |
|
389 | + */ |
|
390 | + public function user_note( $invoice, $note ) { |
|
391 | + |
|
392 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
393 | + $recipient = $invoice->get_email(); |
|
394 | 394 | |
395 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
396 | - |
|
397 | - } |
|
398 | - |
|
399 | - /** |
|
400 | - * (Force) Sends overdue notices. |
|
401 | - * |
|
402 | - * @param WPInv_Invoice $invoice |
|
403 | - */ |
|
404 | - public function force_send_overdue_notice( $invoice ) { |
|
405 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
406 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
407 | - } |
|
408 | - |
|
409 | - /** |
|
410 | - * Sends overdue notices. |
|
411 | - * |
|
412 | - * @TODO: Create an invoices query class. |
|
413 | - */ |
|
414 | - public function overdue() { |
|
415 | - global $wpdb; |
|
416 | - |
|
417 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
418 | - |
|
419 | - // Fetch reminder days. |
|
420 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
421 | - |
|
422 | - // Abort if non is set. |
|
423 | - if ( empty( $reminder_days ) ) { |
|
424 | - return; |
|
425 | - } |
|
426 | - |
|
427 | - // Retrieve date query. |
|
428 | - $date_query = $this->get_date_query( $reminder_days ); |
|
429 | - |
|
430 | - // Invoices table. |
|
431 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
432 | - |
|
433 | - // Fetch invoices. |
|
434 | - $invoices = $wpdb->get_col( |
|
435 | - "SELECT posts.ID FROM $wpdb->posts as posts |
|
395 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
396 | + |
|
397 | + } |
|
398 | + |
|
399 | + /** |
|
400 | + * (Force) Sends overdue notices. |
|
401 | + * |
|
402 | + * @param WPInv_Invoice $invoice |
|
403 | + */ |
|
404 | + public function force_send_overdue_notice( $invoice ) { |
|
405 | + $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
406 | + return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
407 | + } |
|
408 | + |
|
409 | + /** |
|
410 | + * Sends overdue notices. |
|
411 | + * |
|
412 | + * @TODO: Create an invoices query class. |
|
413 | + */ |
|
414 | + public function overdue() { |
|
415 | + global $wpdb; |
|
416 | + |
|
417 | + $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
418 | + |
|
419 | + // Fetch reminder days. |
|
420 | + $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
421 | + |
|
422 | + // Abort if non is set. |
|
423 | + if ( empty( $reminder_days ) ) { |
|
424 | + return; |
|
425 | + } |
|
426 | + |
|
427 | + // Retrieve date query. |
|
428 | + $date_query = $this->get_date_query( $reminder_days ); |
|
429 | + |
|
430 | + // Invoices table. |
|
431 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
432 | + |
|
433 | + // Fetch invoices. |
|
434 | + $invoices = $wpdb->get_col( |
|
435 | + "SELECT posts.ID FROM $wpdb->posts as posts |
|
436 | 436 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
437 | 437 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
438 | 438 | |
439 | - foreach ( $invoices as $invoice ) { |
|
439 | + foreach ( $invoices as $invoice ) { |
|
440 | 440 | |
441 | - // Only send this email for invoices created via the admin page. |
|
442 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
443 | - $invoice = new WPInv_Invoice( $invoice ); |
|
444 | - $email->object = $invoice; |
|
441 | + // Only send this email for invoices created via the admin page. |
|
442 | + if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
443 | + $invoice = new WPInv_Invoice( $invoice ); |
|
444 | + $email->object = $invoice; |
|
445 | 445 | |
446 | - if ( $invoice->needs_payment() ) { |
|
447 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
448 | - } |
|
446 | + if ( $invoice->needs_payment() ) { |
|
447 | + $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
448 | + } |
|
449 | 449 | |
450 | - } |
|
450 | + } |
|
451 | 451 | |
452 | - } |
|
452 | + } |
|
453 | 453 | |
454 | - } |
|
454 | + } |
|
455 | 455 | |
456 | - /** |
|
457 | - * Calculates the date query for an invoices query |
|
458 | - * |
|
459 | - * @param array $reminder_days |
|
460 | - * @return string |
|
461 | - */ |
|
462 | - public function get_date_query( $reminder_days ) { |
|
456 | + /** |
|
457 | + * Calculates the date query for an invoices query |
|
458 | + * |
|
459 | + * @param array $reminder_days |
|
460 | + * @return string |
|
461 | + */ |
|
462 | + public function get_date_query( $reminder_days ) { |
|
463 | 463 | |
464 | - $date_query = array( |
|
465 | - 'relation' => 'OR' |
|
466 | - ); |
|
464 | + $date_query = array( |
|
465 | + 'relation' => 'OR' |
|
466 | + ); |
|
467 | 467 | |
468 | - foreach ( $reminder_days as $days ) { |
|
469 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
468 | + foreach ( $reminder_days as $days ) { |
|
469 | + $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
470 | 470 | |
471 | - $date_query[] = array( |
|
472 | - 'year' => $date['year'], |
|
473 | - 'month' => $date['month'], |
|
474 | - 'day' => $date['day'], |
|
475 | - ); |
|
471 | + $date_query[] = array( |
|
472 | + 'year' => $date['year'], |
|
473 | + 'month' => $date['month'], |
|
474 | + 'day' => $date['day'], |
|
475 | + ); |
|
476 | 476 | |
477 | - } |
|
477 | + } |
|
478 | 478 | |
479 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
479 | + $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
480 | 480 | |
481 | - return $date_query->get_sql(); |
|
481 | + return $date_query->get_sql(); |
|
482 | 482 | |
483 | - } |
|
483 | + } |
|
484 | 484 | |
485 | 485 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,52 +119,52 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $merge_tags = array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field(strtolower($invoice->get_label())), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_label())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - $payment_form_data = $invoice->get_meta( 'payment_form_data', true ); |
|
150 | + $payment_form_data = $invoice->get_meta('payment_form_data', true); |
|
151 | 151 | |
152 | - if ( is_array( $payment_form_data ) ) { |
|
152 | + if (is_array($payment_form_data)) { |
|
153 | 153 | |
154 | - foreach ( $payment_form_data as $label => $value ) { |
|
154 | + foreach ($payment_form_data as $label => $value) { |
|
155 | 155 | |
156 | - $label = preg_replace( '/[^a-z0-9]+/', '_', strtolower( $label ) ); |
|
157 | - $value = is_array( $value ) ? implode( ', ', $value ) : $value; |
|
156 | + $label = preg_replace('/[^a-z0-9]+/', '_', strtolower($label)); |
|
157 | + $value = is_array($value) ? implode(', ', $value) : $value; |
|
158 | 158 | |
159 | - if ( is_scalar ( $value ) ) { |
|
160 | - $merge_tags[ "{{$label}}" ] = wp_kses_post( $value ); |
|
159 | + if (is_scalar($value)) { |
|
160 | + $merge_tags["{{$label}}"] = wp_kses_post($value); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | } |
164 | 164 | |
165 | 165 | } |
166 | 166 | |
167 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
167 | + return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | /** |
@@ -176,12 +176,12 @@ discard block |
||
176 | 176 | * @param string|array $recipients |
177 | 177 | * @param array $extra_args Extra template args. |
178 | 178 | */ |
179 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
179 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
180 | 180 | |
181 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
181 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
182 | 182 | |
183 | - $skip = $invoice->is_free() && wpinv_get_option( 'skip_email_free_invoice' ); |
|
184 | - if ( apply_filters( 'getpaid_skip_invoice_email', $skip, $type, $invoice ) ) { |
|
183 | + $skip = $invoice->is_free() && wpinv_get_option('skip_email_free_invoice'); |
|
184 | + if (apply_filters('getpaid_skip_invoice_email', $skip, $type, $invoice)) { |
|
185 | 185 | return; |
186 | 186 | } |
187 | 187 | |
@@ -189,29 +189,29 @@ discard block |
||
189 | 189 | $merge_tags = $email->get_merge_tags(); |
190 | 190 | |
191 | 191 | $result = $mailer->send( |
192 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
193 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
194 | - $email->get_content( $merge_tags, $extra_args ), |
|
192 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
193 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
194 | + $email->get_content($merge_tags, $extra_args), |
|
195 | 195 | $email->get_attachments() |
196 | 196 | ); |
197 | 197 | |
198 | 198 | // Maybe send a copy to the admin. |
199 | - if ( $email->include_admin_bcc() ) { |
|
199 | + if ($email->include_admin_bcc()) { |
|
200 | 200 | $mailer->send( |
201 | 201 | wpinv_get_admin_email(), |
202 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
203 | - $email->get_content( $merge_tags ), |
|
202 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
203 | + $email->get_content($merge_tags), |
|
204 | 204 | $email->get_attachments() |
205 | 205 | ); |
206 | 206 | } |
207 | 207 | |
208 | - if ( $result ) { |
|
209 | - $invoice->add_note( sprintf( __( 'Successfully sent %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
208 | + if ($result) { |
|
209 | + $invoice->add_note(sprintf(__('Successfully sent %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
210 | 210 | } else { |
211 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
211 | + $invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
212 | 212 | } |
213 | 213 | |
214 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
214 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
215 | 215 | |
216 | 216 | return $result; |
217 | 217 | } |
@@ -222,14 +222,14 @@ discard block |
||
222 | 222 | * @param array $recipients |
223 | 223 | * @param GetPaid_Notification_Email $email |
224 | 224 | */ |
225 | - public function filter_email_recipients( $recipients, $email ) { |
|
225 | + public function filter_email_recipients($recipients, $email) { |
|
226 | 226 | |
227 | - if ( ! $email->is_admin_email() ) { |
|
227 | + if (!$email->is_admin_email()) { |
|
228 | 228 | $cc = $email->object->get_email_cc(); |
229 | 229 | |
230 | - if ( ! empty( $cc ) ) { |
|
231 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
232 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
230 | + if (!empty($cc)) { |
|
231 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
232 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
233 | 233 | } |
234 | 234 | |
235 | 235 | } |
@@ -243,17 +243,17 @@ discard block |
||
243 | 243 | * |
244 | 244 | * @param WPInv_Invoice $invoice |
245 | 245 | */ |
246 | - public function new_invoice( $invoice ) { |
|
246 | + public function new_invoice($invoice) { |
|
247 | 247 | |
248 | 248 | // Only send this email for invoices created via the admin page. |
249 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
249 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
250 | 250 | return; |
251 | 251 | } |
252 | 252 | |
253 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
253 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
254 | 254 | $recipient = wpinv_get_admin_email(); |
255 | 255 | |
256 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
256 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
257 | 257 | |
258 | 258 | } |
259 | 259 | |
@@ -262,12 +262,12 @@ discard block |
||
262 | 262 | * |
263 | 263 | * @param WPInv_Invoice $invoice |
264 | 264 | */ |
265 | - public function cancelled_invoice( $invoice ) { |
|
265 | + public function cancelled_invoice($invoice) { |
|
266 | 266 | |
267 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
267 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
268 | 268 | $recipient = wpinv_get_admin_email(); |
269 | 269 | |
270 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
270 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
271 | 271 | |
272 | 272 | } |
273 | 273 | |
@@ -276,12 +276,12 @@ discard block |
||
276 | 276 | * |
277 | 277 | * @param WPInv_Invoice $invoice |
278 | 278 | */ |
279 | - public function failed_invoice( $invoice ) { |
|
279 | + public function failed_invoice($invoice) { |
|
280 | 280 | |
281 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
281 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
282 | 282 | $recipient = wpinv_get_admin_email(); |
283 | 283 | |
284 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
284 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
285 | 285 | |
286 | 286 | } |
287 | 287 | |
@@ -290,12 +290,12 @@ discard block |
||
290 | 290 | * |
291 | 291 | * @param WPInv_Invoice $invoice |
292 | 292 | */ |
293 | - public function onhold_invoice( $invoice ) { |
|
293 | + public function onhold_invoice($invoice) { |
|
294 | 294 | |
295 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
295 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
296 | 296 | $recipient = $invoice->get_email(); |
297 | 297 | |
298 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
298 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
299 | 299 | |
300 | 300 | } |
301 | 301 | |
@@ -304,12 +304,12 @@ discard block |
||
304 | 304 | * |
305 | 305 | * @param WPInv_Invoice $invoice |
306 | 306 | */ |
307 | - public function processing_invoice( $invoice ) { |
|
307 | + public function processing_invoice($invoice) { |
|
308 | 308 | |
309 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
309 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
310 | 310 | $recipient = $invoice->get_email(); |
311 | 311 | |
312 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
312 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
313 | 313 | |
314 | 314 | } |
315 | 315 | |
@@ -318,17 +318,17 @@ discard block |
||
318 | 318 | * |
319 | 319 | * @param WPInv_Invoice $invoice |
320 | 320 | */ |
321 | - public function completed_invoice( $invoice ) { |
|
321 | + public function completed_invoice($invoice) { |
|
322 | 322 | |
323 | 323 | // (Maybe) abort if it is a renewal invoice. |
324 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
324 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
325 | 325 | return; |
326 | 326 | } |
327 | 327 | |
328 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
328 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
329 | 329 | $recipient = $invoice->get_email(); |
330 | 330 | |
331 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
331 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
332 | 332 | |
333 | 333 | } |
334 | 334 | |
@@ -337,12 +337,12 @@ discard block |
||
337 | 337 | * |
338 | 338 | * @param WPInv_Invoice $invoice |
339 | 339 | */ |
340 | - public function refunded_invoice( $invoice ) { |
|
340 | + public function refunded_invoice($invoice) { |
|
341 | 341 | |
342 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
342 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
343 | 343 | $recipient = $invoice->get_email(); |
344 | 344 | |
345 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
345 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
346 | 346 | |
347 | 347 | } |
348 | 348 | |
@@ -352,21 +352,21 @@ discard block |
||
352 | 352 | * @param WPInv_Invoice $invoice |
353 | 353 | * @param bool $force |
354 | 354 | */ |
355 | - public function user_invoice( $invoice, $force = false ) { |
|
355 | + public function user_invoice($invoice, $force = false) { |
|
356 | 356 | |
357 | - if ( ! empty( $GLOBALS['wpinv_skip_invoice_notification'] ) ) { |
|
357 | + if (!empty($GLOBALS['wpinv_skip_invoice_notification'])) { |
|
358 | 358 | return; |
359 | 359 | } |
360 | 360 | |
361 | 361 | // Only send this email for invoices created via the admin page. |
362 | - if ( ! $invoice->is_type( 'invoice' ) || ( empty( $force ) && $this->is_payment_form_invoice( $invoice->get_id() ) ) ) { |
|
362 | + if (!$invoice->is_type('invoice') || (empty($force) && $this->is_payment_form_invoice($invoice->get_id()))) { |
|
363 | 363 | return; |
364 | 364 | } |
365 | 365 | |
366 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
366 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
367 | 367 | $recipient = $invoice->get_email(); |
368 | 368 | |
369 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
369 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
370 | 370 | |
371 | 371 | } |
372 | 372 | |
@@ -376,9 +376,9 @@ discard block |
||
376 | 376 | * @param int $invoice |
377 | 377 | * @return bool |
378 | 378 | */ |
379 | - public function is_payment_form_invoice( $invoice ) { |
|
380 | - $is_payment_form_invoice = empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
381 | - return apply_filters( 'getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice ); |
|
379 | + public function is_payment_form_invoice($invoice) { |
|
380 | + $is_payment_form_invoice = empty($_GET['getpaid-admin-action']) && ('payment_form' == get_post_meta($invoice, 'wpinv_created_via', true) || 'geodirectory' == get_post_meta($invoice, 'wpinv_created_via', true)); |
|
381 | + return apply_filters('getpaid_invoice_notifications_is_payment_form_invoice', $is_payment_form_invoice, $invoice); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,12 +387,12 @@ discard block |
||
387 | 387 | * @param WPInv_Invoice $invoice |
388 | 388 | * @param string $note |
389 | 389 | */ |
390 | - public function user_note( $invoice, $note ) { |
|
390 | + public function user_note($invoice, $note) { |
|
391 | 391 | |
392 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
392 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
393 | 393 | $recipient = $invoice->get_email(); |
394 | 394 | |
395 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
395 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
396 | 396 | |
397 | 397 | } |
398 | 398 | |
@@ -401,9 +401,9 @@ discard block |
||
401 | 401 | * |
402 | 402 | * @param WPInv_Invoice $invoice |
403 | 403 | */ |
404 | - public function force_send_overdue_notice( $invoice ) { |
|
405 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
406 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
404 | + public function force_send_overdue_notice($invoice) { |
|
405 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
406 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | /** |
@@ -414,37 +414,37 @@ discard block |
||
414 | 414 | public function overdue() { |
415 | 415 | global $wpdb; |
416 | 416 | |
417 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
417 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
418 | 418 | |
419 | 419 | // Fetch reminder days. |
420 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
420 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
421 | 421 | |
422 | 422 | // Abort if non is set. |
423 | - if ( empty( $reminder_days ) ) { |
|
423 | + if (empty($reminder_days)) { |
|
424 | 424 | return; |
425 | 425 | } |
426 | 426 | |
427 | 427 | // Retrieve date query. |
428 | - $date_query = $this->get_date_query( $reminder_days ); |
|
428 | + $date_query = $this->get_date_query($reminder_days); |
|
429 | 429 | |
430 | 430 | // Invoices table. |
431 | 431 | $table = $wpdb->prefix . 'getpaid_invoices'; |
432 | 432 | |
433 | 433 | // Fetch invoices. |
434 | - $invoices = $wpdb->get_col( |
|
434 | + $invoices = $wpdb->get_col( |
|
435 | 435 | "SELECT posts.ID FROM $wpdb->posts as posts |
436 | 436 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
437 | 437 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
438 | 438 | |
439 | - foreach ( $invoices as $invoice ) { |
|
439 | + foreach ($invoices as $invoice) { |
|
440 | 440 | |
441 | 441 | // Only send this email for invoices created via the admin page. |
442 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
443 | - $invoice = new WPInv_Invoice( $invoice ); |
|
442 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
443 | + $invoice = new WPInv_Invoice($invoice); |
|
444 | 444 | $email->object = $invoice; |
445 | 445 | |
446 | - if ( $invoice->needs_payment() ) { |
|
447 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
446 | + if ($invoice->needs_payment()) { |
|
447 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | } |
@@ -459,14 +459,14 @@ discard block |
||
459 | 459 | * @param array $reminder_days |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - public function get_date_query( $reminder_days ) { |
|
462 | + public function get_date_query($reminder_days) { |
|
463 | 463 | |
464 | 464 | $date_query = array( |
465 | 465 | 'relation' => 'OR' |
466 | 466 | ); |
467 | 467 | |
468 | - foreach ( $reminder_days as $days ) { |
|
469 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
468 | + foreach ($reminder_days as $days) { |
|
469 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
470 | 470 | |
471 | 471 | $date_query[] = array( |
472 | 472 | 'year' => $date['year'], |
@@ -476,7 +476,7 @@ discard block |
||
476 | 476 | |
477 | 477 | } |
478 | 478 | |
479 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
479 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
480 | 480 | |
481 | 481 | return $date_query->get_sql(); |
482 | 482 |
@@ -16,165 +16,165 @@ |
||
16 | 16 | */ |
17 | 17 | class GetPaid_MaxMind_Geolocation { |
18 | 18 | |
19 | - /** |
|
20 | - * The service responsible for interacting with the MaxMind database. |
|
21 | - * |
|
22 | - * @var GetPaid_MaxMind_Database_Service |
|
23 | - */ |
|
24 | - private $database_service; |
|
25 | - |
|
26 | - /** |
|
27 | - * Initialize the integration. |
|
28 | - */ |
|
29 | - public function __construct() { |
|
30 | - |
|
31 | - /** |
|
32 | - * Supports overriding the database service to be used. |
|
33 | - * |
|
34 | - * @since 1.0.19 |
|
35 | - * @return mixed|null The geolocation database service. |
|
36 | - */ |
|
37 | - $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null ); |
|
38 | - if ( null === $this->database_service ) { |
|
39 | - $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() ); |
|
40 | - } |
|
41 | - |
|
42 | - // Bind to the scheduled updater action. |
|
43 | - add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) ); |
|
44 | - |
|
45 | - // Bind to the geolocation filter for MaxMind database lookups. |
|
46 | - add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 ); |
|
47 | - |
|
48 | - // Handle maxmind key updates. |
|
49 | - add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) ); |
|
50 | - |
|
51 | - } |
|
52 | - |
|
53 | - /** |
|
54 | - * Get database service. |
|
55 | - * |
|
56 | - * @return GetPaid_MaxMind_Database_Service|null |
|
57 | - */ |
|
58 | - public function get_database_service() { |
|
59 | - return $this->database_service; |
|
60 | - } |
|
61 | - |
|
62 | - /** |
|
63 | - * Checks to make sure that the license key is valid. |
|
64 | - * |
|
65 | - * @param string $license_key The new license key. |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function handle_key_updates( $license_key ) { |
|
69 | - |
|
70 | - // Trim whitespaces and strip slashes. |
|
71 | - $license_key = trim( $license_key ); |
|
72 | - |
|
73 | - // Abort if the license key is empty or unchanged. |
|
74 | - if ( empty( $license_key ) ) { |
|
75 | - return $license_key; |
|
76 | - } |
|
77 | - |
|
78 | - // Abort if a database exists and the license key is unchaged. |
|
79 | - if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) { |
|
80 | - return $license_key; |
|
81 | - } |
|
82 | - |
|
83 | - // Check the license key by attempting to download the Geolocation database. |
|
84 | - $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
85 | - if ( is_wp_error( $tmp_database_path ) ) { |
|
86 | - getpaid_admin()->show_error( $tmp_database_path->get_error_message() ); |
|
87 | - return $license_key; |
|
88 | - } |
|
89 | - |
|
90 | - $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path ); |
|
91 | - |
|
92 | - return $license_key; |
|
93 | - } |
|
94 | - |
|
95 | - /** |
|
96 | - * Updates the database used for geolocation queries. |
|
97 | - * |
|
98 | - * @param string $tmp_database_path Temporary database path. |
|
99 | - */ |
|
100 | - public function update_database( $tmp_database_path = null ) { |
|
101 | - |
|
102 | - // Allow us to easily interact with the filesystem. |
|
103 | - require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
104 | - WP_Filesystem(); |
|
105 | - global $wp_filesystem; |
|
106 | - |
|
107 | - // Remove any existing archives to comply with the MaxMind TOS. |
|
108 | - $target_database_path = $this->database_service->get_database_path(); |
|
109 | - |
|
110 | - // If there's no database path, we can't store the database. |
|
111 | - if ( empty( $target_database_path ) ) { |
|
112 | - return; |
|
113 | - } |
|
114 | - |
|
115 | - if ( $wp_filesystem->exists( $target_database_path ) ) { |
|
116 | - $wp_filesystem->delete( $target_database_path ); |
|
117 | - } |
|
118 | - |
|
119 | - // We can't download a database if there's no license key configured. |
|
120 | - $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
121 | - if ( empty( $license_key ) ) { |
|
122 | - return; |
|
123 | - } |
|
124 | - |
|
125 | - if ( empty( $tmp_database_path ) ) { |
|
126 | - $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
127 | - } |
|
128 | - |
|
129 | - if ( is_wp_error( $tmp_database_path ) ) { |
|
130 | - wpinv_error_log( $tmp_database_path->get_error_message() ); |
|
131 | - return; |
|
132 | - } |
|
133 | - |
|
134 | - // Move the new database into position. |
|
135 | - $wp_filesystem->move( $tmp_database_path, $target_database_path, true ); |
|
136 | - $wp_filesystem->delete( dirname( $tmp_database_path ) ); |
|
137 | - } |
|
138 | - |
|
139 | - /** |
|
140 | - * Performs a geolocation lookup against the MaxMind database for the given IP address. |
|
141 | - * |
|
142 | - * @param array $data Geolocation data. |
|
143 | - * @param string $ip_address The IP address to geolocate. |
|
144 | - * @return array Geolocation including country code, state, city and postcode based on an IP address. |
|
145 | - */ |
|
146 | - public function get_geolocation( $data, $ip_address ) { |
|
147 | - |
|
148 | - if ( ! empty( $data['country'] ) || empty( $ip_address ) ) { |
|
149 | - return $data; |
|
150 | - } |
|
151 | - |
|
152 | - $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address ); |
|
153 | - |
|
154 | - return array( |
|
155 | - 'country' => $country_code, |
|
156 | - 'state' => '', |
|
157 | - 'city' => '', |
|
158 | - 'postcode' => '', |
|
159 | - ); |
|
160 | - |
|
161 | - } |
|
162 | - |
|
163 | - /** |
|
164 | - * Fetches the prefix for the MaxMind database file. |
|
165 | - * |
|
166 | - * @return string |
|
167 | - */ |
|
168 | - private function get_database_prefix() { |
|
169 | - |
|
170 | - $prefix = get_option( 'wpinv_maxmind_database_prefix' ); |
|
171 | - |
|
172 | - if ( empty( $prefix ) ) { |
|
173 | - $prefix = md5( uniqid( 'wpinv' ) ); |
|
174 | - update_option( 'wpinv_maxmind_database_prefix', $prefix ); |
|
175 | - } |
|
176 | - |
|
177 | - return $prefix; |
|
178 | - } |
|
19 | + /** |
|
20 | + * The service responsible for interacting with the MaxMind database. |
|
21 | + * |
|
22 | + * @var GetPaid_MaxMind_Database_Service |
|
23 | + */ |
|
24 | + private $database_service; |
|
25 | + |
|
26 | + /** |
|
27 | + * Initialize the integration. |
|
28 | + */ |
|
29 | + public function __construct() { |
|
30 | + |
|
31 | + /** |
|
32 | + * Supports overriding the database service to be used. |
|
33 | + * |
|
34 | + * @since 1.0.19 |
|
35 | + * @return mixed|null The geolocation database service. |
|
36 | + */ |
|
37 | + $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null ); |
|
38 | + if ( null === $this->database_service ) { |
|
39 | + $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() ); |
|
40 | + } |
|
41 | + |
|
42 | + // Bind to the scheduled updater action. |
|
43 | + add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) ); |
|
44 | + |
|
45 | + // Bind to the geolocation filter for MaxMind database lookups. |
|
46 | + add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 ); |
|
47 | + |
|
48 | + // Handle maxmind key updates. |
|
49 | + add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) ); |
|
50 | + |
|
51 | + } |
|
52 | + |
|
53 | + /** |
|
54 | + * Get database service. |
|
55 | + * |
|
56 | + * @return GetPaid_MaxMind_Database_Service|null |
|
57 | + */ |
|
58 | + public function get_database_service() { |
|
59 | + return $this->database_service; |
|
60 | + } |
|
61 | + |
|
62 | + /** |
|
63 | + * Checks to make sure that the license key is valid. |
|
64 | + * |
|
65 | + * @param string $license_key The new license key. |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function handle_key_updates( $license_key ) { |
|
69 | + |
|
70 | + // Trim whitespaces and strip slashes. |
|
71 | + $license_key = trim( $license_key ); |
|
72 | + |
|
73 | + // Abort if the license key is empty or unchanged. |
|
74 | + if ( empty( $license_key ) ) { |
|
75 | + return $license_key; |
|
76 | + } |
|
77 | + |
|
78 | + // Abort if a database exists and the license key is unchaged. |
|
79 | + if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) { |
|
80 | + return $license_key; |
|
81 | + } |
|
82 | + |
|
83 | + // Check the license key by attempting to download the Geolocation database. |
|
84 | + $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
85 | + if ( is_wp_error( $tmp_database_path ) ) { |
|
86 | + getpaid_admin()->show_error( $tmp_database_path->get_error_message() ); |
|
87 | + return $license_key; |
|
88 | + } |
|
89 | + |
|
90 | + $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path ); |
|
91 | + |
|
92 | + return $license_key; |
|
93 | + } |
|
94 | + |
|
95 | + /** |
|
96 | + * Updates the database used for geolocation queries. |
|
97 | + * |
|
98 | + * @param string $tmp_database_path Temporary database path. |
|
99 | + */ |
|
100 | + public function update_database( $tmp_database_path = null ) { |
|
101 | + |
|
102 | + // Allow us to easily interact with the filesystem. |
|
103 | + require_once ABSPATH . 'wp-admin/includes/file.php'; |
|
104 | + WP_Filesystem(); |
|
105 | + global $wp_filesystem; |
|
106 | + |
|
107 | + // Remove any existing archives to comply with the MaxMind TOS. |
|
108 | + $target_database_path = $this->database_service->get_database_path(); |
|
109 | + |
|
110 | + // If there's no database path, we can't store the database. |
|
111 | + if ( empty( $target_database_path ) ) { |
|
112 | + return; |
|
113 | + } |
|
114 | + |
|
115 | + if ( $wp_filesystem->exists( $target_database_path ) ) { |
|
116 | + $wp_filesystem->delete( $target_database_path ); |
|
117 | + } |
|
118 | + |
|
119 | + // We can't download a database if there's no license key configured. |
|
120 | + $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
121 | + if ( empty( $license_key ) ) { |
|
122 | + return; |
|
123 | + } |
|
124 | + |
|
125 | + if ( empty( $tmp_database_path ) ) { |
|
126 | + $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
127 | + } |
|
128 | + |
|
129 | + if ( is_wp_error( $tmp_database_path ) ) { |
|
130 | + wpinv_error_log( $tmp_database_path->get_error_message() ); |
|
131 | + return; |
|
132 | + } |
|
133 | + |
|
134 | + // Move the new database into position. |
|
135 | + $wp_filesystem->move( $tmp_database_path, $target_database_path, true ); |
|
136 | + $wp_filesystem->delete( dirname( $tmp_database_path ) ); |
|
137 | + } |
|
138 | + |
|
139 | + /** |
|
140 | + * Performs a geolocation lookup against the MaxMind database for the given IP address. |
|
141 | + * |
|
142 | + * @param array $data Geolocation data. |
|
143 | + * @param string $ip_address The IP address to geolocate. |
|
144 | + * @return array Geolocation including country code, state, city and postcode based on an IP address. |
|
145 | + */ |
|
146 | + public function get_geolocation( $data, $ip_address ) { |
|
147 | + |
|
148 | + if ( ! empty( $data['country'] ) || empty( $ip_address ) ) { |
|
149 | + return $data; |
|
150 | + } |
|
151 | + |
|
152 | + $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address ); |
|
153 | + |
|
154 | + return array( |
|
155 | + 'country' => $country_code, |
|
156 | + 'state' => '', |
|
157 | + 'city' => '', |
|
158 | + 'postcode' => '', |
|
159 | + ); |
|
160 | + |
|
161 | + } |
|
162 | + |
|
163 | + /** |
|
164 | + * Fetches the prefix for the MaxMind database file. |
|
165 | + * |
|
166 | + * @return string |
|
167 | + */ |
|
168 | + private function get_database_prefix() { |
|
169 | + |
|
170 | + $prefix = get_option( 'wpinv_maxmind_database_prefix' ); |
|
171 | + |
|
172 | + if ( empty( $prefix ) ) { |
|
173 | + $prefix = md5( uniqid( 'wpinv' ) ); |
|
174 | + update_option( 'wpinv_maxmind_database_prefix', $prefix ); |
|
175 | + } |
|
176 | + |
|
177 | + return $prefix; |
|
178 | + } |
|
179 | 179 | |
180 | 180 | } |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | /** |
13 | 13 | * Uses MaxMind for Geolocation |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | * @since 1.0.19 |
35 | 35 | * @return mixed|null The geolocation database service. |
36 | 36 | */ |
37 | - $this->database_service = apply_filters( 'getpaid_maxmind_geolocation_database_service', null ); |
|
38 | - if ( null === $this->database_service ) { |
|
39 | - $this->database_service = new GetPaid_MaxMind_Database_Service( $this->get_database_prefix() ); |
|
37 | + $this->database_service = apply_filters('getpaid_maxmind_geolocation_database_service', null); |
|
38 | + if (null === $this->database_service) { |
|
39 | + $this->database_service = new GetPaid_MaxMind_Database_Service($this->get_database_prefix()); |
|
40 | 40 | } |
41 | 41 | |
42 | 42 | // Bind to the scheduled updater action. |
43 | - add_action( 'getpaid_update_geoip_databases', array( $this, 'update_database' ) ); |
|
43 | + add_action('getpaid_update_geoip_databases', array($this, 'update_database')); |
|
44 | 44 | |
45 | 45 | // Bind to the geolocation filter for MaxMind database lookups. |
46 | - add_filter( 'getpaid_get_geolocation', array( $this, 'get_geolocation' ), 10, 2 ); |
|
46 | + add_filter('getpaid_get_geolocation', array($this, 'get_geolocation'), 10, 2); |
|
47 | 47 | |
48 | 48 | // Handle maxmind key updates. |
49 | - add_filter( 'wpinv_settings_sanitize_maxmind_license_key', array( $this, 'handle_key_updates' ) ); |
|
49 | + add_filter('wpinv_settings_sanitize_maxmind_license_key', array($this, 'handle_key_updates')); |
|
50 | 50 | |
51 | 51 | } |
52 | 52 | |
@@ -65,29 +65,29 @@ discard block |
||
65 | 65 | * @param string $license_key The new license key. |
66 | 66 | * @return string |
67 | 67 | */ |
68 | - public function handle_key_updates( $license_key ) { |
|
68 | + public function handle_key_updates($license_key) { |
|
69 | 69 | |
70 | 70 | // Trim whitespaces and strip slashes. |
71 | - $license_key = trim( $license_key ); |
|
71 | + $license_key = trim($license_key); |
|
72 | 72 | |
73 | 73 | // Abort if the license key is empty or unchanged. |
74 | - if ( empty( $license_key ) ) { |
|
74 | + if (empty($license_key)) { |
|
75 | 75 | return $license_key; |
76 | 76 | } |
77 | 77 | |
78 | 78 | // Abort if a database exists and the license key is unchaged. |
79 | - if ( file_exists( $this->database_service->get_database_path() && $license_key == wpinv_get_option( 'maxmind_license_key' ) ) ) { |
|
79 | + if (file_exists($this->database_service->get_database_path() && $license_key == wpinv_get_option('maxmind_license_key'))) { |
|
80 | 80 | return $license_key; |
81 | 81 | } |
82 | 82 | |
83 | 83 | // Check the license key by attempting to download the Geolocation database. |
84 | - $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
85 | - if ( is_wp_error( $tmp_database_path ) ) { |
|
86 | - getpaid_admin()->show_error( $tmp_database_path->get_error_message() ); |
|
84 | + $tmp_database_path = $this->database_service->download_database($license_key); |
|
85 | + if (is_wp_error($tmp_database_path)) { |
|
86 | + getpaid_admin()->show_error($tmp_database_path->get_error_message()); |
|
87 | 87 | return $license_key; |
88 | 88 | } |
89 | 89 | |
90 | - $this->update_database( /** @scrutinizer ignore-type */ $tmp_database_path ); |
|
90 | + $this->update_database(/** @scrutinizer ignore-type */ $tmp_database_path); |
|
91 | 91 | |
92 | 92 | return $license_key; |
93 | 93 | } |
@@ -97,7 +97,7 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param string $tmp_database_path Temporary database path. |
99 | 99 | */ |
100 | - public function update_database( $tmp_database_path = null ) { |
|
100 | + public function update_database($tmp_database_path = null) { |
|
101 | 101 | |
102 | 102 | // Allow us to easily interact with the filesystem. |
103 | 103 | require_once ABSPATH . 'wp-admin/includes/file.php'; |
@@ -108,32 +108,32 @@ discard block |
||
108 | 108 | $target_database_path = $this->database_service->get_database_path(); |
109 | 109 | |
110 | 110 | // If there's no database path, we can't store the database. |
111 | - if ( empty( $target_database_path ) ) { |
|
111 | + if (empty($target_database_path)) { |
|
112 | 112 | return; |
113 | 113 | } |
114 | 114 | |
115 | - if ( $wp_filesystem->exists( $target_database_path ) ) { |
|
116 | - $wp_filesystem->delete( $target_database_path ); |
|
115 | + if ($wp_filesystem->exists($target_database_path)) { |
|
116 | + $wp_filesystem->delete($target_database_path); |
|
117 | 117 | } |
118 | 118 | |
119 | 119 | // We can't download a database if there's no license key configured. |
120 | - $license_key = wpinv_get_option( 'maxmind_license_key' ); |
|
121 | - if ( empty( $license_key ) ) { |
|
120 | + $license_key = wpinv_get_option('maxmind_license_key'); |
|
121 | + if (empty($license_key)) { |
|
122 | 122 | return; |
123 | 123 | } |
124 | 124 | |
125 | - if ( empty( $tmp_database_path ) ) { |
|
126 | - $tmp_database_path = $this->database_service->download_database( $license_key ); |
|
125 | + if (empty($tmp_database_path)) { |
|
126 | + $tmp_database_path = $this->database_service->download_database($license_key); |
|
127 | 127 | } |
128 | 128 | |
129 | - if ( is_wp_error( $tmp_database_path ) ) { |
|
130 | - wpinv_error_log( $tmp_database_path->get_error_message() ); |
|
129 | + if (is_wp_error($tmp_database_path)) { |
|
130 | + wpinv_error_log($tmp_database_path->get_error_message()); |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | // Move the new database into position. |
135 | - $wp_filesystem->move( $tmp_database_path, $target_database_path, true ); |
|
136 | - $wp_filesystem->delete( dirname( $tmp_database_path ) ); |
|
135 | + $wp_filesystem->move($tmp_database_path, $target_database_path, true); |
|
136 | + $wp_filesystem->delete(dirname($tmp_database_path)); |
|
137 | 137 | } |
138 | 138 | |
139 | 139 | /** |
@@ -143,13 +143,13 @@ discard block |
||
143 | 143 | * @param string $ip_address The IP address to geolocate. |
144 | 144 | * @return array Geolocation including country code, state, city and postcode based on an IP address. |
145 | 145 | */ |
146 | - public function get_geolocation( $data, $ip_address ) { |
|
146 | + public function get_geolocation($data, $ip_address) { |
|
147 | 147 | |
148 | - if ( ! empty( $data['country'] ) || empty( $ip_address ) ) { |
|
148 | + if (!empty($data['country']) || empty($ip_address)) { |
|
149 | 149 | return $data; |
150 | 150 | } |
151 | 151 | |
152 | - $country_code = $this->database_service->get_iso_country_code_for_ip( $ip_address ); |
|
152 | + $country_code = $this->database_service->get_iso_country_code_for_ip($ip_address); |
|
153 | 153 | |
154 | 154 | return array( |
155 | 155 | 'country' => $country_code, |
@@ -167,11 +167,11 @@ discard block |
||
167 | 167 | */ |
168 | 168 | private function get_database_prefix() { |
169 | 169 | |
170 | - $prefix = get_option( 'wpinv_maxmind_database_prefix' ); |
|
170 | + $prefix = get_option('wpinv_maxmind_database_prefix'); |
|
171 | 171 | |
172 | - if ( empty( $prefix ) ) { |
|
173 | - $prefix = md5( uniqid( 'wpinv' ) ); |
|
174 | - update_option( 'wpinv_maxmind_database_prefix', $prefix ); |
|
172 | + if (empty($prefix)) { |
|
173 | + $prefix = md5(uniqid('wpinv')); |
|
174 | + update_option('wpinv_maxmind_database_prefix', $prefix); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | return $prefix; |