@@ -13,462 +13,462 @@ discard block |
||
13 | 13 | */ |
14 | 14 | abstract class GetPaid_Payment_Gateway { |
15 | 15 | |
16 | - /** |
|
17 | - * Set if the place checkout button should be renamed on selection. |
|
18 | - * |
|
19 | - * @var string |
|
20 | - */ |
|
21 | - public $checkout_button_text; |
|
22 | - |
|
23 | - /** |
|
24 | - * Boolean whether the method is enabled. |
|
25 | - * |
|
26 | - * @var bool |
|
27 | - */ |
|
28 | - public $enabled = true; |
|
29 | - |
|
30 | - /** |
|
31 | - * Payment method id. |
|
32 | - * |
|
33 | - * @var string |
|
34 | - */ |
|
35 | - public $id; |
|
36 | - |
|
37 | - /** |
|
38 | - * Payment method order. |
|
39 | - * |
|
40 | - * @var int |
|
41 | - */ |
|
42 | - public $order = 10; |
|
43 | - |
|
44 | - /** |
|
45 | - * Payment method title for the frontend. |
|
46 | - * |
|
47 | - * @var string |
|
48 | - */ |
|
49 | - public $title; |
|
50 | - |
|
51 | - /** |
|
52 | - * Payment method description for the frontend. |
|
53 | - * |
|
54 | - * @var string |
|
55 | - */ |
|
56 | - public $description; |
|
57 | - |
|
58 | - /** |
|
59 | - * Gateway title. |
|
60 | - * |
|
61 | - * @var string |
|
62 | - */ |
|
63 | - public $method_title = ''; |
|
64 | - |
|
65 | - /** |
|
66 | - * Gateway description. |
|
67 | - * |
|
68 | - * @var string |
|
69 | - */ |
|
70 | - public $method_description = ''; |
|
71 | - |
|
72 | - /** |
|
73 | - * Countries this gateway is allowed for. |
|
74 | - * |
|
75 | - * @var array |
|
76 | - */ |
|
77 | - public $countries; |
|
78 | - |
|
79 | - /** |
|
80 | - * Currencies this gateway is allowed for. |
|
81 | - * |
|
82 | - * @var array |
|
83 | - */ |
|
84 | - public $currencies; |
|
85 | - |
|
86 | - /** |
|
87 | - * Currencies this gateway is not allowed for. |
|
88 | - * |
|
89 | - * @var array |
|
90 | - */ |
|
91 | - public $exclude_currencies; |
|
92 | - |
|
93 | - /** |
|
94 | - * Maximum transaction amount, zero does not define a maximum. |
|
95 | - * |
|
96 | - * @var int |
|
97 | - */ |
|
98 | - public $max_amount = 0; |
|
99 | - |
|
100 | - /** |
|
101 | - * Optional URL to view a transaction. |
|
102 | - * |
|
103 | - * @var string |
|
104 | - */ |
|
105 | - public $view_transaction_url = ''; |
|
106 | - |
|
107 | - /** |
|
108 | - * Optional URL to view a subscription. |
|
109 | - * |
|
110 | - * @var string |
|
111 | - */ |
|
112 | - public $view_subscription_url = ''; |
|
113 | - |
|
114 | - /** |
|
115 | - * Optional label to show for "new payment method" in the payment |
|
116 | - * method/token selection radio selection. |
|
117 | - * |
|
118 | - * @var string |
|
119 | - */ |
|
120 | - public $new_method_label = ''; |
|
121 | - |
|
122 | - /** |
|
123 | - * Contains a user's saved tokens for this gateway. |
|
124 | - * |
|
125 | - * @var array |
|
126 | - */ |
|
127 | - protected $tokens = array(); |
|
128 | - |
|
129 | - /** |
|
130 | - * An array of features that this gateway supports. |
|
131 | - * |
|
132 | - * @var array |
|
133 | - */ |
|
134 | - protected $supports = array(); |
|
135 | - |
|
136 | - /** |
|
137 | - * Class constructor. |
|
138 | - */ |
|
139 | - public function __construct() { |
|
140 | - |
|
141 | - // Register gateway. |
|
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | - |
|
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | - |
|
146 | - // Add support for various features. |
|
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | - } |
|
152 | - |
|
153 | - // Invoice addons. |
|
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | - } |
|
157 | - |
|
158 | - // Gateway settings. |
|
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | - |
|
161 | - // Gateway checkout fiellds. |
|
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | - |
|
164 | - // Process payment. |
|
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | - |
|
167 | - // Change the checkout button text. |
|
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | - } |
|
171 | - |
|
172 | - // Check if a gateway is valid for a given currency. |
|
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | - |
|
175 | - // Generate the transaction url. |
|
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | - |
|
178 | - // Generate the subscription url. |
|
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | - |
|
181 | - // Confirm payments. |
|
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | - |
|
184 | - // Verify IPNs. |
|
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | - |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Checks if this gateway is a given gateway. |
|
191 | - * |
|
192 | - * @since 1.0.19 |
|
193 | - * @return bool |
|
194 | - */ |
|
195 | - public function is( $gateway ) { |
|
196 | - return $gateway == $this->id; |
|
197 | - } |
|
198 | - |
|
199 | - /** |
|
200 | - * Returns a users saved tokens for this gateway. |
|
201 | - * |
|
202 | - * @since 1.0.19 |
|
203 | - * @return array |
|
204 | - */ |
|
205 | - public function get_tokens( $sandbox = null ) { |
|
206 | - |
|
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | - |
|
210 | - if ( is_array( $tokens ) ) { |
|
211 | - $this->tokens = $tokens; |
|
212 | - } |
|
16 | + /** |
|
17 | + * Set if the place checkout button should be renamed on selection. |
|
18 | + * |
|
19 | + * @var string |
|
20 | + */ |
|
21 | + public $checkout_button_text; |
|
22 | + |
|
23 | + /** |
|
24 | + * Boolean whether the method is enabled. |
|
25 | + * |
|
26 | + * @var bool |
|
27 | + */ |
|
28 | + public $enabled = true; |
|
29 | + |
|
30 | + /** |
|
31 | + * Payment method id. |
|
32 | + * |
|
33 | + * @var string |
|
34 | + */ |
|
35 | + public $id; |
|
36 | + |
|
37 | + /** |
|
38 | + * Payment method order. |
|
39 | + * |
|
40 | + * @var int |
|
41 | + */ |
|
42 | + public $order = 10; |
|
43 | + |
|
44 | + /** |
|
45 | + * Payment method title for the frontend. |
|
46 | + * |
|
47 | + * @var string |
|
48 | + */ |
|
49 | + public $title; |
|
50 | + |
|
51 | + /** |
|
52 | + * Payment method description for the frontend. |
|
53 | + * |
|
54 | + * @var string |
|
55 | + */ |
|
56 | + public $description; |
|
57 | + |
|
58 | + /** |
|
59 | + * Gateway title. |
|
60 | + * |
|
61 | + * @var string |
|
62 | + */ |
|
63 | + public $method_title = ''; |
|
64 | + |
|
65 | + /** |
|
66 | + * Gateway description. |
|
67 | + * |
|
68 | + * @var string |
|
69 | + */ |
|
70 | + public $method_description = ''; |
|
71 | + |
|
72 | + /** |
|
73 | + * Countries this gateway is allowed for. |
|
74 | + * |
|
75 | + * @var array |
|
76 | + */ |
|
77 | + public $countries; |
|
78 | + |
|
79 | + /** |
|
80 | + * Currencies this gateway is allowed for. |
|
81 | + * |
|
82 | + * @var array |
|
83 | + */ |
|
84 | + public $currencies; |
|
85 | + |
|
86 | + /** |
|
87 | + * Currencies this gateway is not allowed for. |
|
88 | + * |
|
89 | + * @var array |
|
90 | + */ |
|
91 | + public $exclude_currencies; |
|
92 | + |
|
93 | + /** |
|
94 | + * Maximum transaction amount, zero does not define a maximum. |
|
95 | + * |
|
96 | + * @var int |
|
97 | + */ |
|
98 | + public $max_amount = 0; |
|
99 | + |
|
100 | + /** |
|
101 | + * Optional URL to view a transaction. |
|
102 | + * |
|
103 | + * @var string |
|
104 | + */ |
|
105 | + public $view_transaction_url = ''; |
|
106 | + |
|
107 | + /** |
|
108 | + * Optional URL to view a subscription. |
|
109 | + * |
|
110 | + * @var string |
|
111 | + */ |
|
112 | + public $view_subscription_url = ''; |
|
113 | + |
|
114 | + /** |
|
115 | + * Optional label to show for "new payment method" in the payment |
|
116 | + * method/token selection radio selection. |
|
117 | + * |
|
118 | + * @var string |
|
119 | + */ |
|
120 | + public $new_method_label = ''; |
|
121 | + |
|
122 | + /** |
|
123 | + * Contains a user's saved tokens for this gateway. |
|
124 | + * |
|
125 | + * @var array |
|
126 | + */ |
|
127 | + protected $tokens = array(); |
|
128 | + |
|
129 | + /** |
|
130 | + * An array of features that this gateway supports. |
|
131 | + * |
|
132 | + * @var array |
|
133 | + */ |
|
134 | + protected $supports = array(); |
|
135 | + |
|
136 | + /** |
|
137 | + * Class constructor. |
|
138 | + */ |
|
139 | + public function __construct() { |
|
140 | + |
|
141 | + // Register gateway. |
|
142 | + add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
143 | + |
|
144 | + $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
145 | + |
|
146 | + // Add support for various features. |
|
147 | + foreach ( $this->supports as $feature ) { |
|
148 | + add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | + add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | + add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
151 | + } |
|
152 | + |
|
153 | + // Invoice addons. |
|
154 | + if ( $this->supports( 'addons' ) ) { |
|
155 | + add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
156 | + } |
|
157 | + |
|
158 | + // Gateway settings. |
|
159 | + add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
160 | + |
|
161 | + // Gateway checkout fiellds. |
|
162 | + add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
163 | + |
|
164 | + // Process payment. |
|
165 | + add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
166 | + |
|
167 | + // Change the checkout button text. |
|
168 | + if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | + add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
170 | + } |
|
171 | + |
|
172 | + // Check if a gateway is valid for a given currency. |
|
173 | + add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
174 | + |
|
175 | + // Generate the transaction url. |
|
176 | + add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
177 | + |
|
178 | + // Generate the subscription url. |
|
179 | + add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
180 | + |
|
181 | + // Confirm payments. |
|
182 | + add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
183 | + |
|
184 | + // Verify IPNs. |
|
185 | + add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
186 | + |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Checks if this gateway is a given gateway. |
|
191 | + * |
|
192 | + * @since 1.0.19 |
|
193 | + * @return bool |
|
194 | + */ |
|
195 | + public function is( $gateway ) { |
|
196 | + return $gateway == $this->id; |
|
197 | + } |
|
198 | + |
|
199 | + /** |
|
200 | + * Returns a users saved tokens for this gateway. |
|
201 | + * |
|
202 | + * @since 1.0.19 |
|
203 | + * @return array |
|
204 | + */ |
|
205 | + public function get_tokens( $sandbox = null ) { |
|
206 | + |
|
207 | + if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | + $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
209 | + |
|
210 | + if ( is_array( $tokens ) ) { |
|
211 | + $this->tokens = $tokens; |
|
212 | + } |
|
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
216 | - return $this->tokens; |
|
217 | - } |
|
218 | - |
|
219 | - // Filter tokens. |
|
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
222 | - |
|
223 | - } |
|
224 | - |
|
225 | - /** |
|
226 | - * Saves a token for this gateway. |
|
227 | - * |
|
228 | - * @since 1.0.19 |
|
229 | - */ |
|
230 | - public function save_token( $token ) { |
|
231 | - |
|
232 | - $tokens = $this->get_tokens(); |
|
233 | - $tokens[] = $token; |
|
234 | - |
|
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | - |
|
237 | - $this->tokens = $tokens; |
|
238 | - |
|
239 | - } |
|
240 | - |
|
241 | - /** |
|
242 | - * Return the title for admin screens. |
|
243 | - * |
|
244 | - * @return string |
|
245 | - */ |
|
246 | - public function get_method_title() { |
|
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | - } |
|
249 | - |
|
250 | - /** |
|
251 | - * Return the description for admin screens. |
|
252 | - * |
|
253 | - * @return string |
|
254 | - */ |
|
255 | - public function get_method_description() { |
|
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | - } |
|
258 | - |
|
259 | - /** |
|
260 | - * Get the success url. |
|
261 | - * |
|
262 | - * @param WPInv_Invoice $invoice Invoice object. |
|
263 | - * @return string |
|
264 | - */ |
|
265 | - public function get_return_url( $invoice ) { |
|
266 | - |
|
267 | - // Payment success url |
|
268 | - $return_url = add_query_arg( |
|
269 | - array( |
|
270 | - 'payment-confirm' => $this->id, |
|
271 | - 'invoice_key' => $invoice->get_key(), |
|
272 | - 'utm_nooverride' => 1, |
|
273 | - ), |
|
274 | - wpinv_get_success_page_uri() |
|
275 | - ); |
|
276 | - |
|
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Confirms payments when rendering the success page. |
|
282 | - * |
|
283 | - * @param string $content Success page content. |
|
284 | - * @return string |
|
285 | - */ |
|
286 | - public function confirm_payment( $content ) { |
|
287 | - |
|
288 | - // Retrieve the invoice. |
|
289 | - $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | - |
|
292 | - // Ensure that it exists and that it is pending payment. |
|
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | - return $content; |
|
295 | - } |
|
296 | - |
|
297 | - // Can the user view this invoice?? |
|
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | - return $content; |
|
300 | - } |
|
301 | - |
|
302 | - // Show payment processing indicator. |
|
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | - } |
|
305 | - |
|
306 | - /** |
|
307 | - * Processes ipns and marks payments as complete. |
|
308 | - * |
|
309 | - * @return void |
|
310 | - */ |
|
311 | - public function verify_ipn() {} |
|
312 | - |
|
313 | - /** |
|
314 | - * Processes invoice addons. |
|
315 | - * |
|
316 | - * @param WPInv_Invoice $invoice |
|
317 | - * @param GetPaid_Form_Item[] $items |
|
318 | - * @return WPInv_Invoice |
|
319 | - */ |
|
320 | - public function process_addons( $invoice, $items ) { |
|
321 | - |
|
322 | - } |
|
323 | - |
|
324 | - /** |
|
325 | - * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | - * |
|
327 | - * @param string $transaction_url transaction url. |
|
328 | - * @param WPInv_Invoice $invoice Invoice object. |
|
329 | - * @return string transaction URL, or empty string. |
|
330 | - */ |
|
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | - |
|
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
334 | - |
|
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | - } |
|
340 | - |
|
341 | - return $transaction_url; |
|
342 | - } |
|
343 | - |
|
344 | - /** |
|
345 | - * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | - * |
|
347 | - * @param string $subscription_url transaction url. |
|
348 | - * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | - * @return string subscription URL, or empty string. |
|
350 | - */ |
|
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | - |
|
353 | - $profile_id = $subscription->get_profile_id(); |
|
354 | - |
|
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | - |
|
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | - |
|
361 | - } |
|
362 | - |
|
363 | - return $subscription_url; |
|
364 | - } |
|
365 | - |
|
366 | - /** |
|
367 | - * Check if the gateway is available for use. |
|
368 | - * |
|
369 | - * @return bool |
|
370 | - */ |
|
371 | - public function is_available() { |
|
372 | - return ! empty( $this->enabled ); |
|
373 | - } |
|
374 | - |
|
375 | - /** |
|
376 | - * Return the gateway's title. |
|
377 | - * |
|
378 | - * @return string |
|
379 | - */ |
|
380 | - public function get_title() { |
|
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | - } |
|
383 | - |
|
384 | - /** |
|
385 | - * Return the gateway's description. |
|
386 | - * |
|
387 | - * @return string |
|
388 | - */ |
|
389 | - public function get_description() { |
|
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | - } |
|
392 | - |
|
393 | - /** |
|
394 | - * Process Payment. |
|
395 | - * |
|
396 | - * |
|
397 | - * @param WPInv_Invoice $invoice Invoice. |
|
398 | - * @param array $submission_data Posted checkout fields. |
|
399 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | - * @return void |
|
401 | - */ |
|
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | - // Process the payment then either redirect to the success page or the gateway. |
|
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | - } |
|
406 | - |
|
407 | - /** |
|
408 | - * Process refund. |
|
409 | - * |
|
410 | - * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | - * a passed in amount. |
|
412 | - * |
|
413 | - * @param WPInv_Invoice $invoice Invoice. |
|
414 | - * @param float $amount Refund amount. |
|
415 | - * @param string $reason Refund reason. |
|
416 | - * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | - */ |
|
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Displays the payment fields, credit cards etc. |
|
424 | - * |
|
425 | - * @param int $invoice_id 0 or invoice id. |
|
426 | - * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | - */ |
|
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | - } |
|
431 | - |
|
432 | - /** |
|
433 | - * Filters the gateway settings. |
|
434 | - * |
|
435 | - * @param array $admin_settings |
|
436 | - */ |
|
437 | - public function admin_settings( $admin_settings ) { |
|
438 | - return $admin_settings; |
|
439 | - } |
|
440 | - |
|
441 | - /** |
|
442 | - * Retrieves the value of a gateway setting. |
|
443 | - * |
|
444 | - * @param string $option |
|
445 | - */ |
|
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | - } |
|
449 | - |
|
450 | - /** |
|
451 | - * Check if a gateway supports a given feature. |
|
452 | - * |
|
453 | - * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | - * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | - * |
|
456 | - * @param string $feature string The name of a feature to test support for. |
|
457 | - * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | - * @since 1.0.19 |
|
459 | - */ |
|
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | - } |
|
463 | - |
|
464 | - /** |
|
465 | - * Returns the credit card form html. |
|
466 | - * |
|
467 | - * @param bool $save whether or not to display the save button. |
|
468 | - */ |
|
215 | + if ( ! is_bool( $sandbox ) ) { |
|
216 | + return $this->tokens; |
|
217 | + } |
|
218 | + |
|
219 | + // Filter tokens. |
|
220 | + $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | + return wp_list_filter( $this->tokens, $args ); |
|
222 | + |
|
223 | + } |
|
224 | + |
|
225 | + /** |
|
226 | + * Saves a token for this gateway. |
|
227 | + * |
|
228 | + * @since 1.0.19 |
|
229 | + */ |
|
230 | + public function save_token( $token ) { |
|
231 | + |
|
232 | + $tokens = $this->get_tokens(); |
|
233 | + $tokens[] = $token; |
|
234 | + |
|
235 | + update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
236 | + |
|
237 | + $this->tokens = $tokens; |
|
238 | + |
|
239 | + } |
|
240 | + |
|
241 | + /** |
|
242 | + * Return the title for admin screens. |
|
243 | + * |
|
244 | + * @return string |
|
245 | + */ |
|
246 | + public function get_method_title() { |
|
247 | + return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
248 | + } |
|
249 | + |
|
250 | + /** |
|
251 | + * Return the description for admin screens. |
|
252 | + * |
|
253 | + * @return string |
|
254 | + */ |
|
255 | + public function get_method_description() { |
|
256 | + return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
257 | + } |
|
258 | + |
|
259 | + /** |
|
260 | + * Get the success url. |
|
261 | + * |
|
262 | + * @param WPInv_Invoice $invoice Invoice object. |
|
263 | + * @return string |
|
264 | + */ |
|
265 | + public function get_return_url( $invoice ) { |
|
266 | + |
|
267 | + // Payment success url |
|
268 | + $return_url = add_query_arg( |
|
269 | + array( |
|
270 | + 'payment-confirm' => $this->id, |
|
271 | + 'invoice_key' => $invoice->get_key(), |
|
272 | + 'utm_nooverride' => 1, |
|
273 | + ), |
|
274 | + wpinv_get_success_page_uri() |
|
275 | + ); |
|
276 | + |
|
277 | + return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Confirms payments when rendering the success page. |
|
282 | + * |
|
283 | + * @param string $content Success page content. |
|
284 | + * @return string |
|
285 | + */ |
|
286 | + public function confirm_payment( $content ) { |
|
287 | + |
|
288 | + // Retrieve the invoice. |
|
289 | + $invoice_id = getpaid_get_current_invoice_id(); |
|
290 | + $invoice = wpinv_get_invoice( $invoice_id ); |
|
291 | + |
|
292 | + // Ensure that it exists and that it is pending payment. |
|
293 | + if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
294 | + return $content; |
|
295 | + } |
|
296 | + |
|
297 | + // Can the user view this invoice?? |
|
298 | + if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
299 | + return $content; |
|
300 | + } |
|
301 | + |
|
302 | + // Show payment processing indicator. |
|
303 | + return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
304 | + } |
|
305 | + |
|
306 | + /** |
|
307 | + * Processes ipns and marks payments as complete. |
|
308 | + * |
|
309 | + * @return void |
|
310 | + */ |
|
311 | + public function verify_ipn() {} |
|
312 | + |
|
313 | + /** |
|
314 | + * Processes invoice addons. |
|
315 | + * |
|
316 | + * @param WPInv_Invoice $invoice |
|
317 | + * @param GetPaid_Form_Item[] $items |
|
318 | + * @return WPInv_Invoice |
|
319 | + */ |
|
320 | + public function process_addons( $invoice, $items ) { |
|
321 | + |
|
322 | + } |
|
323 | + |
|
324 | + /** |
|
325 | + * Get a link to the transaction on the 3rd party gateway site (if applicable). |
|
326 | + * |
|
327 | + * @param string $transaction_url transaction url. |
|
328 | + * @param WPInv_Invoice $invoice Invoice object. |
|
329 | + * @return string transaction URL, or empty string. |
|
330 | + */ |
|
331 | + public function filter_transaction_url( $transaction_url, $invoice ) { |
|
332 | + |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | + |
|
335 | + if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | + $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | + $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
339 | + } |
|
340 | + |
|
341 | + return $transaction_url; |
|
342 | + } |
|
343 | + |
|
344 | + /** |
|
345 | + * Get a link to the subscription on the 3rd party gateway site (if applicable). |
|
346 | + * |
|
347 | + * @param string $subscription_url transaction url. |
|
348 | + * @param WPInv_Subscription $subscription Subscription objectt. |
|
349 | + * @return string subscription URL, or empty string. |
|
350 | + */ |
|
351 | + public function generate_subscription_url( $subscription_url, $subscription ) { |
|
352 | + |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | + |
|
355 | + if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
356 | + |
|
357 | + $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | + $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
360 | + |
|
361 | + } |
|
362 | + |
|
363 | + return $subscription_url; |
|
364 | + } |
|
365 | + |
|
366 | + /** |
|
367 | + * Check if the gateway is available for use. |
|
368 | + * |
|
369 | + * @return bool |
|
370 | + */ |
|
371 | + public function is_available() { |
|
372 | + return ! empty( $this->enabled ); |
|
373 | + } |
|
374 | + |
|
375 | + /** |
|
376 | + * Return the gateway's title. |
|
377 | + * |
|
378 | + * @return string |
|
379 | + */ |
|
380 | + public function get_title() { |
|
381 | + return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
382 | + } |
|
383 | + |
|
384 | + /** |
|
385 | + * Return the gateway's description. |
|
386 | + * |
|
387 | + * @return string |
|
388 | + */ |
|
389 | + public function get_description() { |
|
390 | + return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
391 | + } |
|
392 | + |
|
393 | + /** |
|
394 | + * Process Payment. |
|
395 | + * |
|
396 | + * |
|
397 | + * @param WPInv_Invoice $invoice Invoice. |
|
398 | + * @param array $submission_data Posted checkout fields. |
|
399 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
400 | + * @return void |
|
401 | + */ |
|
402 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
403 | + // Process the payment then either redirect to the success page or the gateway. |
|
404 | + do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
405 | + } |
|
406 | + |
|
407 | + /** |
|
408 | + * Process refund. |
|
409 | + * |
|
410 | + * If the gateway declares 'refunds' support, this will allow it to refund. |
|
411 | + * a passed in amount. |
|
412 | + * |
|
413 | + * @param WPInv_Invoice $invoice Invoice. |
|
414 | + * @param float $amount Refund amount. |
|
415 | + * @param string $reason Refund reason. |
|
416 | + * @return WP_Error|bool True or false based on success, or a WP_Error object. |
|
417 | + */ |
|
418 | + public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | + return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Displays the payment fields, credit cards etc. |
|
424 | + * |
|
425 | + * @param int $invoice_id 0 or invoice id. |
|
426 | + * @param GetPaid_Payment_Form $form Current payment form. |
|
427 | + */ |
|
428 | + public function payment_fields( $invoice_id, $form ) { |
|
429 | + do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
430 | + } |
|
431 | + |
|
432 | + /** |
|
433 | + * Filters the gateway settings. |
|
434 | + * |
|
435 | + * @param array $admin_settings |
|
436 | + */ |
|
437 | + public function admin_settings( $admin_settings ) { |
|
438 | + return $admin_settings; |
|
439 | + } |
|
440 | + |
|
441 | + /** |
|
442 | + * Retrieves the value of a gateway setting. |
|
443 | + * |
|
444 | + * @param string $option |
|
445 | + */ |
|
446 | + public function get_option( $option, $default = false ) { |
|
447 | + return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
448 | + } |
|
449 | + |
|
450 | + /** |
|
451 | + * Check if a gateway supports a given feature. |
|
452 | + * |
|
453 | + * Gateways should override this to declare support (or lack of support) for a feature. |
|
454 | + * For backward compatibility, gateways support 'products' by default, but nothing else. |
|
455 | + * |
|
456 | + * @param string $feature string The name of a feature to test support for. |
|
457 | + * @return bool True if the gateway supports the feature, false otherwise. |
|
458 | + * @since 1.0.19 |
|
459 | + */ |
|
460 | + public function supports( $feature ) { |
|
461 | + return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
462 | + } |
|
463 | + |
|
464 | + /** |
|
465 | + * Returns the credit card form html. |
|
466 | + * |
|
467 | + * @param bool $save whether or not to display the save button. |
|
468 | + */ |
|
469 | 469 | public function get_cc_form( $save = false ) { |
470 | 470 | |
471 | - ob_start(); |
|
471 | + ob_start(); |
|
472 | 472 | |
473 | 473 | $id_prefix = esc_attr( uniqid( $this->id ) ); |
474 | 474 | |
@@ -486,7 +486,7 @@ discard block |
||
486 | 486 | '11' => __( 'November', 'invoicing' ), |
487 | 487 | '12' => __( 'December', 'invoicing' ), |
488 | 488 | ); |
489 | - $months = apply_filters( 'getpaid_cc_months', $months, $this ); |
|
489 | + $months = apply_filters( 'getpaid_cc_months', $months, $this ); |
|
490 | 490 | |
491 | 491 | $year = (int) current_time( 'Y' ); |
492 | 492 | $years = array(); |
@@ -495,7 +495,7 @@ discard block |
||
495 | 495 | $years[ $year + $i ] = $year + $i; |
496 | 496 | } |
497 | 497 | |
498 | - $years = apply_filters( 'getpaid_cc_years', $years, $this ); |
|
498 | + $years = apply_filters( 'getpaid_cc_years', $years, $this ); |
|
499 | 499 | |
500 | 500 | ?> |
501 | 501 | <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1"> |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | |
532 | 532 | <?php |
533 | 533 | foreach ( $months as $key => $month ) { |
534 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . '</option>'; |
|
534 | + echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . '</option>'; |
|
535 | 535 | } |
536 | 536 | ?> |
537 | 537 | |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | |
545 | 545 | <?php |
546 | 546 | foreach ( $years as $key => $year ) { |
547 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . '</option>'; |
|
547 | + echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . '</option>'; |
|
548 | 548 | } |
549 | 549 | ?> |
550 | 550 | |
@@ -562,13 +562,13 @@ discard block |
||
562 | 562 | 'name' => $this->id . '[cc_cvv2]', |
563 | 563 | 'id' => "$id_prefix-cc-cvv2", |
564 | 564 | 'label' => __( 'CCV', 'invoicing' ), |
565 | - 'label_type' => 'vertical', |
|
566 | - 'class' => 'form-control-sm', |
|
567 | - 'extra_attributes' => array( |
|
568 | - 'autocomplete' => 'cc-csc', |
|
569 | - ), |
|
565 | + 'label_type' => 'vertical', |
|
566 | + 'class' => 'form-control-sm', |
|
567 | + 'extra_attributes' => array( |
|
568 | + 'autocomplete' => 'cc-csc', |
|
569 | + ), |
|
570 | 570 | ), |
571 | - true |
|
571 | + true |
|
572 | 572 | ); |
573 | 573 | ?> |
574 | 574 | </div> |
@@ -577,192 +577,192 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
581 | - $this->save_payment_method_checkbox(); |
|
582 | - } |
|
580 | + if ( $save ) { |
|
581 | + $this->save_payment_method_checkbox(); |
|
582 | + } |
|
583 | 583 | |
584 | - ?> |
|
584 | + ?> |
|
585 | 585 | </div> |
586 | 586 | |
587 | 587 | </div> |
588 | 588 | <?php |
589 | 589 | |
590 | - return ob_get_clean(); |
|
590 | + return ob_get_clean(); |
|
591 | + |
|
592 | + } |
|
593 | + |
|
594 | + /** |
|
595 | + * Displays a new payment method entry form. |
|
596 | + * |
|
597 | + * @since 1.0.19 |
|
598 | + */ |
|
599 | + public function new_payment_method_entry( $form ) { |
|
600 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . '</div>'; |
|
601 | + } |
|
602 | + |
|
603 | + /** |
|
604 | + * Grab and display our saved payment methods. |
|
605 | + * |
|
606 | + * @since 1.0.19 |
|
607 | + */ |
|
608 | + public function saved_payment_methods() { |
|
609 | + echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
610 | + |
|
611 | + foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | + $this->get_saved_payment_method_option_html( $token ); |
|
613 | + } |
|
614 | + |
|
615 | + $this->get_new_payment_method_option_html(); |
|
616 | + echo '</ul>'; |
|
591 | 617 | |
592 | 618 | } |
593 | 619 | |
594 | - /** |
|
595 | - * Displays a new payment method entry form. |
|
596 | - * |
|
597 | - * @since 1.0.19 |
|
598 | - */ |
|
599 | - public function new_payment_method_entry( $form ) { |
|
600 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . '</div>'; |
|
601 | - } |
|
602 | - |
|
603 | - /** |
|
604 | - * Grab and display our saved payment methods. |
|
605 | - * |
|
606 | - * @since 1.0.19 |
|
607 | - */ |
|
608 | - public function saved_payment_methods() { |
|
609 | - echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
610 | - |
|
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $this->get_saved_payment_method_option_html( $token ); |
|
613 | - } |
|
614 | - |
|
615 | - $this->get_new_payment_method_option_html(); |
|
616 | - echo '</ul>'; |
|
617 | - |
|
618 | - } |
|
619 | - |
|
620 | - /** |
|
621 | - * Gets saved payment method HTML from a token. |
|
622 | - * |
|
623 | - * @since 1.0.19 |
|
624 | - * @param array $token Payment Token. |
|
625 | - * @return string Generated payment method HTML |
|
626 | - */ |
|
627 | - public function get_saved_payment_method_option_html( $token ) { |
|
628 | - |
|
629 | - printf( |
|
630 | - '<li class="getpaid-payment-method form-group mb-3"> |
|
620 | + /** |
|
621 | + * Gets saved payment method HTML from a token. |
|
622 | + * |
|
623 | + * @since 1.0.19 |
|
624 | + * @param array $token Payment Token. |
|
625 | + * @return string Generated payment method HTML |
|
626 | + */ |
|
627 | + public function get_saved_payment_method_option_html( $token ) { |
|
628 | + |
|
629 | + printf( |
|
630 | + '<li class="getpaid-payment-method form-group mb-3"> |
|
631 | 631 | <label> |
632 | 632 | <input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s /> |
633 | 633 | <span>%3$s</span> |
634 | 634 | </label> |
635 | 635 | </li>', |
636 | - esc_attr( $this->id ), |
|
637 | - esc_attr( $token['id'] ), |
|
638 | - esc_html( $token['name'] ), |
|
639 | - checked( empty( $token['default'] ), false, false ), |
|
640 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
641 | - ); |
|
642 | - |
|
643 | - } |
|
644 | - |
|
645 | - /** |
|
646 | - * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
647 | - * |
|
648 | - * @since 1.0.19 |
|
649 | - */ |
|
650 | - public function get_new_payment_method_option_html() { |
|
651 | - |
|
652 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
653 | - |
|
654 | - printf( |
|
655 | - '<li class="getpaid-new-payment-method"> |
|
636 | + esc_attr( $this->id ), |
|
637 | + esc_attr( $token['id'] ), |
|
638 | + esc_html( $token['name'] ), |
|
639 | + checked( empty( $token['default'] ), false, false ), |
|
640 | + empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
641 | + ); |
|
642 | + |
|
643 | + } |
|
644 | + |
|
645 | + /** |
|
646 | + * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method. |
|
647 | + * |
|
648 | + * @since 1.0.19 |
|
649 | + */ |
|
650 | + public function get_new_payment_method_option_html() { |
|
651 | + |
|
652 | + $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
653 | + |
|
654 | + printf( |
|
655 | + '<li class="getpaid-new-payment-method"> |
|
656 | 656 | <label> |
657 | 657 | <input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" /> |
658 | 658 | <span>%2$s</span> |
659 | 659 | </label> |
660 | 660 | </li>', |
661 | - esc_attr( $this->id ), |
|
662 | - esc_html( $label ) |
|
663 | - ); |
|
664 | - |
|
665 | - } |
|
666 | - |
|
667 | - /** |
|
668 | - * Outputs a checkbox for saving a new payment method to the database. |
|
669 | - * |
|
670 | - * @since 1.0.19 |
|
671 | - */ |
|
672 | - public function save_payment_method_checkbox() { |
|
673 | - |
|
674 | - aui()->input( |
|
675 | - array( |
|
676 | - 'type' => 'checkbox', |
|
677 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
678 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
679 | - 'required' => false, |
|
680 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
681 | - 'value' => 'true', |
|
682 | - 'checked' => true, |
|
683 | - 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
684 | - ), |
|
685 | - true |
|
686 | - ); |
|
687 | - |
|
688 | - } |
|
689 | - |
|
690 | - /** |
|
691 | - * Registers the gateway. |
|
692 | - * |
|
693 | - * @return array |
|
694 | - */ |
|
695 | - public function register_gateway( $gateways ) { |
|
696 | - |
|
697 | - $gateways[ $this->id ] = array( |
|
698 | - |
|
699 | - 'admin_label' => $this->method_title, |
|
661 | + esc_attr( $this->id ), |
|
662 | + esc_html( $label ) |
|
663 | + ); |
|
664 | + |
|
665 | + } |
|
666 | + |
|
667 | + /** |
|
668 | + * Outputs a checkbox for saving a new payment method to the database. |
|
669 | + * |
|
670 | + * @since 1.0.19 |
|
671 | + */ |
|
672 | + public function save_payment_method_checkbox() { |
|
673 | + |
|
674 | + aui()->input( |
|
675 | + array( |
|
676 | + 'type' => 'checkbox', |
|
677 | + 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
678 | + 'id' => esc_attr( uniqid( $this->id ) ), |
|
679 | + 'required' => false, |
|
680 | + 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
681 | + 'value' => 'true', |
|
682 | + 'checked' => true, |
|
683 | + 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
|
684 | + ), |
|
685 | + true |
|
686 | + ); |
|
687 | + |
|
688 | + } |
|
689 | + |
|
690 | + /** |
|
691 | + * Registers the gateway. |
|
692 | + * |
|
693 | + * @return array |
|
694 | + */ |
|
695 | + public function register_gateway( $gateways ) { |
|
696 | + |
|
697 | + $gateways[ $this->id ] = array( |
|
698 | + |
|
699 | + 'admin_label' => $this->method_title, |
|
700 | 700 | 'checkout_label' => $this->title, |
701 | - 'ordering' => $this->order, |
|
701 | + 'ordering' => $this->order, |
|
702 | 702 | |
703 | - ); |
|
703 | + ); |
|
704 | 704 | |
705 | - return $gateways; |
|
705 | + return $gateways; |
|
706 | 706 | |
707 | - } |
|
707 | + } |
|
708 | 708 | |
709 | - /** |
|
710 | - * Checks whether or not this is a sandbox request. |
|
711 | - * |
|
712 | - * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
713 | - * @return bool |
|
714 | - */ |
|
715 | - public function is_sandbox( $invoice = null ) { |
|
709 | + /** |
|
710 | + * Checks whether or not this is a sandbox request. |
|
711 | + * |
|
712 | + * @param WPInv_Invoice|null $invoice Invoice object or null. |
|
713 | + * @return bool |
|
714 | + */ |
|
715 | + public function is_sandbox( $invoice = null ) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
718 | - return $invoice->get_mode() == 'test'; |
|
719 | - } |
|
717 | + if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
718 | + return $invoice->get_mode() == 'test'; |
|
719 | + } |
|
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode( $this->id ); |
|
722 | 722 | |
723 | - } |
|
723 | + } |
|
724 | 724 | |
725 | - /** |
|
726 | - * Renames the checkout button |
|
727 | - * |
|
728 | - * @return string |
|
729 | - */ |
|
730 | - public function rename_checkout_button() { |
|
731 | - return $this->checkout_button_text; |
|
732 | - } |
|
725 | + /** |
|
726 | + * Renames the checkout button |
|
727 | + * |
|
728 | + * @return string |
|
729 | + */ |
|
730 | + public function rename_checkout_button() { |
|
731 | + return $this->checkout_button_text; |
|
732 | + } |
|
733 | 733 | |
734 | - /** |
|
735 | - * Validate gateway currency |
|
736 | - * |
|
737 | - * @return bool |
|
738 | - */ |
|
739 | - public function validate_currency( $validation, $currency ) { |
|
734 | + /** |
|
735 | + * Validate gateway currency |
|
736 | + * |
|
737 | + * @return bool |
|
738 | + */ |
|
739 | + public function validate_currency( $validation, $currency ) { |
|
740 | 740 | |
741 | - // Required currencies. |
|
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
743 | - return false; |
|
744 | - } |
|
741 | + // Required currencies. |
|
742 | + if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
743 | + return false; |
|
744 | + } |
|
745 | 745 | |
746 | - // Excluded currencies. |
|
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
748 | - return false; |
|
749 | - } |
|
746 | + // Excluded currencies. |
|
747 | + if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
748 | + return false; |
|
749 | + } |
|
750 | 750 | |
751 | - return $validation; |
|
752 | - } |
|
751 | + return $validation; |
|
752 | + } |
|
753 | 753 | |
754 | - /** |
|
755 | - * Displays an error |
|
756 | - * |
|
757 | - */ |
|
758 | - public function show_error( $code, $message, $type ) { |
|
754 | + /** |
|
755 | + * Displays an error |
|
756 | + * |
|
757 | + */ |
|
758 | + public function show_error( $code, $message, $type ) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
762 | - } |
|
760 | + if ( is_admin() ) { |
|
761 | + getpaid_admin()->{"show_$type"}( $message ); |
|
762 | + } |
|
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error( $code, $message, $type ); |
|
765 | 765 | |
766 | - } |
|
766 | + } |
|
767 | 767 | |
768 | 768 | } |
@@ -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 | * Abstaract Payment Gateway class. |
@@ -139,50 +139,50 @@ discard block |
||
139 | 139 | public function __construct() { |
140 | 140 | |
141 | 141 | // Register gateway. |
142 | - add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) ); |
|
142 | + add_filter('wpinv_payment_gateways', array($this, 'register_gateway')); |
|
143 | 143 | |
144 | - $this->enabled = wpinv_is_gateway_active( $this->id ); |
|
144 | + $this->enabled = wpinv_is_gateway_active($this->id); |
|
145 | 145 | |
146 | 146 | // Add support for various features. |
147 | - foreach ( $this->supports as $feature ) { |
|
148 | - add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' ); |
|
149 | - add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' ); |
|
150 | - add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' ); |
|
147 | + foreach ($this->supports as $feature) { |
|
148 | + add_filter("wpinv_{$this->id}_support_{$feature}", '__return_true'); |
|
149 | + add_filter("getpaid_{$this->id}_support_{$feature}", '__return_true'); |
|
150 | + add_filter("getpaid_{$this->id}_supports_{$feature}", '__return_true'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | // Invoice addons. |
154 | - if ( $this->supports( 'addons' ) ) { |
|
155 | - add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 ); |
|
154 | + if ($this->supports('addons')) { |
|
155 | + add_action("getpaid_process_{$this->id}_invoice_addons", array($this, 'process_addons'), 10, 2); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | // Gateway settings. |
159 | - add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) ); |
|
159 | + add_filter("wpinv_gateway_settings_{$this->id}", array($this, 'admin_settings')); |
|
160 | 160 | |
161 | 161 | // Gateway checkout fiellds. |
162 | - add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 ); |
|
162 | + add_action("wpinv_{$this->id}_cc_form", array($this, 'payment_fields'), 10, 2); |
|
163 | 163 | |
164 | 164 | // Process payment. |
165 | - add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 ); |
|
165 | + add_action("getpaid_gateway_{$this->id}", array($this, 'process_payment'), 10, 3); |
|
166 | 166 | |
167 | 167 | // Change the checkout button text. |
168 | - if ( ! empty( $this->checkout_button_text ) ) { |
|
169 | - add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) ); |
|
168 | + if (!empty($this->checkout_button_text)) { |
|
169 | + add_filter("getpaid_gateway_{$this->id}_checkout_button_label", array($this, 'rename_checkout_button')); |
|
170 | 170 | } |
171 | 171 | |
172 | 172 | // Check if a gateway is valid for a given currency. |
173 | - add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 ); |
|
173 | + add_filter("getpaid_gateway_{$this->id}_is_valid_for_currency", array($this, 'validate_currency'), 10, 2); |
|
174 | 174 | |
175 | 175 | // Generate the transaction url. |
176 | - add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 ); |
|
176 | + add_filter("getpaid_gateway_{$this->id}_transaction_url", array($this, 'filter_transaction_url'), 10, 2); |
|
177 | 177 | |
178 | 178 | // Generate the subscription url. |
179 | - add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 ); |
|
179 | + add_filter('getpaid_remote_subscription_profile_url', array($this, 'generate_subscription_url'), 10, 2); |
|
180 | 180 | |
181 | 181 | // Confirm payments. |
182 | - add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 ); |
|
182 | + add_filter("wpinv_payment_confirm_{$this->id}", array($this, 'confirm_payment'), 10, 2); |
|
183 | 183 | |
184 | 184 | // Verify IPNs. |
185 | - add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) ); |
|
185 | + add_action("wpinv_verify_{$this->id}_ipn", array($this, 'verify_ipn')); |
|
186 | 186 | |
187 | 187 | } |
188 | 188 | |
@@ -192,7 +192,7 @@ discard block |
||
192 | 192 | * @since 1.0.19 |
193 | 193 | * @return bool |
194 | 194 | */ |
195 | - public function is( $gateway ) { |
|
195 | + public function is($gateway) { |
|
196 | 196 | return $gateway == $this->id; |
197 | 197 | } |
198 | 198 | |
@@ -202,23 +202,23 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return array |
204 | 204 | */ |
205 | - public function get_tokens( $sandbox = null ) { |
|
205 | + public function get_tokens($sandbox = null) { |
|
206 | 206 | |
207 | - if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) { |
|
208 | - $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true ); |
|
207 | + if (is_user_logged_in() && $this->supports('tokens') && 0 == count($this->tokens)) { |
|
208 | + $tokens = get_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", true); |
|
209 | 209 | |
210 | - if ( is_array( $tokens ) ) { |
|
210 | + if (is_array($tokens)) { |
|
211 | 211 | $this->tokens = $tokens; |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | - if ( ! is_bool( $sandbox ) ) { |
|
215 | + if (!is_bool($sandbox)) { |
|
216 | 216 | return $this->tokens; |
217 | 217 | } |
218 | 218 | |
219 | 219 | // Filter tokens. |
220 | - $args = array( 'type' => $sandbox ? 'sandbox' : 'live' ); |
|
221 | - return wp_list_filter( $this->tokens, $args ); |
|
220 | + $args = array('type' => $sandbox ? 'sandbox' : 'live'); |
|
221 | + return wp_list_filter($this->tokens, $args); |
|
222 | 222 | |
223 | 223 | } |
224 | 224 | |
@@ -227,12 +227,12 @@ discard block |
||
227 | 227 | * |
228 | 228 | * @since 1.0.19 |
229 | 229 | */ |
230 | - public function save_token( $token ) { |
|
230 | + public function save_token($token) { |
|
231 | 231 | |
232 | 232 | $tokens = $this->get_tokens(); |
233 | 233 | $tokens[] = $token; |
234 | 234 | |
235 | - update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens ); |
|
235 | + update_user_meta(get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens); |
|
236 | 236 | |
237 | 237 | $this->tokens = $tokens; |
238 | 238 | |
@@ -244,7 +244,7 @@ discard block |
||
244 | 244 | * @return string |
245 | 245 | */ |
246 | 246 | public function get_method_title() { |
247 | - return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this ); |
|
247 | + return apply_filters('getpaid_gateway_method_title', $this->method_title, $this); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | /** |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | * @return string |
254 | 254 | */ |
255 | 255 | public function get_method_description() { |
256 | - return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this ); |
|
256 | + return apply_filters('getpaid_gateway_method_description', $this->method_description, $this); |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | /** |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @param WPInv_Invoice $invoice Invoice object. |
263 | 263 | * @return string |
264 | 264 | */ |
265 | - public function get_return_url( $invoice ) { |
|
265 | + public function get_return_url($invoice) { |
|
266 | 266 | |
267 | 267 | // Payment success url |
268 | 268 | $return_url = add_query_arg( |
@@ -274,7 +274,7 @@ discard block |
||
274 | 274 | wpinv_get_success_page_uri() |
275 | 275 | ); |
276 | 276 | |
277 | - return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this ); |
|
277 | + return apply_filters('getpaid_gateway_success_url', $return_url, $invoice, $this); |
|
278 | 278 | } |
279 | 279 | |
280 | 280 | /** |
@@ -283,24 +283,24 @@ discard block |
||
283 | 283 | * @param string $content Success page content. |
284 | 284 | * @return string |
285 | 285 | */ |
286 | - public function confirm_payment( $content ) { |
|
286 | + public function confirm_payment($content) { |
|
287 | 287 | |
288 | 288 | // Retrieve the invoice. |
289 | 289 | $invoice_id = getpaid_get_current_invoice_id(); |
290 | - $invoice = wpinv_get_invoice( $invoice_id ); |
|
290 | + $invoice = wpinv_get_invoice($invoice_id); |
|
291 | 291 | |
292 | 292 | // Ensure that it exists and that it is pending payment. |
293 | - if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) { |
|
293 | + if (empty($invoice_id) || !$invoice->needs_payment()) { |
|
294 | 294 | return $content; |
295 | 295 | } |
296 | 296 | |
297 | 297 | // Can the user view this invoice?? |
298 | - if ( ! wpinv_user_can_view_invoice( $invoice ) ) { |
|
298 | + if (!wpinv_user_can_view_invoice($invoice)) { |
|
299 | 299 | return $content; |
300 | 300 | } |
301 | 301 | |
302 | 302 | // Show payment processing indicator. |
303 | - return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) ); |
|
303 | + return wpinv_get_template_html('wpinv-payment-processing.php', compact('invoice')); |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | /** |
@@ -317,7 +317,7 @@ discard block |
||
317 | 317 | * @param GetPaid_Form_Item[] $items |
318 | 318 | * @return WPInv_Invoice |
319 | 319 | */ |
320 | - public function process_addons( $invoice, $items ) { |
|
320 | + public function process_addons($invoice, $items) { |
|
321 | 321 | |
322 | 322 | } |
323 | 323 | |
@@ -328,14 +328,14 @@ discard block |
||
328 | 328 | * @param WPInv_Invoice $invoice Invoice object. |
329 | 329 | * @return string transaction URL, or empty string. |
330 | 330 | */ |
331 | - public function filter_transaction_url( $transaction_url, $invoice ) { |
|
331 | + public function filter_transaction_url($transaction_url, $invoice) { |
|
332 | 332 | |
333 | - $transaction_id = $invoice->get_transaction_id(); |
|
333 | + $transaction_id = $invoice->get_transaction_id(); |
|
334 | 334 | |
335 | - if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) { |
|
336 | - $transaction_url = sprintf( $this->view_transaction_url, $transaction_id ); |
|
337 | - $replace = $this->is_sandbox( $invoice ) ? 'sandbox' : ''; |
|
338 | - $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url ); |
|
335 | + if (!empty($this->view_transaction_url) && !empty($transaction_id)) { |
|
336 | + $transaction_url = sprintf($this->view_transaction_url, $transaction_id); |
|
337 | + $replace = $this->is_sandbox($invoice) ? 'sandbox' : ''; |
|
338 | + $transaction_url = str_replace('{sandbox}', $replace, $transaction_url); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | return $transaction_url; |
@@ -348,15 +348,15 @@ discard block |
||
348 | 348 | * @param WPInv_Subscription $subscription Subscription objectt. |
349 | 349 | * @return string subscription URL, or empty string. |
350 | 350 | */ |
351 | - public function generate_subscription_url( $subscription_url, $subscription ) { |
|
351 | + public function generate_subscription_url($subscription_url, $subscription) { |
|
352 | 352 | |
353 | - $profile_id = $subscription->get_profile_id(); |
|
353 | + $profile_id = $subscription->get_profile_id(); |
|
354 | 354 | |
355 | - if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) { |
|
355 | + if ($this->id == $subscription->get_gateway() && !empty($this->view_subscription_url) && !empty($profile_id)) { |
|
356 | 356 | |
357 | - $subscription_url = sprintf( $this->view_subscription_url, $profile_id ); |
|
358 | - $replace = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : ''; |
|
359 | - $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url ); |
|
357 | + $subscription_url = sprintf($this->view_subscription_url, $profile_id); |
|
358 | + $replace = $this->is_sandbox($subscription->get_parent_invoice()) ? 'sandbox' : ''; |
|
359 | + $subscription_url = str_replace('{sandbox}', $replace, $subscription_url); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -369,7 +369,7 @@ discard block |
||
369 | 369 | * @return bool |
370 | 370 | */ |
371 | 371 | public function is_available() { |
372 | - return ! empty( $this->enabled ); |
|
372 | + return !empty($this->enabled); |
|
373 | 373 | } |
374 | 374 | |
375 | 375 | /** |
@@ -378,7 +378,7 @@ discard block |
||
378 | 378 | * @return string |
379 | 379 | */ |
380 | 380 | public function get_title() { |
381 | - return apply_filters( 'getpaid_gateway_title', $this->title, $this ); |
|
381 | + return apply_filters('getpaid_gateway_title', $this->title, $this); |
|
382 | 382 | } |
383 | 383 | |
384 | 384 | /** |
@@ -387,7 +387,7 @@ discard block |
||
387 | 387 | * @return string |
388 | 388 | */ |
389 | 389 | public function get_description() { |
390 | - return apply_filters( 'getpaid_gateway_description', $this->description, $this ); |
|
390 | + return apply_filters('getpaid_gateway_description', $this->description, $this); |
|
391 | 391 | } |
392 | 392 | |
393 | 393 | /** |
@@ -399,9 +399,9 @@ discard block |
||
399 | 399 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
400 | 400 | * @return void |
401 | 401 | */ |
402 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
402 | + public function process_payment($invoice, $submission_data, $submission) { |
|
403 | 403 | // Process the payment then either redirect to the success page or the gateway. |
404 | - do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission ); |
|
404 | + do_action('getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param string $reason Refund reason. |
416 | 416 | * @return WP_Error|bool True or false based on success, or a WP_Error object. |
417 | 417 | */ |
418 | - public function process_refund( $invoice, $amount = null, $reason = '' ) { |
|
419 | - return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason ); |
|
418 | + public function process_refund($invoice, $amount = null, $reason = '') { |
|
419 | + return apply_filters('getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | /** |
@@ -425,8 +425,8 @@ discard block |
||
425 | 425 | * @param int $invoice_id 0 or invoice id. |
426 | 426 | * @param GetPaid_Payment_Form $form Current payment form. |
427 | 427 | */ |
428 | - public function payment_fields( $invoice_id, $form ) { |
|
429 | - do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form ); |
|
428 | + public function payment_fields($invoice_id, $form) { |
|
429 | + do_action('getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | /** |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | * |
435 | 435 | * @param array $admin_settings |
436 | 436 | */ |
437 | - public function admin_settings( $admin_settings ) { |
|
437 | + public function admin_settings($admin_settings) { |
|
438 | 438 | return $admin_settings; |
439 | 439 | } |
440 | 440 | |
@@ -443,8 +443,8 @@ discard block |
||
443 | 443 | * |
444 | 444 | * @param string $option |
445 | 445 | */ |
446 | - public function get_option( $option, $default = false ) { |
|
447 | - return wpinv_get_option( $this->id . '_' . $option, $default ); |
|
446 | + public function get_option($option, $default = false) { |
|
447 | + return wpinv_get_option($this->id . '_' . $option, $default); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | /** |
@@ -457,8 +457,8 @@ discard block |
||
457 | 457 | * @return bool True if the gateway supports the feature, false otherwise. |
458 | 458 | * @since 1.0.19 |
459 | 459 | */ |
460 | - public function supports( $feature ) { |
|
461 | - return getpaid_payment_gateway_supports( $this->id, $feature ); |
|
460 | + public function supports($feature) { |
|
461 | + return getpaid_payment_gateway_supports($this->id, $feature); |
|
462 | 462 | } |
463 | 463 | |
464 | 464 | /** |
@@ -466,39 +466,39 @@ discard block |
||
466 | 466 | * |
467 | 467 | * @param bool $save whether or not to display the save button. |
468 | 468 | */ |
469 | - public function get_cc_form( $save = false ) { |
|
469 | + public function get_cc_form($save = false) { |
|
470 | 470 | |
471 | 471 | ob_start(); |
472 | 472 | |
473 | - $id_prefix = esc_attr( uniqid( $this->id ) ); |
|
473 | + $id_prefix = esc_attr(uniqid($this->id)); |
|
474 | 474 | |
475 | 475 | $months = array( |
476 | - '01' => __( 'January', 'invoicing' ), |
|
477 | - '02' => __( 'February', 'invoicing' ), |
|
478 | - '03' => __( 'March', 'invoicing' ), |
|
479 | - '04' => __( 'April', 'invoicing' ), |
|
480 | - '05' => __( 'May', 'invoicing' ), |
|
481 | - '06' => __( 'June', 'invoicing' ), |
|
482 | - '07' => __( 'July', 'invoicing' ), |
|
483 | - '08' => __( 'August', 'invoicing' ), |
|
484 | - '09' => __( 'September', 'invoicing' ), |
|
485 | - '10' => __( 'October', 'invoicing' ), |
|
486 | - '11' => __( 'November', 'invoicing' ), |
|
487 | - '12' => __( 'December', 'invoicing' ), |
|
476 | + '01' => __('January', 'invoicing'), |
|
477 | + '02' => __('February', 'invoicing'), |
|
478 | + '03' => __('March', 'invoicing'), |
|
479 | + '04' => __('April', 'invoicing'), |
|
480 | + '05' => __('May', 'invoicing'), |
|
481 | + '06' => __('June', 'invoicing'), |
|
482 | + '07' => __('July', 'invoicing'), |
|
483 | + '08' => __('August', 'invoicing'), |
|
484 | + '09' => __('September', 'invoicing'), |
|
485 | + '10' => __('October', 'invoicing'), |
|
486 | + '11' => __('November', 'invoicing'), |
|
487 | + '12' => __('December', 'invoicing'), |
|
488 | 488 | ); |
489 | - $months = apply_filters( 'getpaid_cc_months', $months, $this ); |
|
489 | + $months = apply_filters('getpaid_cc_months', $months, $this); |
|
490 | 490 | |
491 | - $year = (int) current_time( 'Y' ); |
|
491 | + $year = (int) current_time('Y'); |
|
492 | 492 | $years = array(); |
493 | 493 | |
494 | - for ( $i = 0; $i <= 10; $i++ ) { |
|
495 | - $years[ $year + $i ] = $year + $i; |
|
494 | + for ($i = 0; $i <= 10; $i++) { |
|
495 | + $years[$year + $i] = $year + $i; |
|
496 | 496 | } |
497 | 497 | |
498 | - $years = apply_filters( 'getpaid_cc_years', $years, $this ); |
|
498 | + $years = apply_filters('getpaid_cc_years', $years, $this); |
|
499 | 499 | |
500 | 500 | ?> |
501 | - <div class="<?php echo esc_attr( $this->id ); ?>-cc-form getpaid-cc-form mt-1"> |
|
501 | + <div class="<?php echo esc_attr($this->id); ?>-cc-form getpaid-cc-form mt-1"> |
|
502 | 502 | |
503 | 503 | |
504 | 504 | <div class="getpaid-cc-card-inner"> |
@@ -507,14 +507,14 @@ discard block |
||
507 | 507 | <div class="col-12"> |
508 | 508 | |
509 | 509 | <div class="form-group mb-3"> |
510 | - <label for="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>"><?php esc_html_e( 'Card number', 'invoicing' ); ?></label> |
|
510 | + <label for="<?php echo esc_attr("$id_prefix-cc-number"); ?>"><?php esc_html_e('Card number', 'invoicing'); ?></label> |
|
511 | 511 | <div class="input-group input-group-sm"> |
512 | 512 | <div class="input-group-prepend "> |
513 | 513 | <span class="input-group-text"> |
514 | 514 | <i class="fa fa-credit-card"></i> |
515 | 515 | </span> |
516 | 516 | </div> |
517 | - <input type="text" name="<?php echo esc_attr( $this->id . '[cc_number]' ); ?>" id="<?php echo esc_attr( "$id_prefix-cc-number" ); ?>" class="form-control form-control-sm getpaid-format-card-number" autocomplete="cc-number"> |
|
517 | + <input type="text" name="<?php echo esc_attr($this->id . '[cc_number]'); ?>" id="<?php echo esc_attr("$id_prefix-cc-number"); ?>" class="form-control form-control-sm getpaid-format-card-number" autocomplete="cc-number"> |
|
518 | 518 | </div> |
519 | 519 | </div> |
520 | 520 | |
@@ -522,16 +522,16 @@ discard block |
||
522 | 522 | |
523 | 523 | <div class="col-12"> |
524 | 524 | <div class="form-group mb-3"> |
525 | - <label><?php esc_html_e( 'Expiration', 'invoicing' ); ?></label> |
|
525 | + <label><?php esc_html_e('Expiration', 'invoicing'); ?></label> |
|
526 | 526 | <div class="form-row"> |
527 | 527 | |
528 | 528 | <div class="col"> |
529 | - <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_month]"> |
|
530 | - <option disabled selected="selected"><?php esc_html_e( 'MM', 'invoicing' ); ?></option> |
|
529 | + <select class="form-control form-control-sm" autocomplete="cc-exp-month" name="<?php echo esc_attr($this->id); ?>[cc_expire_month]"> |
|
530 | + <option disabled selected="selected"><?php esc_html_e('MM', 'invoicing'); ?></option> |
|
531 | 531 | |
532 | 532 | <?php |
533 | - foreach ( $months as $key => $month ) { |
|
534 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $month ) . '</option>'; |
|
533 | + foreach ($months as $key => $month) { |
|
534 | + echo "<option value='" . esc_attr($key) . "'>" . esc_html($month) . '</option>'; |
|
535 | 535 | } |
536 | 536 | ?> |
537 | 537 | |
@@ -539,12 +539,12 @@ discard block |
||
539 | 539 | </div> |
540 | 540 | |
541 | 541 | <div class="col"> |
542 | - <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr( $this->id ); ?>[cc_expire_year]"> |
|
543 | - <option disabled selected="selected"><?php esc_html_e( 'YY', 'invoicing' ); ?></option> |
|
542 | + <select class="form-control form-control-sm" autocomplete="cc-exp-year" name="<?php echo esc_attr($this->id); ?>[cc_expire_year]"> |
|
543 | + <option disabled selected="selected"><?php esc_html_e('YY', 'invoicing'); ?></option> |
|
544 | 544 | |
545 | 545 | <?php |
546 | - foreach ( $years as $key => $year ) { |
|
547 | - echo "<option value='" . esc_attr( $key ) . "'>" . esc_html( $year ) . '</option>'; |
|
546 | + foreach ($years as $key => $year) { |
|
547 | + echo "<option value='" . esc_attr($key) . "'>" . esc_html($year) . '</option>'; |
|
548 | 548 | } |
549 | 549 | ?> |
550 | 550 | |
@@ -561,7 +561,7 @@ discard block |
||
561 | 561 | array( |
562 | 562 | 'name' => $this->id . '[cc_cvv2]', |
563 | 563 | 'id' => "$id_prefix-cc-cvv2", |
564 | - 'label' => __( 'CCV', 'invoicing' ), |
|
564 | + 'label' => __('CCV', 'invoicing'), |
|
565 | 565 | 'label_type' => 'vertical', |
566 | 566 | 'class' => 'form-control-sm', |
567 | 567 | 'extra_attributes' => array( |
@@ -577,7 +577,7 @@ discard block |
||
577 | 577 | |
578 | 578 | <?php |
579 | 579 | |
580 | - if ( $save ) { |
|
580 | + if ($save) { |
|
581 | 581 | $this->save_payment_method_checkbox(); |
582 | 582 | } |
583 | 583 | |
@@ -596,8 +596,8 @@ discard block |
||
596 | 596 | * |
597 | 597 | * @since 1.0.19 |
598 | 598 | */ |
599 | - public function new_payment_method_entry( $form ) { |
|
600 | - echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses( $form, getpaid_allowed_html() ) . '</div>'; |
|
599 | + public function new_payment_method_entry($form) { |
|
600 | + echo "<div class='getpaid-new-payment-method-form' style='display:none;'> " . wp_kses($form, getpaid_allowed_html()) . '</div>'; |
|
601 | 601 | } |
602 | 602 | |
603 | 603 | /** |
@@ -606,10 +606,10 @@ discard block |
||
606 | 606 | * @since 1.0.19 |
607 | 607 | */ |
608 | 608 | public function saved_payment_methods() { |
609 | - echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">'; |
|
609 | + echo '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr(count($this->get_tokens($this->is_sandbox()))) . '">'; |
|
610 | 610 | |
611 | - foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) { |
|
612 | - $this->get_saved_payment_method_option_html( $token ); |
|
611 | + foreach ($this->get_tokens($this->is_sandbox()) as $token) { |
|
612 | + $this->get_saved_payment_method_option_html($token); |
|
613 | 613 | } |
614 | 614 | |
615 | 615 | $this->get_new_payment_method_option_html(); |
@@ -624,7 +624,7 @@ discard block |
||
624 | 624 | * @param array $token Payment Token. |
625 | 625 | * @return string Generated payment method HTML |
626 | 626 | */ |
627 | - public function get_saved_payment_method_option_html( $token ) { |
|
627 | + public function get_saved_payment_method_option_html($token) { |
|
628 | 628 | |
629 | 629 | printf( |
630 | 630 | '<li class="getpaid-payment-method form-group mb-3"> |
@@ -633,11 +633,11 @@ discard block |
||
633 | 633 | <span>%3$s</span> |
634 | 634 | </label> |
635 | 635 | </li>', |
636 | - esc_attr( $this->id ), |
|
637 | - esc_attr( $token['id'] ), |
|
638 | - esc_html( $token['name'] ), |
|
639 | - checked( empty( $token['default'] ), false, false ), |
|
640 | - empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] ) |
|
636 | + esc_attr($this->id), |
|
637 | + esc_attr($token['id']), |
|
638 | + esc_html($token['name']), |
|
639 | + checked(empty($token['default']), false, false), |
|
640 | + empty($token['currency']) ? 'none' : esc_attr($token['currency']) |
|
641 | 641 | ); |
642 | 642 | |
643 | 643 | } |
@@ -649,7 +649,7 @@ discard block |
||
649 | 649 | */ |
650 | 650 | public function get_new_payment_method_option_html() { |
651 | 651 | |
652 | - $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this ); |
|
652 | + $label = apply_filters('getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __('Use a new payment method', 'invoicing'), $this); |
|
653 | 653 | |
654 | 654 | printf( |
655 | 655 | '<li class="getpaid-new-payment-method"> |
@@ -658,8 +658,8 @@ discard block |
||
658 | 658 | <span>%2$s</span> |
659 | 659 | </label> |
660 | 660 | </li>', |
661 | - esc_attr( $this->id ), |
|
662 | - esc_html( $label ) |
|
661 | + esc_attr($this->id), |
|
662 | + esc_html($label) |
|
663 | 663 | ); |
664 | 664 | |
665 | 665 | } |
@@ -674,10 +674,10 @@ discard block |
||
674 | 674 | aui()->input( |
675 | 675 | array( |
676 | 676 | 'type' => 'checkbox', |
677 | - 'name' => esc_attr( "getpaid-$this->id-new-payment-method" ), |
|
678 | - 'id' => esc_attr( uniqid( $this->id ) ), |
|
677 | + 'name' => esc_attr("getpaid-$this->id-new-payment-method"), |
|
678 | + 'id' => esc_attr(uniqid($this->id)), |
|
679 | 679 | 'required' => false, |
680 | - 'label' => esc_html__( 'Save payment method', 'invoicing' ), |
|
680 | + 'label' => esc_html__('Save payment method', 'invoicing'), |
|
681 | 681 | 'value' => 'true', |
682 | 682 | 'checked' => true, |
683 | 683 | 'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1', |
@@ -692,9 +692,9 @@ discard block |
||
692 | 692 | * |
693 | 693 | * @return array |
694 | 694 | */ |
695 | - public function register_gateway( $gateways ) { |
|
695 | + public function register_gateway($gateways) { |
|
696 | 696 | |
697 | - $gateways[ $this->id ] = array( |
|
697 | + $gateways[$this->id] = array( |
|
698 | 698 | |
699 | 699 | 'admin_label' => $this->method_title, |
700 | 700 | 'checkout_label' => $this->title, |
@@ -712,13 +712,13 @@ discard block |
||
712 | 712 | * @param WPInv_Invoice|null $invoice Invoice object or null. |
713 | 713 | * @return bool |
714 | 714 | */ |
715 | - public function is_sandbox( $invoice = null ) { |
|
715 | + public function is_sandbox($invoice = null) { |
|
716 | 716 | |
717 | - if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) { |
|
717 | + if (!empty($invoice) && !$invoice->needs_payment()) { |
|
718 | 718 | return $invoice->get_mode() == 'test'; |
719 | 719 | } |
720 | 720 | |
721 | - return wpinv_is_test_mode( $this->id ); |
|
721 | + return wpinv_is_test_mode($this->id); |
|
722 | 722 | |
723 | 723 | } |
724 | 724 | |
@@ -736,15 +736,15 @@ discard block |
||
736 | 736 | * |
737 | 737 | * @return bool |
738 | 738 | */ |
739 | - public function validate_currency( $validation, $currency ) { |
|
739 | + public function validate_currency($validation, $currency) { |
|
740 | 740 | |
741 | 741 | // Required currencies. |
742 | - if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) { |
|
742 | + if (!empty($this->currencies) && !in_array($currency, $this->currencies)) { |
|
743 | 743 | return false; |
744 | 744 | } |
745 | 745 | |
746 | 746 | // Excluded currencies. |
747 | - if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) { |
|
747 | + if (!empty($this->exclude_currencies) && in_array($currency, $this->exclude_currencies)) { |
|
748 | 748 | return false; |
749 | 749 | } |
750 | 750 | |
@@ -755,13 +755,13 @@ discard block |
||
755 | 755 | * Displays an error |
756 | 756 | * |
757 | 757 | */ |
758 | - public function show_error( $code, $message, $type ) { |
|
758 | + public function show_error($code, $message, $type) { |
|
759 | 759 | |
760 | - if ( is_admin() ) { |
|
761 | - getpaid_admin()->{"show_$type"}( $message ); |
|
760 | + if (is_admin()) { |
|
761 | + getpaid_admin()->{"show_$type"}($message); |
|
762 | 762 | } |
763 | 763 | |
764 | - wpinv_set_error( $code, $message, $type ); |
|
764 | + wpinv_set_error($code, $message, $type); |
|
765 | 765 | |
766 | 766 | } |
767 | 767 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,24 +21,24 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the discount. |
27 | - $discount = new WPInv_Discount( $post ); |
|
27 | + $discount = new WPInv_Discount($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
30 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
31 | 31 | |
32 | - do_action( 'wpinv_discount_form_top', $discount ); |
|
32 | + do_action('wpinv_discount_form_top', $discount); |
|
33 | 33 | |
34 | 34 | // Set the currency position. |
35 | 35 | $position = wpinv_currency_position(); |
36 | 36 | |
37 | - if ( $position == 'left_space' ) { |
|
37 | + if ($position == 'left_space') { |
|
38 | 38 | $position = 'left'; |
39 | 39 | } |
40 | 40 | |
41 | - if ( $position == 'right_space' ) { |
|
41 | + if ($position == 'right_space') { |
|
42 | 42 | $position = 'right'; |
43 | 43 | } |
44 | 44 | |
@@ -52,68 +52,68 @@ discard block |
||
52 | 52 | </style> |
53 | 53 | <div class='bsui' style='max-width: 600px;padding-top: 10px;'> |
54 | 54 | |
55 | - <?php do_action( 'wpinv_discount_form_first', $discount ); ?> |
|
55 | + <?php do_action('wpinv_discount_form_first', $discount); ?> |
|
56 | 56 | |
57 | - <?php do_action( 'wpinv_discount_form_before_code', $discount ); ?> |
|
57 | + <?php do_action('wpinv_discount_form_before_code', $discount); ?> |
|
58 | 58 | <div class="form-group mb-3 row"> |
59 | 59 | <label for="wpinv_discount_code" class="col-sm-3 col-form-label"> |
60 | - <?php esc_html_e( 'Discount Code', 'invoicing' ); ?> |
|
60 | + <?php esc_html_e('Discount Code', 'invoicing'); ?> |
|
61 | 61 | </label> |
62 | 62 | <div class="col-sm-8"> |
63 | 63 | <div class="row"> |
64 | 64 | <div class="col-sm-12 form-group mb-3"> |
65 | - <input type="text" value="<?php echo esc_attr( $discount->get_code( 'edit' ) ); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
65 | + <input type="text" value="<?php echo esc_attr($discount->get_code('edit')); ?>" placeholder="SUMMER_SALE" name="wpinv_discount_code" id="wpinv_discount_code" style="width: 100%;" /> |
|
66 | 66 | </div> |
67 | 67 | <div class="col-sm-12"> |
68 | 68 | <?php |
69 | - do_action( 'wpinv_discount_form_before_single_use', $discount ); |
|
69 | + do_action('wpinv_discount_form_before_single_use', $discount); |
|
70 | 70 | |
71 | 71 | aui()->input( |
72 | 72 | array( |
73 | 73 | 'id' => 'wpinv_discount_single_use', |
74 | 74 | 'name' => 'wpinv_discount_single_use', |
75 | 75 | 'type' => 'checkbox', |
76 | - 'label' => __( 'Each customer can only use this discount once', 'invoicing' ), |
|
76 | + 'label' => __('Each customer can only use this discount once', 'invoicing'), |
|
77 | 77 | 'value' => '1', |
78 | 78 | 'checked' => $discount->is_single_use(), |
79 | 79 | ), |
80 | 80 | true |
81 | 81 | ); |
82 | 82 | |
83 | - do_action( 'wpinv_discount_form_single_use', $discount ); |
|
83 | + do_action('wpinv_discount_form_single_use', $discount); |
|
84 | 84 | ?> |
85 | 85 | </div> |
86 | 86 | <div class="col-sm-12"> |
87 | 87 | <?php |
88 | - do_action( 'wpinv_discount_form_before_recurring', $discount ); |
|
88 | + do_action('wpinv_discount_form_before_recurring', $discount); |
|
89 | 89 | |
90 | 90 | aui()->input( |
91 | 91 | array( |
92 | 92 | 'id' => 'wpinv_discount_recurring', |
93 | 93 | 'name' => 'wpinv_discount_recurring', |
94 | 94 | 'type' => 'checkbox', |
95 | - 'label' => __( 'Apply this discount to all recurring payments for subscriptions', 'invoicing' ), |
|
95 | + 'label' => __('Apply this discount to all recurring payments for subscriptions', 'invoicing'), |
|
96 | 96 | 'value' => '1', |
97 | 97 | 'checked' => $discount->is_recurring(), |
98 | 98 | ), |
99 | 99 | true |
100 | 100 | ); |
101 | 101 | |
102 | - do_action( 'wpinv_discount_form_recurring', $discount ); |
|
102 | + do_action('wpinv_discount_form_recurring', $discount); |
|
103 | 103 | ?> |
104 | 104 | </div> |
105 | 105 | </div> |
106 | 106 | </div> |
107 | 107 | <div class="col-sm-1 pt-2 pl-0"> |
108 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter a discount code such as 10OFF.', 'invoicing' ); ?>"></span> |
|
108 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter a discount code such as 10OFF.', 'invoicing'); ?>"></span> |
|
109 | 109 | </div> |
110 | 110 | </div> |
111 | - <?php do_action( 'wpinv_discount_form_code', $discount ); ?> |
|
111 | + <?php do_action('wpinv_discount_form_code', $discount); ?> |
|
112 | 112 | |
113 | - <?php do_action( 'wpinv_discount_form_before_type', $discount ); ?> |
|
113 | + <?php do_action('wpinv_discount_form_before_type', $discount); ?> |
|
114 | 114 | <div class="form-group mb-3 row"> |
115 | 115 | <label for="wpinv_discount_type" class="col-sm-3 col-form-label"> |
116 | - <?php esc_html_e( 'Discount Type', 'invoicing' ); ?> |
|
116 | + <?php esc_html_e('Discount Type', 'invoicing'); ?> |
|
117 | 117 | </label> |
118 | 118 | <div class="col-sm-8"> |
119 | 119 | <?php |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | array( |
122 | 122 | 'id' => 'wpinv_discount_type', |
123 | 123 | 'name' => 'wpinv_discount_type', |
124 | - 'label' => __( 'Discount Type', 'invoicing' ), |
|
125 | - 'placeholder' => __( 'Select Discount Type', 'invoicing' ), |
|
126 | - 'value' => $discount->get_type( 'edit' ), |
|
124 | + 'label' => __('Discount Type', 'invoicing'), |
|
125 | + 'placeholder' => __('Select Discount Type', 'invoicing'), |
|
126 | + 'value' => $discount->get_type('edit'), |
|
127 | 127 | 'select2' => true, |
128 | 128 | 'data-allow-clear' => 'false', |
129 | 129 | 'options' => wpinv_get_discount_types(), |
@@ -133,32 +133,32 @@ discard block |
||
133 | 133 | ?> |
134 | 134 | </div> |
135 | 135 | <div class="col-sm-1 pt-2 pl-0"> |
136 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Discount type.', 'invoicing' ); ?>"></span> |
|
136 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Discount type.', 'invoicing'); ?>"></span> |
|
137 | 137 | </div> |
138 | 138 | </div> |
139 | - <?php do_action( 'wpinv_discount_form_type', $discount ); ?> |
|
139 | + <?php do_action('wpinv_discount_form_type', $discount); ?> |
|
140 | 140 | |
141 | - <?php do_action( 'wpinv_discount_form_before_amount', $discount ); ?> |
|
142 | - <div class="form-group mb-3 row <?php echo esc_attr( $discount->get_type( 'edit' ) ); ?>" id="wpinv_discount_amount_wrap"> |
|
141 | + <?php do_action('wpinv_discount_form_before_amount', $discount); ?> |
|
142 | + <div class="form-group mb-3 row <?php echo esc_attr($discount->get_type('edit')); ?>" id="wpinv_discount_amount_wrap"> |
|
143 | 143 | <label for="wpinv_discount_amount" class="col-sm-3 col-form-label"> |
144 | - <?php esc_html_e( 'Discount Amount', 'invoicing' ); ?> |
|
144 | + <?php esc_html_e('Discount Amount', 'invoicing'); ?> |
|
145 | 145 | </label> |
146 | 146 | <div class="col-sm-8"> |
147 | 147 | <div class="input-group input-group-sm"> |
148 | - <?php if ( 'left' == $position ) : ?> |
|
148 | + <?php if ('left' == $position) : ?> |
|
149 | 149 | <div class="input-group-prepend left wpinv-if-flat"> |
150 | 150 | <span class="input-group-text"> |
151 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
151 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
152 | 152 | </span> |
153 | 153 | </div> |
154 | 154 | <?php endif; ?> |
155 | 155 | |
156 | - <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr( $discount->get_amount( 'edit' ) ); ?>" placeholder="0" class="form-control"> |
|
156 | + <input type="text" name="wpinv_discount_amount" id="wpinv_discount_amount" value="<?php echo esc_attr($discount->get_amount('edit')); ?>" placeholder="0" class="form-control"> |
|
157 | 157 | |
158 | - <?php if ( 'right' == $position ) : ?> |
|
158 | + <?php if ('right' == $position) : ?> |
|
159 | 159 | <div class="input-group-prepend left wpinv-if-flat"> |
160 | 160 | <span class="input-group-text"> |
161 | - <?php echo wp_kses_post( wpinv_currency_symbol() ); ?> |
|
161 | + <?php echo wp_kses_post(wpinv_currency_symbol()); ?> |
|
162 | 162 | </span> |
163 | 163 | </div> |
164 | 164 | <?php endif; ?> |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | </div> |
169 | 169 | </div> |
170 | 170 | <div class="col-sm-1 pt-2 pl-0"> |
171 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the discount value. Ex: 10', 'invoicing' ); ?>"></span> |
|
171 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the discount value. Ex: 10', 'invoicing'); ?>"></span> |
|
172 | 172 | </div> |
173 | 173 | </div> |
174 | - <?php do_action( 'wpinv_discount_form_amount', $discount ); ?> |
|
174 | + <?php do_action('wpinv_discount_form_amount', $discount); ?> |
|
175 | 175 | |
176 | - <?php do_action( 'wpinv_discount_form_before_items', $discount ); ?> |
|
176 | + <?php do_action('wpinv_discount_form_before_items', $discount); ?> |
|
177 | 177 | <div class="form-group mb-3 row"> |
178 | 178 | <label for="wpinv_discount_items" class="col-sm-3 col-form-label"> |
179 | - <?php esc_html_e( 'Items', 'invoicing' ); ?> |
|
179 | + <?php esc_html_e('Items', 'invoicing'); ?> |
|
180 | 180 | </label> |
181 | 181 | <div class="col-sm-8"> |
182 | 182 | <?php |
@@ -184,9 +184,9 @@ discard block |
||
184 | 184 | array( |
185 | 185 | 'id' => 'wpinv_discount_items', |
186 | 186 | 'name' => 'wpinv_discount_items[]', |
187 | - 'label' => __( 'Items', 'invoicing' ), |
|
188 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
189 | - 'value' => $discount->get_items( 'edit' ), |
|
187 | + 'label' => __('Items', 'invoicing'), |
|
188 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
189 | + 'value' => $discount->get_items('edit'), |
|
190 | 190 | 'select2' => true, |
191 | 191 | 'multiple' => true, |
192 | 192 | 'data-allow-clear' => 'false', |
@@ -197,15 +197,15 @@ discard block |
||
197 | 197 | ?> |
198 | 198 | </div> |
199 | 199 | <div class="col-sm-1 pt-2 pl-0"> |
200 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing' ); ?>"></span> |
|
200 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select the items that are allowed to use this discount or leave blank to use this discount all items.', 'invoicing'); ?>"></span> |
|
201 | 201 | </div> |
202 | 202 | </div> |
203 | - <?php do_action( 'wpinv_discount_form_items', $discount ); ?> |
|
203 | + <?php do_action('wpinv_discount_form_items', $discount); ?> |
|
204 | 204 | |
205 | - <?php do_action( 'wpinv_discount_form_before_excluded_items', $discount ); ?> |
|
205 | + <?php do_action('wpinv_discount_form_before_excluded_items', $discount); ?> |
|
206 | 206 | <div class="form-group mb-3 row"> |
207 | 207 | <label for="wpinv_discount_excluded_items" class="col-sm-3 col-form-label"> |
208 | - <?php esc_html_e( 'Excluded Items', 'invoicing' ); ?> |
|
208 | + <?php esc_html_e('Excluded Items', 'invoicing'); ?> |
|
209 | 209 | </label> |
210 | 210 | <div class="col-sm-8"> |
211 | 211 | <?php |
@@ -213,9 +213,9 @@ discard block |
||
213 | 213 | array( |
214 | 214 | 'id' => 'wpinv_discount_excluded_items', |
215 | 215 | 'name' => 'wpinv_discount_excluded_items[]', |
216 | - 'label' => __( 'Excluded Items', 'invoicing' ), |
|
217 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
218 | - 'value' => $discount->get_excluded_items( 'edit' ), |
|
216 | + 'label' => __('Excluded Items', 'invoicing'), |
|
217 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
218 | + 'value' => $discount->get_excluded_items('edit'), |
|
219 | 219 | 'select2' => true, |
220 | 220 | 'multiple' => true, |
221 | 221 | 'data-allow-clear' => 'false', |
@@ -226,15 +226,15 @@ discard block |
||
226 | 226 | ?> |
227 | 227 | </div> |
228 | 228 | <div class="col-sm-1 pt-2 pl-0"> |
229 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are not allowed to use this discount.', 'invoicing' ); ?>"></span> |
|
229 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are not allowed to use this discount.', 'invoicing'); ?>"></span> |
|
230 | 230 | </div> |
231 | 231 | </div> |
232 | - <?php do_action( 'wpinv_discount_form_excluded_items', $discount ); ?> |
|
232 | + <?php do_action('wpinv_discount_form_excluded_items', $discount); ?> |
|
233 | 233 | |
234 | - <?php do_action( 'wpinv_discount_form_before_required_items', $discount ); ?> |
|
234 | + <?php do_action('wpinv_discount_form_before_required_items', $discount); ?> |
|
235 | 235 | <div class="form-group mb-3 row"> |
236 | 236 | <label for="wpinv_discount_required_items" class="col-sm-3 col-form-label"> |
237 | - <?php esc_html_e( 'Required Items', 'invoicing' ); ?> |
|
237 | + <?php esc_html_e('Required Items', 'invoicing'); ?> |
|
238 | 238 | </label> |
239 | 239 | <div class="col-sm-8"> |
240 | 240 | <?php |
@@ -242,9 +242,9 @@ discard block |
||
242 | 242 | array( |
243 | 243 | 'id' => 'wpinv_discount_required_items', |
244 | 244 | 'name' => 'wpinv_discount_required_items[]', |
245 | - 'label' => __( 'Required Items', 'invoicing' ), |
|
246 | - 'placeholder' => __( 'Select Items', 'invoicing' ), |
|
247 | - 'value' => $discount->get_required_items( 'edit' ), |
|
245 | + 'label' => __('Required Items', 'invoicing'), |
|
246 | + 'placeholder' => __('Select Items', 'invoicing'), |
|
247 | + 'value' => $discount->get_required_items('edit'), |
|
248 | 248 | 'select2' => true, |
249 | 249 | 'multiple' => true, |
250 | 250 | 'data-allow-clear' => 'false', |
@@ -255,15 +255,15 @@ discard block |
||
255 | 255 | ?> |
256 | 256 | </div> |
257 | 257 | <div class="col-sm-1 pt-2 pl-0"> |
258 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Select all the items that are required to be in the cart before using this discount.', 'invoicing' ); ?>"></span> |
|
258 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Select all the items that are required to be in the cart before using this discount.', 'invoicing'); ?>"></span> |
|
259 | 259 | </div> |
260 | 260 | </div> |
261 | - <?php do_action( 'wpinv_discount_form_required_items', $discount ); ?> |
|
261 | + <?php do_action('wpinv_discount_form_required_items', $discount); ?> |
|
262 | 262 | |
263 | - <?php do_action( 'wpinv_discount_form_before_start', $discount ); ?> |
|
263 | + <?php do_action('wpinv_discount_form_before_start', $discount); ?> |
|
264 | 264 | <div class="form-group mb-3 row"> |
265 | 265 | <label for="wpinv_discount_start" class="col-sm-3 col-form-label"> |
266 | - <?php esc_html_e( 'Start Date', 'invoicing' ); ?> |
|
266 | + <?php esc_html_e('Start Date', 'invoicing'); ?> |
|
267 | 267 | </label> |
268 | 268 | <div class="col-sm-8"> |
269 | 269 | <?php |
@@ -272,10 +272,10 @@ discard block |
||
272 | 272 | 'type' => 'datepicker', |
273 | 273 | 'id' => 'wpinv_discount_start', |
274 | 274 | 'name' => 'wpinv_discount_start', |
275 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
275 | + 'label' => __('Start Date', 'invoicing'), |
|
276 | 276 | 'placeholder' => 'YYYY-MM-DD 00:00', |
277 | 277 | 'class' => 'form-control-sm', |
278 | - 'value' => $discount->get_start_date( 'edit' ), |
|
278 | + 'value' => $discount->get_start_date('edit'), |
|
279 | 279 | 'extra_attributes' => array( |
280 | 280 | 'data-enable-time' => 'true', |
281 | 281 | 'data-time_24hr' => 'true', |
@@ -287,15 +287,15 @@ discard block |
||
287 | 287 | ?> |
288 | 288 | </div> |
289 | 289 | <div class="col-sm-1 pt-2 pl-0"> |
290 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing' ); ?>"></span> |
|
290 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('For no start date, leave blank. If entered, the discount can only be used after or on this date.', 'invoicing'); ?>"></span> |
|
291 | 291 | </div> |
292 | 292 | </div> |
293 | - <?php do_action( 'wpinv_discount_form_start', $discount ); ?> |
|
293 | + <?php do_action('wpinv_discount_form_start', $discount); ?> |
|
294 | 294 | |
295 | - <?php do_action( 'wpinv_discount_form_before_expiration', $discount ); ?> |
|
295 | + <?php do_action('wpinv_discount_form_before_expiration', $discount); ?> |
|
296 | 296 | <div class="form-group mb-3 row"> |
297 | 297 | <label for="wpinv_discount_expiration" class="col-sm-3 col-form-label"> |
298 | - <?php esc_html_e( 'Expiration Date', 'invoicing' ); ?> |
|
298 | + <?php esc_html_e('Expiration Date', 'invoicing'); ?> |
|
299 | 299 | </label> |
300 | 300 | <div class="col-sm-8"> |
301 | 301 | <?php |
@@ -304,10 +304,10 @@ discard block |
||
304 | 304 | 'type' => 'datepicker', |
305 | 305 | 'id' => 'wpinv_discount_expiration', |
306 | 306 | 'name' => 'wpinv_discount_expiration', |
307 | - 'label' => __( 'Expiration Date', 'invoicing' ), |
|
307 | + 'label' => __('Expiration Date', 'invoicing'), |
|
308 | 308 | 'placeholder' => 'YYYY-MM-DD 00:00', |
309 | 309 | 'class' => 'form-control-sm', |
310 | - 'value' => $discount->get_end_date( 'edit' ), |
|
310 | + 'value' => $discount->get_end_date('edit'), |
|
311 | 311 | 'extra_attributes' => array( |
312 | 312 | 'data-enable-time' => 'true', |
313 | 313 | 'data-time_24hr' => 'true', |
@@ -321,86 +321,86 @@ discard block |
||
321 | 321 | ?> |
322 | 322 | </div> |
323 | 323 | <div class="col-sm-1 pt-2 pl-0"> |
324 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the date after which the discount will expire.', 'invoicing' ); ?>"></span> |
|
324 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the date after which the discount will expire.', 'invoicing'); ?>"></span> |
|
325 | 325 | </div> |
326 | 326 | </div> |
327 | - <?php do_action( 'wpinv_discount_form_expiration', $discount ); ?> |
|
327 | + <?php do_action('wpinv_discount_form_expiration', $discount); ?> |
|
328 | 328 | |
329 | - <?php do_action( 'wpinv_discount_form_before_min_total', $discount ); ?> |
|
329 | + <?php do_action('wpinv_discount_form_before_min_total', $discount); ?> |
|
330 | 330 | <div class="form-group mb-3 row"> |
331 | 331 | <label for="wpinv_discount_min_total" class="col-sm-3 col-form-label"> |
332 | - <?php esc_html_e( 'Minimum Amount', 'invoicing' ); ?> |
|
332 | + <?php esc_html_e('Minimum Amount', 'invoicing'); ?> |
|
333 | 333 | </label> |
334 | 334 | <div class="col-sm-8"> |
335 | 335 | <div class="input-group input-group-sm"> |
336 | - <?php if ( 'left' == $position ) : ?> |
|
336 | + <?php if ('left' == $position) : ?> |
|
337 | 337 | <div class="input-group-prepend"> |
338 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
338 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
339 | 339 | </div> |
340 | 340 | <?php endif; ?> |
341 | 341 | |
342 | - <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr( $discount->get_minimum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No minimum', 'invoicing' ); ?>" class="form-control"> |
|
342 | + <input type="text" name="wpinv_discount_min_total" id="wpinv_discount_min_total" value="<?php echo esc_attr($discount->get_minimum_total('edit')); ?>" placeholder="<?php esc_attr_e('No minimum', 'invoicing'); ?>" class="form-control"> |
|
343 | 343 | |
344 | - <?php if ( 'left' != $position ) : ?> |
|
344 | + <?php if ('left' != $position) : ?> |
|
345 | 345 | <div class="input-group-append"> |
346 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
346 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
347 | 347 | </div> |
348 | 348 | <?php endif; ?> |
349 | 349 | </div> |
350 | 350 | </div> |
351 | 351 | <div class="col-sm-1 pt-2 pl-0"> |
352 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing' ); ?>"></span> |
|
352 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the minimum amount (including taxes) required to use this discount.', 'invoicing'); ?>"></span> |
|
353 | 353 | </div> |
354 | 354 | </div> |
355 | - <?php do_action( 'wpinv_discount_form_min_total', $discount ); ?> |
|
355 | + <?php do_action('wpinv_discount_form_min_total', $discount); ?> |
|
356 | 356 | |
357 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
357 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
358 | 358 | <div class="form-group mb-3 row"> |
359 | 359 | <label for="wpinv_discount_max_total" class="col-sm-3 col-form-label"> |
360 | - <?php esc_html_e( 'Maximum Amount', 'invoicing' ); ?> |
|
360 | + <?php esc_html_e('Maximum Amount', 'invoicing'); ?> |
|
361 | 361 | </label> |
362 | 362 | <div class="col-sm-8"> |
363 | 363 | <div class="input-group input-group-sm"> |
364 | - <?php if ( 'left' == $position ) : ?> |
|
364 | + <?php if ('left' == $position) : ?> |
|
365 | 365 | <div class="input-group-prepend"> |
366 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
366 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
367 | 367 | </div> |
368 | 368 | <?php endif; ?> |
369 | 369 | |
370 | - <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr( $discount->get_maximum_total( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'No maximum', 'invoicing' ); ?>" class="form-control"> |
|
370 | + <input type="text" name="wpinv_discount_max_total" id="wpinv_discount_max_total" value="<?php echo esc_attr($discount->get_maximum_total('edit')); ?>" placeholder="<?php esc_attr_e('No maximum', 'invoicing'); ?>" class="form-control"> |
|
371 | 371 | |
372 | - <?php if ( 'left' != $position ) : ?> |
|
372 | + <?php if ('left' != $position) : ?> |
|
373 | 373 | <div class="input-group-append"> |
374 | - <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span> |
|
374 | + <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span> |
|
375 | 375 | </div> |
376 | 376 | <?php endif; ?> |
377 | 377 | </div> |
378 | 378 | </div> |
379 | 379 | <div class="col-sm-1 pt-2 pl-0"> |
380 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing' ); ?>"></span> |
|
380 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum amount (including taxes) allowed when using this discount.', 'invoicing'); ?>"></span> |
|
381 | 381 | </div> |
382 | 382 | </div> |
383 | - <?php do_action( 'wpinv_discount_form_before_max_total', $discount ); ?> |
|
383 | + <?php do_action('wpinv_discount_form_before_max_total', $discount); ?> |
|
384 | 384 | |
385 | - <?php do_action( 'wpinv_discount_form_before_max_uses', $discount ); ?> |
|
385 | + <?php do_action('wpinv_discount_form_before_max_uses', $discount); ?> |
|
386 | 386 | <div class="form-group mb-3 row"> |
387 | 387 | <label for="wpinv_discount_max_uses" class="col-sm-3 col-form-label"> |
388 | - <?php esc_html_e( 'Maximum Uses', 'invoicing' ); ?> |
|
388 | + <?php esc_html_e('Maximum Uses', 'invoicing'); ?> |
|
389 | 389 | </label> |
390 | 390 | <div class="col-sm-8"> |
391 | - <input type="text" value="<?php echo esc_attr( $discount->get_max_uses( 'edit' ) ); ?>" placeholder="<?php esc_attr_e( 'Unlimited', 'invoicing' ); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
391 | + <input type="text" value="<?php echo esc_attr($discount->get_max_uses('edit')); ?>" placeholder="<?php esc_attr_e('Unlimited', 'invoicing'); ?>" name="wpinv_discount_max_uses" id="wpinv_discount_max_uses" style="width: 100%;" /> |
|
392 | 392 | </div> |
393 | 393 | <div class="col-sm-1 pt-2 pl-0"> |
394 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Optionally set the maximum number of times that this discount code can be used.', 'invoicing' ); ?>"></span> |
|
394 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Optionally set the maximum number of times that this discount code can be used.', 'invoicing'); ?>"></span> |
|
395 | 395 | </div> |
396 | 396 | </div> |
397 | - <?php do_action( 'wpinv_discount_form_max_uses', $discount ); ?> |
|
397 | + <?php do_action('wpinv_discount_form_max_uses', $discount); ?> |
|
398 | 398 | |
399 | - <?php do_action( 'wpinv_discount_form_last', $discount ); ?> |
|
399 | + <?php do_action('wpinv_discount_form_last', $discount); ?> |
|
400 | 400 | |
401 | 401 | </div> |
402 | 402 | <?php |
403 | - do_action( 'wpinv_discount_form_bottom', $post ); |
|
403 | + do_action('wpinv_discount_form_bottom', $post); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | /** |
@@ -408,31 +408,31 @@ discard block |
||
408 | 408 | * |
409 | 409 | * @param int $post_id |
410 | 410 | */ |
411 | - public static function save( $post_id ) { |
|
411 | + public static function save($post_id) { |
|
412 | 412 | |
413 | 413 | // Prepare the discount. |
414 | - $discount = new WPInv_Discount( $post_id ); |
|
414 | + $discount = new WPInv_Discount($post_id); |
|
415 | 415 | |
416 | 416 | // Load new data. |
417 | 417 | $discount->set_props( |
418 | 418 | array( |
419 | - 'code' => isset( $_POST['wpinv_discount_code'] ) ? wpinv_clean( $_POST['wpinv_discount_code'] ) : null, |
|
420 | - 'amount' => isset( $_POST['wpinv_discount_amount'] ) ? floatval( $_POST['wpinv_discount_amount'] ) : null, |
|
421 | - 'start' => isset( $_POST['wpinv_discount_start'] ) ? wpinv_clean( $_POST['wpinv_discount_start'] ) : null, |
|
422 | - 'expiration' => isset( $_POST['wpinv_discount_expiration'] ) ? wpinv_clean( $_POST['wpinv_discount_expiration'] ) : null, |
|
423 | - 'is_single_use' => ! empty( $_POST['wpinv_discount_single_use'] ), |
|
424 | - 'type' => isset( $_POST['wpinv_discount_type'] ) ? wpinv_clean( $_POST['wpinv_discount_type'] ) : null, |
|
425 | - 'is_recurring' => ! empty( $_POST['wpinv_discount_recurring'] ), |
|
426 | - 'items' => isset( $_POST['wpinv_discount_items'] ) ? wpinv_clean( $_POST['wpinv_discount_items'] ) : array(), |
|
427 | - 'excluded_items' => isset( $_POST['wpinv_discount_excluded_items'] ) ? wpinv_clean( $_POST['wpinv_discount_excluded_items'] ) : array(), |
|
428 | - 'required_items' => isset( $_POST['wpinv_discount_required_items'] ) ? wpinv_clean( $_POST['wpinv_discount_required_items'] ) : array(), |
|
429 | - 'max_uses' => isset( $_POST['wpinv_discount_max_uses'] ) ? intval( $_POST['wpinv_discount_max_uses'] ) : null, |
|
430 | - 'min_total' => isset( $_POST['wpinv_discount_min_total'] ) ? floatval( $_POST['wpinv_discount_min_total'] ) : null, |
|
431 | - 'max_total' => isset( $_POST['wpinv_discount_max_total'] ) ? floatval( $_POST['wpinv_discount_max_total'] ) : null, |
|
419 | + 'code' => isset($_POST['wpinv_discount_code']) ? wpinv_clean($_POST['wpinv_discount_code']) : null, |
|
420 | + 'amount' => isset($_POST['wpinv_discount_amount']) ? floatval($_POST['wpinv_discount_amount']) : null, |
|
421 | + 'start' => isset($_POST['wpinv_discount_start']) ? wpinv_clean($_POST['wpinv_discount_start']) : null, |
|
422 | + 'expiration' => isset($_POST['wpinv_discount_expiration']) ? wpinv_clean($_POST['wpinv_discount_expiration']) : null, |
|
423 | + 'is_single_use' => !empty($_POST['wpinv_discount_single_use']), |
|
424 | + 'type' => isset($_POST['wpinv_discount_type']) ? wpinv_clean($_POST['wpinv_discount_type']) : null, |
|
425 | + 'is_recurring' => !empty($_POST['wpinv_discount_recurring']), |
|
426 | + 'items' => isset($_POST['wpinv_discount_items']) ? wpinv_clean($_POST['wpinv_discount_items']) : array(), |
|
427 | + 'excluded_items' => isset($_POST['wpinv_discount_excluded_items']) ? wpinv_clean($_POST['wpinv_discount_excluded_items']) : array(), |
|
428 | + 'required_items' => isset($_POST['wpinv_discount_required_items']) ? wpinv_clean($_POST['wpinv_discount_required_items']) : array(), |
|
429 | + 'max_uses' => isset($_POST['wpinv_discount_max_uses']) ? intval($_POST['wpinv_discount_max_uses']) : null, |
|
430 | + 'min_total' => isset($_POST['wpinv_discount_min_total']) ? floatval($_POST['wpinv_discount_min_total']) : null, |
|
431 | + 'max_total' => isset($_POST['wpinv_discount_max_total']) ? floatval($_POST['wpinv_discount_max_total']) : null, |
|
432 | 432 | ) |
433 | 433 | ); |
434 | 434 | |
435 | 435 | $discount->save(); |
436 | - do_action( 'getpaid_discount_metabox_save', $post_id, $discount ); |
|
436 | + do_action('getpaid_discount_metabox_save', $post_id, $discount); |
|
437 | 437 | } |
438 | 438 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,13 +20,13 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | |
25 | 25 | // Retrieve shipping address. |
26 | - $shipping_address = get_post_meta( $post->ID, 'shipping_address', true ); |
|
26 | + $shipping_address = get_post_meta($post->ID, 'shipping_address', true); |
|
27 | 27 | |
28 | 28 | // Abort if it is invalid. |
29 | - if ( ! is_array( $shipping_address ) ) { |
|
29 | + if (!is_array($shipping_address)) { |
|
30 | 30 | return; |
31 | 31 | } |
32 | 32 | |
@@ -34,29 +34,29 @@ discard block |
||
34 | 34 | |
35 | 35 | <div class="bsui"> |
36 | 36 | |
37 | - <?php if ( ! empty( $shipping_address['method'] ) ) : ?> |
|
37 | + <?php if (!empty($shipping_address['method'])) : ?> |
|
38 | 38 | |
39 | 39 | <div class="form-group mb-3 form-row row" style="color: green;"> |
40 | 40 | <div class="col"> |
41 | - <span style="font-weight: 600"><?php esc_html_e( 'Shipping Method', 'invoicing' ); ?>:</span> |
|
41 | + <span style="font-weight: 600"><?php esc_html_e('Shipping Method', 'invoicing'); ?>:</span> |
|
42 | 42 | </div> |
43 | 43 | <div class="col"> |
44 | - <?php echo wp_kses_post( $shipping_address['method'] ); ?> |
|
44 | + <?php echo wp_kses_post($shipping_address['method']); ?> |
|
45 | 45 | </div> |
46 | 46 | </div> |
47 | 47 | |
48 | 48 | <?php endif; ?> |
49 | 49 | |
50 | - <?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?> |
|
50 | + <?php foreach (getpaid_user_address_fields() as $key => $label) : ?> |
|
51 | 51 | |
52 | - <?php if ( ! empty( $shipping_address[ $key ] ) ) : ?> |
|
52 | + <?php if (!empty($shipping_address[$key])) : ?> |
|
53 | 53 | |
54 | 54 | <div class="form-group mb-3 form-row row"> |
55 | 55 | <div class="col"> |
56 | - <span style="font-weight: 600"><?php echo esc_html( $label ); ?>:</span> |
|
56 | + <span style="font-weight: 600"><?php echo esc_html($label); ?>:</span> |
|
57 | 57 | </div> |
58 | 58 | <div class="col"> |
59 | - <?php echo esc_html( self::prepare_for_display( $shipping_address, $key ) ); ?> |
|
59 | + <?php echo esc_html(self::prepare_for_display($shipping_address, $key)); ?> |
|
60 | 60 | </div> |
61 | 61 | </div> |
62 | 62 | |
@@ -77,21 +77,21 @@ discard block |
||
77 | 77 | * @param string $key |
78 | 78 | * @return string |
79 | 79 | */ |
80 | - public static function prepare_for_display( $address, $key ) { |
|
80 | + public static function prepare_for_display($address, $key) { |
|
81 | 81 | |
82 | 82 | // Prepare the value. |
83 | - $value = $address[ $key ]; |
|
83 | + $value = $address[$key]; |
|
84 | 84 | |
85 | - if ( $key == 'country' ) { |
|
86 | - $value = wpinv_country_name( $value ); |
|
85 | + if ($key == 'country') { |
|
86 | + $value = wpinv_country_name($value); |
|
87 | 87 | } |
88 | 88 | |
89 | - if ( $key == 'state' ) { |
|
90 | - $country = isset( $address['country'] ) ? $address['country'] : wpinv_get_default_country(); |
|
91 | - $value = wpinv_state_name( $value, $country ); |
|
89 | + if ($key == 'state') { |
|
90 | + $country = isset($address['country']) ? $address['country'] : wpinv_get_default_country(); |
|
91 | + $value = wpinv_state_name($value, $country); |
|
92 | 92 | } |
93 | 93 | |
94 | - return esc_html( $value ); |
|
94 | + return esc_html($value); |
|
95 | 95 | |
96 | 96 | } |
97 | 97 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,13 +21,13 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | 28 | |
29 | 29 | // Nonce field. |
30 | - wp_nonce_field( 'wpinv_details', 'wpinv_details_nonce' ); |
|
30 | + wp_nonce_field('wpinv_details', 'wpinv_details_nonce'); |
|
31 | 31 | |
32 | 32 | ?> |
33 | 33 | |
@@ -45,11 +45,11 @@ discard block |
||
45 | 45 | |
46 | 46 | <div class="bsui" style="margin-top: 1.5rem"> |
47 | 47 | |
48 | - <?php do_action( 'getpaid_invoice_edit_before_viewed_by_customer', $invoice ); ?> |
|
49 | - <?php if ( ! $invoice->is_draft() ) : ?> |
|
48 | + <?php do_action('getpaid_invoice_edit_before_viewed_by_customer', $invoice); ?> |
|
49 | + <?php if (!$invoice->is_draft()) : ?> |
|
50 | 50 | <div class="form-group mb-3"> |
51 | - <strong><?php esc_html_e( 'Viewed by Customer:', 'invoicing' ); ?></strong> |
|
52 | - <?php ( $invoice->get_is_viewed() ) ? esc_html_e( 'Yes', 'invoicing' ) : esc_html_e( 'No', 'invoicing' ); ?> |
|
51 | + <strong><?php esc_html_e('Viewed by Customer:', 'invoicing'); ?></strong> |
|
52 | + <?php ($invoice->get_is_viewed()) ? esc_html_e('Yes', 'invoicing') : esc_html_e('No', 'invoicing'); ?> |
|
53 | 53 | </div> |
54 | 54 | <?php endif; ?> |
55 | 55 | |
@@ -58,14 +58,14 @@ discard block |
||
58 | 58 | // Date created. |
59 | 59 | $label = sprintf( |
60 | 60 | // translators: %s is the invoice type. |
61 | - __( '%s Date:', 'invoicing' ), |
|
62 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
61 | + __('%s Date:', 'invoicing'), |
|
62 | + ucfirst($invoice->get_invoice_quote_type()) |
|
63 | 63 | ); |
64 | 64 | |
65 | - $info = sprintf( |
|
65 | + $info = sprintf( |
|
66 | 66 | // translators: %s is the invoice type. |
67 | - __( 'The date this %s was created.', 'invoicing' ), |
|
68 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
67 | + __('The date this %s was created.', 'invoicing'), |
|
68 | + strtolower($invoice->get_invoice_quote_type()) |
|
69 | 69 | ); |
70 | 70 | |
71 | 71 | aui()->input( |
@@ -73,11 +73,11 @@ discard block |
||
73 | 73 | 'type' => 'datepicker', |
74 | 74 | 'id' => 'wpinv_date_created', |
75 | 75 | 'name' => 'date_created', |
76 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
76 | + 'label' => $label . getpaid_get_help_tip($info), |
|
77 | 77 | 'label_type' => 'vertical', |
78 | 78 | 'placeholder' => 'YYYY-MM-DD 00:00', |
79 | 79 | 'class' => 'form-control-sm', |
80 | - 'value' => $invoice->get_date_created( 'edit' ), |
|
80 | + 'value' => $invoice->get_date_created('edit'), |
|
81 | 81 | 'extra_attributes' => array( |
82 | 82 | 'data-enable-time' => 'true', |
83 | 83 | 'data-time_24hr' => 'true', |
@@ -94,28 +94,28 @@ discard block |
||
94 | 94 | 'type' => 'text', |
95 | 95 | 'id' => 'wpinv_date_completed', |
96 | 96 | 'name' => 'wpinv_date_completed', |
97 | - 'label' => __( 'Date Completed:', 'invoicing' ), |
|
97 | + 'label' => __('Date Completed:', 'invoicing'), |
|
98 | 98 | 'label_type' => 'vertical', |
99 | 99 | 'class' => 'form-control-sm', |
100 | - 'value' => $invoice->get_date_completed( 'edit' ), |
|
100 | + 'value' => $invoice->get_date_completed('edit'), |
|
101 | 101 | 'placeholder' => 'YYYY-MM-DD 00:00', |
102 | 102 | ), |
103 | 103 | true |
104 | 104 | ); |
105 | 105 | |
106 | 106 | // Due date. |
107 | - if ( $invoice->is_type( 'invoice' ) && wpinv_get_option( 'overdue_active' ) && ( ! $invoice->is_paid() || $invoice->is_draft() ) ) { |
|
107 | + if ($invoice->is_type('invoice') && wpinv_get_option('overdue_active') && (!$invoice->is_paid() || $invoice->is_draft())) { |
|
108 | 108 | |
109 | 109 | aui()->input( |
110 | 110 | array( |
111 | 111 | 'type' => 'datepicker', |
112 | 112 | 'id' => 'wpinv_due_date', |
113 | 113 | 'name' => 'wpinv_due_date', |
114 | - 'label' => __( 'Due Date:', 'invoicing' ) . getpaid_get_help_tip( __( 'Leave blank to disable automated reminder emails for this invoice.', 'invoicing' ) ), |
|
114 | + 'label' => __('Due Date:', 'invoicing') . getpaid_get_help_tip(__('Leave blank to disable automated reminder emails for this invoice.', 'invoicing')), |
|
115 | 115 | 'label_type' => 'vertical', |
116 | - 'placeholder' => __( 'No due date', 'invoicing' ), |
|
116 | + 'placeholder' => __('No due date', 'invoicing'), |
|
117 | 117 | 'class' => 'form-control-sm', |
118 | - 'value' => $invoice->get_due_date( 'edit' ), |
|
118 | + 'value' => $invoice->get_due_date('edit'), |
|
119 | 119 | 'extra_attributes' => array( |
120 | 120 | 'data-enable-time' => 'true', |
121 | 121 | 'data-time_24hr' => 'true', |
@@ -128,28 +128,28 @@ discard block |
||
128 | 128 | |
129 | 129 | } |
130 | 130 | |
131 | - do_action( 'wpinv_meta_box_details_after_due_date', $invoice->get_id() ); |
|
132 | - do_action( 'getpaid_metabox_after_due_date', $invoice ); |
|
131 | + do_action('wpinv_meta_box_details_after_due_date', $invoice->get_id()); |
|
132 | + do_action('getpaid_metabox_after_due_date', $invoice); |
|
133 | 133 | |
134 | 134 | // Status. |
135 | 135 | $label = sprintf( |
136 | 136 | // translators: %s: Invoice type. |
137 | - __( '%s Status:', 'invoicing' ), |
|
138 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
137 | + __('%s Status:', 'invoicing'), |
|
138 | + ucfirst($invoice->get_invoice_quote_type()) |
|
139 | 139 | ); |
140 | 140 | |
141 | - $status = $invoice->get_status( 'edit' ); |
|
141 | + $status = $invoice->get_status('edit'); |
|
142 | 142 | aui()->select( |
143 | 143 | array( |
144 | 144 | 'id' => 'wpinv_status', |
145 | 145 | 'name' => 'wpinv_status', |
146 | 146 | 'label' => $label, |
147 | 147 | 'label_type' => 'vertical', |
148 | - 'placeholder' => __( 'Select Status', 'invoicing' ), |
|
149 | - 'value' => array_key_exists( $status, $invoice->get_all_statuses() ) ? $status : $invoice->get_default_status(), |
|
148 | + 'placeholder' => __('Select Status', 'invoicing'), |
|
149 | + 'value' => array_key_exists($status, $invoice->get_all_statuses()) ? $status : $invoice->get_default_status(), |
|
150 | 150 | 'select2' => true, |
151 | 151 | 'data-allow-clear' => 'false', |
152 | - 'options' => wpinv_get_invoice_statuses( true, false, $invoice ), |
|
152 | + 'options' => wpinv_get_invoice_statuses(true, false, $invoice), |
|
153 | 153 | ), |
154 | 154 | true |
155 | 155 | ); |
@@ -157,14 +157,14 @@ discard block |
||
157 | 157 | // Invoice number. |
158 | 158 | $label = sprintf( |
159 | 159 | // translators: %s: Invoice type. |
160 | - __( '%s Number:', 'invoicing' ), |
|
161 | - ucfirst( $invoice->get_invoice_quote_type() ) |
|
160 | + __('%s Number:', 'invoicing'), |
|
161 | + ucfirst($invoice->get_invoice_quote_type()) |
|
162 | 162 | ); |
163 | 163 | |
164 | - $info = sprintf( |
|
164 | + $info = sprintf( |
|
165 | 165 | // translators: %s: Invoice type. |
166 | - __( 'Each %s number must be unique.', 'invoicing' ), |
|
167 | - strtolower( $invoice->get_invoice_quote_type() ) |
|
166 | + __('Each %s number must be unique.', 'invoicing'), |
|
167 | + strtolower($invoice->get_invoice_quote_type()) |
|
168 | 168 | ); |
169 | 169 | |
170 | 170 | aui()->input( |
@@ -172,11 +172,11 @@ discard block |
||
172 | 172 | 'type' => 'text', |
173 | 173 | 'id' => 'wpinv_number', |
174 | 174 | 'name' => 'wpinv_number', |
175 | - 'label' => $label . getpaid_get_help_tip( $info ), |
|
175 | + 'label' => $label . getpaid_get_help_tip($info), |
|
176 | 176 | 'label_type' => 'vertical', |
177 | - 'placeholder' => __( 'Autogenerate', 'invoicing' ), |
|
177 | + 'placeholder' => __('Autogenerate', 'invoicing'), |
|
178 | 178 | 'class' => 'form-control-sm', |
179 | - 'value' => $invoice->get_number( 'edit' ), |
|
179 | + 'value' => $invoice->get_number('edit'), |
|
180 | 180 | ), |
181 | 181 | true |
182 | 182 | ); |
@@ -187,16 +187,16 @@ discard block |
||
187 | 187 | 'type' => 'text', |
188 | 188 | 'id' => 'wpinv_cc', |
189 | 189 | 'name' => 'wpinv_cc', |
190 | - 'label' => __( 'Email CC:', 'invoicing' ) . getpaid_get_help_tip( __( 'Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing' ) ), |
|
190 | + 'label' => __('Email CC:', 'invoicing') . getpaid_get_help_tip(__('Enter a comma separated list of other emails that should be notified about the invoice.', 'invoicing')), |
|
191 | 191 | 'label_type' => 'vertical', |
192 | - 'placeholder' => __( '[email protected], [email protected]', 'invoicing' ), |
|
192 | + 'placeholder' => __('[email protected], [email protected]', 'invoicing'), |
|
193 | 193 | 'class' => 'form-control-sm', |
194 | - 'value' => $invoice->get_email_cc( 'edit' ), |
|
194 | + 'value' => $invoice->get_email_cc('edit'), |
|
195 | 195 | ), |
196 | 196 | true |
197 | 197 | ); |
198 | 198 | |
199 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
199 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
200 | 200 | |
201 | 201 | // Apply a discount. |
202 | 202 | aui()->input( |
@@ -204,26 +204,26 @@ discard block |
||
204 | 204 | 'type' => 'text', |
205 | 205 | 'id' => 'wpinv_discount_code', |
206 | 206 | 'name' => 'wpinv_discount_code', |
207 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
208 | - 'placeholder' => __( 'Apply Discount', 'invoicing' ), |
|
207 | + 'label' => __('Discount Code:', 'invoicing'), |
|
208 | + 'placeholder' => __('Apply Discount', 'invoicing'), |
|
209 | 209 | 'label_type' => 'vertical', |
210 | 210 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
211 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
211 | + 'value' => $invoice->get_discount_code('edit'), |
|
212 | 212 | ), |
213 | 213 | true |
214 | 214 | ); |
215 | 215 | |
216 | - } elseif ( $invoice->get_discount_code( 'edit' ) ) { |
|
216 | + } elseif ($invoice->get_discount_code('edit')) { |
|
217 | 217 | |
218 | 218 | aui()->input( |
219 | 219 | array( |
220 | 220 | 'type' => 'text', |
221 | 221 | 'id' => 'wpinv_discount_code', |
222 | 222 | 'name' => 'wpinv_discount_code', |
223 | - 'label' => __( 'Discount Code:', 'invoicing' ), |
|
223 | + 'label' => __('Discount Code:', 'invoicing'), |
|
224 | 224 | 'label_type' => 'vertical', |
225 | 225 | 'class' => 'form-control-sm', |
226 | - 'value' => $invoice->get_discount_code( 'edit' ), |
|
226 | + 'value' => $invoice->get_discount_code('edit'), |
|
227 | 227 | 'extra_attributes' => array( |
228 | 228 | 'onclick' => 'this.select();', |
229 | 229 | 'readonly' => 'true', |
@@ -234,17 +234,17 @@ discard block |
||
234 | 234 | |
235 | 235 | } |
236 | 236 | |
237 | - do_action( 'wpinv_meta_box_details_inner', $invoice->get_id() ); |
|
237 | + do_action('wpinv_meta_box_details_inner', $invoice->get_id()); |
|
238 | 238 | |
239 | 239 | // Disable taxes. |
240 | - if ( wpinv_use_taxes() && ! ( $invoice->is_paid() || $invoice->is_refunded() ) ) { |
|
240 | + if (wpinv_use_taxes() && !($invoice->is_paid() || $invoice->is_refunded())) { |
|
241 | 241 | |
242 | 242 | aui()->input( |
243 | 243 | array( |
244 | 244 | 'id' => 'wpinv_taxable', |
245 | 245 | 'name' => 'disable_taxes', |
246 | 246 | 'type' => 'checkbox', |
247 | - 'label' => __( 'Disable taxes', 'invoicing' ), |
|
247 | + 'label' => __('Disable taxes', 'invoicing'), |
|
248 | 248 | 'value' => '1', |
249 | 249 | 'checked' => (bool) $invoice->get_disable_taxes(), |
250 | 250 | 'class' => 'getpaid-recalculate-prices-on-change', |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | |
255 | 255 | } |
256 | 256 | |
257 | - if ( $invoice->is_type( 'invoice' ) ) { |
|
257 | + if ($invoice->is_type('invoice')) { |
|
258 | 258 | |
259 | 259 | // Send to customer. |
260 | 260 | aui()->input( |
@@ -262,16 +262,16 @@ discard block |
||
262 | 262 | 'id' => 'wpinv_send_to_customer', |
263 | 263 | 'name' => 'send_to_customer', |
264 | 264 | 'type' => 'checkbox', |
265 | - 'label' => __( 'Send invoice to customer after saving', 'invoicing' ), |
|
265 | + 'label' => __('Send invoice to customer after saving', 'invoicing'), |
|
266 | 266 | 'value' => '1', |
267 | - 'checked' => $invoice->is_draft() && (bool) wpinv_get_option( 'email_user_invoice_active', true ), |
|
267 | + 'checked' => $invoice->is_draft() && (bool) wpinv_get_option('email_user_invoice_active', true), |
|
268 | 268 | ), |
269 | 269 | true |
270 | 270 | ); |
271 | 271 | |
272 | 272 | } |
273 | 273 | |
274 | - do_action( 'getpaid_metabox_after_invoice_details', $invoice ); |
|
274 | + do_action('getpaid_metabox_after_invoice_details', $invoice); |
|
275 | 275 | |
276 | 276 | ?> |
277 | 277 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,20 +21,20 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_item_before_info_metabox', $item ); ?> |
|
32 | + <?php do_action('wpinv_item_before_info_metabox', $item); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_item_type form-group mb-3 row"> |
35 | 35 | <label for="wpinv_item_type" class="col-sm-12 col-form-label"> |
36 | - <?php esc_html_e( 'Item Type', 'invoicing' ); ?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr( self::get_tooltip( $post ) ); ?>"></span> |
|
36 | + <?php esc_html_e('Item Type', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php echo esc_attr(self::get_tooltip($post)); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | array( |
45 | 45 | 'id' => 'wpinv_item_type', |
46 | 46 | 'name' => 'wpinv_item_type', |
47 | - 'placeholder' => __( 'Select item type', 'invoicing' ), |
|
48 | - 'value' => $item->get_type( 'edit' ), |
|
47 | + 'placeholder' => __('Select item type', 'invoicing'), |
|
48 | + 'value' => $item->get_type('edit'), |
|
49 | 49 | 'select2' => true, |
50 | 50 | 'data-allow-clear' => 'false', |
51 | 51 | 'no_wrap' => true, |
@@ -58,59 +58,59 @@ discard block |
||
58 | 58 | </div> |
59 | 59 | </div> |
60 | 60 | |
61 | - <?php if ( 'fee' === $item->get_type( 'edit' ) || 'custom' === $item->get_type( 'edit' ) ) : ?> |
|
61 | + <?php if ('fee' === $item->get_type('edit') || 'custom' === $item->get_type('edit')) : ?> |
|
62 | 62 | |
63 | 63 | <div class="wpinv_item_shortcode form-group mb-3 row"> |
64 | 64 | <label for="wpinv_item_shortcode" class="col-sm-12 col-form-label"> |
65 | - <?php esc_html_e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
66 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
65 | + <?php esc_html_e('Payment Form Shortcode', 'invoicing'); ?> |
|
66 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
67 | 67 | </label> |
68 | 68 | |
69 | 69 | <div class="col-sm-12"> |
70 | - <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?>]" style="width: 100%;" readonly/> |
|
70 | + <input onClick="this.select()" type="text" id="wpinv_item_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?>]" style="width: 100%;" readonly/> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | |
74 | 74 | <div class="wpinv_item_buy_shortcode form-group mb-3 row"> |
75 | 75 | <label for="wpinv_item_button_shortcode" class="col-sm-12 col-form-label"> |
76 | - <?php esc_html_e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
77 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
76 | + <?php esc_html_e('Payment Button Shortcode', 'invoicing'); ?> |
|
77 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
78 | 78 | </label> |
79 | 79 | |
80 | 80 | <div class="col-sm-12"> |
81 | - <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr( $item->get_id() ); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
81 | + <input onClick="this.select()" type="text" id="wpinv_item_button_shortcode" value="[getpaid item=<?php echo esc_attr($item->get_id()); ?> button='Buy Now']" style="width: 100%;" readonly/> |
|
82 | 82 | <small class="form-text text-muted"> |
83 | - <?php esc_html_e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
84 | - <code>#getpaid-item-<?php echo intval( $item->get_id() ); ?>|0</code> |
|
83 | + <?php esc_html_e('Or use the following URL in a link:', 'invoicing'); ?> |
|
84 | + <code>#getpaid-item-<?php echo intval($item->get_id()); ?>|0</code> |
|
85 | 85 | </small> |
86 | 86 | </div> |
87 | 87 | </div> |
88 | 88 | |
89 | 89 | <div class="wpinv_item_buy_url form-group mb-3 row"> |
90 | 90 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
91 | - <?php esc_html_e( 'Direct Payment URL', 'invoicing' ); ?> |
|
92 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
91 | + <?php esc_html_e('Direct Payment URL', 'invoicing'); ?> |
|
92 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
93 | 93 | </label> |
94 | 94 | |
95 | 95 | <div class="col-sm-12"> |
96 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( false, $item->get_id() . '|0' ) ); ?>" style="width: 100%;" readonly/> |
|
96 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url(false, $item->get_id() . '|0')); ?>" style="width: 100%;" readonly/> |
|
97 | 97 | </div> |
98 | 98 | </div> |
99 | 99 | |
100 | 100 | <?php endif; ?> |
101 | 101 | |
102 | 102 | <div class="wpinv_item_custom_id form-group mb-3"> |
103 | - <?php esc_html_e( 'Custom ID', 'invoicing' ); ?> — <?php echo esc_html( $item->get_custom_id() ); ?> |
|
103 | + <?php esc_html_e('Custom ID', 'invoicing'); ?> — <?php echo esc_html($item->get_custom_id()); ?> |
|
104 | 104 | </div> |
105 | 105 | |
106 | - <?php do_action( 'wpinv_meta_values_metabox_before', $post ); ?> |
|
107 | - <?php foreach ( apply_filters( 'wpinv_show_meta_values_for_keys', array() ) as $meta_key ) : ?> |
|
106 | + <?php do_action('wpinv_meta_values_metabox_before', $post); ?> |
|
107 | + <?php foreach (apply_filters('wpinv_show_meta_values_for_keys', array()) as $meta_key) : ?> |
|
108 | 108 | <div class="wpinv_item_custom_id form-group mb-3"> |
109 | - <?php echo esc_html( $meta_key ); ?> — <?php echo esc_html( get_post_meta( $item->get_id(), '_wpinv_' . $meta_key, true ) ); ?> |
|
109 | + <?php echo esc_html($meta_key); ?> — <?php echo esc_html(get_post_meta($item->get_id(), '_wpinv_' . $meta_key, true)); ?> |
|
110 | 110 | </div> |
111 | 111 | <?php endforeach; ?> |
112 | - <?php do_action( 'wpinv_meta_values_metabox_after', $post ); ?> |
|
113 | - <?php do_action( 'wpinv_item_info_metabox', $item ); ?> |
|
112 | + <?php do_action('wpinv_meta_values_metabox_after', $post); ?> |
|
113 | + <?php do_action('wpinv_item_info_metabox', $item); ?> |
|
114 | 114 | </div> |
115 | 115 | <?php |
116 | 116 | |
@@ -120,16 +120,16 @@ discard block |
||
120 | 120 | * Returns item type tolltip. |
121 | 121 | * |
122 | 122 | */ |
123 | - public static function get_tooltip( $post ) { |
|
123 | + public static function get_tooltip($post) { |
|
124 | 124 | |
125 | 125 | ob_start(); |
126 | 126 | ?> |
127 | 127 | |
128 | - <?php esc_html_e( 'Standard: Standard item type', 'invoicing' ); ?> |
|
129 | - <?php esc_html_e( 'Fee: Like Registration Fee, Sign up Fee etc', 'invoicing' ); ?> |
|
128 | + <?php esc_html_e('Standard: Standard item type', 'invoicing'); ?> |
|
129 | + <?php esc_html_e('Fee: Like Registration Fee, Sign up Fee etc', 'invoicing'); ?> |
|
130 | 130 | |
131 | 131 | <?php |
132 | - do_action( 'wpinv_item_info_metabox_after', $post ); |
|
132 | + do_action('wpinv_item_info_metabox_after', $post); |
|
133 | 133 | |
134 | 134 | return ob_get_clean(); |
135 | 135 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,54 +21,54 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the form. |
27 | - $form = new GetPaid_Payment_Form( $post ); |
|
27 | + $form = new GetPaid_Payment_Form($post); |
|
28 | 28 | |
29 | 29 | ?> |
30 | 30 | |
31 | 31 | <div class='bsui' style='padding-top: 10px;'> |
32 | - <?php do_action( 'wpinv_payment_form_before_info_metabox', $form ); ?> |
|
32 | + <?php do_action('wpinv_payment_form_before_info_metabox', $form); ?> |
|
33 | 33 | |
34 | 34 | <div class="wpinv_payment_form_shortcode form-group mb-3 row"> |
35 | 35 | <label for="wpinv_payment_form_shortcode" class="col-sm-12 col-form-label"> |
36 | - <?php esc_html_e( 'Payment Form Shortcode', 'invoicing' ); ?> |
|
37 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a payment form', 'invoicing' ); ?>"></span> |
|
36 | + <?php esc_html_e('Payment Form Shortcode', 'invoicing'); ?> |
|
37 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a payment form', 'invoicing'); ?>"></span> |
|
38 | 38 | </label> |
39 | 39 | |
40 | 40 | <div class="col-sm-12"> |
41 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?>]" style="width: 100%;" /> |
|
41 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?>]" style="width: 100%;" /> |
|
42 | 42 | </div> |
43 | 43 | </div> |
44 | 44 | |
45 | 45 | <div class="wpinv_payment_form_buy_shortcode form-group mb-3 row"> |
46 | 46 | <label for="wpinv_payment_form_buy_shortcode" class="col-sm-12 col-form-label"> |
47 | - <?php esc_html_e( 'Payment Button Shortcode', 'invoicing' ); ?> |
|
48 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Displays a buy now button', 'invoicing' ); ?>"></span> |
|
47 | + <?php esc_html_e('Payment Button Shortcode', 'invoicing'); ?> |
|
48 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Displays a buy now button', 'invoicing'); ?>"></span> |
|
49 | 49 | </label> |
50 | 50 | |
51 | 51 | <div class="col-sm-12"> |
52 | - <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr( $form->get_id() ); ?> button='Buy Now']" style="width: 100%;" /> |
|
52 | + <input onClick="this.select()" type="text" id="wpinv_payment_form_buy_shortcode" value="[getpaid form=<?php echo esc_attr($form->get_id()); ?> button='Buy Now']" style="width: 100%;" /> |
|
53 | 53 | <small class="form-text text-muted"> |
54 | - <?php esc_html_e( 'Or use the following URL in a link:', 'invoicing' ); ?> |
|
55 | - <code>#getpaid-form-<?php echo intval( $form->get_id() ); ?></code> |
|
54 | + <?php esc_html_e('Or use the following URL in a link:', 'invoicing'); ?> |
|
55 | + <code>#getpaid-form-<?php echo intval($form->get_id()); ?></code> |
|
56 | 56 | </small> |
57 | 57 | </div> |
58 | 58 | </div> |
59 | 59 | |
60 | 60 | <div class="wpinv_item_buy_url form-group row mb-3"> |
61 | 61 | <label for="wpinv_item_buy_url" class="col-sm-12 col-form-label"> |
62 | - <?php esc_html_e( 'Direct Payment URL', 'invoicing' ); ?> |
|
63 | - <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'You can use this in an iFrame to embed the payment form on another website', 'invoicing' ); ?>"></span> |
|
62 | + <?php esc_html_e('Direct Payment URL', 'invoicing'); ?> |
|
63 | + <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('You can use this in an iFrame to embed the payment form on another website', 'invoicing'); ?>"></span> |
|
64 | 64 | </label> |
65 | 65 | |
66 | 66 | <div class="col-sm-12"> |
67 | - <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url( getpaid_embed_url( $form->get_id(), false ) ); ?>" style="width: 100%;" readonly/> |
|
67 | + <input onClick="this.select()" type="text" id="wpinv_item_buy_url" value="<?php echo esc_url(getpaid_embed_url($form->get_id(), false)); ?>" style="width: 100%;" readonly/> |
|
68 | 68 | </div> |
69 | 69 | </div> |
70 | 70 | |
71 | - <?php do_action( 'wpinv_payment_form_info_metabox', $form ); ?> |
|
71 | + <?php do_action('wpinv_payment_form_info_metabox', $form); ?> |
|
72 | 72 | </div> |
73 | 73 | <?php |
74 | 74 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,14 +21,14 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the invoice. |
27 | - $invoice = new WPInv_Invoice( $post ); |
|
28 | - $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id(); |
|
29 | - $customer = new WP_User( $customer ); |
|
30 | - $display = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email ); |
|
31 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
27 | + $invoice = new WPInv_Invoice($post); |
|
28 | + $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id(); |
|
29 | + $customer = new WP_User($customer); |
|
30 | + $display = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email); |
|
31 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
32 | 32 | |
33 | 33 | ?> |
34 | 34 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | <div class="col-12 col-sm-6"> |
44 | 44 | <div id="getpaid-invoice-user-id-wrapper" class="form-group mb-3"> |
45 | 45 | <div> |
46 | - <label for="post_author_override"><?php esc_html_e( 'Customer', 'invoicing' ); ?></label> |
|
46 | + <label for="post_author_override"><?php esc_html_e('Customer', 'invoicing'); ?></label> |
|
47 | 47 | </div> |
48 | 48 | <div> |
49 | - <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>"> |
|
50 | - <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>) |
|
49 | + <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>"> |
|
50 | + <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>) |
|
51 | 51 | </select> |
52 | 52 | </div> |
53 | 53 | </div> |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'type' => 'text', |
61 | 61 | 'id' => 'getpaid-invoice-new-user-email', |
62 | 62 | 'name' => 'wpinv_email', |
63 | - 'label' => __( 'Email', 'invoicing' ) . '<span class="required">*</span>', |
|
63 | + 'label' => __('Email', 'invoicing') . '<span class="required">*</span>', |
|
64 | 64 | 'label_type' => 'vertical', |
65 | 65 | 'placeholder' => '[email protected]', |
66 | 66 | 'class' => 'form-control-sm', |
@@ -71,18 +71,18 @@ discard block |
||
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | <div class="col-12 col-sm-6 form-group mb-3 mt-sm-4"> |
74 | - <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?> |
|
74 | + <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?> |
|
75 | 75 | <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)"> |
76 | 76 | <i aria-hidden="true" class="fa fa-refresh"></i> |
77 | - <?php esc_html_e( 'Fill User Details', 'invoicing' ); ?> |
|
77 | + <?php esc_html_e('Fill User Details', 'invoicing'); ?> |
|
78 | 78 | </a> |
79 | 79 | <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)"> |
80 | 80 | <i aria-hidden="true" class="fa fa-plus"></i> |
81 | - <?php esc_html_e( 'Add New User', 'invoicing' ); ?> |
|
81 | + <?php esc_html_e('Add New User', 'invoicing'); ?> |
|
82 | 82 | </a> |
83 | 83 | <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)"> |
84 | 84 | <i aria-hidden="true" class="fa fa-close"></i> |
85 | - <?php esc_html_e( 'Cancel', 'invoicing' ); ?> |
|
85 | + <?php esc_html_e('Cancel', 'invoicing'); ?> |
|
86 | 86 | </a> |
87 | 87 | <?php endif; ?> |
88 | 88 | </div> |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | 'type' => 'text', |
96 | 96 | 'id' => 'wpinv_first_name', |
97 | 97 | 'name' => 'wpinv_first_name', |
98 | - 'label' => __( 'First Name', 'invoicing' ), |
|
98 | + 'label' => __('First Name', 'invoicing'), |
|
99 | 99 | 'label_type' => 'vertical', |
100 | 100 | 'placeholder' => '', |
101 | 101 | 'class' => 'form-control-sm', |
102 | - 'value' => $invoice->get_first_name( 'edit' ), |
|
102 | + 'value' => $invoice->get_first_name('edit'), |
|
103 | 103 | ), |
104 | 104 | true |
105 | 105 | ); |
@@ -112,11 +112,11 @@ discard block |
||
112 | 112 | 'type' => 'text', |
113 | 113 | 'id' => 'wpinv_last_name', |
114 | 114 | 'name' => 'wpinv_last_name', |
115 | - 'label' => __( 'Last Name', 'invoicing' ), |
|
115 | + 'label' => __('Last Name', 'invoicing'), |
|
116 | 116 | 'label_type' => 'vertical', |
117 | 117 | 'placeholder' => '', |
118 | 118 | 'class' => 'form-control-sm', |
119 | - 'value' => $invoice->get_last_name( 'edit' ), |
|
119 | + 'value' => $invoice->get_last_name('edit'), |
|
120 | 120 | ), |
121 | 121 | true |
122 | 122 | ); |
@@ -132,11 +132,11 @@ discard block |
||
132 | 132 | 'type' => 'text', |
133 | 133 | 'id' => 'wpinv_company', |
134 | 134 | 'name' => 'wpinv_company', |
135 | - 'label' => __( 'Company', 'invoicing' ), |
|
135 | + 'label' => __('Company', 'invoicing'), |
|
136 | 136 | 'label_type' => 'vertical', |
137 | 137 | 'placeholder' => '', |
138 | 138 | 'class' => 'form-control-sm', |
139 | - 'value' => $invoice->get_company( 'edit' ), |
|
139 | + 'value' => $invoice->get_company('edit'), |
|
140 | 140 | ), |
141 | 141 | true |
142 | 142 | ); |
@@ -149,11 +149,11 @@ discard block |
||
149 | 149 | 'type' => 'text', |
150 | 150 | 'id' => 'wpinv_vat_number', |
151 | 151 | 'name' => 'wpinv_vat_number', |
152 | - 'label' => __( 'Vat Number', 'invoicing' ), |
|
152 | + 'label' => __('Vat Number', 'invoicing'), |
|
153 | 153 | 'label_type' => 'vertical', |
154 | 154 | 'placeholder' => '', |
155 | 155 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
156 | - 'value' => $invoice->get_vat_number( 'edit' ), |
|
156 | + 'value' => $invoice->get_vat_number('edit'), |
|
157 | 157 | ), |
158 | 158 | true |
159 | 159 | ); |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | 'type' => 'text', |
170 | 170 | 'id' => 'wpinv_address', |
171 | 171 | 'name' => 'wpinv_address', |
172 | - 'label' => __( 'Address', 'invoicing' ), |
|
172 | + 'label' => __('Address', 'invoicing'), |
|
173 | 173 | 'label_type' => 'vertical', |
174 | 174 | 'placeholder' => '', |
175 | 175 | 'class' => 'form-control-sm', |
176 | - 'value' => $invoice->get_address( 'edit' ), |
|
176 | + 'value' => $invoice->get_address('edit'), |
|
177 | 177 | ), |
178 | 178 | true |
179 | 179 | ); |
@@ -186,11 +186,11 @@ discard block |
||
186 | 186 | 'type' => 'text', |
187 | 187 | 'id' => 'wpinv_city', |
188 | 188 | 'name' => 'wpinv_city', |
189 | - 'label' => __( 'City', 'invoicing' ), |
|
189 | + 'label' => __('City', 'invoicing'), |
|
190 | 190 | 'label_type' => 'vertical', |
191 | 191 | 'placeholder' => '', |
192 | 192 | 'class' => 'form-control-sm', |
193 | - 'value' => $invoice->get_city( 'edit' ), |
|
193 | + 'value' => $invoice->get_city('edit'), |
|
194 | 194 | ), |
195 | 195 | true |
196 | 196 | ); |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | array( |
206 | 206 | 'id' => 'wpinv_country', |
207 | 207 | 'name' => 'wpinv_country', |
208 | - 'label' => __( 'Country', 'invoicing' ), |
|
208 | + 'label' => __('Country', 'invoicing'), |
|
209 | 209 | 'label_type' => 'vertical', |
210 | - 'placeholder' => __( 'Choose a country', 'invoicing' ), |
|
210 | + 'placeholder' => __('Choose a country', 'invoicing'), |
|
211 | 211 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
212 | - 'value' => $invoice->get_country( 'edit' ), |
|
212 | + 'value' => $invoice->get_country('edit'), |
|
213 | 213 | 'options' => wpinv_get_country_list(), |
214 | 214 | 'data-allow-clear' => 'false', |
215 | 215 | 'select2' => true, |
@@ -221,20 +221,20 @@ discard block |
||
221 | 221 | <div class="col-12 col-sm-6"> |
222 | 222 | <?php |
223 | 223 | |
224 | - $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) ); |
|
224 | + $states = wpinv_get_country_states($invoice->get_country('edit')); |
|
225 | 225 | |
226 | - if ( empty( $states ) ) { |
|
226 | + if (empty($states)) { |
|
227 | 227 | |
228 | 228 | aui()->input( |
229 | 229 | array( |
230 | 230 | 'type' => 'text', |
231 | 231 | 'id' => 'wpinv_state', |
232 | 232 | 'name' => 'wpinv_state', |
233 | - 'label' => __( 'State', 'invoicing' ), |
|
233 | + 'label' => __('State', 'invoicing'), |
|
234 | 234 | 'label_type' => 'vertical', |
235 | 235 | 'placeholder' => '', |
236 | 236 | 'class' => 'form-control-sm', |
237 | - 'value' => $invoice->get_state( 'edit' ), |
|
237 | + 'value' => $invoice->get_state('edit'), |
|
238 | 238 | ), |
239 | 239 | true |
240 | 240 | ); |
@@ -245,11 +245,11 @@ discard block |
||
245 | 245 | array( |
246 | 246 | 'id' => 'wpinv_state', |
247 | 247 | 'name' => 'wpinv_state', |
248 | - 'label' => __( 'State', 'invoicing' ), |
|
248 | + 'label' => __('State', 'invoicing'), |
|
249 | 249 | 'label_type' => 'vertical', |
250 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
250 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
251 | 251 | 'class' => 'form-control-sm', |
252 | - 'value' => $invoice->get_state( 'edit' ), |
|
252 | + 'value' => $invoice->get_state('edit'), |
|
253 | 253 | 'options' => $states, |
254 | 254 | 'data-allow-clear' => 'false', |
255 | 255 | 'select2' => true, |
@@ -271,11 +271,11 @@ discard block |
||
271 | 271 | 'type' => 'text', |
272 | 272 | 'id' => 'wpinv_zip', |
273 | 273 | 'name' => 'wpinv_zip', |
274 | - 'label' => __( 'Zip / Postal Code', 'invoicing' ), |
|
274 | + 'label' => __('Zip / Postal Code', 'invoicing'), |
|
275 | 275 | 'label_type' => 'vertical', |
276 | 276 | 'placeholder' => '', |
277 | 277 | 'class' => 'form-control-sm', |
278 | - 'value' => $invoice->get_zip( 'edit' ), |
|
278 | + 'value' => $invoice->get_zip('edit'), |
|
279 | 279 | ), |
280 | 280 | true |
281 | 281 | ); |
@@ -288,11 +288,11 @@ discard block |
||
288 | 288 | 'type' => 'text', |
289 | 289 | 'id' => 'wpinv_phone', |
290 | 290 | 'name' => 'wpinv_phone', |
291 | - 'label' => __( 'Phone', 'invoicing' ), |
|
291 | + 'label' => __('Phone', 'invoicing'), |
|
292 | 292 | 'label_type' => 'vertical', |
293 | 293 | 'placeholder' => '', |
294 | 294 | 'class' => 'form-control-sm', |
295 | - 'value' => $invoice->get_phone( 'edit' ), |
|
295 | + 'value' => $invoice->get_phone('edit'), |
|
296 | 296 | ), |
297 | 297 | true |
298 | 298 | ); |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | </div> |
301 | 301 | </div> |
302 | 302 | |
303 | - <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?> |
|
304 | - <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?> |
|
303 | + <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?> |
|
304 | + <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?> |
|
305 | 305 | |
306 | 306 | <div class="row"> |
307 | 307 | <div class="col-12 col-sm-6"> |
@@ -310,14 +310,14 @@ discard block |
||
310 | 310 | array( |
311 | 311 | 'id' => 'wpinv_template', |
312 | 312 | 'name' => 'wpinv_template', |
313 | - 'label' => __( 'Template', 'invoicing' ), |
|
313 | + 'label' => __('Template', 'invoicing'), |
|
314 | 314 | 'label_type' => 'vertical', |
315 | - 'placeholder' => __( 'Choose a template', 'invoicing' ), |
|
315 | + 'placeholder' => __('Choose a template', 'invoicing'), |
|
316 | 316 | 'class' => 'form-control-sm', |
317 | - 'value' => $invoice->get_template( 'edit' ), |
|
317 | + 'value' => $invoice->get_template('edit'), |
|
318 | 318 | 'options' => array( |
319 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
320 | - 'hours' => __( 'Hours', 'invoicing' ), |
|
319 | + 'quantity' => __('Quantity', 'invoicing'), |
|
320 | + 'hours' => __('Hours', 'invoicing'), |
|
321 | 321 | //'amount' => __( 'Amount Only', 'invoicing' ), |
322 | 322 | ), |
323 | 323 | 'data-allow-clear' => 'false', |
@@ -335,11 +335,11 @@ discard block |
||
335 | 335 | array( |
336 | 336 | 'id' => 'wpinv_currency', |
337 | 337 | 'name' => 'wpinv_currency', |
338 | - 'label' => __( 'Currency', 'invoicing' ), |
|
338 | + 'label' => __('Currency', 'invoicing'), |
|
339 | 339 | 'label_type' => 'vertical', |
340 | - 'placeholder' => __( 'Select Invoice Currency', 'invoicing' ), |
|
340 | + 'placeholder' => __('Select Invoice Currency', 'invoicing'), |
|
341 | 341 | 'class' => 'form-control-sm getpaid-recalculate-prices-on-change', |
342 | - 'value' => $invoice->get_currency( 'edit' ), |
|
342 | + 'value' => $invoice->get_currency('edit'), |
|
343 | 343 | 'required' => false, |
344 | 344 | 'data-allow-clear' => 'false', |
345 | 345 | 'select2' => true, |
@@ -352,7 +352,7 @@ discard block |
||
352 | 352 | </div> |
353 | 353 | </div> |
354 | 354 | |
355 | - <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?> |
|
355 | + <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?> |
|
356 | 356 | <?php endif; ?> |
357 | 357 | |
358 | 358 | <div class="row"> |
@@ -363,11 +363,11 @@ discard block |
||
363 | 363 | 'type' => 'text', |
364 | 364 | 'id' => 'wpinv_company_id', |
365 | 365 | 'name' => 'wpinv_company_id', |
366 | - 'label' => __( 'Company ID', 'invoicing' ), |
|
366 | + 'label' => __('Company ID', 'invoicing'), |
|
367 | 367 | 'label_type' => 'vertical', |
368 | 368 | 'placeholder' => '', |
369 | 369 | 'class' => 'form-control-sm', |
370 | - 'value' => $invoice->get_company_id( 'edit' ), |
|
370 | + 'value' => $invoice->get_company_id('edit'), |
|
371 | 371 | ), |
372 | 372 | true |
373 | 373 | ); |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | </div> |
376 | 376 | </div> |
377 | 377 | |
378 | - <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?> |
|
378 | + <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?> |
|
379 | 379 | </div> |
380 | 380 | <?php |
381 | 381 | } |
@@ -385,51 +385,51 @@ discard block |
||
385 | 385 | * |
386 | 386 | * @param int $post_id |
387 | 387 | */ |
388 | - public static function save( $post_id ) { |
|
388 | + public static function save($post_id) { |
|
389 | 389 | |
390 | 390 | // Prepare the invoice. |
391 | - $invoice = new WPInv_Invoice( $post_id ); |
|
391 | + $invoice = new WPInv_Invoice($post_id); |
|
392 | 392 | |
393 | 393 | // Load new data. |
394 | 394 | $invoice->set_props( |
395 | 395 | array( |
396 | - 'template' => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null, |
|
397 | - 'email_cc' => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null, |
|
398 | - 'disable_taxes' => ! empty( $_POST['disable_taxes'] ), |
|
399 | - 'currency' => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null, |
|
400 | - 'gateway' => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null, |
|
401 | - 'address' => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null, |
|
402 | - 'vat_number' => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null, |
|
403 | - 'company' => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null, |
|
404 | - 'company_id' => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null, |
|
405 | - 'zip' => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null, |
|
406 | - 'state' => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null, |
|
407 | - 'city' => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null, |
|
408 | - 'country' => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null, |
|
409 | - 'phone' => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null, |
|
410 | - 'first_name' => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null, |
|
411 | - 'last_name' => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null, |
|
412 | - 'author' => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null, |
|
413 | - 'date_created' => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null, |
|
414 | - 'date_completed' => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null, |
|
415 | - 'due_date' => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null, |
|
416 | - 'number' => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null, |
|
417 | - 'status' => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null, |
|
396 | + 'template' => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null, |
|
397 | + 'email_cc' => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null, |
|
398 | + 'disable_taxes' => !empty($_POST['disable_taxes']), |
|
399 | + 'currency' => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null, |
|
400 | + 'gateway' => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null, |
|
401 | + 'address' => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null, |
|
402 | + 'vat_number' => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null, |
|
403 | + 'company' => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null, |
|
404 | + 'company_id' => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null, |
|
405 | + 'zip' => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null, |
|
406 | + 'state' => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null, |
|
407 | + 'city' => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null, |
|
408 | + 'country' => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null, |
|
409 | + 'phone' => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null, |
|
410 | + 'first_name' => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null, |
|
411 | + 'last_name' => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null, |
|
412 | + 'author' => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null, |
|
413 | + 'date_created' => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null, |
|
414 | + 'date_completed' => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null, |
|
415 | + 'due_date' => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null, |
|
416 | + 'number' => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null, |
|
417 | + 'status' => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null, |
|
418 | 418 | ) |
419 | 419 | ); |
420 | 420 | |
421 | 421 | // Discount code. |
422 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
422 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
423 | 423 | |
424 | - if ( isset( $_POST['wpinv_discount_code'] ) ) { |
|
425 | - $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) ); |
|
424 | + if (isset($_POST['wpinv_discount_code'])) { |
|
425 | + $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code'])); |
|
426 | 426 | } |
427 | 427 | |
428 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
429 | - if ( $discount->exists() ) { |
|
430 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
428 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
429 | + if ($discount->exists()) { |
|
430 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
431 | 431 | } else { |
432 | - $invoice->remove_discount( 'discount_code' ); |
|
432 | + $invoice->remove_discount('discount_code'); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | // Recalculate totals. |
@@ -438,16 +438,16 @@ discard block |
||
438 | 438 | } |
439 | 439 | |
440 | 440 | // If we're creating a new user... |
441 | - if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) { |
|
441 | + if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) { |
|
442 | 442 | |
443 | 443 | // Attempt to create the user. |
444 | - $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ), $invoice->get_first_name() . $invoice->get_last_name() ); |
|
444 | + $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])), $invoice->get_first_name() . $invoice->get_last_name()); |
|
445 | 445 | |
446 | 446 | // If successful, update the invoice author. |
447 | - if ( is_numeric( $user ) ) { |
|
448 | - $invoice->set_author( $user ); |
|
447 | + if (is_numeric($user)) { |
|
448 | + $invoice->set_author($user); |
|
449 | 449 | } else { |
450 | - wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ ); |
|
450 | + wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__); |
|
451 | 451 | } |
452 | 452 | } |
453 | 453 | |
@@ -461,16 +461,16 @@ discard block |
||
461 | 461 | $GLOBALS['wpinv_skip_invoice_notification'] = false; |
462 | 462 | |
463 | 463 | // (Maybe) send new user notification. |
464 | - $should_send_notification = wpinv_get_option( 'disable_new_user_emails' ); |
|
465 | - if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) { |
|
466 | - wp_send_new_user_notifications( $user, 'user' ); |
|
464 | + $should_send_notification = wpinv_get_option('disable_new_user_emails'); |
|
465 | + if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) { |
|
466 | + wp_send_new_user_notifications($user, 'user'); |
|
467 | 467 | } |
468 | 468 | |
469 | - if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) { |
|
470 | - getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true ); |
|
469 | + if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) { |
|
470 | + getpaid()->get('invoice_emails')->user_invoice($invoice, true); |
|
471 | 471 | } |
472 | 472 | |
473 | 473 | // Fires after an invoice is saved. |
474 | - do_action( 'wpinv_invoice_metabox_saved', $invoice ); |
|
474 | + do_action('wpinv_invoice_metabox_saved', $invoice); |
|
475 | 475 | } |
476 | 476 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * |
7 | 7 | */ |
8 | 8 | |
9 | -if ( ! defined( 'ABSPATH' ) ) { |
|
9 | +if (!defined('ABSPATH')) { |
|
10 | 10 | exit; // Exit if accessed directly |
11 | 11 | } |
12 | 12 | |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | * |
21 | 21 | * @param WP_Post $post |
22 | 22 | */ |
23 | - public static function output( $post ) { |
|
23 | + public static function output($post) { |
|
24 | 24 | ?> |
25 | 25 | <style> |
26 | 26 | .wpinv-form-builder-edit-field-wrapper label.d-block > span:first-child{ |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | <div class="col-sm-4"> |
34 | 34 | |
35 | 35 | <!-- Builder tabs --> |
36 | - <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e( 'Go Back', 'invoicing' ); ?></button> |
|
36 | + <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php esc_html_e('Go Back', 'invoicing'); ?></button> |
|
37 | 37 | |
38 | 38 | <!-- Builder tab content --> |
39 | 39 | <div class="mt-4"> |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | <!-- Available builder elements --> |
42 | 42 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'"> |
43 | 43 | <div class="wpinv-form-builder-add-field-types"> |
44 | - <small class='form-text text-muted'><?php esc_html_e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small> |
|
44 | + <small class='form-text text-muted'><?php esc_html_e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small> |
|
45 | 45 | <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable"> |
46 | 46 | <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }"> |
47 | 47 | <button class="button btn text-dark"> |
@@ -56,18 +56,18 @@ discard block |
||
56 | 56 | <!-- Edit an element --> |
57 | 57 | <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;"> |
58 | 58 | <div class="wpinv-form-builder-edit-field-wrapper"> |
59 | - <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?> |
|
60 | - <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?> |
|
59 | + <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?> |
|
60 | + <?php do_action('getpaid_payment_form_edit_element_template', $post); ?> |
|
61 | 61 | <div class='form-group mb-3'> |
62 | - <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ); ?></label> |
|
62 | + <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing'); ?></label> |
|
63 | 63 | <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'> |
64 | - <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option> |
|
65 | - <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option> |
|
66 | - <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option> |
|
64 | + <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option> |
|
65 | + <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option> |
|
66 | + <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option> |
|
67 | 67 | </select> |
68 | 68 | </div> |
69 | 69 | <div> |
70 | - <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e( 'Delete Element', 'invoicing' ); ?></button> |
|
70 | + <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php esc_html_e('Delete Element', 'invoicing'); ?></button> |
|
71 | 71 | </div> |
72 | 72 | </div> |
73 | 73 | </div> |
@@ -76,15 +76,15 @@ discard block |
||
76 | 76 | |
77 | 77 | </div> |
78 | 78 | <div class="col-sm-8 border-left"> |
79 | - <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small> |
|
80 | - <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p> |
|
79 | + <small class='form-text text-muted' v-if='form_elements.length'><?php esc_html_e('Click on any element to edit or delete it.', 'invoicing'); ?></small> |
|
80 | + <p class='form-text text-muted' v-if='! form_elements.length'><?php esc_html_e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p> |
|
81 | 81 | |
82 | 82 | <div class="container-fluid"> |
83 | 83 | <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;"> |
84 | 84 | <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element && active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element"> |
85 | 85 | <div class="wpinv-form-builder-element-preview-inner"> |
86 | 86 | <div class="wpinv-payment-form-field-preview-overlay"></div> |
87 | - <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?> |
|
87 | + <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?> |
|
88 | 88 | </div> |
89 | 89 | </div> |
90 | 90 | </draggable> |
@@ -103,7 +103,7 @@ discard block |
||
103 | 103 | </script> |
104 | 104 | <?php |
105 | 105 | |
106 | - wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' ); |
|
106 | + wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -111,33 +111,33 @@ discard block |
||
111 | 111 | * |
112 | 112 | * @param int $post_id |
113 | 113 | */ |
114 | - public static function save( $post_id ) { |
|
114 | + public static function save($post_id) { |
|
115 | 115 | |
116 | 116 | // Prepare the form. |
117 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
117 | + $form = new GetPaid_Payment_Form($post_id); |
|
118 | 118 | |
119 | 119 | // Fetch form items. |
120 | - $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true ); |
|
120 | + $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true); |
|
121 | 121 | |
122 | 122 | // Ensure that we have an array... |
123 | - if ( empty( $form_items ) ) { |
|
123 | + if (empty($form_items)) { |
|
124 | 124 | $form_items = array(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | // Add it to the form. |
128 | - $form->set_items( self::item_to_objects( wp_kses_post_deep( $form_items ) ) ); |
|
128 | + $form->set_items(self::item_to_objects(wp_kses_post_deep($form_items))); |
|
129 | 129 | |
130 | 130 | // Save form elements. |
131 | - $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true ); |
|
132 | - if ( empty( $form_elements ) ) { |
|
131 | + $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true); |
|
132 | + if (empty($form_elements)) { |
|
133 | 133 | $form_elements = array(); |
134 | 134 | } |
135 | 135 | |
136 | - $form->set_elements( wp_kses_post_deep( $form_elements ) ); |
|
136 | + $form->set_elements(wp_kses_post_deep($form_elements)); |
|
137 | 137 | |
138 | 138 | // Persist data to the datastore. |
139 | 139 | $form->save(); |
140 | - do_action( 'getpaid_payment_form_metabox_save', $post_id, $form ); |
|
140 | + do_action('getpaid_payment_form_metabox_save', $post_id, $form); |
|
141 | 141 | |
142 | 142 | } |
143 | 143 | |
@@ -146,14 +146,14 @@ discard block |
||
146 | 146 | * |
147 | 147 | * @param array $items |
148 | 148 | */ |
149 | - public static function item_to_objects( $items ) { |
|
149 | + public static function item_to_objects($items) { |
|
150 | 150 | |
151 | 151 | $objects = array(); |
152 | 152 | |
153 | - foreach ( $items as $item ) { |
|
154 | - $_item = new GetPaid_Form_Item( $item['id'] ); |
|
155 | - $_item->set_allow_quantities( (bool) $item['allow_quantities'] ); |
|
156 | - $_item->set_is_required( (bool) $item['required'] ); |
|
153 | + foreach ($items as $item) { |
|
154 | + $_item = new GetPaid_Form_Item($item['id']); |
|
155 | + $_item->set_allow_quantities((bool) $item['allow_quantities']); |
|
156 | + $_item->set_is_required((bool) $item['required']); |
|
157 | 157 | $objects[] = $_item; |
158 | 158 | } |
159 | 159 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * |
8 | 8 | */ |
9 | 9 | |
10 | -if ( ! defined( 'ABSPATH' ) ) { |
|
10 | +if (!defined('ABSPATH')) { |
|
11 | 11 | exit; // Exit if accessed directly |
12 | 12 | } |
13 | 13 | |
@@ -21,26 +21,26 @@ discard block |
||
21 | 21 | * |
22 | 22 | * @param WP_Post $post |
23 | 23 | */ |
24 | - public static function output( $post ) { |
|
24 | + public static function output($post) { |
|
25 | 25 | |
26 | 26 | // Prepare the item. |
27 | - $item = new WPInv_Item( $post ); |
|
27 | + $item = new WPInv_Item($post); |
|
28 | 28 | |
29 | 29 | echo "<div class='bsui' style='max-width: 600px;padding-top: 10px;'>"; |
30 | 30 | |
31 | - do_action( 'wpinv_item_before_vat_metabox', $item ); |
|
31 | + do_action('wpinv_item_before_vat_metabox', $item); |
|
32 | 32 | |
33 | 33 | // Output the vat rules settings. |
34 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
35 | - self::output_vat_rules( $item ); |
|
36 | - do_action( 'wpinv_item_vat_metabox_vat_rules', $item ); |
|
34 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
35 | + self::output_vat_rules($item); |
|
36 | + do_action('wpinv_item_vat_metabox_vat_rules', $item); |
|
37 | 37 | |
38 | 38 | // Output vat class settings. |
39 | - do_action( 'wpinv_item_vat_metabox_before_vat_rules', $item ); |
|
40 | - self::output_vat_classes( $item ); |
|
41 | - do_action( 'wpinv_item_vat_metabox_vat_class', $item ); |
|
39 | + do_action('wpinv_item_vat_metabox_before_vat_rules', $item); |
|
40 | + self::output_vat_classes($item); |
|
41 | + do_action('wpinv_item_vat_metabox_vat_class', $item); |
|
42 | 42 | |
43 | - do_action( 'wpinv_item_vat_metabox', $item ); |
|
43 | + do_action('wpinv_item_vat_metabox', $item); |
|
44 | 44 | |
45 | 45 | echo '</div>'; |
46 | 46 | } |
@@ -50,14 +50,14 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param WPInv_Item $item |
52 | 52 | */ |
53 | - public static function output_vat_rules( $item ) { |
|
53 | + public static function output_vat_rules($item) { |
|
54 | 54 | ?> |
55 | 55 | |
56 | 56 | <div class="wpinv_vat_rules"> |
57 | 57 | |
58 | 58 | <div class="form-group mb-3 row"> |
59 | 59 | <label for="wpinv_vat_rules" class="col-sm-3 col-form-label"> |
60 | - <?php esc_html_e( 'Tax Rule', 'invoicing' ); ?> |
|
60 | + <?php esc_html_e('Tax Rule', 'invoicing'); ?> |
|
61 | 61 | </label> |
62 | 62 | <div class="col-sm-8"> |
63 | 63 | <?php |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | array( |
66 | 66 | 'id' => 'wpinv_vat_rules', |
67 | 67 | 'name' => 'wpinv_vat_rules', |
68 | - 'placeholder' => __( 'Select tax rule', 'invoicing' ), |
|
69 | - 'value' => $item->get_vat_rule( 'edit' ), |
|
68 | + 'placeholder' => __('Select tax rule', 'invoicing'), |
|
69 | + 'value' => $item->get_vat_rule('edit'), |
|
70 | 70 | 'select2' => true, |
71 | 71 | 'data-allow-clear' => 'false', |
72 | 72 | 'no_wrap' => true, |
@@ -89,14 +89,14 @@ discard block |
||
89 | 89 | * |
90 | 90 | * @param WPInv_Item $item |
91 | 91 | */ |
92 | - public static function output_vat_classes( $item ) { |
|
92 | + public static function output_vat_classes($item) { |
|
93 | 93 | ?> |
94 | 94 | |
95 | 95 | <div class="wpinv_vat_classes"> |
96 | 96 | |
97 | 97 | <div class="form-group mb-3 row"> |
98 | 98 | <label for="wpinv_vat_class" class="col-sm-3 col-form-label"> |
99 | - <?php esc_html_e( 'Tax Class', 'invoicing' ); ?> |
|
99 | + <?php esc_html_e('Tax Class', 'invoicing'); ?> |
|
100 | 100 | </label> |
101 | 101 | <div class="col-sm-8"> |
102 | 102 | <?php |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | array( |
105 | 105 | 'id' => 'wpinv_vat_class', |
106 | 106 | 'name' => 'wpinv_vat_class', |
107 | - 'placeholder' => __( 'Select tax class', 'invoicing' ), |
|
108 | - 'value' => $item->get_vat_class( 'edit' ), |
|
107 | + 'placeholder' => __('Select tax class', 'invoicing'), |
|
108 | + 'value' => $item->get_vat_class('edit'), |
|
109 | 109 | 'select2' => true, |
110 | 110 | 'data-allow-clear' => 'false', |
111 | 111 | 'no_wrap' => true, |