@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | public function getLocations() |
37 | 37 | { |
38 | 38 | if ($this->matchesCakeVersion('>=', '3.0.0')) { |
39 | - $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
|
39 | + $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/'; |
|
40 | 40 | } |
41 | 41 | return $this->locations; |
42 | 42 | } |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | protected function matchesCakeVersion($matcher, $version) |
52 | 52 | { |
53 | 53 | $repositoryManager = $this->composer->getRepositoryManager(); |
54 | - if (! $repositoryManager) { |
|
54 | + if (!$repositoryManager) { |
|
55 | 55 | return false; |
56 | 56 | } |
57 | 57 |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | class OxidInstaller extends BaseInstaller |
7 | 7 | { |
8 | - const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
8 | + const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/'; |
|
9 | 9 | |
10 | 10 | protected $locations = array( |
11 | 11 | 'module' => 'modules/{$name}/', |
@@ -13,47 +13,47 @@ discard block |
||
13 | 13 | 'out' => 'out/{$name}/', |
14 | 14 | ); |
15 | 15 | |
16 | - /** |
|
17 | - * getInstallPath |
|
18 | - * |
|
19 | - * @param PackageInterface $package |
|
20 | - * @param string $frameworkType |
|
21 | - * @return string |
|
22 | - */ |
|
23 | - public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | - { |
|
25 | - $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | - $type = $this->package->getType(); |
|
27 | - if ($type === 'oxid-module') { |
|
28 | - $this->prepareVendorDirectory($installPath); |
|
29 | - } |
|
30 | - return $installPath; |
|
31 | - } |
|
16 | + /** |
|
17 | + * getInstallPath |
|
18 | + * |
|
19 | + * @param PackageInterface $package |
|
20 | + * @param string $frameworkType |
|
21 | + * @return string |
|
22 | + */ |
|
23 | + public function getInstallPath(PackageInterface $package, $frameworkType = '') |
|
24 | + { |
|
25 | + $installPath = parent::getInstallPath($package, $frameworkType); |
|
26 | + $type = $this->package->getType(); |
|
27 | + if ($type === 'oxid-module') { |
|
28 | + $this->prepareVendorDirectory($installPath); |
|
29 | + } |
|
30 | + return $installPath; |
|
31 | + } |
|
32 | 32 | |
33 | - /** |
|
34 | - * prepareVendorDirectory |
|
35 | - * |
|
36 | - * Makes sure there is a vendormetadata.php file inside |
|
37 | - * the vendor folder if there is a vendor folder. |
|
38 | - * |
|
39 | - * @param string $installPath |
|
40 | - * @return void |
|
41 | - */ |
|
42 | - protected function prepareVendorDirectory($installPath) |
|
43 | - { |
|
44 | - $matches = ''; |
|
45 | - $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | - if (!$hasVendorDirectory) { |
|
47 | - return; |
|
48 | - } |
|
33 | + /** |
|
34 | + * prepareVendorDirectory |
|
35 | + * |
|
36 | + * Makes sure there is a vendormetadata.php file inside |
|
37 | + * the vendor folder if there is a vendor folder. |
|
38 | + * |
|
39 | + * @param string $installPath |
|
40 | + * @return void |
|
41 | + */ |
|
42 | + protected function prepareVendorDirectory($installPath) |
|
43 | + { |
|
44 | + $matches = ''; |
|
45 | + $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches); |
|
46 | + if (!$hasVendorDirectory) { |
|
47 | + return; |
|
48 | + } |
|
49 | 49 | |
50 | - $vendorDirectory = $matches['vendor']; |
|
51 | - $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | - if (!file_exists($vendorPath)) { |
|
53 | - mkdir($vendorPath, 0755, true); |
|
54 | - } |
|
50 | + $vendorDirectory = $matches['vendor']; |
|
51 | + $vendorPath = getcwd() . '/modules/' . $vendorDirectory; |
|
52 | + if (!file_exists($vendorPath)) { |
|
53 | + mkdir($vendorPath, 0755, true); |
|
54 | + } |
|
55 | 55 | |
56 | - $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | - touch($vendorMetaDataPath); |
|
58 | - } |
|
56 | + $vendorMetaDataPath = $vendorPath . '/vendormetadata.php'; |
|
57 | + touch($vendorMetaDataPath); |
|
58 | + } |
|
59 | 59 | } |
@@ -7,44 +7,44 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Make sure that the form is active. |
13 | -if ( ! $form->is_active() ) { |
|
13 | +if (!$form->is_active()) { |
|
14 | 14 | echo aui()->alert( |
15 | 15 | array( |
16 | 16 | 'type' => 'warning', |
17 | - 'content' => __( 'This payment form is no longer active', 'invoicing' ), |
|
17 | + 'content' => __('This payment form is no longer active', 'invoicing'), |
|
18 | 18 | ) |
19 | 19 | ); |
20 | 20 | return; |
21 | 21 | } |
22 | 22 | |
23 | 23 | // Fires before displaying a payment form. |
24 | -do_action( 'getpaid_before_payment_form', $form ); |
|
24 | +do_action('getpaid_before_payment_form', $form); |
|
25 | 25 | ?> |
26 | 26 | |
27 | -<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>'> |
|
27 | +<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui position-relative' method='POST' data-key='<?php echo uniqid('gpf'); ?>'> |
|
28 | 28 | |
29 | 29 | |
30 | 30 | <?php |
31 | 31 | |
32 | 32 | // Fires when printing the top of a payment form. |
33 | - do_action( 'getpaid_payment_form_top', $form ); |
|
33 | + do_action('getpaid_payment_form_top', $form); |
|
34 | 34 | |
35 | 35 | // And the optional invoice id. |
36 | - if ( ! empty( $form->invoice ) ) { |
|
37 | - echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() ); |
|
36 | + if (!empty($form->invoice)) { |
|
37 | + echo getpaid_hidden_field('invoice_id', $form->invoice->get_id()); |
|
38 | 38 | } |
39 | 39 | |
40 | 40 | // We also want to include the form id. |
41 | - echo getpaid_hidden_field( 'form_id', $form->get_id() ); |
|
41 | + echo getpaid_hidden_field('form_id', $form->get_id()); |
|
42 | 42 | |
43 | 43 | // And an indication that this is a payment form submission. |
44 | - echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' ); |
|
44 | + echo getpaid_hidden_field('getpaid_payment_form_submission', '1'); |
|
45 | 45 | |
46 | 46 | // Fires before displaying payment form elements. |
47 | - do_action( 'getpaid_payment_form_before_elements', $form ); |
|
47 | + do_action('getpaid_payment_form_before_elements', $form); |
|
48 | 48 | |
49 | 49 | // Display the elements. |
50 | 50 | ?> |
@@ -52,13 +52,13 @@ discard block |
||
52 | 52 | <div class="row"> |
53 | 53 | <?php |
54 | 54 | |
55 | - foreach ( $form->get_elements() as $element ) { |
|
55 | + foreach ($form->get_elements() as $element) { |
|
56 | 56 | |
57 | - if ( isset( $element['type'] ) ) { |
|
58 | - $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) ); |
|
57 | + if (isset($element['type'])) { |
|
58 | + $grid_class = esc_attr(getpaid_get_form_element_grid_class($element)); |
|
59 | 59 | echo "<div class='$grid_class'>"; |
60 | - do_action( 'getpaid_payment_form_element', $element, $form ); |
|
61 | - do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form ); |
|
60 | + do_action('getpaid_payment_form_element', $element, $form); |
|
61 | + do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form); |
|
62 | 62 | echo "</div>"; |
63 | 63 | } |
64 | 64 | |
@@ -70,16 +70,16 @@ discard block |
||
70 | 70 | |
71 | 71 | <?php |
72 | 72 | // Fires after displaying payment form elements. |
73 | - do_action( 'getpaid_payment_form_after_elements', $form ); |
|
73 | + do_action('getpaid_payment_form_after_elements', $form); |
|
74 | 74 | |
75 | 75 | echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>"; |
76 | 76 | |
77 | - if ( wpinv_current_user_can_manage_invoicing() ) { |
|
77 | + if (wpinv_current_user_can_manage_invoicing()) { |
|
78 | 78 | |
79 | 79 | edit_post_link( |
80 | - __( 'Edit this form.', 'invoicing' ), |
|
80 | + __('Edit this form.', 'invoicing'), |
|
81 | 81 | '<small class="form-text text-muted">', |
82 | - ' ' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>', |
|
82 | + ' ' . __('This is only visible to website administators.', 'invoicing') . '</small>', |
|
83 | 83 | $form->get_id(), |
84 | 84 | 'text-danger' |
85 | 85 | ); |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | |
92 | 92 | <div class="loading_div overlay overlay-black position-absolute row m-0 rounded overflow-hidden" style="height: 100%;width: 100%;top: 0px;z-index: 2;display:none;"> |
93 | 93 | <div class="spinner-border mx-auto align-self-center text-white" role="status"> |
94 | - <span class="sr-only"><?php _e( 'Loading...', 'invoicing' );?></span> |
|
94 | + <span class="sr-only"><?php _e('Loading...', 'invoicing'); ?></span> |
|
95 | 95 | </div> |
96 | 96 | </div> |
97 | 97 | |
@@ -100,4 +100,4 @@ discard block |
||
100 | 100 | <?php |
101 | 101 | |
102 | 102 | // Fires after displaying a payment form. |
103 | -do_action( 'getpaid_after_payment_form', $form ); |
|
103 | +do_action('getpaid_after_payment_form', $form); |
@@ -12,444 +12,444 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Invoice_Notification_Emails { |
14 | 14 | |
15 | - /** |
|
16 | - * The array of invoice email actions. |
|
17 | - * |
|
18 | - * @param array |
|
19 | - */ |
|
20 | - public $invoice_actions; |
|
21 | - |
|
22 | - /** |
|
23 | - * Class constructor |
|
24 | - * |
|
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - |
|
28 | - $this->invoice_actions = apply_filters( |
|
29 | - 'getpaid_notification_email_invoice_triggers', |
|
30 | - array( |
|
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
32 | - 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
|
33 | - 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
|
34 | - 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
|
35 | - 'getpaid_invoice_status_wpi-processing' => 'processing_invoice', |
|
36 | - 'getpaid_invoice_status_publish' => 'completed_invoice', |
|
37 | - 'getpaid_invoice_status_wpi-renewal' => 'completed_invoice', |
|
38 | - 'getpaid_invoice_status_wpi-refunded' => 'refunded_invoice', |
|
39 | - 'getpaid_new_customer_note' => 'user_note', |
|
40 | - 'getpaid_daily_maintenance' => 'overdue', |
|
41 | - ) |
|
42 | - ); |
|
43 | - |
|
44 | - $this->init_hooks(); |
|
45 | - |
|
46 | - } |
|
47 | - |
|
48 | - /** |
|
49 | - * Registers email hooks. |
|
50 | - */ |
|
51 | - public function init_hooks() { |
|
52 | - |
|
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
55 | - |
|
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
58 | - } |
|
59 | - } |
|
60 | - |
|
61 | - /** |
|
62 | - * Registers an email hook for an invoice action. |
|
63 | - * |
|
64 | - * @param string $hook |
|
65 | - * @param string|array $email_type |
|
66 | - */ |
|
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
68 | - |
|
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
70 | - |
|
71 | - foreach ( $email_type as $type ) { |
|
72 | - |
|
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
74 | - |
|
75 | - // Abort if it is not active. |
|
76 | - if ( ! $email->is_active() ) { |
|
77 | - continue; |
|
78 | - } |
|
79 | - |
|
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
82 | - continue; |
|
83 | - } |
|
84 | - |
|
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
86 | - } |
|
87 | - |
|
88 | - } |
|
89 | - |
|
90 | - /** |
|
91 | - * Filters invoice merge tags. |
|
92 | - * |
|
93 | - * @param array $merge_tags |
|
94 | - * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
95 | - */ |
|
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
97 | - |
|
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
99 | - return array_merge( |
|
100 | - $merge_tags, |
|
101 | - $this->get_invoice_merge_tags( $object ) |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
106 | - return array_merge( |
|
107 | - $merge_tags, |
|
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
109 | - ); |
|
110 | - } |
|
111 | - |
|
112 | - return $merge_tags; |
|
113 | - |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Generates invoice merge tags. |
|
118 | - * |
|
119 | - * @param WPInv_Invoice $invoice |
|
120 | - * @return array |
|
121 | - */ |
|
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
123 | - |
|
124 | - // Abort if it does not exist. |
|
125 | - if ( ! $invoice->get_id() ) { |
|
126 | - return array(); |
|
127 | - } |
|
128 | - |
|
129 | - $merge_tags = array( |
|
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
148 | - ); |
|
149 | - |
|
150 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Helper function to send an email. |
|
155 | - * |
|
156 | - * @param WPInv_Invoice $invoice |
|
157 | - * @param GetPaid_Notification_Email $email |
|
158 | - * @param string $type |
|
159 | - * @param string|array $recipients |
|
160 | - * @param array $extra_args Extra template args. |
|
161 | - */ |
|
162 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
163 | - |
|
164 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
165 | - |
|
166 | - $mailer = new GetPaid_Notification_Email_Sender(); |
|
167 | - $merge_tags = $email->get_merge_tags(); |
|
168 | - |
|
169 | - $result = $mailer->send( |
|
170 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
172 | - $email->get_content( $merge_tags, $extra_args ), |
|
173 | - $email->get_attachments() |
|
174 | - ); |
|
175 | - |
|
176 | - // Maybe send a copy to the admin. |
|
177 | - if ( $email->include_admin_bcc() ) { |
|
178 | - $mailer->send( |
|
179 | - wpinv_get_admin_email(), |
|
180 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
181 | - $email->get_content( $merge_tags ), |
|
182 | - $email->get_attachments() |
|
183 | - ); |
|
184 | - } |
|
185 | - |
|
186 | - if ( ! $result ) { |
|
187 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
188 | - } |
|
189 | - |
|
190 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
191 | - |
|
192 | - return $result; |
|
193 | - } |
|
194 | - |
|
195 | - /** |
|
196 | - * Also send emails to any cc users. |
|
197 | - * |
|
198 | - * @param array $recipients |
|
199 | - * @param GetPaid_Notification_Email $email |
|
200 | - */ |
|
201 | - public function filter_email_recipients( $recipients, $email ) { |
|
202 | - |
|
203 | - if ( ! $email->is_admin_email() ) { |
|
204 | - $cc = $email->object->get_email_cc(); |
|
205 | - |
|
206 | - if ( ! empty( $cc ) ) { |
|
207 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
208 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
209 | - } |
|
210 | - |
|
211 | - } |
|
212 | - |
|
213 | - return $recipients; |
|
214 | - |
|
215 | - } |
|
216 | - |
|
217 | - /** |
|
218 | - * Sends a new invoice notification. |
|
219 | - * |
|
220 | - * @param WPInv_Invoice $invoice |
|
221 | - */ |
|
222 | - public function new_invoice( $invoice ) { |
|
223 | - |
|
224 | - // Only send this email for invoices created via the admin page. |
|
225 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
226 | - return; |
|
227 | - } |
|
228 | - |
|
229 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
230 | - $recipient = wpinv_get_admin_email(); |
|
231 | - |
|
232 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
233 | - |
|
234 | - } |
|
235 | - |
|
236 | - /** |
|
237 | - * Sends a cancelled invoice notification. |
|
238 | - * |
|
239 | - * @param WPInv_Invoice $invoice |
|
240 | - */ |
|
241 | - public function cancelled_invoice( $invoice ) { |
|
15 | + /** |
|
16 | + * The array of invoice email actions. |
|
17 | + * |
|
18 | + * @param array |
|
19 | + */ |
|
20 | + public $invoice_actions; |
|
21 | + |
|
22 | + /** |
|
23 | + * Class constructor |
|
24 | + * |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + |
|
28 | + $this->invoice_actions = apply_filters( |
|
29 | + 'getpaid_notification_email_invoice_triggers', |
|
30 | + array( |
|
31 | + 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
32 | + 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
|
33 | + 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
|
34 | + 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
|
35 | + 'getpaid_invoice_status_wpi-processing' => 'processing_invoice', |
|
36 | + 'getpaid_invoice_status_publish' => 'completed_invoice', |
|
37 | + 'getpaid_invoice_status_wpi-renewal' => 'completed_invoice', |
|
38 | + 'getpaid_invoice_status_wpi-refunded' => 'refunded_invoice', |
|
39 | + 'getpaid_new_customer_note' => 'user_note', |
|
40 | + 'getpaid_daily_maintenance' => 'overdue', |
|
41 | + ) |
|
42 | + ); |
|
43 | + |
|
44 | + $this->init_hooks(); |
|
45 | + |
|
46 | + } |
|
47 | + |
|
48 | + /** |
|
49 | + * Registers email hooks. |
|
50 | + */ |
|
51 | + public function init_hooks() { |
|
52 | + |
|
53 | + add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | + add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
55 | + |
|
56 | + foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | + $this->init_email_type_hook( $hook, $email_type ); |
|
58 | + } |
|
59 | + } |
|
60 | + |
|
61 | + /** |
|
62 | + * Registers an email hook for an invoice action. |
|
63 | + * |
|
64 | + * @param string $hook |
|
65 | + * @param string|array $email_type |
|
66 | + */ |
|
67 | + public function init_email_type_hook( $hook, $email_type ) { |
|
68 | + |
|
69 | + $email_type = wpinv_parse_list( $email_type ); |
|
70 | + |
|
71 | + foreach ( $email_type as $type ) { |
|
72 | + |
|
73 | + $email = new GetPaid_Notification_Email( $type ); |
|
74 | + |
|
75 | + // Abort if it is not active. |
|
76 | + if ( ! $email->is_active() ) { |
|
77 | + continue; |
|
78 | + } |
|
79 | + |
|
80 | + if ( method_exists( $this, $type ) ) { |
|
81 | + add_action( $hook, array( $this, $type ), 100, 2 ); |
|
82 | + continue; |
|
83 | + } |
|
84 | + |
|
85 | + do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
86 | + } |
|
87 | + |
|
88 | + } |
|
89 | + |
|
90 | + /** |
|
91 | + * Filters invoice merge tags. |
|
92 | + * |
|
93 | + * @param array $merge_tags |
|
94 | + * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
95 | + */ |
|
96 | + public function invoice_merge_tags( $merge_tags, $object ) { |
|
97 | + |
|
98 | + if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
99 | + return array_merge( |
|
100 | + $merge_tags, |
|
101 | + $this->get_invoice_merge_tags( $object ) |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
106 | + return array_merge( |
|
107 | + $merge_tags, |
|
108 | + $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
109 | + ); |
|
110 | + } |
|
111 | + |
|
112 | + return $merge_tags; |
|
113 | + |
|
114 | + } |
|
115 | + |
|
116 | + /** |
|
117 | + * Generates invoice merge tags. |
|
118 | + * |
|
119 | + * @param WPInv_Invoice $invoice |
|
120 | + * @return array |
|
121 | + */ |
|
122 | + public function get_invoice_merge_tags( $invoice ) { |
|
123 | + |
|
124 | + // Abort if it does not exist. |
|
125 | + if ( ! $invoice->get_id() ) { |
|
126 | + return array(); |
|
127 | + } |
|
128 | + |
|
129 | + $merge_tags = array( |
|
130 | + '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | + '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | + '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | + '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | + '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | + '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | + '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | + '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | + '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | + '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | + '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | + '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | + '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | + '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | + '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | + '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | + '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
148 | + ); |
|
149 | + |
|
150 | + return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Helper function to send an email. |
|
155 | + * |
|
156 | + * @param WPInv_Invoice $invoice |
|
157 | + * @param GetPaid_Notification_Email $email |
|
158 | + * @param string $type |
|
159 | + * @param string|array $recipients |
|
160 | + * @param array $extra_args Extra template args. |
|
161 | + */ |
|
162 | + public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
163 | + |
|
164 | + do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
165 | + |
|
166 | + $mailer = new GetPaid_Notification_Email_Sender(); |
|
167 | + $merge_tags = $email->get_merge_tags(); |
|
168 | + |
|
169 | + $result = $mailer->send( |
|
170 | + apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | + $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
172 | + $email->get_content( $merge_tags, $extra_args ), |
|
173 | + $email->get_attachments() |
|
174 | + ); |
|
175 | + |
|
176 | + // Maybe send a copy to the admin. |
|
177 | + if ( $email->include_admin_bcc() ) { |
|
178 | + $mailer->send( |
|
179 | + wpinv_get_admin_email(), |
|
180 | + $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
181 | + $email->get_content( $merge_tags ), |
|
182 | + $email->get_attachments() |
|
183 | + ); |
|
184 | + } |
|
185 | + |
|
186 | + if ( ! $result ) { |
|
187 | + $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
188 | + } |
|
189 | + |
|
190 | + do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
191 | + |
|
192 | + return $result; |
|
193 | + } |
|
194 | + |
|
195 | + /** |
|
196 | + * Also send emails to any cc users. |
|
197 | + * |
|
198 | + * @param array $recipients |
|
199 | + * @param GetPaid_Notification_Email $email |
|
200 | + */ |
|
201 | + public function filter_email_recipients( $recipients, $email ) { |
|
202 | + |
|
203 | + if ( ! $email->is_admin_email() ) { |
|
204 | + $cc = $email->object->get_email_cc(); |
|
205 | + |
|
206 | + if ( ! empty( $cc ) ) { |
|
207 | + $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
208 | + $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
209 | + } |
|
210 | + |
|
211 | + } |
|
212 | + |
|
213 | + return $recipients; |
|
214 | + |
|
215 | + } |
|
216 | + |
|
217 | + /** |
|
218 | + * Sends a new invoice notification. |
|
219 | + * |
|
220 | + * @param WPInv_Invoice $invoice |
|
221 | + */ |
|
222 | + public function new_invoice( $invoice ) { |
|
223 | + |
|
224 | + // Only send this email for invoices created via the admin page. |
|
225 | + if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
226 | + return; |
|
227 | + } |
|
228 | + |
|
229 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
230 | + $recipient = wpinv_get_admin_email(); |
|
231 | + |
|
232 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
233 | + |
|
234 | + } |
|
235 | + |
|
236 | + /** |
|
237 | + * Sends a cancelled invoice notification. |
|
238 | + * |
|
239 | + * @param WPInv_Invoice $invoice |
|
240 | + */ |
|
241 | + public function cancelled_invoice( $invoice ) { |
|
242 | 242 | |
243 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
244 | - $recipient = wpinv_get_admin_email(); |
|
243 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
244 | + $recipient = wpinv_get_admin_email(); |
|
245 | 245 | |
246 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
246 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
247 | 247 | |
248 | - } |
|
248 | + } |
|
249 | 249 | |
250 | - /** |
|
251 | - * Sends a failed invoice notification. |
|
252 | - * |
|
253 | - * @param WPInv_Invoice $invoice |
|
254 | - */ |
|
255 | - public function failed_invoice( $invoice ) { |
|
250 | + /** |
|
251 | + * Sends a failed invoice notification. |
|
252 | + * |
|
253 | + * @param WPInv_Invoice $invoice |
|
254 | + */ |
|
255 | + public function failed_invoice( $invoice ) { |
|
256 | 256 | |
257 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
258 | - $recipient = wpinv_get_admin_email(); |
|
257 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
258 | + $recipient = wpinv_get_admin_email(); |
|
259 | 259 | |
260 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
260 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
261 | 261 | |
262 | - } |
|
262 | + } |
|
263 | 263 | |
264 | - /** |
|
265 | - * Sends a notification whenever an invoice is put on hold. |
|
266 | - * |
|
267 | - * @param WPInv_Invoice $invoice |
|
268 | - */ |
|
269 | - public function onhold_invoice( $invoice ) { |
|
264 | + /** |
|
265 | + * Sends a notification whenever an invoice is put on hold. |
|
266 | + * |
|
267 | + * @param WPInv_Invoice $invoice |
|
268 | + */ |
|
269 | + public function onhold_invoice( $invoice ) { |
|
270 | 270 | |
271 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
272 | - $recipient = $invoice->get_email(); |
|
271 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
272 | + $recipient = $invoice->get_email(); |
|
273 | 273 | |
274 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
274 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
275 | 275 | |
276 | - } |
|
276 | + } |
|
277 | 277 | |
278 | - /** |
|
279 | - * Sends a notification whenever an invoice is marked as processing payment. |
|
280 | - * |
|
281 | - * @param WPInv_Invoice $invoice |
|
282 | - */ |
|
283 | - public function processing_invoice( $invoice ) { |
|
278 | + /** |
|
279 | + * Sends a notification whenever an invoice is marked as processing payment. |
|
280 | + * |
|
281 | + * @param WPInv_Invoice $invoice |
|
282 | + */ |
|
283 | + public function processing_invoice( $invoice ) { |
|
284 | 284 | |
285 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
286 | - $recipient = $invoice->get_email(); |
|
285 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
286 | + $recipient = $invoice->get_email(); |
|
287 | 287 | |
288 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
288 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
289 | 289 | |
290 | - } |
|
290 | + } |
|
291 | 291 | |
292 | - /** |
|
293 | - * Sends a notification whenever an invoice is paid. |
|
294 | - * |
|
295 | - * @param WPInv_Invoice $invoice |
|
296 | - */ |
|
297 | - public function completed_invoice( $invoice ) { |
|
292 | + /** |
|
293 | + * Sends a notification whenever an invoice is paid. |
|
294 | + * |
|
295 | + * @param WPInv_Invoice $invoice |
|
296 | + */ |
|
297 | + public function completed_invoice( $invoice ) { |
|
298 | 298 | |
299 | - // (Maybe) abort if it is a renewal invoice. |
|
300 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
301 | - return; |
|
302 | - } |
|
299 | + // (Maybe) abort if it is a renewal invoice. |
|
300 | + if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
301 | + return; |
|
302 | + } |
|
303 | 303 | |
304 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
305 | - $recipient = $invoice->get_email(); |
|
304 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
305 | + $recipient = $invoice->get_email(); |
|
306 | 306 | |
307 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
307 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
308 | 308 | |
309 | - } |
|
309 | + } |
|
310 | 310 | |
311 | - /** |
|
312 | - * Sends a notification whenever an invoice is refunded. |
|
313 | - * |
|
314 | - * @param WPInv_Invoice $invoice |
|
315 | - */ |
|
316 | - public function refunded_invoice( $invoice ) { |
|
311 | + /** |
|
312 | + * Sends a notification whenever an invoice is refunded. |
|
313 | + * |
|
314 | + * @param WPInv_Invoice $invoice |
|
315 | + */ |
|
316 | + public function refunded_invoice( $invoice ) { |
|
317 | 317 | |
318 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
319 | - $recipient = $invoice->get_email(); |
|
318 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
319 | + $recipient = $invoice->get_email(); |
|
320 | 320 | |
321 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
321 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
322 | 322 | |
323 | - } |
|
323 | + } |
|
324 | 324 | |
325 | - /** |
|
326 | - * Notifies a user about new invoices |
|
327 | - * |
|
328 | - * @param WPInv_Invoice $invoice |
|
329 | - */ |
|
330 | - public function user_invoice( $invoice ) { |
|
325 | + /** |
|
326 | + * Notifies a user about new invoices |
|
327 | + * |
|
328 | + * @param WPInv_Invoice $invoice |
|
329 | + */ |
|
330 | + public function user_invoice( $invoice ) { |
|
331 | 331 | |
332 | - // Only send this email for invoices created via the admin page. |
|
333 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
334 | - return; |
|
335 | - } |
|
332 | + // Only send this email for invoices created via the admin page. |
|
333 | + if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
334 | + return; |
|
335 | + } |
|
336 | 336 | |
337 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
338 | - $recipient = $invoice->get_email(); |
|
337 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
338 | + $recipient = $invoice->get_email(); |
|
339 | 339 | |
340 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
340 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
341 | 341 | |
342 | - } |
|
342 | + } |
|
343 | 343 | |
344 | - /** |
|
345 | - * Checks if an invoice is a payment form invoice. |
|
346 | - * |
|
347 | - * @param int $invoice |
|
348 | - * @return bool |
|
349 | - */ |
|
350 | - public function is_payment_form_invoice( $invoice ) { |
|
351 | - return empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
352 | - } |
|
344 | + /** |
|
345 | + * Checks if an invoice is a payment form invoice. |
|
346 | + * |
|
347 | + * @param int $invoice |
|
348 | + * @return bool |
|
349 | + */ |
|
350 | + public function is_payment_form_invoice( $invoice ) { |
|
351 | + return empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
352 | + } |
|
353 | 353 | |
354 | - /** |
|
355 | - * Notifies admin about new invoice notes |
|
356 | - * |
|
357 | - * @param WPInv_Invoice $invoice |
|
358 | - * @param string $note |
|
359 | - */ |
|
360 | - public function user_note( $invoice, $note ) { |
|
354 | + /** |
|
355 | + * Notifies admin about new invoice notes |
|
356 | + * |
|
357 | + * @param WPInv_Invoice $invoice |
|
358 | + * @param string $note |
|
359 | + */ |
|
360 | + public function user_note( $invoice, $note ) { |
|
361 | 361 | |
362 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
363 | - $recipient = $invoice->get_email(); |
|
364 | - |
|
365 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
366 | - |
|
367 | - } |
|
362 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
363 | + $recipient = $invoice->get_email(); |
|
364 | + |
|
365 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
366 | + |
|
367 | + } |
|
368 | 368 | |
369 | - /** |
|
370 | - * (Force) Sends overdue notices. |
|
371 | - * |
|
372 | - * @param WPInv_Invoice $invoice |
|
373 | - */ |
|
374 | - public function force_send_overdue_notice( $invoice ) { |
|
375 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
376 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
377 | - } |
|
378 | - |
|
379 | - /** |
|
380 | - * Sends overdue notices. |
|
381 | - * |
|
382 | - * @TODO: Create an invoices query class. |
|
383 | - */ |
|
384 | - public function overdue() { |
|
385 | - global $wpdb; |
|
386 | - |
|
387 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
388 | - |
|
389 | - // Fetch reminder days. |
|
390 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
391 | - |
|
392 | - // Abort if non is set. |
|
393 | - if ( empty( $reminder_days ) ) { |
|
394 | - return; |
|
395 | - } |
|
396 | - |
|
397 | - // Retrieve date query. |
|
398 | - $date_query = $this->get_date_query( $reminder_days ); |
|
399 | - |
|
400 | - // Invoices table. |
|
401 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
402 | - |
|
403 | - // Fetch invoices. |
|
404 | - $invoices = $wpdb->get_col( |
|
405 | - "SELECT posts.ID FROM $wpdb->posts as posts |
|
369 | + /** |
|
370 | + * (Force) Sends overdue notices. |
|
371 | + * |
|
372 | + * @param WPInv_Invoice $invoice |
|
373 | + */ |
|
374 | + public function force_send_overdue_notice( $invoice ) { |
|
375 | + $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
376 | + return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
377 | + } |
|
378 | + |
|
379 | + /** |
|
380 | + * Sends overdue notices. |
|
381 | + * |
|
382 | + * @TODO: Create an invoices query class. |
|
383 | + */ |
|
384 | + public function overdue() { |
|
385 | + global $wpdb; |
|
386 | + |
|
387 | + $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
388 | + |
|
389 | + // Fetch reminder days. |
|
390 | + $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
391 | + |
|
392 | + // Abort if non is set. |
|
393 | + if ( empty( $reminder_days ) ) { |
|
394 | + return; |
|
395 | + } |
|
396 | + |
|
397 | + // Retrieve date query. |
|
398 | + $date_query = $this->get_date_query( $reminder_days ); |
|
399 | + |
|
400 | + // Invoices table. |
|
401 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
402 | + |
|
403 | + // Fetch invoices. |
|
404 | + $invoices = $wpdb->get_col( |
|
405 | + "SELECT posts.ID FROM $wpdb->posts as posts |
|
406 | 406 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
407 | 407 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
408 | 408 | |
409 | - foreach ( $invoices as $invoice ) { |
|
409 | + foreach ( $invoices as $invoice ) { |
|
410 | 410 | |
411 | - // Only send this email for invoices created via the admin page. |
|
412 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
413 | - $invoice = new WPInv_Invoice( $invoice ); |
|
414 | - $email->object = $invoice; |
|
411 | + // Only send this email for invoices created via the admin page. |
|
412 | + if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
413 | + $invoice = new WPInv_Invoice( $invoice ); |
|
414 | + $email->object = $invoice; |
|
415 | 415 | |
416 | - if ( $invoice->needs_payment() ) { |
|
417 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
418 | - } |
|
416 | + if ( $invoice->needs_payment() ) { |
|
417 | + $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
418 | + } |
|
419 | 419 | |
420 | - } |
|
420 | + } |
|
421 | 421 | |
422 | - } |
|
422 | + } |
|
423 | 423 | |
424 | - } |
|
424 | + } |
|
425 | 425 | |
426 | - /** |
|
427 | - * Calculates the date query for an invoices query |
|
428 | - * |
|
429 | - * @param array $reminder_days |
|
430 | - * @return string |
|
431 | - */ |
|
432 | - public function get_date_query( $reminder_days ) { |
|
426 | + /** |
|
427 | + * Calculates the date query for an invoices query |
|
428 | + * |
|
429 | + * @param array $reminder_days |
|
430 | + * @return string |
|
431 | + */ |
|
432 | + public function get_date_query( $reminder_days ) { |
|
433 | 433 | |
434 | - $date_query = array( |
|
435 | - 'relation' => 'OR' |
|
436 | - ); |
|
434 | + $date_query = array( |
|
435 | + 'relation' => 'OR' |
|
436 | + ); |
|
437 | 437 | |
438 | - foreach ( $reminder_days as $days ) { |
|
439 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
438 | + foreach ( $reminder_days as $days ) { |
|
439 | + $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
440 | 440 | |
441 | - $date_query[] = array( |
|
442 | - 'year' => $date['year'], |
|
443 | - 'month' => $date['month'], |
|
444 | - 'day' => $date['day'], |
|
445 | - ); |
|
441 | + $date_query[] = array( |
|
442 | + 'year' => $date['year'], |
|
443 | + 'month' => $date['month'], |
|
444 | + 'day' => $date['day'], |
|
445 | + ); |
|
446 | 446 | |
447 | - } |
|
447 | + } |
|
448 | 448 | |
449 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
449 | + $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
450 | 450 | |
451 | - return $date_query->get_sql(); |
|
451 | + return $date_query->get_sql(); |
|
452 | 452 | |
453 | - } |
|
453 | + } |
|
454 | 454 | |
455 | 455 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * This class handles invoice notificaiton emails. |
@@ -28,7 +28,7 @@ discard block |
||
28 | 28 | $this->invoice_actions = apply_filters( |
29 | 29 | 'getpaid_notification_email_invoice_triggers', |
30 | 30 | array( |
31 | - 'getpaid_new_invoice' => array( 'new_invoice', 'user_invoice' ), |
|
31 | + 'getpaid_new_invoice' => array('new_invoice', 'user_invoice'), |
|
32 | 32 | 'getpaid_invoice_status_wpi-cancelled' => 'cancelled_invoice', |
33 | 33 | 'getpaid_invoice_status_wpi-failed' => 'failed_invoice', |
34 | 34 | 'getpaid_invoice_status_wpi-onhold' => 'onhold_invoice', |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | */ |
51 | 51 | public function init_hooks() { |
52 | 52 | |
53 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 2 ); |
|
54 | - add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 ); |
|
53 | + add_filter('getpaid_get_email_merge_tags', array($this, 'invoice_merge_tags'), 10, 2); |
|
54 | + add_filter('getpaid_invoice_email_recipients', array($this, 'filter_email_recipients'), 10, 2); |
|
55 | 55 | |
56 | - foreach ( $this->invoice_actions as $hook => $email_type ) { |
|
57 | - $this->init_email_type_hook( $hook, $email_type ); |
|
56 | + foreach ($this->invoice_actions as $hook => $email_type) { |
|
57 | + $this->init_email_type_hook($hook, $email_type); |
|
58 | 58 | } |
59 | 59 | } |
60 | 60 | |
@@ -64,25 +64,25 @@ discard block |
||
64 | 64 | * @param string $hook |
65 | 65 | * @param string|array $email_type |
66 | 66 | */ |
67 | - public function init_email_type_hook( $hook, $email_type ) { |
|
67 | + public function init_email_type_hook($hook, $email_type) { |
|
68 | 68 | |
69 | - $email_type = wpinv_parse_list( $email_type ); |
|
69 | + $email_type = wpinv_parse_list($email_type); |
|
70 | 70 | |
71 | - foreach ( $email_type as $type ) { |
|
71 | + foreach ($email_type as $type) { |
|
72 | 72 | |
73 | - $email = new GetPaid_Notification_Email( $type ); |
|
73 | + $email = new GetPaid_Notification_Email($type); |
|
74 | 74 | |
75 | 75 | // Abort if it is not active. |
76 | - if ( ! $email->is_active() ) { |
|
76 | + if (!$email->is_active()) { |
|
77 | 77 | continue; |
78 | 78 | } |
79 | 79 | |
80 | - if ( method_exists( $this, $type ) ) { |
|
81 | - add_action( $hook, array( $this, $type ), 100, 2 ); |
|
80 | + if (method_exists($this, $type)) { |
|
81 | + add_action($hook, array($this, $type), 100, 2); |
|
82 | 82 | continue; |
83 | 83 | } |
84 | 84 | |
85 | - do_action( 'getpaid_invoice_init_email_type_hook', $type, $hook ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type, $hook); |
|
86 | 86 | } |
87 | 87 | |
88 | 88 | } |
@@ -93,19 +93,19 @@ discard block |
||
93 | 93 | * @param array $merge_tags |
94 | 94 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
95 | 95 | */ |
96 | - public function invoice_merge_tags( $merge_tags, $object ) { |
|
96 | + public function invoice_merge_tags($merge_tags, $object) { |
|
97 | 97 | |
98 | - if ( is_a( $object, 'WPInv_Invoice' ) ) { |
|
98 | + if (is_a($object, 'WPInv_Invoice')) { |
|
99 | 99 | return array_merge( |
100 | 100 | $merge_tags, |
101 | - $this->get_invoice_merge_tags( $object ) |
|
101 | + $this->get_invoice_merge_tags($object) |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | |
105 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
105 | + if (is_a($object, 'WPInv_Subscription')) { |
|
106 | 106 | return array_merge( |
107 | 107 | $merge_tags, |
108 | - $this->get_invoice_merge_tags( $object->get_parent_payment() ) |
|
108 | + $this->get_invoice_merge_tags($object->get_parent_payment()) |
|
109 | 109 | ); |
110 | 110 | } |
111 | 111 | |
@@ -119,35 +119,35 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return array |
121 | 121 | */ |
122 | - public function get_invoice_merge_tags( $invoice ) { |
|
122 | + public function get_invoice_merge_tags($invoice) { |
|
123 | 123 | |
124 | 124 | // Abort if it does not exist. |
125 | - if ( ! $invoice->get_id() ) { |
|
125 | + if (!$invoice->get_id()) { |
|
126 | 126 | return array(); |
127 | 127 | } |
128 | 128 | |
129 | 129 | $merge_tags = array( |
130 | - '{name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
131 | - '{full_name}' => sanitize_text_field( $invoice->get_user_full_name() ), |
|
132 | - '{first_name}' => sanitize_text_field( $invoice->get_first_name() ), |
|
133 | - '{last_name}' => sanitize_text_field( $invoice->get_last_name() ), |
|
134 | - '{email}' => sanitize_email( $invoice->get_email() ), |
|
135 | - '{invoice_number}' => sanitize_text_field( $invoice->get_number() ), |
|
136 | - '{invoice_currency}' => sanitize_text_field( $invoice->get_currency() ), |
|
137 | - '{invoice_total}' => sanitize_text_field( wpinv_price( $invoice->get_total(), $invoice->get_currency() ) ), |
|
138 | - '{invoice_link}' => esc_url( $invoice->get_view_url() ), |
|
139 | - '{invoice_pay_link}' => esc_url( $invoice->get_checkout_payment_url() ), |
|
140 | - '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ), |
|
141 | - '{invoice_date}' => getpaid_format_date_value( $invoice->get_date_created() ), |
|
142 | - '{invoice_due_date}' => getpaid_format_date_value( $invoice->get_due_date(), __( 'on receipt', 'invoicing' ) ), |
|
143 | - '{invoice_quote}' => sanitize_text_field( strtolower( $invoice->get_label() ) ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_label() ) ), |
|
145 | - '{invoice_description}' => wp_kses_post( $invoice->get_description() ), |
|
146 | - '{subscription_name}' => wp_kses_post( $invoice->get_subscription_name() ), |
|
147 | - '{is_was}' => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ), |
|
130 | + '{name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
131 | + '{full_name}' => sanitize_text_field($invoice->get_user_full_name()), |
|
132 | + '{first_name}' => sanitize_text_field($invoice->get_first_name()), |
|
133 | + '{last_name}' => sanitize_text_field($invoice->get_last_name()), |
|
134 | + '{email}' => sanitize_email($invoice->get_email()), |
|
135 | + '{invoice_number}' => sanitize_text_field($invoice->get_number()), |
|
136 | + '{invoice_currency}' => sanitize_text_field($invoice->get_currency()), |
|
137 | + '{invoice_total}' => sanitize_text_field(wpinv_price($invoice->get_total(), $invoice->get_currency())), |
|
138 | + '{invoice_link}' => esc_url($invoice->get_view_url()), |
|
139 | + '{invoice_pay_link}' => esc_url($invoice->get_checkout_payment_url()), |
|
140 | + '{invoice_receipt_link}'=> esc_url($invoice->get_receipt_url()), |
|
141 | + '{invoice_date}' => getpaid_format_date_value($invoice->get_date_created()), |
|
142 | + '{invoice_due_date}' => getpaid_format_date_value($invoice->get_due_date(), __('on receipt', 'invoicing')), |
|
143 | + '{invoice_quote}' => sanitize_text_field(strtolower($invoice->get_label())), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_label())), |
|
145 | + '{invoice_description}' => wp_kses_post($invoice->get_description()), |
|
146 | + '{subscription_name}' => wp_kses_post($invoice->get_subscription_name()), |
|
147 | + '{is_was}' => strtotime($invoice->get_due_date()) < current_time('timestamp') ? __('was', 'invoicing') : __('is', 'invoicing'), |
|
148 | 148 | ); |
149 | 149 | |
150 | - return apply_filters( 'getpaid_invoice_email_merge_tags', $merge_tags, $invoice ); |
|
150 | + return apply_filters('getpaid_invoice_email_merge_tags', $merge_tags, $invoice); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | /** |
@@ -159,35 +159,35 @@ discard block |
||
159 | 159 | * @param string|array $recipients |
160 | 160 | * @param array $extra_args Extra template args. |
161 | 161 | */ |
162 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
162 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
163 | 163 | |
164 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
164 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
165 | 165 | |
166 | 166 | $mailer = new GetPaid_Notification_Email_Sender(); |
167 | 167 | $merge_tags = $email->get_merge_tags(); |
168 | 168 | |
169 | 169 | $result = $mailer->send( |
170 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
172 | - $email->get_content( $merge_tags, $extra_args ), |
|
170 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
171 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
172 | + $email->get_content($merge_tags, $extra_args), |
|
173 | 173 | $email->get_attachments() |
174 | 174 | ); |
175 | 175 | |
176 | 176 | // Maybe send a copy to the admin. |
177 | - if ( $email->include_admin_bcc() ) { |
|
177 | + if ($email->include_admin_bcc()) { |
|
178 | 178 | $mailer->send( |
179 | 179 | wpinv_get_admin_email(), |
180 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
181 | - $email->get_content( $merge_tags ), |
|
180 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
181 | + $email->get_content($merge_tags), |
|
182 | 182 | $email->get_attachments() |
183 | 183 | ); |
184 | 184 | } |
185 | 185 | |
186 | - if ( ! $result ) { |
|
187 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
186 | + if (!$result) { |
|
187 | + $invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
188 | 188 | } |
189 | 189 | |
190 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
190 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
191 | 191 | |
192 | 192 | return $result; |
193 | 193 | } |
@@ -198,14 +198,14 @@ discard block |
||
198 | 198 | * @param array $recipients |
199 | 199 | * @param GetPaid_Notification_Email $email |
200 | 200 | */ |
201 | - public function filter_email_recipients( $recipients, $email ) { |
|
201 | + public function filter_email_recipients($recipients, $email) { |
|
202 | 202 | |
203 | - if ( ! $email->is_admin_email() ) { |
|
203 | + if (!$email->is_admin_email()) { |
|
204 | 204 | $cc = $email->object->get_email_cc(); |
205 | 205 | |
206 | - if ( ! empty( $cc ) ) { |
|
207 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
208 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
206 | + if (!empty($cc)) { |
|
207 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
208 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
209 | 209 | } |
210 | 210 | |
211 | 211 | } |
@@ -219,17 +219,17 @@ discard block |
||
219 | 219 | * |
220 | 220 | * @param WPInv_Invoice $invoice |
221 | 221 | */ |
222 | - public function new_invoice( $invoice ) { |
|
222 | + public function new_invoice($invoice) { |
|
223 | 223 | |
224 | 224 | // Only send this email for invoices created via the admin page. |
225 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
225 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
229 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
230 | 230 | $recipient = wpinv_get_admin_email(); |
231 | 231 | |
232 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
232 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
233 | 233 | |
234 | 234 | } |
235 | 235 | |
@@ -238,12 +238,12 @@ discard block |
||
238 | 238 | * |
239 | 239 | * @param WPInv_Invoice $invoice |
240 | 240 | */ |
241 | - public function cancelled_invoice( $invoice ) { |
|
241 | + public function cancelled_invoice($invoice) { |
|
242 | 242 | |
243 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
243 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
244 | 244 | $recipient = wpinv_get_admin_email(); |
245 | 245 | |
246 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
246 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
247 | 247 | |
248 | 248 | } |
249 | 249 | |
@@ -252,12 +252,12 @@ discard block |
||
252 | 252 | * |
253 | 253 | * @param WPInv_Invoice $invoice |
254 | 254 | */ |
255 | - public function failed_invoice( $invoice ) { |
|
255 | + public function failed_invoice($invoice) { |
|
256 | 256 | |
257 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
257 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
258 | 258 | $recipient = wpinv_get_admin_email(); |
259 | 259 | |
260 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
260 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
261 | 261 | |
262 | 262 | } |
263 | 263 | |
@@ -266,12 +266,12 @@ discard block |
||
266 | 266 | * |
267 | 267 | * @param WPInv_Invoice $invoice |
268 | 268 | */ |
269 | - public function onhold_invoice( $invoice ) { |
|
269 | + public function onhold_invoice($invoice) { |
|
270 | 270 | |
271 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
271 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
272 | 272 | $recipient = $invoice->get_email(); |
273 | 273 | |
274 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
274 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
275 | 275 | |
276 | 276 | } |
277 | 277 | |
@@ -280,12 +280,12 @@ discard block |
||
280 | 280 | * |
281 | 281 | * @param WPInv_Invoice $invoice |
282 | 282 | */ |
283 | - public function processing_invoice( $invoice ) { |
|
283 | + public function processing_invoice($invoice) { |
|
284 | 284 | |
285 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
285 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
286 | 286 | $recipient = $invoice->get_email(); |
287 | 287 | |
288 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
288 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
289 | 289 | |
290 | 290 | } |
291 | 291 | |
@@ -294,17 +294,17 @@ discard block |
||
294 | 294 | * |
295 | 295 | * @param WPInv_Invoice $invoice |
296 | 296 | */ |
297 | - public function completed_invoice( $invoice ) { |
|
297 | + public function completed_invoice($invoice) { |
|
298 | 298 | |
299 | 299 | // (Maybe) abort if it is a renewal invoice. |
300 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
300 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
301 | 301 | return; |
302 | 302 | } |
303 | 303 | |
304 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
304 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
305 | 305 | $recipient = $invoice->get_email(); |
306 | 306 | |
307 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
307 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
308 | 308 | |
309 | 309 | } |
310 | 310 | |
@@ -313,12 +313,12 @@ discard block |
||
313 | 313 | * |
314 | 314 | * @param WPInv_Invoice $invoice |
315 | 315 | */ |
316 | - public function refunded_invoice( $invoice ) { |
|
316 | + public function refunded_invoice($invoice) { |
|
317 | 317 | |
318 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
318 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
319 | 319 | $recipient = $invoice->get_email(); |
320 | 320 | |
321 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
321 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
322 | 322 | |
323 | 323 | } |
324 | 324 | |
@@ -327,17 +327,17 @@ discard block |
||
327 | 327 | * |
328 | 328 | * @param WPInv_Invoice $invoice |
329 | 329 | */ |
330 | - public function user_invoice( $invoice ) { |
|
330 | + public function user_invoice($invoice) { |
|
331 | 331 | |
332 | 332 | // Only send this email for invoices created via the admin page. |
333 | - if ( ! $invoice->is_type( 'invoice' ) || $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
333 | + if (!$invoice->is_type('invoice') || $this->is_payment_form_invoice($invoice->get_id())) { |
|
334 | 334 | return; |
335 | 335 | } |
336 | 336 | |
337 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
337 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
338 | 338 | $recipient = $invoice->get_email(); |
339 | 339 | |
340 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
340 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
341 | 341 | |
342 | 342 | } |
343 | 343 | |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * @param int $invoice |
348 | 348 | * @return bool |
349 | 349 | */ |
350 | - public function is_payment_form_invoice( $invoice ) { |
|
351 | - return empty( $_GET['getpaid-admin-action'] ) && ( 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ) || 'geodirectory' == get_post_meta( $invoice, 'wpinv_created_via', true ) ); |
|
350 | + public function is_payment_form_invoice($invoice) { |
|
351 | + return empty($_GET['getpaid-admin-action']) && ('payment_form' == get_post_meta($invoice, 'wpinv_created_via', true) || 'geodirectory' == get_post_meta($invoice, 'wpinv_created_via', true)); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -357,12 +357,12 @@ discard block |
||
357 | 357 | * @param WPInv_Invoice $invoice |
358 | 358 | * @param string $note |
359 | 359 | */ |
360 | - public function user_note( $invoice, $note ) { |
|
360 | + public function user_note($invoice, $note) { |
|
361 | 361 | |
362 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
362 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
363 | 363 | $recipient = $invoice->get_email(); |
364 | 364 | |
365 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
365 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
366 | 366 | |
367 | 367 | } |
368 | 368 | |
@@ -371,9 +371,9 @@ discard block |
||
371 | 371 | * |
372 | 372 | * @param WPInv_Invoice $invoice |
373 | 373 | */ |
374 | - public function force_send_overdue_notice( $invoice ) { |
|
375 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
376 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
374 | + public function force_send_overdue_notice($invoice) { |
|
375 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
376 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
377 | 377 | } |
378 | 378 | |
379 | 379 | /** |
@@ -384,37 +384,37 @@ discard block |
||
384 | 384 | public function overdue() { |
385 | 385 | global $wpdb; |
386 | 386 | |
387 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
387 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
388 | 388 | |
389 | 389 | // Fetch reminder days. |
390 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
390 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
391 | 391 | |
392 | 392 | // Abort if non is set. |
393 | - if ( empty( $reminder_days ) ) { |
|
393 | + if (empty($reminder_days)) { |
|
394 | 394 | return; |
395 | 395 | } |
396 | 396 | |
397 | 397 | // Retrieve date query. |
398 | - $date_query = $this->get_date_query( $reminder_days ); |
|
398 | + $date_query = $this->get_date_query($reminder_days); |
|
399 | 399 | |
400 | 400 | // Invoices table. |
401 | 401 | $table = $wpdb->prefix . 'getpaid_invoices'; |
402 | 402 | |
403 | 403 | // Fetch invoices. |
404 | - $invoices = $wpdb->get_col( |
|
404 | + $invoices = $wpdb->get_col( |
|
405 | 405 | "SELECT posts.ID FROM $wpdb->posts as posts |
406 | 406 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
407 | 407 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
408 | 408 | |
409 | - foreach ( $invoices as $invoice ) { |
|
409 | + foreach ($invoices as $invoice) { |
|
410 | 410 | |
411 | 411 | // Only send this email for invoices created via the admin page. |
412 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
413 | - $invoice = new WPInv_Invoice( $invoice ); |
|
412 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
413 | + $invoice = new WPInv_Invoice($invoice); |
|
414 | 414 | $email->object = $invoice; |
415 | 415 | |
416 | - if ( $invoice->needs_payment() ) { |
|
417 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
416 | + if ($invoice->needs_payment()) { |
|
417 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
418 | 418 | } |
419 | 419 | |
420 | 420 | } |
@@ -429,14 +429,14 @@ discard block |
||
429 | 429 | * @param array $reminder_days |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function get_date_query( $reminder_days ) { |
|
432 | + public function get_date_query($reminder_days) { |
|
433 | 433 | |
434 | 434 | $date_query = array( |
435 | 435 | 'relation' => 'OR' |
436 | 436 | ); |
437 | 437 | |
438 | - foreach ( $reminder_days as $days ) { |
|
439 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
438 | + foreach ($reminder_days as $days) { |
|
439 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
440 | 440 | |
441 | 441 | $date_query[] = array( |
442 | 442 | 'year' => $date['year'], |
@@ -446,7 +446,7 @@ discard block |
||
446 | 446 | |
447 | 447 | } |
448 | 448 | |
449 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
449 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
450 | 450 | |
451 | 451 | return $date_query->get_sql(); |
452 | 452 |
@@ -13,646 +13,646 @@ discard block |
||
13 | 13 | class GetPaid_Post_Types_Admin { |
14 | 14 | |
15 | 15 | /** |
16 | - * Hook in methods. |
|
17 | - */ |
|
18 | - public static function init() { |
|
19 | - |
|
20 | - // Init metaboxes. |
|
21 | - GetPaid_Metaboxes::init(); |
|
22 | - |
|
23 | - // Filter the post updated messages. |
|
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | - |
|
26 | - // Filter post actions. |
|
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | - |
|
30 | - // Invoice table columns. |
|
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | - |
|
34 | - // Items table columns. |
|
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | - |
|
42 | - // Payment forms columns. |
|
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | - |
|
47 | - // Discount table columns. |
|
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | - |
|
51 | - // Deleting posts. |
|
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | - } |
|
55 | - |
|
56 | - /** |
|
57 | - * Post updated messages. |
|
58 | - */ |
|
59 | - public static function post_updated_messages( $messages ) { |
|
60 | - global $post; |
|
61 | - |
|
62 | - $messages['wpi_discount'] = array( |
|
63 | - 0 => '', |
|
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
74 | - ); |
|
75 | - |
|
76 | - $messages['wpi_payment_form'] = array( |
|
77 | - 0 => '', |
|
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
88 | - ); |
|
89 | - |
|
90 | - return $messages; |
|
91 | - |
|
92 | - } |
|
93 | - |
|
94 | - /** |
|
95 | - * Post row actions. |
|
96 | - */ |
|
97 | - public static function post_row_actions( $actions, $post ) { |
|
98 | - |
|
99 | - $post = get_post( $post ); |
|
100 | - |
|
101 | - // We do not want to edit the default payment form. |
|
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
105 | - } |
|
106 | - |
|
107 | - return $actions; |
|
108 | - } |
|
109 | - |
|
110 | - /** |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
19 | + |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
22 | + |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
25 | + |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
29 | + |
|
30 | + // Invoice table columns. |
|
31 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
33 | + |
|
34 | + // Items table columns. |
|
35 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
41 | + |
|
42 | + // Payment forms columns. |
|
43 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
46 | + |
|
47 | + // Discount table columns. |
|
48 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | + add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
50 | + |
|
51 | + // Deleting posts. |
|
52 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
54 | + } |
|
55 | + |
|
56 | + /** |
|
57 | + * Post updated messages. |
|
58 | + */ |
|
59 | + public static function post_updated_messages( $messages ) { |
|
60 | + global $post; |
|
61 | + |
|
62 | + $messages['wpi_discount'] = array( |
|
63 | + 0 => '', |
|
64 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
74 | + ); |
|
75 | + |
|
76 | + $messages['wpi_payment_form'] = array( |
|
77 | + 0 => '', |
|
78 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
88 | + ); |
|
89 | + |
|
90 | + return $messages; |
|
91 | + |
|
92 | + } |
|
93 | + |
|
94 | + /** |
|
95 | + * Post row actions. |
|
96 | + */ |
|
97 | + public static function post_row_actions( $actions, $post ) { |
|
98 | + |
|
99 | + $post = get_post( $post ); |
|
100 | + |
|
101 | + // We do not want to edit the default payment form. |
|
102 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | + unset( $actions['trash'] ); |
|
104 | + unset( $actions['inline hide-if-no-js'] ); |
|
105 | + } |
|
106 | + |
|
107 | + return $actions; |
|
108 | + } |
|
109 | + |
|
110 | + /** |
|
111 | 111 | * Remove bulk edit option from admin side quote listing |
112 | 112 | * |
113 | 113 | * @since 1.0.0 |
114 | 114 | * @param array $actions post actions |
115 | - * @param WP_Post $post |
|
115 | + * @param WP_Post $post |
|
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | 118 | public static function filter_invoice_row_actions( $actions, $post ) { |
119 | 119 | |
120 | 120 | if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
121 | 121 | |
122 | - $actions = array(); |
|
123 | - $invoice = new WPInv_Invoice( $post ); |
|
124 | - |
|
125 | - $actions['edit'] = sprintf( |
|
126 | - '<a href="%1$s">%2$s</a>', |
|
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | - ); |
|
130 | - |
|
131 | - if ( ! $invoice->is_draft() ) { |
|
132 | - |
|
133 | - $actions['view'] = sprintf( |
|
134 | - '<a href="%1$s">%2$s</a>', |
|
135 | - esc_url( $invoice->get_view_url() ), |
|
136 | - sprintf( |
|
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | - ) |
|
140 | - ); |
|
141 | - |
|
142 | - $actions['send'] = sprintf( |
|
143 | - '<a href="%1$s">%2$s</a>', |
|
144 | - esc_url( |
|
145 | - wp_nonce_url( |
|
146 | - add_query_arg( |
|
147 | - array( |
|
148 | - 'getpaid-admin-action' => 'send_invoice', |
|
149 | - 'invoice_id' => $invoice->get_id() |
|
150 | - ) |
|
151 | - ), |
|
152 | - 'getpaid-nonce', |
|
153 | - 'getpaid-nonce' |
|
154 | - ) |
|
155 | - ), |
|
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
157 | - ); |
|
158 | - |
|
159 | - } |
|
122 | + $actions = array(); |
|
123 | + $invoice = new WPInv_Invoice( $post ); |
|
124 | + |
|
125 | + $actions['edit'] = sprintf( |
|
126 | + '<a href="%1$s">%2$s</a>', |
|
127 | + esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | + esc_html( __( 'Edit', 'invoicing' ) ) |
|
129 | + ); |
|
130 | + |
|
131 | + if ( ! $invoice->is_draft() ) { |
|
132 | + |
|
133 | + $actions['view'] = sprintf( |
|
134 | + '<a href="%1$s">%2$s</a>', |
|
135 | + esc_url( $invoice->get_view_url() ), |
|
136 | + sprintf( |
|
137 | + esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | + getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
139 | + ) |
|
140 | + ); |
|
141 | + |
|
142 | + $actions['send'] = sprintf( |
|
143 | + '<a href="%1$s">%2$s</a>', |
|
144 | + esc_url( |
|
145 | + wp_nonce_url( |
|
146 | + add_query_arg( |
|
147 | + array( |
|
148 | + 'getpaid-admin-action' => 'send_invoice', |
|
149 | + 'invoice_id' => $invoice->get_id() |
|
150 | + ) |
|
151 | + ), |
|
152 | + 'getpaid-nonce', |
|
153 | + 'getpaid-nonce' |
|
154 | + ) |
|
155 | + ), |
|
156 | + esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
157 | + ); |
|
158 | + |
|
159 | + } |
|
160 | 160 | |
161 | 161 | } |
162 | 162 | |
163 | 163 | return $actions; |
164 | - } |
|
165 | - |
|
166 | - /** |
|
167 | - * Returns an array of invoice table columns. |
|
168 | - */ |
|
169 | - public static function invoice_columns( $columns ) { |
|
170 | - |
|
171 | - $columns = array( |
|
172 | - 'cb' => $columns['cb'], |
|
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
176 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
177 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
178 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
179 | - 'status' => __( 'Status', 'invoicing' ), |
|
180 | - ); |
|
181 | - |
|
182 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
183 | - } |
|
184 | - |
|
185 | - /** |
|
186 | - * Displays invoice table columns. |
|
187 | - */ |
|
188 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
189 | - |
|
190 | - $invoice = new WPInv_Invoice( $post_id ); |
|
191 | - |
|
192 | - switch ( $column_name ) { |
|
193 | - |
|
194 | - case 'invoice_date' : |
|
195 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
196 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
197 | - echo "<span title='$date_time'>$date</span>"; |
|
198 | - break; |
|
199 | - |
|
200 | - case 'payment_date' : |
|
201 | - |
|
202 | - if ( $invoice->is_paid() ) { |
|
203 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
204 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
205 | - echo "<span title='$date_time'>$date</span>"; |
|
206 | - } else { |
|
207 | - echo "—"; |
|
208 | - } |
|
164 | + } |
|
165 | + |
|
166 | + /** |
|
167 | + * Returns an array of invoice table columns. |
|
168 | + */ |
|
169 | + public static function invoice_columns( $columns ) { |
|
170 | + |
|
171 | + $columns = array( |
|
172 | + 'cb' => $columns['cb'], |
|
173 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | + 'invoice_date' => __( 'Created', 'invoicing' ), |
|
176 | + 'payment_date' => __( 'Completed', 'invoicing' ), |
|
177 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
178 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
179 | + 'status' => __( 'Status', 'invoicing' ), |
|
180 | + ); |
|
181 | + |
|
182 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
183 | + } |
|
184 | + |
|
185 | + /** |
|
186 | + * Displays invoice table columns. |
|
187 | + */ |
|
188 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
189 | + |
|
190 | + $invoice = new WPInv_Invoice( $post_id ); |
|
191 | + |
|
192 | + switch ( $column_name ) { |
|
193 | + |
|
194 | + case 'invoice_date' : |
|
195 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
196 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
197 | + echo "<span title='$date_time'>$date</span>"; |
|
198 | + break; |
|
199 | + |
|
200 | + case 'payment_date' : |
|
201 | + |
|
202 | + if ( $invoice->is_paid() ) { |
|
203 | + $date_time = esc_attr( $invoice->get_completed_date() ); |
|
204 | + $date = getpaid_format_date_value( $date_time, "—", true ); |
|
205 | + echo "<span title='$date_time'>$date</span>"; |
|
206 | + } else { |
|
207 | + echo "—"; |
|
208 | + } |
|
209 | 209 | |
210 | - break; |
|
210 | + break; |
|
211 | 211 | |
212 | - case 'amount' : |
|
212 | + case 'amount' : |
|
213 | 213 | |
214 | - $amount = $invoice->get_total(); |
|
215 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
214 | + $amount = $invoice->get_total(); |
|
215 | + $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
216 | 216 | |
217 | - if ( $invoice->is_refunded() ) { |
|
218 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
219 | - echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
220 | - } else { |
|
217 | + if ( $invoice->is_refunded() ) { |
|
218 | + $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
219 | + echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
|
220 | + } else { |
|
221 | 221 | |
222 | - $discount = $invoice->get_total_discount(); |
|
222 | + $discount = $invoice->get_total_discount(); |
|
223 | 223 | |
224 | - if ( ! empty( $discount ) ) { |
|
225 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
226 | - echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
227 | - } else { |
|
228 | - echo $formated_amount; |
|
229 | - } |
|
224 | + if ( ! empty( $discount ) ) { |
|
225 | + $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
226 | + echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
|
227 | + } else { |
|
228 | + echo $formated_amount; |
|
229 | + } |
|
230 | 230 | |
231 | - } |
|
231 | + } |
|
232 | 232 | |
233 | - break; |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'status' : |
|
236 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
237 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
235 | + case 'status' : |
|
236 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
237 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
238 | 238 | |
239 | - // If it is paid, show the gateway title. |
|
240 | - if ( $invoice->is_paid() ) { |
|
241 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
242 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
239 | + // If it is paid, show the gateway title. |
|
240 | + if ( $invoice->is_paid() ) { |
|
241 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
242 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
243 | 243 | |
244 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
245 | - } else { |
|
246 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
247 | - } |
|
244 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
245 | + } else { |
|
246 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
247 | + } |
|
248 | 248 | |
249 | - // If it is not paid, display the overdue and view status. |
|
250 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
249 | + // If it is not paid, display the overdue and view status. |
|
250 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
251 | 251 | |
252 | - // Invoice view status. |
|
253 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
254 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
255 | - } else { |
|
256 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
257 | - } |
|
252 | + // Invoice view status. |
|
253 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
254 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
255 | + } else { |
|
256 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
257 | + } |
|
258 | 258 | |
259 | - // Display the overview status. |
|
260 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
261 | - $due_date = $invoice->get_due_date(); |
|
262 | - $fomatted = getpaid_format_date( $due_date ); |
|
259 | + // Display the overview status. |
|
260 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
261 | + $due_date = $invoice->get_due_date(); |
|
262 | + $fomatted = getpaid_format_date( $due_date ); |
|
263 | 263 | |
264 | - if ( ! empty( $fomatted ) ) { |
|
265 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
266 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
267 | - } |
|
268 | - } |
|
264 | + if ( ! empty( $fomatted ) ) { |
|
265 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
266 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
267 | + } |
|
268 | + } |
|
269 | 269 | |
270 | - } |
|
270 | + } |
|
271 | 271 | |
272 | - break; |
|
272 | + break; |
|
273 | 273 | |
274 | - case 'recurring': |
|
274 | + case 'recurring': |
|
275 | 275 | |
276 | - if ( $invoice->is_recurring() ) { |
|
277 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
278 | - } else { |
|
279 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
280 | - } |
|
281 | - break; |
|
276 | + if ( $invoice->is_recurring() ) { |
|
277 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
278 | + } else { |
|
279 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
280 | + } |
|
281 | + break; |
|
282 | 282 | |
283 | - case 'number' : |
|
283 | + case 'number' : |
|
284 | 284 | |
285 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
286 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
287 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
285 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
286 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
287 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
288 | 288 | |
289 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
289 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
290 | 290 | |
291 | - break; |
|
291 | + break; |
|
292 | 292 | |
293 | - case 'customer' : |
|
293 | + case 'customer' : |
|
294 | 294 | |
295 | - $customer_name = $invoice->get_user_full_name(); |
|
295 | + $customer_name = $invoice->get_user_full_name(); |
|
296 | 296 | |
297 | - if ( empty( $customer_name ) ) { |
|
298 | - $customer_name = $invoice->get_email(); |
|
299 | - } |
|
297 | + if ( empty( $customer_name ) ) { |
|
298 | + $customer_name = $invoice->get_email(); |
|
299 | + } |
|
300 | 300 | |
301 | - if ( ! empty( $customer_name ) ) { |
|
302 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
303 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
304 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
305 | - } else { |
|
306 | - echo '<div>—</div>'; |
|
307 | - } |
|
301 | + if ( ! empty( $customer_name ) ) { |
|
302 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
303 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
304 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
305 | + } else { |
|
306 | + echo '<div>—</div>'; |
|
307 | + } |
|
308 | 308 | |
309 | - break; |
|
309 | + break; |
|
310 | 310 | |
311 | - } |
|
311 | + } |
|
312 | 312 | |
313 | - } |
|
313 | + } |
|
314 | 314 | |
315 | - /** |
|
316 | - * Returns an array of payment forms table columns. |
|
317 | - */ |
|
318 | - public static function payment_form_columns( $columns ) { |
|
315 | + /** |
|
316 | + * Returns an array of payment forms table columns. |
|
317 | + */ |
|
318 | + public static function payment_form_columns( $columns ) { |
|
319 | 319 | |
320 | - $columns = array( |
|
321 | - 'cb' => $columns['cb'], |
|
322 | - 'title' => __( 'Name', 'invoicing' ), |
|
323 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
324 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
325 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
326 | - 'items' => __( 'Items', 'invoicing' ), |
|
327 | - 'date' => __( 'Date', 'invoicing' ), |
|
328 | - ); |
|
320 | + $columns = array( |
|
321 | + 'cb' => $columns['cb'], |
|
322 | + 'title' => __( 'Name', 'invoicing' ), |
|
323 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
324 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
325 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
326 | + 'items' => __( 'Items', 'invoicing' ), |
|
327 | + 'date' => __( 'Date', 'invoicing' ), |
|
328 | + ); |
|
329 | 329 | |
330 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
330 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
331 | 331 | |
332 | - } |
|
332 | + } |
|
333 | 333 | |
334 | - /** |
|
335 | - * Displays payment form table columns. |
|
336 | - */ |
|
337 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
334 | + /** |
|
335 | + * Displays payment form table columns. |
|
336 | + */ |
|
337 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
338 | 338 | |
339 | - // Retrieve the payment form. |
|
340 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
339 | + // Retrieve the payment form. |
|
340 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
341 | 341 | |
342 | - switch ( $column_name ) { |
|
342 | + switch ( $column_name ) { |
|
343 | 343 | |
344 | - case 'earnings' : |
|
345 | - echo wpinv_price( $form->get_earned() ); |
|
346 | - break; |
|
344 | + case 'earnings' : |
|
345 | + echo wpinv_price( $form->get_earned() ); |
|
346 | + break; |
|
347 | 347 | |
348 | - case 'refunds' : |
|
349 | - echo wpinv_price( $form->get_refunded() ); |
|
350 | - break; |
|
348 | + case 'refunds' : |
|
349 | + echo wpinv_price( $form->get_refunded() ); |
|
350 | + break; |
|
351 | 351 | |
352 | - case 'refunds' : |
|
353 | - echo wpinv_price( $form->get_refunded() ); |
|
354 | - break; |
|
352 | + case 'refunds' : |
|
353 | + echo wpinv_price( $form->get_refunded() ); |
|
354 | + break; |
|
355 | 355 | |
356 | - case 'shortcode' : |
|
356 | + case 'shortcode' : |
|
357 | 357 | |
358 | - if ( $form->is_default() ) { |
|
359 | - echo '—'; |
|
360 | - } else { |
|
361 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
362 | - } |
|
358 | + if ( $form->is_default() ) { |
|
359 | + echo '—'; |
|
360 | + } else { |
|
361 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
362 | + } |
|
363 | 363 | |
364 | - break; |
|
364 | + break; |
|
365 | 365 | |
366 | - case 'items' : |
|
366 | + case 'items' : |
|
367 | 367 | |
368 | - $items = $form->get_items(); |
|
368 | + $items = $form->get_items(); |
|
369 | 369 | |
370 | - if ( $form->is_default() || empty( $items ) ) { |
|
371 | - echo '—'; |
|
372 | - return; |
|
373 | - } |
|
370 | + if ( $form->is_default() || empty( $items ) ) { |
|
371 | + echo '—'; |
|
372 | + return; |
|
373 | + } |
|
374 | 374 | |
375 | - $_items = array(); |
|
375 | + $_items = array(); |
|
376 | 376 | |
377 | - foreach ( $items as $item ) { |
|
378 | - $url = $item->get_edit_url(); |
|
377 | + foreach ( $items as $item ) { |
|
378 | + $url = $item->get_edit_url(); |
|
379 | 379 | |
380 | - if ( empty( $url ) ) { |
|
381 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
382 | - } else { |
|
383 | - $_items[] = sprintf( |
|
384 | - '<a href="%s">%s</a>', |
|
385 | - esc_url( $url ), |
|
386 | - sanitize_text_field( $item->get_name() ) |
|
387 | - ); |
|
388 | - } |
|
380 | + if ( empty( $url ) ) { |
|
381 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
382 | + } else { |
|
383 | + $_items[] = sprintf( |
|
384 | + '<a href="%s">%s</a>', |
|
385 | + esc_url( $url ), |
|
386 | + sanitize_text_field( $item->get_name() ) |
|
387 | + ); |
|
388 | + } |
|
389 | 389 | |
390 | - } |
|
390 | + } |
|
391 | 391 | |
392 | - echo implode( '<br>', $_items ); |
|
392 | + echo implode( '<br>', $_items ); |
|
393 | 393 | |
394 | - break; |
|
394 | + break; |
|
395 | 395 | |
396 | - } |
|
396 | + } |
|
397 | 397 | |
398 | - } |
|
398 | + } |
|
399 | 399 | |
400 | - /** |
|
401 | - * Filters post states. |
|
402 | - */ |
|
403 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
400 | + /** |
|
401 | + * Filters post states. |
|
402 | + */ |
|
403 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
404 | 404 | |
405 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
406 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
407 | - } |
|
405 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
406 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
407 | + } |
|
408 | 408 | |
409 | - return $post_states; |
|
410 | - |
|
411 | - } |
|
412 | - |
|
413 | - /** |
|
414 | - * Returns an array of coupon table columns. |
|
415 | - */ |
|
416 | - public static function discount_columns( $columns ) { |
|
417 | - |
|
418 | - $columns = array( |
|
419 | - 'cb' => $columns['cb'], |
|
420 | - 'title' => __( 'Name', 'invoicing' ), |
|
421 | - 'code' => __( 'Code', 'invoicing' ), |
|
422 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
423 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
424 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
425 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
426 | - ); |
|
427 | - |
|
428 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
429 | - } |
|
430 | - |
|
431 | - /** |
|
432 | - * Filters post states. |
|
433 | - */ |
|
434 | - public static function filter_discount_state( $post_states, $post ) { |
|
435 | - |
|
436 | - if ( 'wpi_discount' == $post->post_type ) { |
|
437 | - |
|
438 | - $discount = new WPInv_Discount( $post ); |
|
439 | - |
|
440 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
441 | - |
|
442 | - if ( $status != 'publish' ) { |
|
443 | - return array( |
|
444 | - 'discount_status' => wpinv_discount_status( $status ), |
|
445 | - ); |
|
446 | - } |
|
447 | - |
|
448 | - return array(); |
|
449 | - |
|
450 | - } |
|
451 | - |
|
452 | - return $post_states; |
|
453 | - |
|
454 | - } |
|
455 | - |
|
456 | - /** |
|
457 | - * Returns an array of items table columns. |
|
458 | - */ |
|
459 | - public static function item_columns( $columns ) { |
|
460 | - |
|
461 | - $columns = array( |
|
462 | - 'cb' => $columns['cb'], |
|
463 | - 'title' => __( 'Name', 'invoicing' ), |
|
464 | - 'price' => __( 'Price', 'invoicing' ), |
|
465 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
466 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
467 | - 'type' => __( 'Type', 'invoicing' ), |
|
468 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
469 | - ); |
|
470 | - |
|
471 | - if ( ! wpinv_use_taxes() ) { |
|
472 | - unset( $columns['vat_rule'] ); |
|
473 | - unset( $columns['vat_class'] ); |
|
474 | - } |
|
475 | - |
|
476 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
477 | - } |
|
478 | - |
|
479 | - /** |
|
480 | - * Returns an array of sortable items table columns. |
|
481 | - */ |
|
482 | - public static function sortable_item_columns( $columns ) { |
|
483 | - |
|
484 | - return array_merge( |
|
485 | - $columns, |
|
486 | - array( |
|
487 | - 'price' => 'price', |
|
488 | - 'vat_rule' => 'vat_rule', |
|
489 | - 'vat_class' => 'vat_class', |
|
490 | - 'type' => 'type', |
|
491 | - ) |
|
492 | - ); |
|
493 | - |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * Displays items table columns. |
|
498 | - */ |
|
499 | - public static function display_item_columns( $column_name, $post_id ) { |
|
409 | + return $post_states; |
|
410 | + |
|
411 | + } |
|
412 | + |
|
413 | + /** |
|
414 | + * Returns an array of coupon table columns. |
|
415 | + */ |
|
416 | + public static function discount_columns( $columns ) { |
|
417 | + |
|
418 | + $columns = array( |
|
419 | + 'cb' => $columns['cb'], |
|
420 | + 'title' => __( 'Name', 'invoicing' ), |
|
421 | + 'code' => __( 'Code', 'invoicing' ), |
|
422 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
423 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
424 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
425 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
426 | + ); |
|
427 | + |
|
428 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
429 | + } |
|
430 | + |
|
431 | + /** |
|
432 | + * Filters post states. |
|
433 | + */ |
|
434 | + public static function filter_discount_state( $post_states, $post ) { |
|
435 | + |
|
436 | + if ( 'wpi_discount' == $post->post_type ) { |
|
437 | + |
|
438 | + $discount = new WPInv_Discount( $post ); |
|
439 | + |
|
440 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
441 | + |
|
442 | + if ( $status != 'publish' ) { |
|
443 | + return array( |
|
444 | + 'discount_status' => wpinv_discount_status( $status ), |
|
445 | + ); |
|
446 | + } |
|
447 | + |
|
448 | + return array(); |
|
449 | + |
|
450 | + } |
|
451 | + |
|
452 | + return $post_states; |
|
453 | + |
|
454 | + } |
|
455 | + |
|
456 | + /** |
|
457 | + * Returns an array of items table columns. |
|
458 | + */ |
|
459 | + public static function item_columns( $columns ) { |
|
460 | + |
|
461 | + $columns = array( |
|
462 | + 'cb' => $columns['cb'], |
|
463 | + 'title' => __( 'Name', 'invoicing' ), |
|
464 | + 'price' => __( 'Price', 'invoicing' ), |
|
465 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
466 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
467 | + 'type' => __( 'Type', 'invoicing' ), |
|
468 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
469 | + ); |
|
470 | + |
|
471 | + if ( ! wpinv_use_taxes() ) { |
|
472 | + unset( $columns['vat_rule'] ); |
|
473 | + unset( $columns['vat_class'] ); |
|
474 | + } |
|
475 | + |
|
476 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
477 | + } |
|
478 | + |
|
479 | + /** |
|
480 | + * Returns an array of sortable items table columns. |
|
481 | + */ |
|
482 | + public static function sortable_item_columns( $columns ) { |
|
483 | + |
|
484 | + return array_merge( |
|
485 | + $columns, |
|
486 | + array( |
|
487 | + 'price' => 'price', |
|
488 | + 'vat_rule' => 'vat_rule', |
|
489 | + 'vat_class' => 'vat_class', |
|
490 | + 'type' => 'type', |
|
491 | + ) |
|
492 | + ); |
|
493 | + |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * Displays items table columns. |
|
498 | + */ |
|
499 | + public static function display_item_columns( $column_name, $post_id ) { |
|
500 | 500 | |
501 | - $item = new WPInv_Item( $post_id ); |
|
501 | + $item = new WPInv_Item( $post_id ); |
|
502 | 502 | |
503 | - switch ( $column_name ) { |
|
503 | + switch ( $column_name ) { |
|
504 | 504 | |
505 | - case 'price' : |
|
505 | + case 'price' : |
|
506 | 506 | |
507 | - if ( ! $item->is_recurring() ) { |
|
508 | - echo $item->get_the_price(); |
|
509 | - break; |
|
510 | - } |
|
507 | + if ( ! $item->is_recurring() ) { |
|
508 | + echo $item->get_the_price(); |
|
509 | + break; |
|
510 | + } |
|
511 | 511 | |
512 | - $price = wp_sprintf( |
|
513 | - __( '%s / %s', 'invoicing' ), |
|
514 | - $item->get_the_price(), |
|
515 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
516 | - ); |
|
512 | + $price = wp_sprintf( |
|
513 | + __( '%s / %s', 'invoicing' ), |
|
514 | + $item->get_the_price(), |
|
515 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
516 | + ); |
|
517 | 517 | |
518 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
519 | - echo $price; |
|
520 | - break; |
|
521 | - } |
|
518 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
519 | + echo $price; |
|
520 | + break; |
|
521 | + } |
|
522 | 522 | |
523 | - echo $item->get_the_initial_price(); |
|
523 | + echo $item->get_the_initial_price(); |
|
524 | 524 | |
525 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
526 | - break; |
|
525 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
526 | + break; |
|
527 | 527 | |
528 | - case 'vat_rule' : |
|
529 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
530 | - break; |
|
528 | + case 'vat_rule' : |
|
529 | + echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
530 | + break; |
|
531 | 531 | |
532 | - case 'vat_class' : |
|
533 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
534 | - break; |
|
532 | + case 'vat_class' : |
|
533 | + echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
534 | + break; |
|
535 | 535 | |
536 | - case 'shortcode' : |
|
537 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
538 | - break; |
|
536 | + case 'shortcode' : |
|
537 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
538 | + break; |
|
539 | 539 | |
540 | - case 'type' : |
|
541 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
542 | - break; |
|
540 | + case 'type' : |
|
541 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
542 | + break; |
|
543 | 543 | |
544 | - } |
|
544 | + } |
|
545 | 545 | |
546 | - } |
|
546 | + } |
|
547 | 547 | |
548 | - /** |
|
549 | - * Lets users filter items using taxes. |
|
550 | - */ |
|
551 | - public static function add_item_filters( $post_type ) { |
|
548 | + /** |
|
549 | + * Lets users filter items using taxes. |
|
550 | + */ |
|
551 | + public static function add_item_filters( $post_type ) { |
|
552 | 552 | |
553 | - // Abort if we're not dealing with items. |
|
554 | - if ( $post_type != 'wpi_item' ) { |
|
555 | - return; |
|
556 | - } |
|
553 | + // Abort if we're not dealing with items. |
|
554 | + if ( $post_type != 'wpi_item' ) { |
|
555 | + return; |
|
556 | + } |
|
557 | 557 | |
558 | - // Filter by vat rules. |
|
559 | - if ( wpinv_use_taxes() ) { |
|
558 | + // Filter by vat rules. |
|
559 | + if ( wpinv_use_taxes() ) { |
|
560 | 560 | |
561 | - // Sanitize selected vat rule. |
|
562 | - $vat_rule = ''; |
|
563 | - $vat_rules = getpaid_get_tax_rules(); |
|
564 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
565 | - $vat_rule = $_GET['vat_rule']; |
|
566 | - } |
|
567 | - |
|
568 | - // Filter by VAT rule. |
|
569 | - echo wpinv_html_select( |
|
570 | - array( |
|
571 | - 'options' => array_merge( |
|
572 | - array( |
|
573 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
574 | - ), |
|
575 | - $vat_rules |
|
576 | - ), |
|
577 | - 'name' => 'vat_rule', |
|
578 | - 'id' => 'vat_rule', |
|
579 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
580 | - 'show_option_all' => false, |
|
581 | - 'show_option_none' => false, |
|
582 | - ) |
|
583 | - ); |
|
584 | - |
|
585 | - // Filter by VAT class. |
|
561 | + // Sanitize selected vat rule. |
|
562 | + $vat_rule = ''; |
|
563 | + $vat_rules = getpaid_get_tax_rules(); |
|
564 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
565 | + $vat_rule = $_GET['vat_rule']; |
|
566 | + } |
|
567 | + |
|
568 | + // Filter by VAT rule. |
|
569 | + echo wpinv_html_select( |
|
570 | + array( |
|
571 | + 'options' => array_merge( |
|
572 | + array( |
|
573 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
574 | + ), |
|
575 | + $vat_rules |
|
576 | + ), |
|
577 | + 'name' => 'vat_rule', |
|
578 | + 'id' => 'vat_rule', |
|
579 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
580 | + 'show_option_all' => false, |
|
581 | + 'show_option_none' => false, |
|
582 | + ) |
|
583 | + ); |
|
584 | + |
|
585 | + // Filter by VAT class. |
|
586 | 586 | |
587 | - // Sanitize selected vat rule. |
|
588 | - $vat_class = ''; |
|
589 | - $vat_classes = getpaid_get_tax_classes(); |
|
590 | - if ( isset( $_GET['vat_class'] ) ) { |
|
591 | - $vat_class = $_GET['vat_class']; |
|
592 | - } |
|
593 | - |
|
594 | - echo wpinv_html_select( |
|
595 | - array( |
|
596 | - 'options' => array_merge( |
|
597 | - array( |
|
598 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
599 | - ), |
|
600 | - $vat_classes |
|
601 | - ), |
|
602 | - 'name' => 'vat_class', |
|
603 | - 'id' => 'vat_class', |
|
604 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
605 | - 'show_option_all' => false, |
|
606 | - 'show_option_none' => false, |
|
607 | - ) |
|
608 | - ); |
|
609 | - |
|
610 | - } |
|
611 | - |
|
612 | - // Filter by item type. |
|
613 | - $type = ''; |
|
614 | - if ( isset( $_GET['type'] ) ) { |
|
615 | - $type = $_GET['type']; |
|
616 | - } |
|
617 | - |
|
618 | - echo wpinv_html_select( |
|
619 | - array( |
|
620 | - 'options' => array_merge( |
|
621 | - array( |
|
622 | - '' => __( 'All item types', 'invoicing' ) |
|
623 | - ), |
|
624 | - wpinv_get_item_types() |
|
625 | - ), |
|
626 | - 'name' => 'type', |
|
627 | - 'id' => 'type', |
|
628 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
629 | - 'show_option_all' => false, |
|
630 | - 'show_option_none' => false, |
|
631 | - ) |
|
632 | - ); |
|
633 | - |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * Filters the item query. |
|
638 | - */ |
|
639 | - public static function filter_item_query( $query ) { |
|
640 | - |
|
641 | - // modify the query only if it admin and main query. |
|
642 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
643 | - return $query; |
|
644 | - } |
|
645 | - |
|
646 | - // we want to modify the query for our items. |
|
647 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
648 | - return $query; |
|
649 | - } |
|
650 | - |
|
651 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
652 | - $query->query_vars['meta_query'] = array(); |
|
653 | - } |
|
654 | - |
|
655 | - // Filter vat rule type |
|
587 | + // Sanitize selected vat rule. |
|
588 | + $vat_class = ''; |
|
589 | + $vat_classes = getpaid_get_tax_classes(); |
|
590 | + if ( isset( $_GET['vat_class'] ) ) { |
|
591 | + $vat_class = $_GET['vat_class']; |
|
592 | + } |
|
593 | + |
|
594 | + echo wpinv_html_select( |
|
595 | + array( |
|
596 | + 'options' => array_merge( |
|
597 | + array( |
|
598 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
599 | + ), |
|
600 | + $vat_classes |
|
601 | + ), |
|
602 | + 'name' => 'vat_class', |
|
603 | + 'id' => 'vat_class', |
|
604 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
605 | + 'show_option_all' => false, |
|
606 | + 'show_option_none' => false, |
|
607 | + ) |
|
608 | + ); |
|
609 | + |
|
610 | + } |
|
611 | + |
|
612 | + // Filter by item type. |
|
613 | + $type = ''; |
|
614 | + if ( isset( $_GET['type'] ) ) { |
|
615 | + $type = $_GET['type']; |
|
616 | + } |
|
617 | + |
|
618 | + echo wpinv_html_select( |
|
619 | + array( |
|
620 | + 'options' => array_merge( |
|
621 | + array( |
|
622 | + '' => __( 'All item types', 'invoicing' ) |
|
623 | + ), |
|
624 | + wpinv_get_item_types() |
|
625 | + ), |
|
626 | + 'name' => 'type', |
|
627 | + 'id' => 'type', |
|
628 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
629 | + 'show_option_all' => false, |
|
630 | + 'show_option_none' => false, |
|
631 | + ) |
|
632 | + ); |
|
633 | + |
|
634 | + } |
|
635 | + |
|
636 | + /** |
|
637 | + * Filters the item query. |
|
638 | + */ |
|
639 | + public static function filter_item_query( $query ) { |
|
640 | + |
|
641 | + // modify the query only if it admin and main query. |
|
642 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
643 | + return $query; |
|
644 | + } |
|
645 | + |
|
646 | + // we want to modify the query for our items. |
|
647 | + if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
648 | + return $query; |
|
649 | + } |
|
650 | + |
|
651 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
652 | + $query->query_vars['meta_query'] = array(); |
|
653 | + } |
|
654 | + |
|
655 | + // Filter vat rule type |
|
656 | 656 | if ( ! empty( $_GET['vat_rule'] ) ) { |
657 | 657 | $query->query_vars['meta_query'][] = array( |
658 | 658 | 'key' => '_wpinv_vat_rule', |
@@ -677,94 +677,94 @@ discard block |
||
677 | 677 | 'value' => sanitize_text_field( $_GET['type'] ), |
678 | 678 | 'compare' => '=' |
679 | 679 | ); |
680 | - } |
|
681 | - |
|
682 | - } |
|
683 | - |
|
684 | - /** |
|
685 | - * Reorders items. |
|
686 | - */ |
|
687 | - public static function reorder_items( $vars ) { |
|
688 | - global $typenow; |
|
689 | - |
|
690 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
691 | - return $vars; |
|
692 | - } |
|
693 | - |
|
694 | - // By item type. |
|
695 | - if ( 'type' == $vars['orderby'] ) { |
|
696 | - return array_merge( |
|
697 | - $vars, |
|
698 | - array( |
|
699 | - 'meta_key' => '_wpinv_type', |
|
700 | - 'orderby' => 'meta_value' |
|
701 | - ) |
|
702 | - ); |
|
703 | - } |
|
704 | - |
|
705 | - // By vat class. |
|
706 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
707 | - return array_merge( |
|
708 | - $vars, |
|
709 | - array( |
|
710 | - 'meta_key' => '_wpinv_vat_class', |
|
711 | - 'orderby' => 'meta_value' |
|
712 | - ) |
|
713 | - ); |
|
714 | - } |
|
715 | - |
|
716 | - // By vat rule. |
|
717 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
718 | - return array_merge( |
|
719 | - $vars, |
|
720 | - array( |
|
721 | - 'meta_key' => '_wpinv_vat_rule', |
|
722 | - 'orderby' => 'meta_value' |
|
723 | - ) |
|
724 | - ); |
|
725 | - } |
|
726 | - |
|
727 | - // By price. |
|
728 | - if ( 'price' == $vars['orderby'] ) { |
|
729 | - return array_merge( |
|
730 | - $vars, |
|
731 | - array( |
|
732 | - 'meta_key' => '_wpinv_price', |
|
733 | - 'orderby' => 'meta_value_num' |
|
734 | - ) |
|
735 | - ); |
|
736 | - } |
|
737 | - |
|
738 | - return $vars; |
|
739 | - |
|
740 | - } |
|
741 | - |
|
742 | - /** |
|
743 | - * Fired when deleting a post. |
|
744 | - */ |
|
745 | - public static function delete_post( $post_id ) { |
|
746 | - |
|
747 | - switch ( get_post_type( $post_id ) ) { |
|
748 | - |
|
749 | - case 'wpi_item' : |
|
750 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
751 | - break; |
|
752 | - |
|
753 | - case 'wpi_payment_form' : |
|
754 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
755 | - break; |
|
756 | - |
|
757 | - case 'wpi_discount' : |
|
758 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
759 | - break; |
|
760 | - |
|
761 | - case 'wpi_invoice' : |
|
762 | - $invoice = new WPInv_Invoice( $post_id ); |
|
763 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
764 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
765 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
766 | - break; |
|
767 | - } |
|
768 | - } |
|
680 | + } |
|
681 | + |
|
682 | + } |
|
683 | + |
|
684 | + /** |
|
685 | + * Reorders items. |
|
686 | + */ |
|
687 | + public static function reorder_items( $vars ) { |
|
688 | + global $typenow; |
|
689 | + |
|
690 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
691 | + return $vars; |
|
692 | + } |
|
693 | + |
|
694 | + // By item type. |
|
695 | + if ( 'type' == $vars['orderby'] ) { |
|
696 | + return array_merge( |
|
697 | + $vars, |
|
698 | + array( |
|
699 | + 'meta_key' => '_wpinv_type', |
|
700 | + 'orderby' => 'meta_value' |
|
701 | + ) |
|
702 | + ); |
|
703 | + } |
|
704 | + |
|
705 | + // By vat class. |
|
706 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
707 | + return array_merge( |
|
708 | + $vars, |
|
709 | + array( |
|
710 | + 'meta_key' => '_wpinv_vat_class', |
|
711 | + 'orderby' => 'meta_value' |
|
712 | + ) |
|
713 | + ); |
|
714 | + } |
|
715 | + |
|
716 | + // By vat rule. |
|
717 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
718 | + return array_merge( |
|
719 | + $vars, |
|
720 | + array( |
|
721 | + 'meta_key' => '_wpinv_vat_rule', |
|
722 | + 'orderby' => 'meta_value' |
|
723 | + ) |
|
724 | + ); |
|
725 | + } |
|
726 | + |
|
727 | + // By price. |
|
728 | + if ( 'price' == $vars['orderby'] ) { |
|
729 | + return array_merge( |
|
730 | + $vars, |
|
731 | + array( |
|
732 | + 'meta_key' => '_wpinv_price', |
|
733 | + 'orderby' => 'meta_value_num' |
|
734 | + ) |
|
735 | + ); |
|
736 | + } |
|
737 | + |
|
738 | + return $vars; |
|
739 | + |
|
740 | + } |
|
741 | + |
|
742 | + /** |
|
743 | + * Fired when deleting a post. |
|
744 | + */ |
|
745 | + public static function delete_post( $post_id ) { |
|
746 | + |
|
747 | + switch ( get_post_type( $post_id ) ) { |
|
748 | + |
|
749 | + case 'wpi_item' : |
|
750 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
751 | + break; |
|
752 | + |
|
753 | + case 'wpi_payment_form' : |
|
754 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
755 | + break; |
|
756 | + |
|
757 | + case 'wpi_discount' : |
|
758 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
759 | + break; |
|
760 | + |
|
761 | + case 'wpi_invoice' : |
|
762 | + $invoice = new WPInv_Invoice( $post_id ); |
|
763 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
764 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
765 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
766 | + break; |
|
767 | + } |
|
768 | + } |
|
769 | 769 | |
770 | 770 | } |
@@ -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 | * Post types Admin Class |
@@ -21,70 +21,70 @@ discard block |
||
21 | 21 | GetPaid_Metaboxes::init(); |
22 | 22 | |
23 | 23 | // Filter the post updated messages. |
24 | - add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
24 | + add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages'); |
|
25 | 25 | |
26 | 26 | // Filter post actions. |
27 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
28 | - add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2); |
|
29 | 29 | |
30 | 30 | // Invoice table columns. |
31 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
32 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
31 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
32 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
33 | 33 | |
34 | 34 | // Items table columns. |
35 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
36 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
37 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
38 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
39 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
40 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
35 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
36 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
37 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
38 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
39 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
40 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
41 | 41 | |
42 | 42 | // Payment forms columns. |
43 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
44 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
45 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
43 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
44 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
45 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
46 | 46 | |
47 | 47 | // Discount table columns. |
48 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
49 | - add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 ); |
|
48 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
49 | + add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100); |
|
50 | 50 | |
51 | 51 | // Deleting posts. |
52 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
53 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
53 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Post updated messages. |
58 | 58 | */ |
59 | - public static function post_updated_messages( $messages ) { |
|
59 | + public static function post_updated_messages($messages) { |
|
60 | 60 | global $post; |
61 | 61 | |
62 | 62 | $messages['wpi_discount'] = array( |
63 | 63 | 0 => '', |
64 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
65 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
66 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
67 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
69 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
70 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
71 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
72 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
73 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
64 | + 1 => __('Discount updated.', 'invoicing'), |
|
65 | + 2 => __('Custom field updated.', 'invoicing'), |
|
66 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
67 | + 4 => __('Discount updated.', 'invoicing'), |
|
68 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
69 | + 6 => __('Discount updated.', 'invoicing'), |
|
70 | + 7 => __('Discount saved.', 'invoicing'), |
|
71 | + 8 => __('Discount submitted.', 'invoicing'), |
|
72 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
73 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
74 | 74 | ); |
75 | 75 | |
76 | 76 | $messages['wpi_payment_form'] = array( |
77 | 77 | 0 => '', |
78 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
79 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
80 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
81 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
83 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
84 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
85 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
86 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
87 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
78 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
79 | + 2 => __('Custom field updated.', 'invoicing'), |
|
80 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
81 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
83 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
84 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
85 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
86 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
87 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | 90 | return $messages; |
@@ -94,14 +94,14 @@ discard block |
||
94 | 94 | /** |
95 | 95 | * Post row actions. |
96 | 96 | */ |
97 | - public static function post_row_actions( $actions, $post ) { |
|
97 | + public static function post_row_actions($actions, $post) { |
|
98 | 98 | |
99 | - $post = get_post( $post ); |
|
99 | + $post = get_post($post); |
|
100 | 100 | |
101 | 101 | // We do not want to edit the default payment form. |
102 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
103 | - unset( $actions['trash'] ); |
|
104 | - unset( $actions['inline hide-if-no-js'] ); |
|
102 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
103 | + unset($actions['trash']); |
|
104 | + unset($actions['inline hide-if-no-js']); |
|
105 | 105 | } |
106 | 106 | |
107 | 107 | return $actions; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | * @param WP_Post $post |
116 | 116 | * @return array $actions actions without edit option |
117 | 117 | */ |
118 | - public static function filter_invoice_row_actions( $actions, $post ) { |
|
118 | + public static function filter_invoice_row_actions($actions, $post) { |
|
119 | 119 | |
120 | - if ( getpaid_is_invoice_post_type( $post->post_type ) ) { |
|
120 | + if (getpaid_is_invoice_post_type($post->post_type)) { |
|
121 | 121 | |
122 | 122 | $actions = array(); |
123 | - $invoice = new WPInv_Invoice( $post ); |
|
123 | + $invoice = new WPInv_Invoice($post); |
|
124 | 124 | |
125 | - $actions['edit'] = sprintf( |
|
125 | + $actions['edit'] = sprintf( |
|
126 | 126 | '<a href="%1$s">%2$s</a>', |
127 | - esc_url( get_edit_post_link( $invoice->get_id() ) ), |
|
128 | - esc_html( __( 'Edit', 'invoicing' ) ) |
|
127 | + esc_url(get_edit_post_link($invoice->get_id())), |
|
128 | + esc_html(__('Edit', 'invoicing')) |
|
129 | 129 | ); |
130 | 130 | |
131 | - if ( ! $invoice->is_draft() ) { |
|
131 | + if (!$invoice->is_draft()) { |
|
132 | 132 | |
133 | - $actions['view'] = sprintf( |
|
133 | + $actions['view'] = sprintf( |
|
134 | 134 | '<a href="%1$s">%2$s</a>', |
135 | - esc_url( $invoice->get_view_url() ), |
|
135 | + esc_url($invoice->get_view_url()), |
|
136 | 136 | sprintf( |
137 | - esc_html( __( 'View %s', 'invoicing' ) ), |
|
138 | - getpaid_get_post_type_label( $invoice->get_post_type(), false ) |
|
137 | + esc_html(__('View %s', 'invoicing')), |
|
138 | + getpaid_get_post_type_label($invoice->get_post_type(), false) |
|
139 | 139 | ) |
140 | 140 | ); |
141 | 141 | |
142 | - $actions['send'] = sprintf( |
|
142 | + $actions['send'] = sprintf( |
|
143 | 143 | '<a href="%1$s">%2$s</a>', |
144 | 144 | esc_url( |
145 | 145 | wp_nonce_url( |
@@ -153,7 +153,7 @@ discard block |
||
153 | 153 | 'getpaid-nonce' |
154 | 154 | ) |
155 | 155 | ), |
156 | - esc_html( __( 'Send to Customer', 'invoicing' ) ) |
|
156 | + esc_html(__('Send to Customer', 'invoicing')) |
|
157 | 157 | ); |
158 | 158 | |
159 | 159 | } |
@@ -166,42 +166,42 @@ discard block |
||
166 | 166 | /** |
167 | 167 | * Returns an array of invoice table columns. |
168 | 168 | */ |
169 | - public static function invoice_columns( $columns ) { |
|
169 | + public static function invoice_columns($columns) { |
|
170 | 170 | |
171 | 171 | $columns = array( |
172 | 172 | 'cb' => $columns['cb'], |
173 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
174 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
175 | - 'invoice_date' => __( 'Created', 'invoicing' ), |
|
176 | - 'payment_date' => __( 'Completed', 'invoicing' ), |
|
177 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
178 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
179 | - 'status' => __( 'Status', 'invoicing' ), |
|
173 | + 'number' => __('Invoice', 'invoicing'), |
|
174 | + 'customer' => __('Customer', 'invoicing'), |
|
175 | + 'invoice_date' => __('Created', 'invoicing'), |
|
176 | + 'payment_date' => __('Completed', 'invoicing'), |
|
177 | + 'amount' => __('Amount', 'invoicing'), |
|
178 | + 'recurring' => __('Recurring', 'invoicing'), |
|
179 | + 'status' => __('Status', 'invoicing'), |
|
180 | 180 | ); |
181 | 181 | |
182 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
182 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
183 | 183 | } |
184 | 184 | |
185 | 185 | /** |
186 | 186 | * Displays invoice table columns. |
187 | 187 | */ |
188 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
188 | + public static function display_invoice_columns($column_name, $post_id) { |
|
189 | 189 | |
190 | - $invoice = new WPInv_Invoice( $post_id ); |
|
190 | + $invoice = new WPInv_Invoice($post_id); |
|
191 | 191 | |
192 | - switch ( $column_name ) { |
|
192 | + switch ($column_name) { |
|
193 | 193 | |
194 | 194 | case 'invoice_date' : |
195 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
196 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
195 | + $date_time = esc_attr($invoice->get_created_date()); |
|
196 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
197 | 197 | echo "<span title='$date_time'>$date</span>"; |
198 | 198 | break; |
199 | 199 | |
200 | 200 | case 'payment_date' : |
201 | 201 | |
202 | - if ( $invoice->is_paid() ) { |
|
203 | - $date_time = esc_attr( $invoice->get_completed_date() ); |
|
204 | - $date = getpaid_format_date_value( $date_time, "—", true ); |
|
202 | + if ($invoice->is_paid()) { |
|
203 | + $date_time = esc_attr($invoice->get_completed_date()); |
|
204 | + $date = getpaid_format_date_value($date_time, "—", true); |
|
205 | 205 | echo "<span title='$date_time'>$date</span>"; |
206 | 206 | } else { |
207 | 207 | echo "—"; |
@@ -212,17 +212,17 @@ discard block |
||
212 | 212 | case 'amount' : |
213 | 213 | |
214 | 214 | $amount = $invoice->get_total(); |
215 | - $formated_amount = wpinv_price( $amount, $invoice->get_currency() ); |
|
215 | + $formated_amount = wpinv_price($amount, $invoice->get_currency()); |
|
216 | 216 | |
217 | - if ( $invoice->is_refunded() ) { |
|
218 | - $refunded_amount = wpinv_price( 0, $invoice->get_currency() ); |
|
217 | + if ($invoice->is_refunded()) { |
|
218 | + $refunded_amount = wpinv_price(0, $invoice->get_currency()); |
|
219 | 219 | echo "<del>$formated_amount</del> <ins>$refunded_amount</ins>"; |
220 | 220 | } else { |
221 | 221 | |
222 | 222 | $discount = $invoice->get_total_discount(); |
223 | 223 | |
224 | - if ( ! empty( $discount ) ) { |
|
225 | - $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() ); |
|
224 | + if (!empty($discount)) { |
|
225 | + $new_amount = wpinv_price($amount + $discount, $invoice->get_currency()); |
|
226 | 226 | echo "<del>$new_amount</del> <ins>$formated_amount</ins>"; |
227 | 227 | } else { |
228 | 228 | echo $formated_amount; |
@@ -233,13 +233,13 @@ discard block |
||
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'status' : |
236 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
237 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
236 | + $status = sanitize_text_field($invoice->get_status()); |
|
237 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
238 | 238 | |
239 | 239 | // If it is paid, show the gateway title. |
240 | - if ( $invoice->is_paid() ) { |
|
241 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
242 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
240 | + if ($invoice->is_paid()) { |
|
241 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
242 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
243 | 243 | |
244 | 244 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
245 | 245 | } else { |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | } |
248 | 248 | |
249 | 249 | // If it is not paid, display the overdue and view status. |
250 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
250 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
251 | 251 | |
252 | 252 | // Invoice view status. |
253 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
254 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
253 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
254 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
255 | 255 | } else { |
256 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
256 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
257 | 257 | } |
258 | 258 | |
259 | 259 | // Display the overview status. |
260 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
260 | + if (wpinv_get_option('overdue_active')) { |
|
261 | 261 | $due_date = $invoice->get_due_date(); |
262 | - $fomatted = getpaid_format_date( $due_date ); |
|
262 | + $fomatted = getpaid_format_date($due_date); |
|
263 | 263 | |
264 | - if ( ! empty( $fomatted ) ) { |
|
265 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
264 | + if (!empty($fomatted)) { |
|
265 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
266 | 266 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
267 | 267 | } |
268 | 268 | } |
@@ -273,7 +273,7 @@ discard block |
||
273 | 273 | |
274 | 274 | case 'recurring': |
275 | 275 | |
276 | - if ( $invoice->is_recurring() ) { |
|
276 | + if ($invoice->is_recurring()) { |
|
277 | 277 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
278 | 278 | } else { |
279 | 279 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -282,9 +282,9 @@ discard block |
||
282 | 282 | |
283 | 283 | case 'number' : |
284 | 284 | |
285 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
286 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
287 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
285 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
286 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
287 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
288 | 288 | |
289 | 289 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
290 | 290 | |
@@ -294,13 +294,13 @@ discard block |
||
294 | 294 | |
295 | 295 | $customer_name = $invoice->get_user_full_name(); |
296 | 296 | |
297 | - if ( empty( $customer_name ) ) { |
|
297 | + if (empty($customer_name)) { |
|
298 | 298 | $customer_name = $invoice->get_email(); |
299 | 299 | } |
300 | 300 | |
301 | - if ( ! empty( $customer_name ) ) { |
|
302 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
303 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
301 | + if (!empty($customer_name)) { |
|
302 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
303 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
304 | 304 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
305 | 305 | } else { |
306 | 306 | echo '<div>—</div>'; |
@@ -315,50 +315,50 @@ discard block |
||
315 | 315 | /** |
316 | 316 | * Returns an array of payment forms table columns. |
317 | 317 | */ |
318 | - public static function payment_form_columns( $columns ) { |
|
318 | + public static function payment_form_columns($columns) { |
|
319 | 319 | |
320 | 320 | $columns = array( |
321 | 321 | 'cb' => $columns['cb'], |
322 | - 'title' => __( 'Name', 'invoicing' ), |
|
323 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
324 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
325 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
326 | - 'items' => __( 'Items', 'invoicing' ), |
|
327 | - 'date' => __( 'Date', 'invoicing' ), |
|
322 | + 'title' => __('Name', 'invoicing'), |
|
323 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
324 | + 'earnings' => __('Revenue', 'invoicing'), |
|
325 | + 'refunds' => __('Refunded', 'invoicing'), |
|
326 | + 'items' => __('Items', 'invoicing'), |
|
327 | + 'date' => __('Date', 'invoicing'), |
|
328 | 328 | ); |
329 | 329 | |
330 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
330 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
331 | 331 | |
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
335 | 335 | * Displays payment form table columns. |
336 | 336 | */ |
337 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
337 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
338 | 338 | |
339 | 339 | // Retrieve the payment form. |
340 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
340 | + $form = new GetPaid_Payment_Form($post_id); |
|
341 | 341 | |
342 | - switch ( $column_name ) { |
|
342 | + switch ($column_name) { |
|
343 | 343 | |
344 | 344 | case 'earnings' : |
345 | - echo wpinv_price( $form->get_earned() ); |
|
345 | + echo wpinv_price($form->get_earned()); |
|
346 | 346 | break; |
347 | 347 | |
348 | 348 | case 'refunds' : |
349 | - echo wpinv_price( $form->get_refunded() ); |
|
349 | + echo wpinv_price($form->get_refunded()); |
|
350 | 350 | break; |
351 | 351 | |
352 | 352 | case 'refunds' : |
353 | - echo wpinv_price( $form->get_refunded() ); |
|
353 | + echo wpinv_price($form->get_refunded()); |
|
354 | 354 | break; |
355 | 355 | |
356 | 356 | case 'shortcode' : |
357 | 357 | |
358 | - if ( $form->is_default() ) { |
|
358 | + if ($form->is_default()) { |
|
359 | 359 | echo '—'; |
360 | 360 | } else { |
361 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
361 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | break; |
@@ -367,29 +367,29 @@ discard block |
||
367 | 367 | |
368 | 368 | $items = $form->get_items(); |
369 | 369 | |
370 | - if ( $form->is_default() || empty( $items ) ) { |
|
370 | + if ($form->is_default() || empty($items)) { |
|
371 | 371 | echo '—'; |
372 | 372 | return; |
373 | 373 | } |
374 | 374 | |
375 | 375 | $_items = array(); |
376 | 376 | |
377 | - foreach ( $items as $item ) { |
|
377 | + foreach ($items as $item) { |
|
378 | 378 | $url = $item->get_edit_url(); |
379 | 379 | |
380 | - if ( empty( $url ) ) { |
|
381 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
380 | + if (empty($url)) { |
|
381 | + $_items[] = sanitize_text_field($item->get_name()); |
|
382 | 382 | } else { |
383 | 383 | $_items[] = sprintf( |
384 | 384 | '<a href="%s">%s</a>', |
385 | - esc_url( $url ), |
|
386 | - sanitize_text_field( $item->get_name() ) |
|
385 | + esc_url($url), |
|
386 | + sanitize_text_field($item->get_name()) |
|
387 | 387 | ); |
388 | 388 | } |
389 | 389 | |
390 | 390 | } |
391 | 391 | |
392 | - echo implode( '<br>', $_items ); |
|
392 | + echo implode('<br>', $_items); |
|
393 | 393 | |
394 | 394 | break; |
395 | 395 | |
@@ -400,10 +400,10 @@ discard block |
||
400 | 400 | /** |
401 | 401 | * Filters post states. |
402 | 402 | */ |
403 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
403 | + public static function filter_payment_form_state($post_states, $post) { |
|
404 | 404 | |
405 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
406 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
405 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
406 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | return $post_states; |
@@ -413,35 +413,35 @@ discard block |
||
413 | 413 | /** |
414 | 414 | * Returns an array of coupon table columns. |
415 | 415 | */ |
416 | - public static function discount_columns( $columns ) { |
|
416 | + public static function discount_columns($columns) { |
|
417 | 417 | |
418 | 418 | $columns = array( |
419 | 419 | 'cb' => $columns['cb'], |
420 | - 'title' => __( 'Name', 'invoicing' ), |
|
421 | - 'code' => __( 'Code', 'invoicing' ), |
|
422 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
423 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
424 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
425 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
420 | + 'title' => __('Name', 'invoicing'), |
|
421 | + 'code' => __('Code', 'invoicing'), |
|
422 | + 'amount' => __('Amount', 'invoicing'), |
|
423 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
424 | + 'start_date' => __('Start Date', 'invoicing'), |
|
425 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
426 | 426 | ); |
427 | 427 | |
428 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
428 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
432 | 432 | * Filters post states. |
433 | 433 | */ |
434 | - public static function filter_discount_state( $post_states, $post ) { |
|
434 | + public static function filter_discount_state($post_states, $post) { |
|
435 | 435 | |
436 | - if ( 'wpi_discount' == $post->post_type ) { |
|
436 | + if ('wpi_discount' == $post->post_type) { |
|
437 | 437 | |
438 | - $discount = new WPInv_Discount( $post ); |
|
438 | + $discount = new WPInv_Discount($post); |
|
439 | 439 | |
440 | 440 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
441 | 441 | |
442 | - if ( $status != 'publish' ) { |
|
442 | + if ($status != 'publish') { |
|
443 | 443 | return array( |
444 | - 'discount_status' => wpinv_discount_status( $status ), |
|
444 | + 'discount_status' => wpinv_discount_status($status), |
|
445 | 445 | ); |
446 | 446 | } |
447 | 447 | |
@@ -456,30 +456,30 @@ discard block |
||
456 | 456 | /** |
457 | 457 | * Returns an array of items table columns. |
458 | 458 | */ |
459 | - public static function item_columns( $columns ) { |
|
459 | + public static function item_columns($columns) { |
|
460 | 460 | |
461 | 461 | $columns = array( |
462 | 462 | 'cb' => $columns['cb'], |
463 | - 'title' => __( 'Name', 'invoicing' ), |
|
464 | - 'price' => __( 'Price', 'invoicing' ), |
|
465 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
466 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
467 | - 'type' => __( 'Type', 'invoicing' ), |
|
468 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
463 | + 'title' => __('Name', 'invoicing'), |
|
464 | + 'price' => __('Price', 'invoicing'), |
|
465 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
466 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
467 | + 'type' => __('Type', 'invoicing'), |
|
468 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
469 | 469 | ); |
470 | 470 | |
471 | - if ( ! wpinv_use_taxes() ) { |
|
472 | - unset( $columns['vat_rule'] ); |
|
473 | - unset( $columns['vat_class'] ); |
|
471 | + if (!wpinv_use_taxes()) { |
|
472 | + unset($columns['vat_rule']); |
|
473 | + unset($columns['vat_class']); |
|
474 | 474 | } |
475 | 475 | |
476 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
476 | + return apply_filters('wpi_item_table_columns', $columns); |
|
477 | 477 | } |
478 | 478 | |
479 | 479 | /** |
480 | 480 | * Returns an array of sortable items table columns. |
481 | 481 | */ |
482 | - public static function sortable_item_columns( $columns ) { |
|
482 | + public static function sortable_item_columns($columns) { |
|
483 | 483 | |
484 | 484 | return array_merge( |
485 | 485 | $columns, |
@@ -496,49 +496,49 @@ discard block |
||
496 | 496 | /** |
497 | 497 | * Displays items table columns. |
498 | 498 | */ |
499 | - public static function display_item_columns( $column_name, $post_id ) { |
|
499 | + public static function display_item_columns($column_name, $post_id) { |
|
500 | 500 | |
501 | - $item = new WPInv_Item( $post_id ); |
|
501 | + $item = new WPInv_Item($post_id); |
|
502 | 502 | |
503 | - switch ( $column_name ) { |
|
503 | + switch ($column_name) { |
|
504 | 504 | |
505 | 505 | case 'price' : |
506 | 506 | |
507 | - if ( ! $item->is_recurring() ) { |
|
507 | + if (!$item->is_recurring()) { |
|
508 | 508 | echo $item->get_the_price(); |
509 | 509 | break; |
510 | 510 | } |
511 | 511 | |
512 | 512 | $price = wp_sprintf( |
513 | - __( '%s / %s', 'invoicing' ), |
|
513 | + __('%s / %s', 'invoicing'), |
|
514 | 514 | $item->get_the_price(), |
515 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
515 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
516 | 516 | ); |
517 | 517 | |
518 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
518 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
519 | 519 | echo $price; |
520 | 520 | break; |
521 | 521 | } |
522 | 522 | |
523 | 523 | echo $item->get_the_initial_price(); |
524 | 524 | |
525 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
525 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
526 | 526 | break; |
527 | 527 | |
528 | 528 | case 'vat_rule' : |
529 | - echo getpaid_get_tax_rule_label( $item->get_vat_rule() ); |
|
529 | + echo getpaid_get_tax_rule_label($item->get_vat_rule()); |
|
530 | 530 | break; |
531 | 531 | |
532 | 532 | case 'vat_class' : |
533 | - echo getpaid_get_tax_class_label( $item->get_vat_class() ); |
|
533 | + echo getpaid_get_tax_class_label($item->get_vat_class()); |
|
534 | 534 | break; |
535 | 535 | |
536 | 536 | case 'shortcode' : |
537 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
537 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
538 | 538 | break; |
539 | 539 | |
540 | 540 | case 'type' : |
541 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
541 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
542 | 542 | break; |
543 | 543 | |
544 | 544 | } |
@@ -548,21 +548,21 @@ discard block |
||
548 | 548 | /** |
549 | 549 | * Lets users filter items using taxes. |
550 | 550 | */ |
551 | - public static function add_item_filters( $post_type ) { |
|
551 | + public static function add_item_filters($post_type) { |
|
552 | 552 | |
553 | 553 | // Abort if we're not dealing with items. |
554 | - if ( $post_type != 'wpi_item' ) { |
|
554 | + if ($post_type != 'wpi_item') { |
|
555 | 555 | return; |
556 | 556 | } |
557 | 557 | |
558 | 558 | // Filter by vat rules. |
559 | - if ( wpinv_use_taxes() ) { |
|
559 | + if (wpinv_use_taxes()) { |
|
560 | 560 | |
561 | 561 | // Sanitize selected vat rule. |
562 | 562 | $vat_rule = ''; |
563 | 563 | $vat_rules = getpaid_get_tax_rules(); |
564 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
565 | - $vat_rule = $_GET['vat_rule']; |
|
564 | + if (isset($_GET['vat_rule'])) { |
|
565 | + $vat_rule = $_GET['vat_rule']; |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | // Filter by VAT rule. |
@@ -570,13 +570,13 @@ discard block |
||
570 | 570 | array( |
571 | 571 | 'options' => array_merge( |
572 | 572 | array( |
573 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
573 | + '' => __('All VAT rules', 'invoicing') |
|
574 | 574 | ), |
575 | 575 | $vat_rules |
576 | 576 | ), |
577 | 577 | 'name' => 'vat_rule', |
578 | 578 | 'id' => 'vat_rule', |
579 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
579 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
580 | 580 | 'show_option_all' => false, |
581 | 581 | 'show_option_none' => false, |
582 | 582 | ) |
@@ -587,21 +587,21 @@ discard block |
||
587 | 587 | // Sanitize selected vat rule. |
588 | 588 | $vat_class = ''; |
589 | 589 | $vat_classes = getpaid_get_tax_classes(); |
590 | - if ( isset( $_GET['vat_class'] ) ) { |
|
591 | - $vat_class = $_GET['vat_class']; |
|
590 | + if (isset($_GET['vat_class'])) { |
|
591 | + $vat_class = $_GET['vat_class']; |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | echo wpinv_html_select( |
595 | 595 | array( |
596 | 596 | 'options' => array_merge( |
597 | 597 | array( |
598 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
598 | + '' => __('All VAT classes', 'invoicing') |
|
599 | 599 | ), |
600 | 600 | $vat_classes |
601 | 601 | ), |
602 | 602 | 'name' => 'vat_class', |
603 | 603 | 'id' => 'vat_class', |
604 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
604 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
605 | 605 | 'show_option_all' => false, |
606 | 606 | 'show_option_none' => false, |
607 | 607 | ) |
@@ -610,22 +610,22 @@ discard block |
||
610 | 610 | } |
611 | 611 | |
612 | 612 | // Filter by item type. |
613 | - $type = ''; |
|
614 | - if ( isset( $_GET['type'] ) ) { |
|
615 | - $type = $_GET['type']; |
|
613 | + $type = ''; |
|
614 | + if (isset($_GET['type'])) { |
|
615 | + $type = $_GET['type']; |
|
616 | 616 | } |
617 | 617 | |
618 | 618 | echo wpinv_html_select( |
619 | 619 | array( |
620 | 620 | 'options' => array_merge( |
621 | 621 | array( |
622 | - '' => __( 'All item types', 'invoicing' ) |
|
622 | + '' => __('All item types', 'invoicing') |
|
623 | 623 | ), |
624 | 624 | wpinv_get_item_types() |
625 | 625 | ), |
626 | 626 | 'name' => 'type', |
627 | 627 | 'id' => 'type', |
628 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
628 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
629 | 629 | 'show_option_all' => false, |
630 | 630 | 'show_option_none' => false, |
631 | 631 | ) |
@@ -636,45 +636,45 @@ discard block |
||
636 | 636 | /** |
637 | 637 | * Filters the item query. |
638 | 638 | */ |
639 | - public static function filter_item_query( $query ) { |
|
639 | + public static function filter_item_query($query) { |
|
640 | 640 | |
641 | 641 | // modify the query only if it admin and main query. |
642 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
642 | + if (!(is_admin() && $query->is_main_query())) { |
|
643 | 643 | return $query; |
644 | 644 | } |
645 | 645 | |
646 | 646 | // we want to modify the query for our items. |
647 | - if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){ |
|
647 | + if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) { |
|
648 | 648 | return $query; |
649 | 649 | } |
650 | 650 | |
651 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
651 | + if (empty($query->query_vars['meta_query'])) { |
|
652 | 652 | $query->query_vars['meta_query'] = array(); |
653 | 653 | } |
654 | 654 | |
655 | 655 | // Filter vat rule type |
656 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
656 | + if (!empty($_GET['vat_rule'])) { |
|
657 | 657 | $query->query_vars['meta_query'][] = array( |
658 | 658 | 'key' => '_wpinv_vat_rule', |
659 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
659 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
660 | 660 | 'compare' => '=' |
661 | 661 | ); |
662 | 662 | } |
663 | 663 | |
664 | 664 | // Filter vat class |
665 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
665 | + if (!empty($_GET['vat_class'])) { |
|
666 | 666 | $query->query_vars['meta_query'][] = array( |
667 | 667 | 'key' => '_wpinv_vat_class', |
668 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
668 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
669 | 669 | 'compare' => '=' |
670 | 670 | ); |
671 | 671 | } |
672 | 672 | |
673 | 673 | // Filter item type |
674 | - if ( ! empty( $_GET['type'] ) ) { |
|
674 | + if (!empty($_GET['type'])) { |
|
675 | 675 | $query->query_vars['meta_query'][] = array( |
676 | 676 | 'key' => '_wpinv_type', |
677 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
677 | + 'value' => sanitize_text_field($_GET['type']), |
|
678 | 678 | 'compare' => '=' |
679 | 679 | ); |
680 | 680 | } |
@@ -684,15 +684,15 @@ discard block |
||
684 | 684 | /** |
685 | 685 | * Reorders items. |
686 | 686 | */ |
687 | - public static function reorder_items( $vars ) { |
|
687 | + public static function reorder_items($vars) { |
|
688 | 688 | global $typenow; |
689 | 689 | |
690 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
690 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
691 | 691 | return $vars; |
692 | 692 | } |
693 | 693 | |
694 | 694 | // By item type. |
695 | - if ( 'type' == $vars['orderby'] ) { |
|
695 | + if ('type' == $vars['orderby']) { |
|
696 | 696 | return array_merge( |
697 | 697 | $vars, |
698 | 698 | array( |
@@ -703,7 +703,7 @@ discard block |
||
703 | 703 | } |
704 | 704 | |
705 | 705 | // By vat class. |
706 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
706 | + if ('vat_class' == $vars['orderby']) { |
|
707 | 707 | return array_merge( |
708 | 708 | $vars, |
709 | 709 | array( |
@@ -714,7 +714,7 @@ discard block |
||
714 | 714 | } |
715 | 715 | |
716 | 716 | // By vat rule. |
717 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
717 | + if ('vat_rule' == $vars['orderby']) { |
|
718 | 718 | return array_merge( |
719 | 719 | $vars, |
720 | 720 | array( |
@@ -725,7 +725,7 @@ discard block |
||
725 | 725 | } |
726 | 726 | |
727 | 727 | // By price. |
728 | - if ( 'price' == $vars['orderby'] ) { |
|
728 | + if ('price' == $vars['orderby']) { |
|
729 | 729 | return array_merge( |
730 | 730 | $vars, |
731 | 731 | array( |
@@ -742,27 +742,27 @@ discard block |
||
742 | 742 | /** |
743 | 743 | * Fired when deleting a post. |
744 | 744 | */ |
745 | - public static function delete_post( $post_id ) { |
|
745 | + public static function delete_post($post_id) { |
|
746 | 746 | |
747 | - switch ( get_post_type( $post_id ) ) { |
|
747 | + switch (get_post_type($post_id)) { |
|
748 | 748 | |
749 | 749 | case 'wpi_item' : |
750 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
750 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
751 | 751 | break; |
752 | 752 | |
753 | 753 | case 'wpi_payment_form' : |
754 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
754 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
755 | 755 | break; |
756 | 756 | |
757 | 757 | case 'wpi_discount' : |
758 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
758 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
759 | 759 | break; |
760 | 760 | |
761 | 761 | case 'wpi_invoice' : |
762 | - $invoice = new WPInv_Invoice( $post_id ); |
|
763 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
764 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
765 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
762 | + $invoice = new WPInv_Invoice($post_id); |
|
763 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
764 | + $invoice->get_data_store()->delete_items($invoice); |
|
765 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
766 | 766 | break; |
767 | 767 | } |
768 | 768 | } |
@@ -4,26 +4,26 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | ?> |
10 | 10 | <div class="table-responsive"> |
11 | 11 | <table id="wpinv_gateways_select" class="table border bg-white form-table"> |
12 | - <caption><?php echo esc_html_e( 'This table displays installed payment methods.', 'invoicing' ); ?></caption> |
|
12 | + <caption><?php echo esc_html_e('This table displays installed payment methods.', 'invoicing'); ?></caption> |
|
13 | 13 | |
14 | 14 | <thead> |
15 | 15 | <tr class="table-light"> |
16 | 16 | |
17 | 17 | <th scope="col" class="border-bottom border-top text-left"> |
18 | - <?php _e( 'Payment Method', 'invoicing' ); ?> |
|
18 | + <?php _e('Payment Method', 'invoicing'); ?> |
|
19 | 19 | </th> |
20 | 20 | |
21 | 21 | <th scope="col" class="border-bottom border-top text-center"> |
22 | - <?php _e( 'Enabled', 'invoicing' ); ?> |
|
22 | + <?php _e('Enabled', 'invoicing'); ?> |
|
23 | 23 | </th> |
24 | 24 | |
25 | 25 | <th scope="col" class="border-bottom border-top text-center"> |
26 | - <?php _e( 'Supports Subscriptions', 'invoicing' ); ?> |
|
26 | + <?php _e('Supports Subscriptions', 'invoicing'); ?> |
|
27 | 27 | </th> |
28 | 28 | |
29 | 29 | <th scope="col" class="border-bottom border-top text-right" style="width:32px"> </th> |
@@ -32,15 +32,15 @@ discard block |
||
32 | 32 | </thead> |
33 | 33 | |
34 | 34 | <tbody> |
35 | - <?php foreach ( wpinv_get_payment_gateways() as $id => $gateway ) : ?> |
|
35 | + <?php foreach (wpinv_get_payment_gateways() as $id => $gateway) : ?> |
|
36 | 36 | <tr> |
37 | 37 | <td class="getpaid-payment-method text-left"> |
38 | - <a style="color: #0073aa;" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>" class="font-weight-bold"><?php echo sanitize_text_field( $gateway['admin_label'] ); ?></a> |
|
38 | + <a style="color: #0073aa;" href="<?php echo esc_url(add_query_arg('section', $id)); ?>" class="font-weight-bold"><?php echo sanitize_text_field($gateway['admin_label']); ?></a> |
|
39 | 39 | </td> |
40 | 40 | <td class="getpaid-payment-method-enabled text-center"> |
41 | 41 | <?php |
42 | 42 | |
43 | - $id = esc_attr( $id ); |
|
43 | + $id = esc_attr($id); |
|
44 | 44 | echo aui()->input( |
45 | 45 | array( |
46 | 46 | 'type' => 'checkbox', |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | 'value' => 1, |
50 | 50 | 'switch' => true, |
51 | 51 | 'label' => ' ', |
52 | - 'checked' => wpinv_is_gateway_active( $id ), |
|
52 | + 'checked' => wpinv_is_gateway_active($id), |
|
53 | 53 | 'no_wrap' => true, |
54 | 54 | ) |
55 | 55 | ); |
@@ -59,10 +59,10 @@ discard block |
||
59 | 59 | <td class="getpaid-payment-method-subscription text-center"> |
60 | 60 | <?php |
61 | 61 | |
62 | - $supports = apply_filters( "wpinv_{$id}_support_subscription", false ); |
|
63 | - $supports = apply_filters( 'getapid_gateway_supports_subscription', $supports, $id ); |
|
62 | + $supports = apply_filters("wpinv_{$id}_support_subscription", false); |
|
63 | + $supports = apply_filters('getapid_gateway_supports_subscription', $supports, $id); |
|
64 | 64 | |
65 | - if ( $supports ) { |
|
65 | + if ($supports) { |
|
66 | 66 | echo "<i class='text-success fa fa-check'></i>"; |
67 | 67 | } else { |
68 | 68 | echo "<i class='text-dark fa fa-times'></i>"; |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | </td> |
73 | 73 | |
74 | 74 | <td class="getpaid-payment-method-action text-right"> |
75 | - <a class="button button-secondary" href="<?php echo esc_url( add_query_arg( 'section', $id ) ); ?>"><?php _e( 'Manage', 'invoicing' ); ?></a> |
|
75 | + <a class="button button-secondary" href="<?php echo esc_url(add_query_arg('section', $id)); ?>"><?php _e('Manage', 'invoicing'); ?></a> |
|
76 | 76 | </td> |
77 | 77 | |
78 | 78 | </tr> |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | <tr class="table-light"> |
84 | 84 | <td colspan="4" class="border-top"> |
85 | 85 | <a class="button button-secondary getpaid-install-gateways" href="https://wpgetpaid.com/downloads/category/gateways/"> |
86 | - <span><?php _e( 'Add Payment Methods', 'invoicing' ); ?></span> |
|
86 | + <span><?php _e('Add Payment Methods', 'invoicing'); ?></span> |
|
87 | 87 | </a> |
88 | 88 | </td> |
89 | 89 | </tr> |
@@ -34,11 +34,11 @@ discard block |
||
34 | 34 | */ |
35 | 35 | function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
38 | - return 'manage_options'; |
|
39 | - }; |
|
37 | + if ( current_user_can( 'manage_options' ) ) { |
|
38 | + return 'manage_options'; |
|
39 | + }; |
|
40 | 40 | |
41 | - return $capalibilty; |
|
41 | + return $capalibilty; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -62,10 +62,10 @@ discard block |
||
62 | 62 | // Prepare user values. |
63 | 63 | $prefix = preg_replace( '/\s+/', '', $prefix ); |
64 | 64 | $prefix = empty( $prefix ) ? $email : $prefix; |
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | - 'user_pass' => wp_generate_password(), |
|
68 | - 'user_email' => $email, |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name( $prefix ), |
|
67 | + 'user_pass' => wp_generate_password(), |
|
68 | + 'user_email' => $email, |
|
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
@@ -82,16 +82,16 @@ discard block |
||
82 | 82 | function wpinv_generate_user_name( $prefix = '' ) { |
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
85 | + $prefix = strtok( $prefix, '@' ); |
|
86 | 86 | $prefix = trim( $prefix, '.' ); |
87 | 87 | |
88 | - // Sanitize the username. |
|
89 | - $prefix = sanitize_user( $prefix, true ); |
|
88 | + // Sanitize the username. |
|
89 | + $prefix = sanitize_user( $prefix, true ); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | - } |
|
91 | + $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | + if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | + $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package GetPaid |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Generates a users select dropdown. |
@@ -16,13 +16,13 @@ discard block |
||
16 | 16 | * @param array $args |
17 | 17 | * @see wp_dropdown_users |
18 | 18 | */ |
19 | -function wpinv_dropdown_users( $args = '' ) { |
|
19 | +function wpinv_dropdown_users($args = '') { |
|
20 | 20 | |
21 | - if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) { |
|
21 | + if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) { |
|
22 | 22 | $args['show'] = 'display_name_with_login'; |
23 | 23 | } |
24 | 24 | |
25 | - return wp_dropdown_users( $args ); |
|
25 | + return wp_dropdown_users($args); |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | /** |
@@ -32,9 +32,9 @@ discard block |
||
32 | 32 | * @return string capability to check against |
33 | 33 | * @param string $capalibilty Optional. The alternative capability to check against. |
34 | 34 | */ |
35 | -function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) { |
|
35 | +function wpinv_get_capability($capalibilty = 'manage_invoicing') { |
|
36 | 36 | |
37 | - if ( current_user_can( 'manage_options' ) ) { |
|
37 | + if (current_user_can('manage_options')) { |
|
38 | 38 | return 'manage_options'; |
39 | 39 | }; |
40 | 40 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @return bool |
49 | 49 | */ |
50 | 50 | function wpinv_current_user_can_manage_invoicing() { |
51 | - return current_user_can( wpinv_get_capability() ); |
|
51 | + return current_user_can(wpinv_get_capability()); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
@@ -57,19 +57,19 @@ discard block |
||
57 | 57 | * @since 1.0.19 |
58 | 58 | * @return int|WP_Error |
59 | 59 | */ |
60 | -function wpinv_create_user( $email, $prefix = '' ) { |
|
60 | +function wpinv_create_user($email, $prefix = '') { |
|
61 | 61 | |
62 | 62 | // Prepare user values. |
63 | - $prefix = preg_replace( '/\s+/', '', $prefix ); |
|
64 | - $prefix = empty( $prefix ) ? $email : $prefix; |
|
65 | - $args = array( |
|
66 | - 'user_login' => wpinv_generate_user_name( $prefix ), |
|
63 | + $prefix = preg_replace('/\s+/', '', $prefix); |
|
64 | + $prefix = empty($prefix) ? $email : $prefix; |
|
65 | + $args = array( |
|
66 | + 'user_login' => wpinv_generate_user_name($prefix), |
|
67 | 67 | 'user_pass' => wp_generate_password(), |
68 | 68 | 'user_email' => $email, |
69 | 69 | 'role' => 'subscriber', |
70 | 70 | ); |
71 | 71 | |
72 | - return wp_insert_user( $args ); |
|
72 | + return wp_insert_user($args); |
|
73 | 73 | |
74 | 74 | } |
75 | 75 | |
@@ -79,26 +79,26 @@ discard block |
||
79 | 79 | * @since 1.0.19 |
80 | 80 | * @return bool|WP_User |
81 | 81 | */ |
82 | -function wpinv_generate_user_name( $prefix = '' ) { |
|
82 | +function wpinv_generate_user_name($prefix = '') { |
|
83 | 83 | |
84 | 84 | // If prefix is an email, retrieve the part before the email. |
85 | - $prefix = strtok( $prefix, '@' ); |
|
86 | - $prefix = trim( $prefix, '.' ); |
|
85 | + $prefix = strtok($prefix, '@'); |
|
86 | + $prefix = trim($prefix, '.'); |
|
87 | 87 | |
88 | 88 | // Sanitize the username. |
89 | - $prefix = sanitize_user( $prefix, true ); |
|
89 | + $prefix = sanitize_user($prefix, true); |
|
90 | 90 | |
91 | - $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() ); |
|
92 | - if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) { |
|
93 | - $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 ); |
|
91 | + $illegal_logins = (array) apply_filters('illegal_user_logins', array()); |
|
92 | + if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) { |
|
93 | + $prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4); |
|
94 | 94 | } |
95 | 95 | |
96 | 96 | $username = $prefix; |
97 | 97 | $postfix = 2; |
98 | 98 | |
99 | - while ( username_exists( $username ) ) { |
|
99 | + while (username_exists($username)) { |
|
100 | 100 | $username = $prefix + $postfix; |
101 | - $postfix ++; |
|
101 | + $postfix++; |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | return $username; |
@@ -115,31 +115,31 @@ discard block |
||
115 | 115 | $tabs = array( |
116 | 116 | |
117 | 117 | 'gp-invoices' => array( |
118 | - 'label' => __( 'Invoices', 'invoicing' ), // Name of the tab. |
|
118 | + 'label' => __('Invoices', 'invoicing'), // Name of the tab. |
|
119 | 119 | 'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead. |
120 | 120 | 'icon' => 'fas fa-file-invoice', // Shown on some profile plugins. |
121 | 121 | ), |
122 | 122 | |
123 | 123 | 'gp-subscriptions' => array( |
124 | - 'label' => __( 'Subscriptions', 'invoicing' ), |
|
124 | + 'label' => __('Subscriptions', 'invoicing'), |
|
125 | 125 | 'content' => '[wpinv_subscriptions]', |
126 | 126 | 'icon' => 'fas fa-redo', |
127 | 127 | ), |
128 | 128 | |
129 | 129 | 'gp-edit-address' => array( |
130 | - 'label' => __( 'Billing Address', 'invoicing' ), |
|
130 | + 'label' => __('Billing Address', 'invoicing'), |
|
131 | 131 | 'callback' => 'getpaid_display_address_edit_tab', |
132 | 132 | 'icon' => 'fas fa-credit-card', |
133 | 133 | ), |
134 | 134 | |
135 | 135 | ); |
136 | 136 | |
137 | - $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs ); |
|
137 | + $tabs = apply_filters('getpaid_user_content_tabs', $tabs); |
|
138 | 138 | |
139 | 139 | // Make sure address editing is last on the list. |
140 | - if ( isset( $tabs['gp-edit-address'] ) ) { |
|
140 | + if (isset($tabs['gp-edit-address'])) { |
|
141 | 141 | $address = $tabs['gp-edit-address']; |
142 | - unset( $tabs['gp-edit-address'] ); |
|
142 | + unset($tabs['gp-edit-address']); |
|
143 | 143 | $tabs['gp-edit-address'] = $address; |
144 | 144 | } |
145 | 145 | |
@@ -153,19 +153,19 @@ discard block |
||
153 | 153 | * @param array $tab |
154 | 154 | * @return array |
155 | 155 | */ |
156 | -function getpaid_prepare_user_content_tab( $tab ) { |
|
156 | +function getpaid_prepare_user_content_tab($tab) { |
|
157 | 157 | |
158 | - if ( ! empty( $tab['callback'] ) ) { |
|
159 | - return call_user_func( $tab['callback'] ); |
|
158 | + if (!empty($tab['callback'])) { |
|
159 | + return call_user_func($tab['callback']); |
|
160 | 160 | } |
161 | 161 | |
162 | - if ( ! empty( $tab['content'] ) ) { |
|
163 | - return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) ); |
|
162 | + if (!empty($tab['content'])) { |
|
163 | + return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content'])))))))); |
|
164 | 164 | } |
165 | 165 | |
166 | 166 | $notice = aui()->alert( |
167 | 167 | array( |
168 | - 'content' => __( 'This tab has no content or content callback.', 'invoicing' ), |
|
168 | + 'content' => __('This tab has no content or content callback.', 'invoicing'), |
|
169 | 169 | 'type' => 'error', |
170 | 170 | ) |
171 | 171 | ); |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param string $default |
182 | 182 | * @return array |
183 | 183 | */ |
184 | -function getpaid_get_tab_url( $tab, $default ) { |
|
184 | +function getpaid_get_tab_url($tab, $default) { |
|
185 | 185 | global $getpaid_tab_url; |
186 | 186 | |
187 | - if ( empty( $getpaid_tab_url ) ) { |
|
187 | + if (empty($getpaid_tab_url)) { |
|
188 | 188 | return $default; |
189 | 189 | } |
190 | 190 | |
191 | - return sprintf( $getpaid_tab_url, $tab ); |
|
191 | + return sprintf($getpaid_tab_url, $tab); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -208,19 +208,19 @@ discard block |
||
208 | 208 | |
209 | 209 | <?php |
210 | 210 | |
211 | - foreach ( getpaid_user_address_fields() as $key => $label ) { |
|
211 | + foreach (getpaid_user_address_fields() as $key => $label) { |
|
212 | 212 | |
213 | 213 | // Display the country. |
214 | - if ( 'country' == $key ) { |
|
214 | + if ('country' == $key) { |
|
215 | 215 | |
216 | 216 | echo aui()->select( |
217 | 217 | array( |
218 | 218 | 'options' => wpinv_get_country_list(), |
219 | - 'name' => esc_attr( $key ), |
|
220 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
221 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
219 | + 'name' => esc_attr($key), |
|
220 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
221 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
222 | 222 | 'placeholder' => $label, |
223 | - 'label' => wp_kses_post( $label ), |
|
223 | + 'label' => wp_kses_post($label), |
|
224 | 224 | 'label_type' => 'vertical', |
225 | 225 | 'class' => 'getpaid-address-field', |
226 | 226 | ) |
@@ -229,11 +229,11 @@ discard block |
||
229 | 229 | } |
230 | 230 | |
231 | 231 | // Display the state. |
232 | - else if ( 'state' == $key ) { |
|
232 | + else if ('state' == $key) { |
|
233 | 233 | |
234 | - echo getpaid_get_states_select_markup ( |
|
235 | - getpaid_get_user_address_field( get_current_user_id(), 'country' ), |
|
236 | - getpaid_get_user_address_field( get_current_user_id(), 'state' ), |
|
234 | + echo getpaid_get_states_select_markup( |
|
235 | + getpaid_get_user_address_field(get_current_user_id(), 'country'), |
|
236 | + getpaid_get_user_address_field(get_current_user_id(), 'state'), |
|
237 | 237 | $label, |
238 | 238 | $label, |
239 | 239 | '', |
@@ -246,13 +246,13 @@ discard block |
||
246 | 246 | |
247 | 247 | echo aui()->input( |
248 | 248 | array( |
249 | - 'name' => esc_attr( $key ), |
|
250 | - 'id' => 'wpinv-' . sanitize_html_class( $key ), |
|
249 | + 'name' => esc_attr($key), |
|
250 | + 'id' => 'wpinv-' . sanitize_html_class($key), |
|
251 | 251 | 'placeholder' => $label, |
252 | - 'label' => wp_kses_post( $label ), |
|
252 | + 'label' => wp_kses_post($label), |
|
253 | 253 | 'label_type' => 'vertical', |
254 | 254 | 'type' => 'text', |
255 | - 'value' => sanitize_text_field( getpaid_get_user_address_field( get_current_user_id(), $key ) ), |
|
255 | + 'value' => sanitize_text_field(getpaid_get_user_address_field(get_current_user_id(), $key)), |
|
256 | 256 | 'class' => 'getpaid-address-field', |
257 | 257 | ) |
258 | 258 | ); |
@@ -261,21 +261,21 @@ discard block |
||
261 | 261 | |
262 | 262 | } |
263 | 263 | |
264 | - do_action( 'getpaid_display_address_edit_tab' ); |
|
264 | + do_action('getpaid_display_address_edit_tab'); |
|
265 | 265 | |
266 | 266 | echo aui()->input( |
267 | 267 | array( |
268 | 268 | 'name' => 'getpaid_profile_edit_submit_button', |
269 | 269 | 'id' => 'getpaid_profile_edit_submit_button', |
270 | - 'value' => __( 'Save Address', 'invoicing' ), |
|
271 | - 'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ), |
|
270 | + 'value' => __('Save Address', 'invoicing'), |
|
271 | + 'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'), |
|
272 | 272 | 'type' => 'submit', |
273 | 273 | 'class' => 'btn btn-primary btn-block submit-button', |
274 | 274 | ) |
275 | 275 | ); |
276 | 276 | |
277 | - wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); |
|
278 | - getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' ); |
|
277 | + wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); |
|
278 | + getpaid_hidden_field('getpaid-action', 'edit_billing_details'); |
|
279 | 279 | ?> |
280 | 280 | |
281 | 281 | </form> |
@@ -292,20 +292,20 @@ discard block |
||
292 | 292 | * @since 2.1.4 |
293 | 293 | * @param array $data |
294 | 294 | */ |
295 | -function getpaid_save_address_edit_tab( $data ) { |
|
295 | +function getpaid_save_address_edit_tab($data) { |
|
296 | 296 | |
297 | - foreach ( array_keys( getpaid_user_address_fields() ) as $field ) { |
|
297 | + foreach (array_keys(getpaid_user_address_fields()) as $field) { |
|
298 | 298 | |
299 | - if ( isset( $data[ $field ] ) ) { |
|
300 | - $value = sanitize_text_field( $data[ $field ] ); |
|
301 | - update_user_meta( get_current_user_id(), '_wpinv_' . $field, $value ); |
|
299 | + if (isset($data[$field])) { |
|
300 | + $value = sanitize_text_field($data[$field]); |
|
301 | + update_user_meta(get_current_user_id(), '_wpinv_' . $field, $value); |
|
302 | 302 | } |
303 | 303 | |
304 | - wpinv_set_error( 'address_updated', __( 'You billing address has been updated', 'invoicing' ), 'success'); |
|
304 | + wpinv_set_error('address_updated', __('You billing address has been updated', 'invoicing'), 'success'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | } |
308 | -add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' ); |
|
308 | +add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab'); |
|
309 | 309 | |
310 | 310 | |
311 | 311 | /* |
@@ -323,27 +323,27 @@ discard block |
||
323 | 323 | * @param array $tabs |
324 | 324 | * @return array |
325 | 325 | */ |
326 | -function getpaid_filter_userswp_account_tabs( $tabs ) { |
|
326 | +function getpaid_filter_userswp_account_tabs($tabs) { |
|
327 | 327 | |
328 | 328 | // Abort if the integration is inactive. |
329 | - if ( ! getpaid_is_userswp_integration_active() ) { |
|
329 | + if (!getpaid_is_userswp_integration_active()) { |
|
330 | 330 | return $tabs; |
331 | 331 | } |
332 | 332 | |
333 | - $new_tabs = array(); |
|
333 | + $new_tabs = array(); |
|
334 | 334 | |
335 | - foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) { |
|
335 | + foreach (getpaid_get_user_content_tabs() as $slug => $tab) { |
|
336 | 336 | |
337 | - $new_tabs[ $slug ] = array( |
|
338 | - 'title' => $tab[ 'label'], |
|
339 | - 'icon' => $tab[ 'icon'], |
|
337 | + $new_tabs[$slug] = array( |
|
338 | + 'title' => $tab['label'], |
|
339 | + 'icon' => $tab['icon'], |
|
340 | 340 | ); |
341 | 341 | |
342 | 342 | } |
343 | 343 | |
344 | - return array_merge( $tabs, $new_tabs ); |
|
344 | + return array_merge($tabs, $new_tabs); |
|
345 | 345 | } |
346 | -add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' ); |
|
346 | +add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs'); |
|
347 | 347 | |
348 | 348 | /** |
349 | 349 | * Display our UsersWP account tabs. |
@@ -352,18 +352,18 @@ discard block |
||
352 | 352 | * @param array $tabs |
353 | 353 | * @return array |
354 | 354 | */ |
355 | -function getpaid_display_userswp_account_tabs( $tab ) { |
|
355 | +function getpaid_display_userswp_account_tabs($tab) { |
|
356 | 356 | global $getpaid_tab_url; |
357 | 357 | |
358 | 358 | $our_tabs = getpaid_get_user_content_tabs(); |
359 | 359 | |
360 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
361 | - $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() ); |
|
362 | - echo getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ); |
|
360 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
361 | + $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url()); |
|
362 | + echo getpaid_prepare_user_content_tab($our_tabs[$tab]); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | } |
366 | -add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' ); |
|
366 | +add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs'); |
|
367 | 367 | |
368 | 368 | |
369 | 369 | /** |
@@ -374,17 +374,17 @@ discard block |
||
374 | 374 | * @param string $tab Current tab. |
375 | 375 | * @return string Title. |
376 | 376 | */ |
377 | -function getpaid_filter_userswp_account_title( $title, $tab ) { |
|
377 | +function getpaid_filter_userswp_account_title($title, $tab) { |
|
378 | 378 | |
379 | - $our_tabs = getpaid_get_user_content_tabs(); |
|
379 | + $our_tabs = getpaid_get_user_content_tabs(); |
|
380 | 380 | |
381 | - if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) { |
|
382 | - return $our_tabs[ $tab ]['label']; |
|
381 | + if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) { |
|
382 | + return $our_tabs[$tab]['label']; |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | return $title; |
386 | 386 | } |
387 | -add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 ); |
|
387 | +add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2); |
|
388 | 388 | |
389 | 389 | /** |
390 | 390 | * Registers the UsersWP integration settings. |
@@ -393,26 +393,26 @@ discard block |
||
393 | 393 | * @param array $settings An array of integration settings. |
394 | 394 | * @return array |
395 | 395 | */ |
396 | -function getpaid_register_userswp_settings( $settings ) { |
|
396 | +function getpaid_register_userswp_settings($settings) { |
|
397 | 397 | |
398 | - if ( defined( 'USERSWP_PLUGIN_FILE' ) ) { |
|
398 | + if (defined('USERSWP_PLUGIN_FILE')) { |
|
399 | 399 | |
400 | 400 | $settings[] = array( |
401 | 401 | |
402 | 402 | 'id' => 'userswp', |
403 | - 'label' => __( 'UsersWP', 'invoicing' ), |
|
403 | + 'label' => __('UsersWP', 'invoicing'), |
|
404 | 404 | 'settings' => array( |
405 | 405 | |
406 | 406 | 'userswp_settings' => array( |
407 | 407 | 'id' => 'userswp_settings', |
408 | - 'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>', |
|
408 | + 'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>', |
|
409 | 409 | 'type' => 'header', |
410 | 410 | ), |
411 | 411 | |
412 | 412 | 'enable_userswp' => array( |
413 | 413 | 'id' => 'enable_userswp', |
414 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
415 | - 'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ), |
|
414 | + 'name' => __('Enable Integration', 'invoicing'), |
|
415 | + 'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'), |
|
416 | 416 | 'type' => 'checkbox', |
417 | 417 | 'std' => 1, |
418 | 418 | ) |
@@ -425,7 +425,7 @@ discard block |
||
425 | 425 | |
426 | 426 | return $settings; |
427 | 427 | } |
428 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' ); |
|
428 | +add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings'); |
|
429 | 429 | |
430 | 430 | /** |
431 | 431 | * Checks if the integration is enabled. |
@@ -434,8 +434,8 @@ discard block |
||
434 | 434 | * @return bool |
435 | 435 | */ |
436 | 436 | function getpaid_is_userswp_integration_active() { |
437 | - $enabled = wpinv_get_option( 'enable_userswp', 1 ); |
|
438 | - return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled ); |
|
437 | + $enabled = wpinv_get_option('enable_userswp', 1); |
|
438 | + return defined('USERSWP_PLUGIN_FILE') && !empty($enabled); |
|
439 | 439 | } |
440 | 440 | |
441 | 441 | /* |
@@ -453,26 +453,26 @@ discard block |
||
453 | 453 | * @param array $settings An array of integration settings. |
454 | 454 | * @return array |
455 | 455 | */ |
456 | -function getpaid_register_buddypress_settings( $settings ) { |
|
456 | +function getpaid_register_buddypress_settings($settings) { |
|
457 | 457 | |
458 | - if ( class_exists( 'BuddyPress' ) ) { |
|
458 | + if (class_exists('BuddyPress')) { |
|
459 | 459 | |
460 | 460 | $settings[] = array( |
461 | 461 | |
462 | 462 | 'id' => 'buddypress', |
463 | - 'label' => __( 'BuddyPress', 'invoicing' ), |
|
463 | + 'label' => __('BuddyPress', 'invoicing'), |
|
464 | 464 | 'settings' => array( |
465 | 465 | |
466 | 466 | 'buddypress_settings' => array( |
467 | 467 | 'id' => 'buddypress_settings', |
468 | - 'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>', |
|
468 | + 'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>', |
|
469 | 469 | 'type' => 'header', |
470 | 470 | ), |
471 | 471 | |
472 | 472 | 'enable_buddypress' => array( |
473 | 473 | 'id' => 'enable_buddypress', |
474 | - 'name' => __( 'Enable Integration', 'invoicing' ), |
|
475 | - 'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ), |
|
474 | + 'name' => __('Enable Integration', 'invoicing'), |
|
475 | + 'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'), |
|
476 | 476 | 'type' => 'checkbox', |
477 | 477 | 'std' => 1, |
478 | 478 | ) |
@@ -485,7 +485,7 @@ discard block |
||
485 | 485 | |
486 | 486 | return $settings; |
487 | 487 | } |
488 | -add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' ); |
|
488 | +add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings'); |
|
489 | 489 | |
490 | 490 | /** |
491 | 491 | * Checks if the integration is enabled. |
@@ -494,8 +494,8 @@ discard block |
||
494 | 494 | * @return bool |
495 | 495 | */ |
496 | 496 | function getpaid_is_buddypress_integration_active() { |
497 | - $enabled = wpinv_get_option( 'enable_buddypress', 1 ); |
|
498 | - return class_exists( 'BuddyPress' ) && ! empty( $enabled ); |
|
497 | + $enabled = wpinv_get_option('enable_buddypress', 1); |
|
498 | + return class_exists('BuddyPress') && !empty($enabled); |
|
499 | 499 | } |
500 | 500 | |
501 | 501 | /** |
@@ -506,10 +506,10 @@ discard block |
||
506 | 506 | */ |
507 | 507 | function getpaid_setup_buddypress_integration() { |
508 | 508 | |
509 | - if ( getpaid_is_buddypress_integration_active() ) { |
|
510 | - require_once( WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php' ); |
|
509 | + if (getpaid_is_buddypress_integration_active()) { |
|
510 | + require_once(WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php'); |
|
511 | 511 | buddypress()->getpaid = new BP_GetPaid_Component(); |
512 | 512 | } |
513 | 513 | |
514 | 514 | } |
515 | -add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' ); |
|
515 | +add_action('bp_setup_components', 'getpaid_setup_buddypress_integration'); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Setup menus in WP admin. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WC_Admin_Menus Class. |
@@ -13,25 +13,25 @@ discard block |
||
13 | 13 | * Hook in tabs. |
14 | 14 | */ |
15 | 15 | public function __construct() { |
16 | - add_action( 'admin_menu', array( $this, 'admin_menu' ), 10 ); |
|
17 | - add_action( 'admin_menu', array( $this, 'add_customers_menu' ), 18 ); |
|
18 | - add_action( 'admin_menu', array( $this, 'add_subscriptions_menu' ), 40 ); |
|
19 | - add_action( 'admin_menu', array( $this, 'add_addons_menu' ), 100 ); |
|
20 | - add_action( 'admin_menu', array( $this, 'add_settings_menu' ), 60 ); |
|
21 | - add_action( 'admin_menu', array( $this, 'remove_admin_submenus' ), 10 ); |
|
22 | - add_action( 'admin_head-nav-menus.php', array( $this, 'add_nav_menu_meta_boxes' ) ); |
|
16 | + add_action('admin_menu', array($this, 'admin_menu'), 10); |
|
17 | + add_action('admin_menu', array($this, 'add_customers_menu'), 18); |
|
18 | + add_action('admin_menu', array($this, 'add_subscriptions_menu'), 40); |
|
19 | + add_action('admin_menu', array($this, 'add_addons_menu'), 100); |
|
20 | + add_action('admin_menu', array($this, 'add_settings_menu'), 60); |
|
21 | + add_action('admin_menu', array($this, 'remove_admin_submenus'), 10); |
|
22 | + add_action('admin_head-nav-menus.php', array($this, 'add_nav_menu_meta_boxes')); |
|
23 | 23 | } |
24 | 24 | |
25 | 25 | public function admin_menu() { |
26 | 26 | |
27 | - $capability = apply_filters( 'invoicing_capability', wpinv_get_capability() ); |
|
27 | + $capability = apply_filters('invoicing_capability', wpinv_get_capability()); |
|
28 | 28 | add_menu_page( |
29 | - __( 'GetPaid', 'invoicing' ), |
|
30 | - __( 'GetPaid', 'invoicing' ), |
|
29 | + __('GetPaid', 'invoicing'), |
|
30 | + __('GetPaid', 'invoicing'), |
|
31 | 31 | $capability, |
32 | 32 | 'wpinv', |
33 | 33 | null, |
34 | - 'data:image/svg+xml;base64,' . base64_encode( file_get_contents( WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg' ) ), |
|
34 | + 'data:image/svg+xml;base64,' . base64_encode(file_get_contents(WPINV_PLUGIN_DIR . 'assets/images/GetPaid.svg')), |
|
35 | 35 | '54.123460' |
36 | 36 | ); |
37 | 37 | |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | public function add_customers_menu() { |
44 | 44 | add_submenu_page( |
45 | 45 | 'wpinv', |
46 | - __( 'Customers', 'invoicing' ), |
|
47 | - __( 'Customers', 'invoicing' ), |
|
46 | + __('Customers', 'invoicing'), |
|
47 | + __('Customers', 'invoicing'), |
|
48 | 48 | wpinv_get_capability(), |
49 | 49 | 'wpinv-customers', |
50 | - array( $this, 'customers_page' ) |
|
50 | + array($this, 'customers_page') |
|
51 | 51 | ); |
52 | 52 | } |
53 | 53 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | public function add_subscriptions_menu() { |
58 | 58 | add_submenu_page( |
59 | 59 | 'wpinv', |
60 | - __( 'Subscriptions', 'invoicing' ), |
|
61 | - __( 'Subscriptions', 'invoicing' ), |
|
60 | + __('Subscriptions', 'invoicing'), |
|
61 | + __('Subscriptions', 'invoicing'), |
|
62 | 62 | wpinv_get_capability(), |
63 | 63 | 'wpinv-subscriptions', |
64 | 64 | 'wpinv_subscriptions_page' |
@@ -69,7 +69,7 @@ discard block |
||
69 | 69 | * Displays the customers page. |
70 | 70 | */ |
71 | 71 | public function customers_page() { |
72 | - require_once( WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php' ); |
|
72 | + require_once(WPINV_PLUGIN_DIR . 'includes/admin/class-wpinv-customers-table.php'); |
|
73 | 73 | ?> |
74 | 74 | <div class="wrap wpi-customers-wrap"> |
75 | 75 | <style> |
@@ -77,12 +77,12 @@ discard block |
||
77 | 77 | width: 30%; |
78 | 78 | } |
79 | 79 | </style> |
80 | - <h1><?php echo esc_html( __( 'Customers', 'invoicing' ) ); ?></h1> |
|
80 | + <h1><?php echo esc_html(__('Customers', 'invoicing')); ?></h1> |
|
81 | 81 | <form method="post"> |
82 | 82 | <?php |
83 | 83 | $table = new WPInv_Customers_Table(); |
84 | 84 | $table->prepare_items(); |
85 | - $table->search_box( __( 'Search Customers', 'invoicing' ), 'search-customers' ); |
|
85 | + $table->search_box(__('Search Customers', 'invoicing'), 'search-customers'); |
|
86 | 86 | $table->display(); |
87 | 87 | ?> |
88 | 88 | </form> |
@@ -96,16 +96,16 @@ discard block |
||
96 | 96 | public function add_settings_menu() { |
97 | 97 | add_submenu_page( |
98 | 98 | 'wpinv', |
99 | - __( 'Invoice Settings', 'invoicing' ), |
|
100 | - __( 'Settings', 'invoicing' ), |
|
101 | - apply_filters( 'invoicing_capability', wpinv_get_capability() ), |
|
99 | + __('Invoice Settings', 'invoicing'), |
|
100 | + __('Settings', 'invoicing'), |
|
101 | + apply_filters('invoicing_capability', wpinv_get_capability()), |
|
102 | 102 | 'wpinv-settings', |
103 | - array( $this, 'options_page' ) |
|
103 | + array($this, 'options_page') |
|
104 | 104 | ); |
105 | 105 | } |
106 | 106 | |
107 | - public function add_addons_menu(){ |
|
108 | - if ( !apply_filters( 'wpi_show_addons_page', true ) ) { |
|
107 | + public function add_addons_menu() { |
|
108 | + if (!apply_filters('wpi_show_addons_page', true)) { |
|
109 | 109 | return; |
110 | 110 | } |
111 | 111 | |
@@ -115,78 +115,78 @@ discard block |
||
115 | 115 | __('Extensions', 'invoicing'), |
116 | 116 | 'manage_options', |
117 | 117 | 'wpi-addons', |
118 | - array( $this, 'addons_page' ) |
|
118 | + array($this, 'addons_page') |
|
119 | 119 | ); |
120 | 120 | } |
121 | 121 | |
122 | - public function addons_page(){ |
|
122 | + public function addons_page() { |
|
123 | 123 | $addon_obj = new WPInv_Admin_Addons(); |
124 | 124 | $addon_obj->output(); |
125 | 125 | } |
126 | 126 | |
127 | 127 | function options_page() { |
128 | - $page = isset( $_GET['page'] ) ? strtolower( $_GET['page'] ) : false; |
|
128 | + $page = isset($_GET['page']) ? strtolower($_GET['page']) : false; |
|
129 | 129 | |
130 | - if ( $page !== 'wpinv-settings' ) { |
|
130 | + if ($page !== 'wpinv-settings') { |
|
131 | 131 | return; |
132 | 132 | } |
133 | 133 | |
134 | 134 | $settings_tabs = wpinv_get_settings_tabs(); |
135 | 135 | $settings_tabs = empty($settings_tabs) ? array() : $settings_tabs; |
136 | - $active_tab = isset( $_GET['tab'] ) && array_key_exists( $_GET['tab'], $settings_tabs ) ? sanitize_text_field( $_GET['tab'] ) : 'general'; |
|
137 | - $sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
136 | + $active_tab = isset($_GET['tab']) && array_key_exists($_GET['tab'], $settings_tabs) ? sanitize_text_field($_GET['tab']) : 'general'; |
|
137 | + $sections = wpinv_get_settings_tab_sections($active_tab); |
|
138 | 138 | $key = 'main'; |
139 | 139 | |
140 | - if ( is_array( $sections ) ) { |
|
141 | - $key = key( $sections ); |
|
140 | + if (is_array($sections)) { |
|
141 | + $key = key($sections); |
|
142 | 142 | } |
143 | 143 | |
144 | - $registered_sections = wpinv_get_settings_tab_sections( $active_tab ); |
|
145 | - $section = isset( $_GET['section'] ) && ! empty( $registered_sections ) && array_key_exists( $_GET['section'], $registered_sections ) ? $_GET['section'] : $key; |
|
144 | + $registered_sections = wpinv_get_settings_tab_sections($active_tab); |
|
145 | + $section = isset($_GET['section']) && !empty($registered_sections) && array_key_exists($_GET['section'], $registered_sections) ? $_GET['section'] : $key; |
|
146 | 146 | ob_start(); |
147 | 147 | ?> |
148 | 148 | <div class="wrap"> |
149 | 149 | <h1 class="nav-tab-wrapper"> |
150 | 150 | <?php |
151 | - foreach( wpinv_get_settings_tabs() as $tab_id => $tab_name ) { |
|
152 | - $tab_url = add_query_arg( array( |
|
151 | + foreach (wpinv_get_settings_tabs() as $tab_id => $tab_name) { |
|
152 | + $tab_url = add_query_arg(array( |
|
153 | 153 | 'settings-updated' => false, |
154 | 154 | 'tab' => $tab_id, |
155 | - ) ); |
|
155 | + )); |
|
156 | 156 | |
157 | 157 | // Remove the section from the tabs so we always end up at the main section |
158 | - $tab_url = remove_query_arg( 'section', $tab_url ); |
|
159 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
158 | + $tab_url = remove_query_arg('section', $tab_url); |
|
159 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
160 | 160 | |
161 | 161 | $active = $active_tab == $tab_id ? ' nav-tab-active' : ''; |
162 | 162 | |
163 | - echo '<a href="' . esc_url( $tab_url ) . '" title="' . esc_attr( $tab_name ) . '" class="nav-tab' . $active . '">'; |
|
164 | - echo esc_html( $tab_name ); |
|
163 | + echo '<a href="' . esc_url($tab_url) . '" title="' . esc_attr($tab_name) . '" class="nav-tab' . $active . '">'; |
|
164 | + echo esc_html($tab_name); |
|
165 | 165 | echo '</a>'; |
166 | 166 | } |
167 | 167 | ?> |
168 | 168 | </h1> |
169 | 169 | <?php |
170 | - $number_of_sections = count( $sections ); |
|
170 | + $number_of_sections = count($sections); |
|
171 | 171 | $number = 0; |
172 | - if ( $number_of_sections > 1 ) { |
|
172 | + if ($number_of_sections > 1) { |
|
173 | 173 | echo '<div><ul class="subsubsub">'; |
174 | - foreach( $sections as $section_id => $section_name ) { |
|
174 | + foreach ($sections as $section_id => $section_name) { |
|
175 | 175 | echo '<li>'; |
176 | 176 | $number++; |
177 | - $tab_url = add_query_arg( array( |
|
177 | + $tab_url = add_query_arg(array( |
|
178 | 178 | 'settings-updated' => false, |
179 | 179 | 'tab' => $active_tab, |
180 | 180 | 'section' => $section_id |
181 | - ) ); |
|
182 | - $tab_url = remove_query_arg( 'wpi_sub', $tab_url ); |
|
181 | + )); |
|
182 | + $tab_url = remove_query_arg('wpi_sub', $tab_url); |
|
183 | 183 | $class = ''; |
184 | - if ( $section == $section_id ) { |
|
184 | + if ($section == $section_id) { |
|
185 | 185 | $class = 'current'; |
186 | 186 | } |
187 | - echo '<a class="' . $class . '" href="' . esc_url( $tab_url ) . '">' . $section_name . '</a>'; |
|
187 | + echo '<a class="' . $class . '" href="' . esc_url($tab_url) . '">' . $section_name . '</a>'; |
|
188 | 188 | |
189 | - if ( $number != $number_of_sections ) { |
|
189 | + if ($number != $number_of_sections) { |
|
190 | 190 | echo ' | '; |
191 | 191 | } |
192 | 192 | echo '</li>'; |
@@ -198,20 +198,20 @@ discard block |
||
198 | 198 | <form method="post" action="options.php"> |
199 | 199 | <table class="form-table"> |
200 | 200 | <?php |
201 | - settings_fields( 'wpinv_settings' ); |
|
201 | + settings_fields('wpinv_settings'); |
|
202 | 202 | |
203 | - if ( 'main' === $section ) { |
|
204 | - do_action( 'wpinv_settings_tab_top', $active_tab ); |
|
203 | + if ('main' === $section) { |
|
204 | + do_action('wpinv_settings_tab_top', $active_tab); |
|
205 | 205 | } |
206 | 206 | |
207 | - do_action( 'wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
208 | - do_settings_sections( 'wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
209 | - do_action( 'wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section ); |
|
210 | - do_action( 'getpaid_settings_tab_bottom', $active_tab, $section ); |
|
207 | + do_action('wpinv_settings_tab_top_' . $active_tab . '_' . $section, $active_tab, $section); |
|
208 | + do_settings_sections('wpinv_settings_' . $active_tab . '_' . $section, $active_tab, $section); |
|
209 | + do_action('wpinv_settings_tab_bottom_' . $active_tab . '_' . $section, $active_tab, $section); |
|
210 | + do_action('getpaid_settings_tab_bottom', $active_tab, $section); |
|
211 | 211 | |
212 | 212 | // For backwards compatibility |
213 | - if ( 'main' === $section ) { |
|
214 | - do_action( 'wpinv_settings_tab_bottom', $active_tab ); |
|
213 | + if ('main' === $section) { |
|
214 | + do_action('wpinv_settings_tab_bottom', $active_tab); |
|
215 | 215 | } |
216 | 216 | ?> |
217 | 217 | </table> |
@@ -225,7 +225,7 @@ discard block |
||
225 | 225 | } |
226 | 226 | |
227 | 227 | public function remove_admin_submenus() { |
228 | - remove_submenu_page( 'edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice' ); |
|
228 | + remove_submenu_page('edit.php?post_type=wpi_invoice', 'post-new.php?post_type=wpi_invoice'); |
|
229 | 229 | } |
230 | 230 | |
231 | 231 | /** |
@@ -235,8 +235,8 @@ discard block |
||
235 | 235 | |
236 | 236 | add_meta_box( |
237 | 237 | 'wpinv_endpoints_nav_link', |
238 | - __( 'GetPaid endpoints', 'invoicing' ), |
|
239 | - array( $this, 'nav_menu_links' ), |
|
238 | + __('GetPaid endpoints', 'invoicing'), |
|
239 | + array($this, 'nav_menu_links'), |
|
240 | 240 | 'nav-menus', |
241 | 241 | 'side', |
242 | 242 | 'low' |
@@ -251,12 +251,12 @@ discard block |
||
251 | 251 | $endpoints = $this->get_menu_items(); |
252 | 252 | ?> |
253 | 253 | <div id="invoicing-endpoints" class="posttypediv"> |
254 | - <?php if ( ! empty( $endpoints['pages'] ) ) : ?> |
|
254 | + <?php if (!empty($endpoints['pages'])) : ?> |
|
255 | 255 | <div id="tabs-panel-invoicing-endpoints" class="tabs-panel tabs-panel-active"> |
256 | 256 | <ul id="invoicing-endpoints-checklist" class="categorychecklist form-no-clear"> |
257 | 257 | <?php |
258 | - $walker = new Walker_Nav_Menu_Checklist( array() ); |
|
259 | - echo walk_nav_menu_tree( array_map( 'wp_setup_nav_menu_item', $endpoints['pages'] ), 0, (object) array( 'walker' => $walker ) ); |
|
258 | + $walker = new Walker_Nav_Menu_Checklist(array()); |
|
259 | + echo walk_nav_menu_tree(array_map('wp_setup_nav_menu_item', $endpoints['pages']), 0, (object) array('walker' => $walker)); |
|
260 | 260 | ?> |
261 | 261 | </ul> |
262 | 262 | </div> |
@@ -265,11 +265,11 @@ discard block |
||
265 | 265 | <p class="button-controls wp-clearfix" data-items-type="invoicing-endpoints"> |
266 | 266 | <span class="list-controls hide-if-no-js"> |
267 | 267 | <input type="checkbox" id="invoicing-endpoints-tab" class="select-all"> |
268 | - <label for="invoicing-endpoints-tab"><?php _e( 'Select all', 'invoicing' ); ?></label> |
|
268 | + <label for="invoicing-endpoints-tab"><?php _e('Select all', 'invoicing'); ?></label> |
|
269 | 269 | </span> |
270 | 270 | |
271 | 271 | <span class="add-to-menu"> |
272 | - <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e( 'Add to menu', 'invoicing' ); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
272 | + <input type="submit" class="button submit-add-to-menu right" value="<?php esc_attr_e('Add to menu', 'invoicing'); ?>" name="add-invoicing-endpoints-item" id="submit-invoicing-endpoints"> |
|
273 | 273 | <span class="spinner"></span> |
274 | 274 | </span> |
275 | 275 | </p> |
@@ -282,35 +282,35 @@ discard block |
||
282 | 282 | * |
283 | 283 | * @return array. |
284 | 284 | */ |
285 | - public function get_menu_items(){ |
|
285 | + public function get_menu_items() { |
|
286 | 286 | $items = array(); |
287 | 287 | |
288 | 288 | $pages = array( |
289 | 289 | array( |
290 | - 'id' => wpinv_get_option( 'invoice_history_page' ), |
|
291 | - 'label' => __( 'My Invoices', 'invoicing' ), |
|
290 | + 'id' => wpinv_get_option('invoice_history_page'), |
|
291 | + 'label' => __('My Invoices', 'invoicing'), |
|
292 | 292 | ), |
293 | 293 | array( |
294 | - 'id' => wpinv_get_option( 'invoice_subscription_page' ), |
|
295 | - 'label' => __( 'My Subscriptions', 'invoicing' ), |
|
294 | + 'id' => wpinv_get_option('invoice_subscription_page'), |
|
295 | + 'label' => __('My Subscriptions', 'invoicing'), |
|
296 | 296 | ) |
297 | 297 | ); |
298 | 298 | |
299 | - foreach ( apply_filters( 'getpaid_menu_pages', $pages ) as $page ) { |
|
299 | + foreach (apply_filters('getpaid_menu_pages', $pages) as $page) { |
|
300 | 300 | |
301 | - if ( (int) $page['id'] > 0 ) { |
|
301 | + if ((int) $page['id'] > 0) { |
|
302 | 302 | |
303 | 303 | $item = new stdClass(); |
304 | 304 | $item->object_id = (int) $page['id']; |
305 | 305 | $item->db_id = 0; |
306 | - $item->object = 'page'; |
|
306 | + $item->object = 'page'; |
|
307 | 307 | $item->menu_item_parent = 0; |
308 | 308 | $item->type = 'post_type'; |
309 | - $item->title = sanitize_text_field( $page['label'] ); |
|
310 | - $item->url = get_permalink( (int) $page['id'] ); |
|
309 | + $item->title = sanitize_text_field($page['label']); |
|
310 | + $item->url = get_permalink((int) $page['id']); |
|
311 | 311 | $item->target = ''; |
312 | 312 | $item->attr_title = ''; |
313 | - $item->classes = array( 'wpinv-menu-item' ); |
|
313 | + $item->classes = array('wpinv-menu-item'); |
|
314 | 314 | $item->xfn = ''; |
315 | 315 | |
316 | 316 | $items['pages'][] = $item; |
@@ -319,7 +319,7 @@ discard block |
||
319 | 319 | |
320 | 320 | } |
321 | 321 | |
322 | - return apply_filters( 'wpinv_menu_items', $items ); |
|
322 | + return apply_filters('wpinv_menu_items', $items); |
|
323 | 323 | } |
324 | 324 | |
325 | 325 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,187 +10,187 @@ discard block |
||
10 | 10 | class GetPaid_Payment_Form_Submission { |
11 | 11 | |
12 | 12 | /** |
13 | - * Submission ID |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - public $id = null; |
|
18 | - |
|
19 | - /** |
|
20 | - * The raw submission data. |
|
21 | - * |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $data = null; |
|
25 | - |
|
26 | - /** |
|
27 | - * Submission totals |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - protected $totals = array( |
|
32 | - |
|
33 | - 'subtotal' => array( |
|
34 | - 'initial' => 0, |
|
35 | - 'recurring' => 0, |
|
36 | - ), |
|
37 | - |
|
38 | - 'discount' => array( |
|
39 | - 'initial' => 0, |
|
40 | - 'recurring' => 0, |
|
41 | - ), |
|
42 | - |
|
43 | - 'fees' => array( |
|
44 | - 'initial' => 0, |
|
45 | - 'recurring' => 0, |
|
46 | - ), |
|
47 | - |
|
48 | - 'taxes' => array( |
|
49 | - 'initial' => 0, |
|
50 | - 'recurring' => 0, |
|
51 | - ), |
|
52 | - |
|
53 | - ); |
|
54 | - |
|
55 | - /** |
|
56 | - * Sets the associated payment form. |
|
57 | - * |
|
58 | - * @var GetPaid_Payment_Form |
|
59 | - */ |
|
13 | + * Submission ID |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + public $id = null; |
|
18 | + |
|
19 | + /** |
|
20 | + * The raw submission data. |
|
21 | + * |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $data = null; |
|
25 | + |
|
26 | + /** |
|
27 | + * Submission totals |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + protected $totals = array( |
|
32 | + |
|
33 | + 'subtotal' => array( |
|
34 | + 'initial' => 0, |
|
35 | + 'recurring' => 0, |
|
36 | + ), |
|
37 | + |
|
38 | + 'discount' => array( |
|
39 | + 'initial' => 0, |
|
40 | + 'recurring' => 0, |
|
41 | + ), |
|
42 | + |
|
43 | + 'fees' => array( |
|
44 | + 'initial' => 0, |
|
45 | + 'recurring' => 0, |
|
46 | + ), |
|
47 | + |
|
48 | + 'taxes' => array( |
|
49 | + 'initial' => 0, |
|
50 | + 'recurring' => 0, |
|
51 | + ), |
|
52 | + |
|
53 | + ); |
|
54 | + |
|
55 | + /** |
|
56 | + * Sets the associated payment form. |
|
57 | + * |
|
58 | + * @var GetPaid_Payment_Form |
|
59 | + */ |
|
60 | 60 | protected $payment_form = null; |
61 | 61 | |
62 | 62 | /** |
63 | - * The country for the submission. |
|
64 | - * |
|
65 | - * @var string |
|
66 | - */ |
|
67 | - public $country = null; |
|
68 | - |
|
69 | - /** |
|
70 | - * The state for the submission. |
|
71 | - * |
|
72 | - * @since 1.0.19 |
|
73 | - * @var string |
|
74 | - */ |
|
75 | - public $state = null; |
|
76 | - |
|
77 | - /** |
|
78 | - * The invoice associated with the submission. |
|
79 | - * |
|
80 | - * @var WPInv_Invoice |
|
81 | - */ |
|
82 | - protected $invoice = null; |
|
83 | - |
|
84 | - /** |
|
85 | - * The recurring item for the submission. |
|
86 | - * |
|
87 | - * @var int |
|
88 | - */ |
|
89 | - public $has_recurring = 0; |
|
90 | - |
|
91 | - /** |
|
92 | - * An array of fees for the submission. |
|
93 | - * |
|
94 | - * @var array |
|
95 | - */ |
|
96 | - protected $fees = array(); |
|
97 | - |
|
98 | - /** |
|
99 | - * An array of discounts for the submission. |
|
100 | - * |
|
101 | - * @var array |
|
102 | - */ |
|
103 | - protected $discounts = array(); |
|
104 | - |
|
105 | - /** |
|
106 | - * An array of taxes for the submission. |
|
107 | - * |
|
108 | - * @var array |
|
109 | - */ |
|
110 | - protected $taxes = array(); |
|
111 | - |
|
112 | - /** |
|
113 | - * An array of items for the submission. |
|
114 | - * |
|
115 | - * @var GetPaid_Form_Item[] |
|
116 | - */ |
|
117 | - protected $items = array(); |
|
118 | - |
|
119 | - /** |
|
120 | - * The last error. |
|
121 | - * |
|
122 | - * @var string |
|
123 | - */ |
|
124 | - public $last_error = null; |
|
125 | - |
|
126 | - /** |
|
127 | - * Class constructor. |
|
128 | - * |
|
129 | - */ |
|
130 | - public function __construct() { |
|
131 | - |
|
132 | - // Set the state and country to the default state and country. |
|
133 | - $this->country = wpinv_default_billing_country(); |
|
134 | - $this->state = wpinv_get_default_state(); |
|
135 | - |
|
136 | - // Do we have an actual submission? |
|
137 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
138 | - $this->load_data( $_POST ); |
|
139 | - } |
|
140 | - |
|
141 | - } |
|
142 | - |
|
143 | - /** |
|
144 | - * Loads submission data. |
|
145 | - * |
|
146 | - * @param array $data |
|
147 | - */ |
|
148 | - public function load_data( $data ) { |
|
149 | - |
|
150 | - // Remove slashes from the submitted data... |
|
151 | - $data = wp_unslash( $data ); |
|
152 | - |
|
153 | - // Allow plugins to filter the data. |
|
154 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
155 | - |
|
156 | - // Cache it... |
|
157 | - $this->data = $data; |
|
158 | - |
|
159 | - // Then generate a unique id from the data. |
|
160 | - $this->id = md5( wp_json_encode( $data ) ); |
|
161 | - |
|
162 | - // Finally, process the submission. |
|
163 | - try { |
|
164 | - |
|
165 | - // Each process is passed an instance of the class (with reference) |
|
166 | - // and should throw an Exception whenever it encounters one. |
|
167 | - $processors = apply_filters( |
|
168 | - 'getpaid_payment_form_submission_processors', |
|
169 | - array( |
|
170 | - array( $this, 'process_payment_form' ), |
|
171 | - array( $this, 'process_invoice' ), |
|
172 | - array( $this, 'process_fees' ), |
|
173 | - array( $this, 'process_items' ), |
|
174 | - array( $this, 'process_discount' ), |
|
175 | - array( $this, 'process_taxes' ), |
|
176 | - ), |
|
177 | - $this |
|
178 | - ); |
|
179 | - |
|
180 | - foreach ( $processors as $processor ) { |
|
181 | - call_user_func_array( $processor, array( &$this ) ); |
|
182 | - } |
|
183 | - |
|
184 | - } catch ( Exception $e ) { |
|
185 | - $this->last_error = $e->getMessage(); |
|
186 | - } |
|
187 | - |
|
188 | - // Fired when we are done processing a submission. |
|
189 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
190 | - |
|
191 | - } |
|
192 | - |
|
193 | - /* |
|
63 | + * The country for the submission. |
|
64 | + * |
|
65 | + * @var string |
|
66 | + */ |
|
67 | + public $country = null; |
|
68 | + |
|
69 | + /** |
|
70 | + * The state for the submission. |
|
71 | + * |
|
72 | + * @since 1.0.19 |
|
73 | + * @var string |
|
74 | + */ |
|
75 | + public $state = null; |
|
76 | + |
|
77 | + /** |
|
78 | + * The invoice associated with the submission. |
|
79 | + * |
|
80 | + * @var WPInv_Invoice |
|
81 | + */ |
|
82 | + protected $invoice = null; |
|
83 | + |
|
84 | + /** |
|
85 | + * The recurring item for the submission. |
|
86 | + * |
|
87 | + * @var int |
|
88 | + */ |
|
89 | + public $has_recurring = 0; |
|
90 | + |
|
91 | + /** |
|
92 | + * An array of fees for the submission. |
|
93 | + * |
|
94 | + * @var array |
|
95 | + */ |
|
96 | + protected $fees = array(); |
|
97 | + |
|
98 | + /** |
|
99 | + * An array of discounts for the submission. |
|
100 | + * |
|
101 | + * @var array |
|
102 | + */ |
|
103 | + protected $discounts = array(); |
|
104 | + |
|
105 | + /** |
|
106 | + * An array of taxes for the submission. |
|
107 | + * |
|
108 | + * @var array |
|
109 | + */ |
|
110 | + protected $taxes = array(); |
|
111 | + |
|
112 | + /** |
|
113 | + * An array of items for the submission. |
|
114 | + * |
|
115 | + * @var GetPaid_Form_Item[] |
|
116 | + */ |
|
117 | + protected $items = array(); |
|
118 | + |
|
119 | + /** |
|
120 | + * The last error. |
|
121 | + * |
|
122 | + * @var string |
|
123 | + */ |
|
124 | + public $last_error = null; |
|
125 | + |
|
126 | + /** |
|
127 | + * Class constructor. |
|
128 | + * |
|
129 | + */ |
|
130 | + public function __construct() { |
|
131 | + |
|
132 | + // Set the state and country to the default state and country. |
|
133 | + $this->country = wpinv_default_billing_country(); |
|
134 | + $this->state = wpinv_get_default_state(); |
|
135 | + |
|
136 | + // Do we have an actual submission? |
|
137 | + if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
138 | + $this->load_data( $_POST ); |
|
139 | + } |
|
140 | + |
|
141 | + } |
|
142 | + |
|
143 | + /** |
|
144 | + * Loads submission data. |
|
145 | + * |
|
146 | + * @param array $data |
|
147 | + */ |
|
148 | + public function load_data( $data ) { |
|
149 | + |
|
150 | + // Remove slashes from the submitted data... |
|
151 | + $data = wp_unslash( $data ); |
|
152 | + |
|
153 | + // Allow plugins to filter the data. |
|
154 | + $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
155 | + |
|
156 | + // Cache it... |
|
157 | + $this->data = $data; |
|
158 | + |
|
159 | + // Then generate a unique id from the data. |
|
160 | + $this->id = md5( wp_json_encode( $data ) ); |
|
161 | + |
|
162 | + // Finally, process the submission. |
|
163 | + try { |
|
164 | + |
|
165 | + // Each process is passed an instance of the class (with reference) |
|
166 | + // and should throw an Exception whenever it encounters one. |
|
167 | + $processors = apply_filters( |
|
168 | + 'getpaid_payment_form_submission_processors', |
|
169 | + array( |
|
170 | + array( $this, 'process_payment_form' ), |
|
171 | + array( $this, 'process_invoice' ), |
|
172 | + array( $this, 'process_fees' ), |
|
173 | + array( $this, 'process_items' ), |
|
174 | + array( $this, 'process_discount' ), |
|
175 | + array( $this, 'process_taxes' ), |
|
176 | + ), |
|
177 | + $this |
|
178 | + ); |
|
179 | + |
|
180 | + foreach ( $processors as $processor ) { |
|
181 | + call_user_func_array( $processor, array( &$this ) ); |
|
182 | + } |
|
183 | + |
|
184 | + } catch ( Exception $e ) { |
|
185 | + $this->last_error = $e->getMessage(); |
|
186 | + } |
|
187 | + |
|
188 | + // Fired when we are done processing a submission. |
|
189 | + do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
190 | + |
|
191 | + } |
|
192 | + |
|
193 | + /* |
|
194 | 194 | |-------------------------------------------------------------------------- |
195 | 195 | | Payment Forms. |
196 | 196 | |-------------------------------------------------------------------------- |
@@ -199,39 +199,39 @@ discard block |
||
199 | 199 | | submission has an active payment form etc. |
200 | 200 | */ |
201 | 201 | |
202 | - /** |
|
203 | - * Prepares the submission's payment form. |
|
204 | - * |
|
205 | - * @since 1.0.19 |
|
206 | - */ |
|
207 | - public function process_payment_form() { |
|
202 | + /** |
|
203 | + * Prepares the submission's payment form. |
|
204 | + * |
|
205 | + * @since 1.0.19 |
|
206 | + */ |
|
207 | + public function process_payment_form() { |
|
208 | 208 | |
209 | - // Every submission needs an active payment form. |
|
210 | - if ( empty( $this->data['form_id'] ) ) { |
|
211 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
212 | - } |
|
209 | + // Every submission needs an active payment form. |
|
210 | + if ( empty( $this->data['form_id'] ) ) { |
|
211 | + throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
212 | + } |
|
213 | 213 | |
214 | - // Fetch the payment form. |
|
215 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
214 | + // Fetch the payment form. |
|
215 | + $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
216 | 216 | |
217 | - if ( ! $this->payment_form->is_active() ) { |
|
218 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
219 | - } |
|
217 | + if ( ! $this->payment_form->is_active() ) { |
|
218 | + throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
219 | + } |
|
220 | 220 | |
221 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
222 | - } |
|
221 | + do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
222 | + } |
|
223 | 223 | |
224 | 224 | /** |
225 | - * Returns the payment form. |
|
226 | - * |
|
227 | - * @since 1.0.19 |
|
228 | - * @return GetPaid_Payment_Form |
|
229 | - */ |
|
230 | - public function get_payment_form() { |
|
231 | - return $this->payment_form; |
|
232 | - } |
|
225 | + * Returns the payment form. |
|
226 | + * |
|
227 | + * @since 1.0.19 |
|
228 | + * @return GetPaid_Payment_Form |
|
229 | + */ |
|
230 | + public function get_payment_form() { |
|
231 | + return $this->payment_form; |
|
232 | + } |
|
233 | 233 | |
234 | - /* |
|
234 | + /* |
|
235 | 235 | |-------------------------------------------------------------------------- |
236 | 236 | | Invoices. |
237 | 237 | |-------------------------------------------------------------------------- |
@@ -240,61 +240,61 @@ discard block |
||
240 | 240 | | might be for an existing invoice. |
241 | 241 | */ |
242 | 242 | |
243 | - /** |
|
244 | - * Prepares the submission's invoice. |
|
245 | - * |
|
246 | - * @since 1.0.19 |
|
247 | - */ |
|
248 | - public function process_invoice() { |
|
243 | + /** |
|
244 | + * Prepares the submission's invoice. |
|
245 | + * |
|
246 | + * @since 1.0.19 |
|
247 | + */ |
|
248 | + public function process_invoice() { |
|
249 | 249 | |
250 | - // Abort if there is no invoice. |
|
251 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
252 | - return; |
|
253 | - } |
|
250 | + // Abort if there is no invoice. |
|
251 | + if ( empty( $this->data['invoice_id'] ) ) { |
|
252 | + return; |
|
253 | + } |
|
254 | 254 | |
255 | - // If the submission is for an existing invoice, ensure that it exists |
|
256 | - // and that it is not paid for. |
|
257 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
255 | + // If the submission is for an existing invoice, ensure that it exists |
|
256 | + // and that it is not paid for. |
|
257 | + $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
258 | 258 | |
259 | 259 | if ( empty( $invoice ) ) { |
260 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
261 | - } |
|
262 | - |
|
263 | - if ( $invoice->is_paid() ) { |
|
264 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
265 | - } |
|
266 | - |
|
267 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
268 | - $this->payment_form->invoice = $invoice; |
|
269 | - |
|
270 | - $this->country = $invoice->get_country(); |
|
271 | - $this->state = $invoice->get_state(); |
|
272 | - $this->invoice = $invoice; |
|
273 | - |
|
274 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
275 | - } |
|
276 | - |
|
277 | - /** |
|
278 | - * Returns the associated invoice. |
|
279 | - * |
|
280 | - * @since 1.0.19 |
|
281 | - * @return WPInv_Invoice |
|
282 | - */ |
|
283 | - public function get_invoice() { |
|
284 | - return $this->invoice; |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * Checks whether there is an invoice associated with this submission. |
|
289 | - * |
|
290 | - * @since 1.0.19 |
|
291 | - * @return bool |
|
292 | - */ |
|
293 | - public function has_invoice() { |
|
294 | - return ! empty( $this->invoice ); |
|
295 | - } |
|
296 | - |
|
297 | - /* |
|
260 | + throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
261 | + } |
|
262 | + |
|
263 | + if ( $invoice->is_paid() ) { |
|
264 | + throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
265 | + } |
|
266 | + |
|
267 | + $this->payment_form->set_items( $invoice->get_items() ); |
|
268 | + $this->payment_form->invoice = $invoice; |
|
269 | + |
|
270 | + $this->country = $invoice->get_country(); |
|
271 | + $this->state = $invoice->get_state(); |
|
272 | + $this->invoice = $invoice; |
|
273 | + |
|
274 | + do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
275 | + } |
|
276 | + |
|
277 | + /** |
|
278 | + * Returns the associated invoice. |
|
279 | + * |
|
280 | + * @since 1.0.19 |
|
281 | + * @return WPInv_Invoice |
|
282 | + */ |
|
283 | + public function get_invoice() { |
|
284 | + return $this->invoice; |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * Checks whether there is an invoice associated with this submission. |
|
289 | + * |
|
290 | + * @since 1.0.19 |
|
291 | + * @return bool |
|
292 | + */ |
|
293 | + public function has_invoice() { |
|
294 | + return ! empty( $this->invoice ); |
|
295 | + } |
|
296 | + |
|
297 | + /* |
|
298 | 298 | |-------------------------------------------------------------------------- |
299 | 299 | | Items. |
300 | 300 | |-------------------------------------------------------------------------- |
@@ -303,115 +303,115 @@ discard block |
||
303 | 303 | | recurring item. But can have an unlimited number of non-recurring items. |
304 | 304 | */ |
305 | 305 | |
306 | - /** |
|
307 | - * Prepares the submission's items. |
|
308 | - * |
|
309 | - * @since 1.0.19 |
|
310 | - */ |
|
311 | - public function process_items() { |
|
312 | - |
|
313 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
314 | - |
|
315 | - foreach ( $processor->items as $item ) { |
|
316 | - $this->add_item( $item ); |
|
317 | - } |
|
318 | - |
|
319 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
320 | - } |
|
321 | - |
|
322 | - /** |
|
323 | - * Adds an item to the submission. |
|
324 | - * |
|
325 | - * @since 1.0.19 |
|
326 | - * @param GetPaid_Form_Item $item |
|
327 | - */ |
|
328 | - public function add_item( $item ) { |
|
329 | - |
|
330 | - // Make sure that it is available for purchase. |
|
331 | - if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
332 | - return; |
|
333 | - } |
|
334 | - |
|
335 | - // Each submission can only contain one recurring item. |
|
336 | - if ( $item->is_recurring() ) { |
|
337 | - |
|
338 | - if ( $this->has_recurring != 0 ) { |
|
339 | - throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) ); |
|
340 | - } |
|
341 | - |
|
342 | - $this->has_recurring = $item->get_id(); |
|
343 | - |
|
344 | - } |
|
345 | - |
|
346 | - // Update the items and totals. |
|
347 | - $this->items[ $item->get_id() ] = $item; |
|
348 | - $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
|
349 | - $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
|
350 | - |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Removes a specific item. |
|
355 | - * |
|
356 | - * You should not call this method after the discounts and taxes |
|
357 | - * have been calculated. |
|
358 | - * |
|
359 | - * @since 1.0.19 |
|
360 | - */ |
|
361 | - public function remove_item( $item_id ) { |
|
362 | - |
|
363 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
364 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
365 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
366 | - |
|
367 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
368 | - $this->has_recurring = 0; |
|
369 | - } |
|
370 | - |
|
371 | - unset( $this->items[ $item_id ] ); |
|
372 | - } |
|
373 | - |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Returns the subtotal. |
|
378 | - * |
|
379 | - * @since 1.0.19 |
|
380 | - */ |
|
381 | - public function get_subtotal() { |
|
382 | - |
|
383 | - if ( wpinv_prices_include_tax() ) { |
|
384 | - return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
|
385 | - } |
|
386 | - |
|
387 | - return $this->totals['subtotal']['initial']; |
|
388 | - } |
|
389 | - |
|
390 | - /** |
|
391 | - * Returns the recurring subtotal. |
|
392 | - * |
|
393 | - * @since 1.0.19 |
|
394 | - */ |
|
395 | - public function get_recurring_subtotal() { |
|
396 | - |
|
397 | - if ( wpinv_prices_include_tax() ) { |
|
398 | - return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
|
399 | - } |
|
400 | - |
|
401 | - return $this->totals['subtotal']['recurring']; |
|
402 | - } |
|
403 | - |
|
404 | - /** |
|
405 | - * Returns all items. |
|
406 | - * |
|
407 | - * @since 1.0.19 |
|
408 | - * @return GetPaid_Form_Item[] |
|
409 | - */ |
|
410 | - public function get_items() { |
|
411 | - return $this->items; |
|
412 | - } |
|
413 | - |
|
414 | - /* |
|
306 | + /** |
|
307 | + * Prepares the submission's items. |
|
308 | + * |
|
309 | + * @since 1.0.19 |
|
310 | + */ |
|
311 | + public function process_items() { |
|
312 | + |
|
313 | + $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
314 | + |
|
315 | + foreach ( $processor->items as $item ) { |
|
316 | + $this->add_item( $item ); |
|
317 | + } |
|
318 | + |
|
319 | + do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
320 | + } |
|
321 | + |
|
322 | + /** |
|
323 | + * Adds an item to the submission. |
|
324 | + * |
|
325 | + * @since 1.0.19 |
|
326 | + * @param GetPaid_Form_Item $item |
|
327 | + */ |
|
328 | + public function add_item( $item ) { |
|
329 | + |
|
330 | + // Make sure that it is available for purchase. |
|
331 | + if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
332 | + return; |
|
333 | + } |
|
334 | + |
|
335 | + // Each submission can only contain one recurring item. |
|
336 | + if ( $item->is_recurring() ) { |
|
337 | + |
|
338 | + if ( $this->has_recurring != 0 ) { |
|
339 | + throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) ); |
|
340 | + } |
|
341 | + |
|
342 | + $this->has_recurring = $item->get_id(); |
|
343 | + |
|
344 | + } |
|
345 | + |
|
346 | + // Update the items and totals. |
|
347 | + $this->items[ $item->get_id() ] = $item; |
|
348 | + $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
|
349 | + $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
|
350 | + |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * Removes a specific item. |
|
355 | + * |
|
356 | + * You should not call this method after the discounts and taxes |
|
357 | + * have been calculated. |
|
358 | + * |
|
359 | + * @since 1.0.19 |
|
360 | + */ |
|
361 | + public function remove_item( $item_id ) { |
|
362 | + |
|
363 | + if ( isset( $this->items[ $item_id ] ) ) { |
|
364 | + $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
365 | + $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
366 | + |
|
367 | + if ( $this->items[ $item_id ]->is_recurring() ) { |
|
368 | + $this->has_recurring = 0; |
|
369 | + } |
|
370 | + |
|
371 | + unset( $this->items[ $item_id ] ); |
|
372 | + } |
|
373 | + |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Returns the subtotal. |
|
378 | + * |
|
379 | + * @since 1.0.19 |
|
380 | + */ |
|
381 | + public function get_subtotal() { |
|
382 | + |
|
383 | + if ( wpinv_prices_include_tax() ) { |
|
384 | + return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
|
385 | + } |
|
386 | + |
|
387 | + return $this->totals['subtotal']['initial']; |
|
388 | + } |
|
389 | + |
|
390 | + /** |
|
391 | + * Returns the recurring subtotal. |
|
392 | + * |
|
393 | + * @since 1.0.19 |
|
394 | + */ |
|
395 | + public function get_recurring_subtotal() { |
|
396 | + |
|
397 | + if ( wpinv_prices_include_tax() ) { |
|
398 | + return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
|
399 | + } |
|
400 | + |
|
401 | + return $this->totals['subtotal']['recurring']; |
|
402 | + } |
|
403 | + |
|
404 | + /** |
|
405 | + * Returns all items. |
|
406 | + * |
|
407 | + * @since 1.0.19 |
|
408 | + * @return GetPaid_Form_Item[] |
|
409 | + */ |
|
410 | + public function get_items() { |
|
411 | + return $this->items; |
|
412 | + } |
|
413 | + |
|
414 | + /* |
|
415 | 415 | |-------------------------------------------------------------------------- |
416 | 416 | | Taxes |
417 | 417 | |-------------------------------------------------------------------------- |
@@ -420,128 +420,128 @@ discard block |
||
420 | 420 | | or only one-time. |
421 | 421 | */ |
422 | 422 | |
423 | - /** |
|
424 | - * Prepares the submission's taxes. |
|
425 | - * |
|
426 | - * @since 1.0.19 |
|
427 | - */ |
|
428 | - public function process_taxes() { |
|
429 | - |
|
430 | - // Abort if we're not using taxes. |
|
431 | - if ( ! $this->use_taxes() ) { |
|
432 | - return; |
|
433 | - } |
|
434 | - |
|
435 | - // If a custom country && state has been passed in, use it to calculate taxes. |
|
436 | - $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
437 | - if ( ! empty( $country ) ) { |
|
438 | - $this->country = $country; |
|
439 | - } |
|
440 | - |
|
441 | - $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
442 | - if ( ! empty( $state ) ) { |
|
443 | - $this->state = $state; |
|
444 | - } |
|
445 | - |
|
446 | - // Confirm if the provided country and the ip country are similar. |
|
447 | - $address_confirmed = $this->get_field( 'confirm-address' ); |
|
448 | - if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) { |
|
449 | - throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) ); |
|
450 | - } |
|
451 | - |
|
452 | - // Abort if the country is not taxable. |
|
453 | - if ( ! wpinv_is_country_taxable( $this->country ) ) { |
|
454 | - return; |
|
455 | - } |
|
456 | - |
|
457 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
458 | - |
|
459 | - foreach ( $processor->taxes as $tax ) { |
|
460 | - $this->add_tax( $tax ); |
|
461 | - } |
|
462 | - |
|
463 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
464 | - } |
|
465 | - |
|
466 | - /** |
|
467 | - * Adds a tax to the submission. |
|
468 | - * |
|
469 | - * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
|
470 | - * @since 1.0.19 |
|
471 | - */ |
|
472 | - public function add_tax( $tax ) { |
|
473 | - |
|
474 | - if ( wpinv_round_tax_per_tax_rate() ) { |
|
475 | - $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
476 | - $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
477 | - } |
|
478 | - |
|
479 | - $this->taxes[ $tax['name'] ] = $tax; |
|
480 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
481 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
482 | - |
|
483 | - } |
|
484 | - |
|
485 | - /** |
|
486 | - * Removes a specific tax. |
|
487 | - * |
|
488 | - * @since 1.0.19 |
|
489 | - */ |
|
490 | - public function remove_tax( $tax_name ) { |
|
491 | - |
|
492 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
493 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
494 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
495 | - unset( $this->taxes[ $tax_name ] ); |
|
496 | - } |
|
497 | - |
|
498 | - } |
|
499 | - |
|
500 | - /** |
|
501 | - * Whether or not we'll use taxes for the submission. |
|
502 | - * |
|
503 | - * @since 1.0.19 |
|
504 | - */ |
|
505 | - public function use_taxes() { |
|
506 | - |
|
507 | - $use_taxes = wpinv_use_taxes(); |
|
508 | - |
|
509 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
510 | - $use_taxes = false; |
|
511 | - } |
|
512 | - |
|
513 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
514 | - |
|
515 | - } |
|
516 | - |
|
517 | - /** |
|
518 | - * Returns the tax. |
|
519 | - * |
|
520 | - * @since 1.0.19 |
|
521 | - */ |
|
522 | - public function get_tax() { |
|
523 | - return $this->totals['taxes']['initial']; |
|
524 | - } |
|
525 | - |
|
526 | - /** |
|
527 | - * Returns the recurring tax. |
|
528 | - * |
|
529 | - * @since 1.0.19 |
|
530 | - */ |
|
531 | - public function get_recurring_tax() { |
|
532 | - return $this->totals['taxes']['recurring']; |
|
533 | - } |
|
534 | - |
|
535 | - /** |
|
536 | - * Returns all taxes. |
|
537 | - * |
|
538 | - * @since 1.0.19 |
|
539 | - */ |
|
540 | - public function get_taxes() { |
|
541 | - return $this->taxes; |
|
542 | - } |
|
543 | - |
|
544 | - /* |
|
423 | + /** |
|
424 | + * Prepares the submission's taxes. |
|
425 | + * |
|
426 | + * @since 1.0.19 |
|
427 | + */ |
|
428 | + public function process_taxes() { |
|
429 | + |
|
430 | + // Abort if we're not using taxes. |
|
431 | + if ( ! $this->use_taxes() ) { |
|
432 | + return; |
|
433 | + } |
|
434 | + |
|
435 | + // If a custom country && state has been passed in, use it to calculate taxes. |
|
436 | + $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
437 | + if ( ! empty( $country ) ) { |
|
438 | + $this->country = $country; |
|
439 | + } |
|
440 | + |
|
441 | + $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
442 | + if ( ! empty( $state ) ) { |
|
443 | + $this->state = $state; |
|
444 | + } |
|
445 | + |
|
446 | + // Confirm if the provided country and the ip country are similar. |
|
447 | + $address_confirmed = $this->get_field( 'confirm-address' ); |
|
448 | + if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) { |
|
449 | + throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) ); |
|
450 | + } |
|
451 | + |
|
452 | + // Abort if the country is not taxable. |
|
453 | + if ( ! wpinv_is_country_taxable( $this->country ) ) { |
|
454 | + return; |
|
455 | + } |
|
456 | + |
|
457 | + $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
458 | + |
|
459 | + foreach ( $processor->taxes as $tax ) { |
|
460 | + $this->add_tax( $tax ); |
|
461 | + } |
|
462 | + |
|
463 | + do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
464 | + } |
|
465 | + |
|
466 | + /** |
|
467 | + * Adds a tax to the submission. |
|
468 | + * |
|
469 | + * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
|
470 | + * @since 1.0.19 |
|
471 | + */ |
|
472 | + public function add_tax( $tax ) { |
|
473 | + |
|
474 | + if ( wpinv_round_tax_per_tax_rate() ) { |
|
475 | + $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
476 | + $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
477 | + } |
|
478 | + |
|
479 | + $this->taxes[ $tax['name'] ] = $tax; |
|
480 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
481 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
482 | + |
|
483 | + } |
|
484 | + |
|
485 | + /** |
|
486 | + * Removes a specific tax. |
|
487 | + * |
|
488 | + * @since 1.0.19 |
|
489 | + */ |
|
490 | + public function remove_tax( $tax_name ) { |
|
491 | + |
|
492 | + if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
493 | + $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
494 | + $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
495 | + unset( $this->taxes[ $tax_name ] ); |
|
496 | + } |
|
497 | + |
|
498 | + } |
|
499 | + |
|
500 | + /** |
|
501 | + * Whether or not we'll use taxes for the submission. |
|
502 | + * |
|
503 | + * @since 1.0.19 |
|
504 | + */ |
|
505 | + public function use_taxes() { |
|
506 | + |
|
507 | + $use_taxes = wpinv_use_taxes(); |
|
508 | + |
|
509 | + if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
510 | + $use_taxes = false; |
|
511 | + } |
|
512 | + |
|
513 | + return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
514 | + |
|
515 | + } |
|
516 | + |
|
517 | + /** |
|
518 | + * Returns the tax. |
|
519 | + * |
|
520 | + * @since 1.0.19 |
|
521 | + */ |
|
522 | + public function get_tax() { |
|
523 | + return $this->totals['taxes']['initial']; |
|
524 | + } |
|
525 | + |
|
526 | + /** |
|
527 | + * Returns the recurring tax. |
|
528 | + * |
|
529 | + * @since 1.0.19 |
|
530 | + */ |
|
531 | + public function get_recurring_tax() { |
|
532 | + return $this->totals['taxes']['recurring']; |
|
533 | + } |
|
534 | + |
|
535 | + /** |
|
536 | + * Returns all taxes. |
|
537 | + * |
|
538 | + * @since 1.0.19 |
|
539 | + */ |
|
540 | + public function get_taxes() { |
|
541 | + return $this->taxes; |
|
542 | + } |
|
543 | + |
|
544 | + /* |
|
545 | 545 | |-------------------------------------------------------------------------- |
546 | 546 | | Discounts |
547 | 547 | |-------------------------------------------------------------------------- |
@@ -550,99 +550,99 @@ discard block |
||
550 | 550 | | or only one-time. They also do not have to come from a discount code. |
551 | 551 | */ |
552 | 552 | |
553 | - /** |
|
554 | - * Prepares the submission's discount. |
|
555 | - * |
|
556 | - * @since 1.0.19 |
|
557 | - */ |
|
558 | - public function process_discount() { |
|
559 | - |
|
560 | - $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
|
561 | - $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
|
562 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
563 | - |
|
564 | - foreach ( $processor->discounts as $discount ) { |
|
565 | - $this->add_discount( $discount ); |
|
566 | - } |
|
567 | - |
|
568 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
569 | - } |
|
570 | - |
|
571 | - /** |
|
572 | - * Adds a discount to the submission. |
|
573 | - * |
|
574 | - * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
575 | - * @since 1.0.19 |
|
576 | - */ |
|
577 | - public function add_discount( $discount ) { |
|
578 | - $this->discounts[ $discount['name'] ] = $discount; |
|
579 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
580 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
581 | - } |
|
582 | - |
|
583 | - /** |
|
584 | - * Removes a discount from the submission. |
|
585 | - * |
|
586 | - * @since 1.0.19 |
|
587 | - */ |
|
588 | - public function remove_discount( $name ) { |
|
589 | - |
|
590 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
591 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
592 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
593 | - unset( $this->discounts[ $name ] ); |
|
594 | - } |
|
595 | - |
|
596 | - } |
|
597 | - |
|
598 | - /** |
|
599 | - * Checks whether there is a discount code associated with this submission. |
|
600 | - * |
|
601 | - * @since 1.0.19 |
|
602 | - * @return bool |
|
603 | - */ |
|
604 | - public function has_discount_code() { |
|
605 | - return ! empty( $this->discounts['discount_code'] ); |
|
606 | - } |
|
607 | - |
|
608 | - /** |
|
609 | - * Returns the discount code. |
|
610 | - * |
|
611 | - * @since 1.0.19 |
|
612 | - * @return string |
|
613 | - */ |
|
614 | - public function get_discount_code() { |
|
615 | - return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : ''; |
|
616 | - } |
|
617 | - |
|
618 | - /** |
|
619 | - * Returns the discount. |
|
620 | - * |
|
621 | - * @since 1.0.19 |
|
622 | - */ |
|
623 | - public function get_discount() { |
|
624 | - return $this->totals['discount']['initial']; |
|
625 | - } |
|
626 | - |
|
627 | - /** |
|
628 | - * Returns the recurring discount. |
|
629 | - * |
|
630 | - * @since 1.0.19 |
|
631 | - */ |
|
632 | - public function get_recurring_discount() { |
|
633 | - return $this->totals['discount']['recurring']; |
|
634 | - } |
|
635 | - |
|
636 | - /** |
|
637 | - * Returns all discounts. |
|
638 | - * |
|
639 | - * @since 1.0.19 |
|
640 | - */ |
|
641 | - public function get_discounts() { |
|
642 | - return $this->discounts; |
|
643 | - } |
|
644 | - |
|
645 | - /* |
|
553 | + /** |
|
554 | + * Prepares the submission's discount. |
|
555 | + * |
|
556 | + * @since 1.0.19 |
|
557 | + */ |
|
558 | + public function process_discount() { |
|
559 | + |
|
560 | + $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
|
561 | + $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
|
562 | + $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
563 | + |
|
564 | + foreach ( $processor->discounts as $discount ) { |
|
565 | + $this->add_discount( $discount ); |
|
566 | + } |
|
567 | + |
|
568 | + do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
569 | + } |
|
570 | + |
|
571 | + /** |
|
572 | + * Adds a discount to the submission. |
|
573 | + * |
|
574 | + * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
|
575 | + * @since 1.0.19 |
|
576 | + */ |
|
577 | + public function add_discount( $discount ) { |
|
578 | + $this->discounts[ $discount['name'] ] = $discount; |
|
579 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
580 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
581 | + } |
|
582 | + |
|
583 | + /** |
|
584 | + * Removes a discount from the submission. |
|
585 | + * |
|
586 | + * @since 1.0.19 |
|
587 | + */ |
|
588 | + public function remove_discount( $name ) { |
|
589 | + |
|
590 | + if ( isset( $this->discounts[ $name ] ) ) { |
|
591 | + $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
592 | + $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
593 | + unset( $this->discounts[ $name ] ); |
|
594 | + } |
|
595 | + |
|
596 | + } |
|
597 | + |
|
598 | + /** |
|
599 | + * Checks whether there is a discount code associated with this submission. |
|
600 | + * |
|
601 | + * @since 1.0.19 |
|
602 | + * @return bool |
|
603 | + */ |
|
604 | + public function has_discount_code() { |
|
605 | + return ! empty( $this->discounts['discount_code'] ); |
|
606 | + } |
|
607 | + |
|
608 | + /** |
|
609 | + * Returns the discount code. |
|
610 | + * |
|
611 | + * @since 1.0.19 |
|
612 | + * @return string |
|
613 | + */ |
|
614 | + public function get_discount_code() { |
|
615 | + return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : ''; |
|
616 | + } |
|
617 | + |
|
618 | + /** |
|
619 | + * Returns the discount. |
|
620 | + * |
|
621 | + * @since 1.0.19 |
|
622 | + */ |
|
623 | + public function get_discount() { |
|
624 | + return $this->totals['discount']['initial']; |
|
625 | + } |
|
626 | + |
|
627 | + /** |
|
628 | + * Returns the recurring discount. |
|
629 | + * |
|
630 | + * @since 1.0.19 |
|
631 | + */ |
|
632 | + public function get_recurring_discount() { |
|
633 | + return $this->totals['discount']['recurring']; |
|
634 | + } |
|
635 | + |
|
636 | + /** |
|
637 | + * Returns all discounts. |
|
638 | + * |
|
639 | + * @since 1.0.19 |
|
640 | + */ |
|
641 | + public function get_discounts() { |
|
642 | + return $this->discounts; |
|
643 | + } |
|
644 | + |
|
645 | + /* |
|
646 | 646 | |-------------------------------------------------------------------------- |
647 | 647 | | Fees |
648 | 648 | |-------------------------------------------------------------------------- |
@@ -652,89 +652,89 @@ discard block |
||
652 | 652 | | fees. |
653 | 653 | */ |
654 | 654 | |
655 | - /** |
|
656 | - * Prepares the submission's fees. |
|
657 | - * |
|
658 | - * @since 1.0.19 |
|
659 | - */ |
|
660 | - public function process_fees() { |
|
661 | - |
|
662 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
663 | - |
|
664 | - foreach ( $fees_processor->fees as $fee ) { |
|
665 | - $this->add_fee( $fee ); |
|
666 | - } |
|
667 | - |
|
668 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
669 | - } |
|
670 | - |
|
671 | - /** |
|
672 | - * Adds a fee to the submission. |
|
673 | - * |
|
674 | - * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
675 | - * @since 1.0.19 |
|
676 | - */ |
|
677 | - public function add_fee( $fee ) { |
|
678 | - |
|
679 | - $this->fees[ $fee['name'] ] = $fee; |
|
680 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
681 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
682 | - |
|
683 | - } |
|
684 | - |
|
685 | - /** |
|
686 | - * Removes a fee from the submission. |
|
687 | - * |
|
688 | - * @since 1.0.19 |
|
689 | - */ |
|
690 | - public function remove_fee( $name ) { |
|
691 | - |
|
692 | - if ( isset( $this->fees[ $name ] ) ) { |
|
693 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
694 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
695 | - unset( $this->fees[ $name ] ); |
|
696 | - } |
|
697 | - |
|
698 | - } |
|
699 | - |
|
700 | - /** |
|
701 | - * Returns the fees. |
|
702 | - * |
|
703 | - * @since 1.0.19 |
|
704 | - */ |
|
705 | - public function get_fee() { |
|
706 | - return $this->totals['fees']['initial']; |
|
707 | - } |
|
708 | - |
|
709 | - /** |
|
710 | - * Returns the recurring fees. |
|
711 | - * |
|
712 | - * @since 1.0.19 |
|
713 | - */ |
|
714 | - public function get_recurring_fee() { |
|
715 | - return $this->totals['fees']['recurring']; |
|
716 | - } |
|
717 | - |
|
718 | - /** |
|
719 | - * Returns all fees. |
|
720 | - * |
|
721 | - * @since 1.0.19 |
|
722 | - */ |
|
723 | - public function get_fees() { |
|
724 | - return $this->fees; |
|
725 | - } |
|
726 | - |
|
727 | - /** |
|
728 | - * Checks if there are any fees for the form. |
|
729 | - * |
|
730 | - * @return bool |
|
731 | - * @since 1.0.19 |
|
732 | - */ |
|
733 | - public function has_fees() { |
|
734 | - return count( $this->fees ) !== 0; |
|
735 | - } |
|
736 | - |
|
737 | - /* |
|
655 | + /** |
|
656 | + * Prepares the submission's fees. |
|
657 | + * |
|
658 | + * @since 1.0.19 |
|
659 | + */ |
|
660 | + public function process_fees() { |
|
661 | + |
|
662 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
663 | + |
|
664 | + foreach ( $fees_processor->fees as $fee ) { |
|
665 | + $this->add_fee( $fee ); |
|
666 | + } |
|
667 | + |
|
668 | + do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
669 | + } |
|
670 | + |
|
671 | + /** |
|
672 | + * Adds a fee to the submission. |
|
673 | + * |
|
674 | + * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
|
675 | + * @since 1.0.19 |
|
676 | + */ |
|
677 | + public function add_fee( $fee ) { |
|
678 | + |
|
679 | + $this->fees[ $fee['name'] ] = $fee; |
|
680 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
681 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
682 | + |
|
683 | + } |
|
684 | + |
|
685 | + /** |
|
686 | + * Removes a fee from the submission. |
|
687 | + * |
|
688 | + * @since 1.0.19 |
|
689 | + */ |
|
690 | + public function remove_fee( $name ) { |
|
691 | + |
|
692 | + if ( isset( $this->fees[ $name ] ) ) { |
|
693 | + $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
694 | + $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
695 | + unset( $this->fees[ $name ] ); |
|
696 | + } |
|
697 | + |
|
698 | + } |
|
699 | + |
|
700 | + /** |
|
701 | + * Returns the fees. |
|
702 | + * |
|
703 | + * @since 1.0.19 |
|
704 | + */ |
|
705 | + public function get_fee() { |
|
706 | + return $this->totals['fees']['initial']; |
|
707 | + } |
|
708 | + |
|
709 | + /** |
|
710 | + * Returns the recurring fees. |
|
711 | + * |
|
712 | + * @since 1.0.19 |
|
713 | + */ |
|
714 | + public function get_recurring_fee() { |
|
715 | + return $this->totals['fees']['recurring']; |
|
716 | + } |
|
717 | + |
|
718 | + /** |
|
719 | + * Returns all fees. |
|
720 | + * |
|
721 | + * @since 1.0.19 |
|
722 | + */ |
|
723 | + public function get_fees() { |
|
724 | + return $this->fees; |
|
725 | + } |
|
726 | + |
|
727 | + /** |
|
728 | + * Checks if there are any fees for the form. |
|
729 | + * |
|
730 | + * @return bool |
|
731 | + * @since 1.0.19 |
|
732 | + */ |
|
733 | + public function has_fees() { |
|
734 | + return count( $this->fees ) !== 0; |
|
735 | + } |
|
736 | + |
|
737 | + /* |
|
738 | 738 | |-------------------------------------------------------------------------- |
739 | 739 | | MISC |
740 | 740 | |-------------------------------------------------------------------------- |
@@ -742,119 +742,119 @@ discard block |
||
742 | 742 | | Extra submission functions. |
743 | 743 | */ |
744 | 744 | |
745 | - /** |
|
746 | - * Checks if this is the initial fetch. |
|
747 | - * |
|
748 | - * @return bool |
|
749 | - * @since 1.0.19 |
|
750 | - */ |
|
751 | - public function is_initial_fetch() { |
|
752 | - return empty( $this->data['initial_state'] ); |
|
753 | - } |
|
754 | - |
|
755 | - /** |
|
756 | - * Returns the total amount to collect for this submission. |
|
757 | - * |
|
758 | - * @since 1.0.19 |
|
759 | - */ |
|
760 | - public function get_total() { |
|
761 | - $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
|
762 | - return max( $total, 0 ); |
|
763 | - } |
|
764 | - |
|
765 | - /** |
|
766 | - * Returns the recurring total amount to collect for this submission. |
|
767 | - * |
|
768 | - * @since 1.0.19 |
|
769 | - */ |
|
770 | - public function get_recurring_total() { |
|
771 | - $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
|
772 | - return max( $total, 0 ); |
|
773 | - } |
|
774 | - |
|
775 | - /** |
|
776 | - * Whether payment details should be collected for this submission. |
|
777 | - * |
|
778 | - * @since 1.0.19 |
|
779 | - */ |
|
780 | - public function should_collect_payment_details() { |
|
781 | - $initial = $this->get_total(); |
|
782 | - $recurring = $this->get_recurring_total(); |
|
783 | - |
|
784 | - if ( $this->has_recurring == 0 ) { |
|
785 | - $recurring = 0; |
|
786 | - } |
|
787 | - |
|
788 | - $collect = $initial > 0 || $recurring > 0; |
|
789 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
790 | - } |
|
791 | - |
|
792 | - /** |
|
793 | - * Returns the billing email of the user. |
|
794 | - * |
|
795 | - * @since 1.0.19 |
|
796 | - */ |
|
797 | - public function get_billing_email() { |
|
798 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
799 | - } |
|
800 | - |
|
801 | - /** |
|
802 | - * Checks if the submitter has a billing email. |
|
803 | - * |
|
804 | - * @since 1.0.19 |
|
805 | - */ |
|
806 | - public function has_billing_email() { |
|
807 | - $billing_email = $this->get_billing_email(); |
|
808 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
809 | - } |
|
810 | - |
|
811 | - /** |
|
812 | - * Returns the appropriate currency for the submission. |
|
813 | - * |
|
814 | - * @since 1.0.19 |
|
815 | - * @return string |
|
816 | - */ |
|
817 | - public function get_currency() { |
|
818 | - return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency(); |
|
819 | - } |
|
820 | - |
|
821 | - /** |
|
822 | - * Returns the raw submission data. |
|
823 | - * |
|
824 | - * @since 1.0.19 |
|
825 | - * @return array |
|
826 | - */ |
|
827 | - public function get_data() { |
|
828 | - return $this->data; |
|
829 | - } |
|
830 | - |
|
831 | - /** |
|
832 | - * Returns a field from the submission data |
|
833 | - * |
|
834 | - * @param string $field |
|
835 | - * @since 1.0.19 |
|
836 | - * @return mixed|null |
|
837 | - */ |
|
838 | - public function get_field( $field, $sub_array_key = null ) { |
|
839 | - return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
840 | - } |
|
841 | - |
|
842 | - /** |
|
843 | - * Checks if a required field is set. |
|
844 | - * |
|
845 | - * @since 1.0.19 |
|
846 | - */ |
|
847 | - public function is_required_field_set( $field ) { |
|
848 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
849 | - } |
|
850 | - |
|
851 | - /** |
|
852 | - * Formats an amount |
|
853 | - * |
|
854 | - * @since 1.0.19 |
|
855 | - */ |
|
856 | - public function format_amount( $amount ) { |
|
857 | - return wpinv_price( $amount, $this->get_currency() ); |
|
858 | - } |
|
745 | + /** |
|
746 | + * Checks if this is the initial fetch. |
|
747 | + * |
|
748 | + * @return bool |
|
749 | + * @since 1.0.19 |
|
750 | + */ |
|
751 | + public function is_initial_fetch() { |
|
752 | + return empty( $this->data['initial_state'] ); |
|
753 | + } |
|
754 | + |
|
755 | + /** |
|
756 | + * Returns the total amount to collect for this submission. |
|
757 | + * |
|
758 | + * @since 1.0.19 |
|
759 | + */ |
|
760 | + public function get_total() { |
|
761 | + $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
|
762 | + return max( $total, 0 ); |
|
763 | + } |
|
764 | + |
|
765 | + /** |
|
766 | + * Returns the recurring total amount to collect for this submission. |
|
767 | + * |
|
768 | + * @since 1.0.19 |
|
769 | + */ |
|
770 | + public function get_recurring_total() { |
|
771 | + $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
|
772 | + return max( $total, 0 ); |
|
773 | + } |
|
774 | + |
|
775 | + /** |
|
776 | + * Whether payment details should be collected for this submission. |
|
777 | + * |
|
778 | + * @since 1.0.19 |
|
779 | + */ |
|
780 | + public function should_collect_payment_details() { |
|
781 | + $initial = $this->get_total(); |
|
782 | + $recurring = $this->get_recurring_total(); |
|
783 | + |
|
784 | + if ( $this->has_recurring == 0 ) { |
|
785 | + $recurring = 0; |
|
786 | + } |
|
787 | + |
|
788 | + $collect = $initial > 0 || $recurring > 0; |
|
789 | + return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
790 | + } |
|
791 | + |
|
792 | + /** |
|
793 | + * Returns the billing email of the user. |
|
794 | + * |
|
795 | + * @since 1.0.19 |
|
796 | + */ |
|
797 | + public function get_billing_email() { |
|
798 | + return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
799 | + } |
|
800 | + |
|
801 | + /** |
|
802 | + * Checks if the submitter has a billing email. |
|
803 | + * |
|
804 | + * @since 1.0.19 |
|
805 | + */ |
|
806 | + public function has_billing_email() { |
|
807 | + $billing_email = $this->get_billing_email(); |
|
808 | + return ! empty( $billing_email ) && is_email( $billing_email ); |
|
809 | + } |
|
810 | + |
|
811 | + /** |
|
812 | + * Returns the appropriate currency for the submission. |
|
813 | + * |
|
814 | + * @since 1.0.19 |
|
815 | + * @return string |
|
816 | + */ |
|
817 | + public function get_currency() { |
|
818 | + return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency(); |
|
819 | + } |
|
820 | + |
|
821 | + /** |
|
822 | + * Returns the raw submission data. |
|
823 | + * |
|
824 | + * @since 1.0.19 |
|
825 | + * @return array |
|
826 | + */ |
|
827 | + public function get_data() { |
|
828 | + return $this->data; |
|
829 | + } |
|
830 | + |
|
831 | + /** |
|
832 | + * Returns a field from the submission data |
|
833 | + * |
|
834 | + * @param string $field |
|
835 | + * @since 1.0.19 |
|
836 | + * @return mixed|null |
|
837 | + */ |
|
838 | + public function get_field( $field, $sub_array_key = null ) { |
|
839 | + return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
840 | + } |
|
841 | + |
|
842 | + /** |
|
843 | + * Checks if a required field is set. |
|
844 | + * |
|
845 | + * @since 1.0.19 |
|
846 | + */ |
|
847 | + public function is_required_field_set( $field ) { |
|
848 | + return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
849 | + } |
|
850 | + |
|
851 | + /** |
|
852 | + * Formats an amount |
|
853 | + * |
|
854 | + * @since 1.0.19 |
|
855 | + */ |
|
856 | + public function format_amount( $amount ) { |
|
857 | + return wpinv_price( $amount, $this->get_currency() ); |
|
858 | + } |
|
859 | 859 | |
860 | 860 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -134,8 +134,8 @@ discard block |
||
134 | 134 | $this->state = wpinv_get_default_state(); |
135 | 135 | |
136 | 136 | // Do we have an actual submission? |
137 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
138 | - $this->load_data( $_POST ); |
|
137 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
138 | + $this->load_data($_POST); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | } |
@@ -145,19 +145,19 @@ discard block |
||
145 | 145 | * |
146 | 146 | * @param array $data |
147 | 147 | */ |
148 | - public function load_data( $data ) { |
|
148 | + public function load_data($data) { |
|
149 | 149 | |
150 | 150 | // Remove slashes from the submitted data... |
151 | - $data = wp_unslash( $data ); |
|
151 | + $data = wp_unslash($data); |
|
152 | 152 | |
153 | 153 | // Allow plugins to filter the data. |
154 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
154 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
155 | 155 | |
156 | 156 | // Cache it... |
157 | 157 | $this->data = $data; |
158 | 158 | |
159 | 159 | // Then generate a unique id from the data. |
160 | - $this->id = md5( wp_json_encode( $data ) ); |
|
160 | + $this->id = md5(wp_json_encode($data)); |
|
161 | 161 | |
162 | 162 | // Finally, process the submission. |
163 | 163 | try { |
@@ -167,26 +167,26 @@ discard block |
||
167 | 167 | $processors = apply_filters( |
168 | 168 | 'getpaid_payment_form_submission_processors', |
169 | 169 | array( |
170 | - array( $this, 'process_payment_form' ), |
|
171 | - array( $this, 'process_invoice' ), |
|
172 | - array( $this, 'process_fees' ), |
|
173 | - array( $this, 'process_items' ), |
|
174 | - array( $this, 'process_discount' ), |
|
175 | - array( $this, 'process_taxes' ), |
|
170 | + array($this, 'process_payment_form'), |
|
171 | + array($this, 'process_invoice'), |
|
172 | + array($this, 'process_fees'), |
|
173 | + array($this, 'process_items'), |
|
174 | + array($this, 'process_discount'), |
|
175 | + array($this, 'process_taxes'), |
|
176 | 176 | ), |
177 | 177 | $this |
178 | 178 | ); |
179 | 179 | |
180 | - foreach ( $processors as $processor ) { |
|
181 | - call_user_func_array( $processor, array( &$this ) ); |
|
180 | + foreach ($processors as $processor) { |
|
181 | + call_user_func_array($processor, array(&$this)); |
|
182 | 182 | } |
183 | 183 | |
184 | - } catch ( Exception $e ) { |
|
184 | + } catch (Exception $e) { |
|
185 | 185 | $this->last_error = $e->getMessage(); |
186 | 186 | } |
187 | 187 | |
188 | 188 | // Fired when we are done processing a submission. |
189 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
189 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
190 | 190 | |
191 | 191 | } |
192 | 192 | |
@@ -207,18 +207,18 @@ discard block |
||
207 | 207 | public function process_payment_form() { |
208 | 208 | |
209 | 209 | // Every submission needs an active payment form. |
210 | - if ( empty( $this->data['form_id'] ) ) { |
|
211 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
210 | + if (empty($this->data['form_id'])) { |
|
211 | + throw new Exception(__('Missing payment form', 'invoicing')); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | // Fetch the payment form. |
215 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
215 | + $this->payment_form = new GetPaid_Payment_Form($this->data['form_id']); |
|
216 | 216 | |
217 | - if ( ! $this->payment_form->is_active() ) { |
|
218 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
217 | + if (!$this->payment_form->is_active()) { |
|
218 | + throw new Exception(__('Payment form not active', 'invoicing')); |
|
219 | 219 | } |
220 | 220 | |
221 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
221 | + do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this)); |
|
222 | 222 | } |
223 | 223 | |
224 | 224 | /** |
@@ -248,30 +248,30 @@ discard block |
||
248 | 248 | public function process_invoice() { |
249 | 249 | |
250 | 250 | // Abort if there is no invoice. |
251 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
251 | + if (empty($this->data['invoice_id'])) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | 255 | // If the submission is for an existing invoice, ensure that it exists |
256 | 256 | // and that it is not paid for. |
257 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
257 | + $invoice = wpinv_get_invoice($this->data['invoice_id']); |
|
258 | 258 | |
259 | - if ( empty( $invoice ) ) { |
|
260 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
259 | + if (empty($invoice)) { |
|
260 | + throw new Exception(__('Invalid invoice', 'invoicing')); |
|
261 | 261 | } |
262 | 262 | |
263 | - if ( $invoice->is_paid() ) { |
|
264 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
263 | + if ($invoice->is_paid()) { |
|
264 | + throw new Exception(__('This invoice is already paid for.', 'invoicing')); |
|
265 | 265 | } |
266 | 266 | |
267 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
267 | + $this->payment_form->set_items($invoice->get_items()); |
|
268 | 268 | $this->payment_form->invoice = $invoice; |
269 | 269 | |
270 | 270 | $this->country = $invoice->get_country(); |
271 | 271 | $this->state = $invoice->get_state(); |
272 | 272 | $this->invoice = $invoice; |
273 | 273 | |
274 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
274 | + do_action_ref_array('getpaid_submissions_process_invoice', array(&$this)); |
|
275 | 275 | } |
276 | 276 | |
277 | 277 | /** |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return bool |
292 | 292 | */ |
293 | 293 | public function has_invoice() { |
294 | - return ! empty( $this->invoice ); |
|
294 | + return !empty($this->invoice); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /* |
@@ -310,13 +310,13 @@ discard block |
||
310 | 310 | */ |
311 | 311 | public function process_items() { |
312 | 312 | |
313 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
313 | + $processor = new GetPaid_Payment_Form_Submission_Items($this); |
|
314 | 314 | |
315 | - foreach ( $processor->items as $item ) { |
|
316 | - $this->add_item( $item ); |
|
315 | + foreach ($processor->items as $item) { |
|
316 | + $this->add_item($item); |
|
317 | 317 | } |
318 | 318 | |
319 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
319 | + do_action_ref_array('getpaid_submissions_process_items', array(&$this)); |
|
320 | 320 | } |
321 | 321 | |
322 | 322 | /** |
@@ -325,18 +325,18 @@ discard block |
||
325 | 325 | * @since 1.0.19 |
326 | 326 | * @param GetPaid_Form_Item $item |
327 | 327 | */ |
328 | - public function add_item( $item ) { |
|
328 | + public function add_item($item) { |
|
329 | 329 | |
330 | 330 | // Make sure that it is available for purchase. |
331 | - if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
331 | + if (!$item->can_purchase() || isset($this->items[$item->get_id()])) { |
|
332 | 332 | return; |
333 | 333 | } |
334 | 334 | |
335 | 335 | // Each submission can only contain one recurring item. |
336 | - if ( $item->is_recurring() ) { |
|
336 | + if ($item->is_recurring()) { |
|
337 | 337 | |
338 | - if ( $this->has_recurring != 0 ) { |
|
339 | - throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) ); |
|
338 | + if ($this->has_recurring != 0) { |
|
339 | + throw new Exception(__('You can only buy one recurring item at a time.', 'invoicing')); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | $this->has_recurring = $item->get_id(); |
@@ -344,7 +344,7 @@ discard block |
||
344 | 344 | } |
345 | 345 | |
346 | 346 | // Update the items and totals. |
347 | - $this->items[ $item->get_id() ] = $item; |
|
347 | + $this->items[$item->get_id()] = $item; |
|
348 | 348 | $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
349 | 349 | $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
350 | 350 | |
@@ -358,17 +358,17 @@ discard block |
||
358 | 358 | * |
359 | 359 | * @since 1.0.19 |
360 | 360 | */ |
361 | - public function remove_item( $item_id ) { |
|
361 | + public function remove_item($item_id) { |
|
362 | 362 | |
363 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
364 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
365 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
363 | + if (isset($this->items[$item_id])) { |
|
364 | + $this->totals['subtotal']['initial'] -= $this->items[$item_id]->get_sub_total(); |
|
365 | + $this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total(); |
|
366 | 366 | |
367 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
367 | + if ($this->items[$item_id]->is_recurring()) { |
|
368 | 368 | $this->has_recurring = 0; |
369 | 369 | } |
370 | 370 | |
371 | - unset( $this->items[ $item_id ] ); |
|
371 | + unset($this->items[$item_id]); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | } |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | */ |
381 | 381 | public function get_subtotal() { |
382 | 382 | |
383 | - if ( wpinv_prices_include_tax() ) { |
|
383 | + if (wpinv_prices_include_tax()) { |
|
384 | 384 | return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
385 | 385 | } |
386 | 386 | |
@@ -394,7 +394,7 @@ discard block |
||
394 | 394 | */ |
395 | 395 | public function get_recurring_subtotal() { |
396 | 396 | |
397 | - if ( wpinv_prices_include_tax() ) { |
|
397 | + if (wpinv_prices_include_tax()) { |
|
398 | 398 | return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
399 | 399 | } |
400 | 400 | |
@@ -428,39 +428,39 @@ discard block |
||
428 | 428 | public function process_taxes() { |
429 | 429 | |
430 | 430 | // Abort if we're not using taxes. |
431 | - if ( ! $this->use_taxes() ) { |
|
431 | + if (!$this->use_taxes()) { |
|
432 | 432 | return; |
433 | 433 | } |
434 | 434 | |
435 | 435 | // If a custom country && state has been passed in, use it to calculate taxes. |
436 | - $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
437 | - if ( ! empty( $country ) ) { |
|
436 | + $country = $this->get_field('wpinv_country', 'billing'); |
|
437 | + if (!empty($country)) { |
|
438 | 438 | $this->country = $country; |
439 | 439 | } |
440 | 440 | |
441 | - $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
442 | - if ( ! empty( $state ) ) { |
|
441 | + $state = $this->get_field('wpinv_state', 'billing'); |
|
442 | + if (!empty($state)) { |
|
443 | 443 | $this->state = $state; |
444 | 444 | } |
445 | 445 | |
446 | 446 | // Confirm if the provided country and the ip country are similar. |
447 | - $address_confirmed = $this->get_field( 'confirm-address' ); |
|
448 | - if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) { |
|
449 | - throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) ); |
|
447 | + $address_confirmed = $this->get_field('confirm-address'); |
|
448 | + if (wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) { |
|
449 | + throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing')); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | // Abort if the country is not taxable. |
453 | - if ( ! wpinv_is_country_taxable( $this->country ) ) { |
|
453 | + if (!wpinv_is_country_taxable($this->country)) { |
|
454 | 454 | return; |
455 | 455 | } |
456 | 456 | |
457 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
457 | + $processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
458 | 458 | |
459 | - foreach ( $processor->taxes as $tax ) { |
|
460 | - $this->add_tax( $tax ); |
|
459 | + foreach ($processor->taxes as $tax) { |
|
460 | + $this->add_tax($tax); |
|
461 | 461 | } |
462 | 462 | |
463 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
463 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
464 | 464 | } |
465 | 465 | |
466 | 466 | /** |
@@ -469,16 +469,16 @@ discard block |
||
469 | 469 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
470 | 470 | * @since 1.0.19 |
471 | 471 | */ |
472 | - public function add_tax( $tax ) { |
|
472 | + public function add_tax($tax) { |
|
473 | 473 | |
474 | - if ( wpinv_round_tax_per_tax_rate() ) { |
|
475 | - $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
476 | - $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
474 | + if (wpinv_round_tax_per_tax_rate()) { |
|
475 | + $tax['initial_tax'] = wpinv_round_amount($tax['initial_tax']); |
|
476 | + $tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']); |
|
477 | 477 | } |
478 | 478 | |
479 | - $this->taxes[ $tax['name'] ] = $tax; |
|
480 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
481 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
479 | + $this->taxes[$tax['name']] = $tax; |
|
480 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount($tax['initial_tax']); |
|
481 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']); |
|
482 | 482 | |
483 | 483 | } |
484 | 484 | |
@@ -487,12 +487,12 @@ discard block |
||
487 | 487 | * |
488 | 488 | * @since 1.0.19 |
489 | 489 | */ |
490 | - public function remove_tax( $tax_name ) { |
|
490 | + public function remove_tax($tax_name) { |
|
491 | 491 | |
492 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
493 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
494 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
495 | - unset( $this->taxes[ $tax_name ] ); |
|
492 | + if (isset($this->taxes[$tax_name])) { |
|
493 | + $this->totals['taxes']['initial'] -= $this->taxes[$tax_name]['initial_tax']; |
|
494 | + $this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax']; |
|
495 | + unset($this->taxes[$tax_name]); |
|
496 | 496 | } |
497 | 497 | |
498 | 498 | } |
@@ -506,11 +506,11 @@ discard block |
||
506 | 506 | |
507 | 507 | $use_taxes = wpinv_use_taxes(); |
508 | 508 | |
509 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
509 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
510 | 510 | $use_taxes = false; |
511 | 511 | } |
512 | 512 | |
513 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
513 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
514 | 514 | |
515 | 515 | } |
516 | 516 | |
@@ -559,13 +559,13 @@ discard block |
||
559 | 559 | |
560 | 560 | $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
561 | 561 | $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
562 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
562 | + $processor = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total); |
|
563 | 563 | |
564 | - foreach ( $processor->discounts as $discount ) { |
|
565 | - $this->add_discount( $discount ); |
|
564 | + foreach ($processor->discounts as $discount) { |
|
565 | + $this->add_discount($discount); |
|
566 | 566 | } |
567 | 567 | |
568 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
568 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
@@ -574,10 +574,10 @@ discard block |
||
574 | 574 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
575 | 575 | * @since 1.0.19 |
576 | 576 | */ |
577 | - public function add_discount( $discount ) { |
|
578 | - $this->discounts[ $discount['name'] ] = $discount; |
|
579 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
580 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
577 | + public function add_discount($discount) { |
|
578 | + $this->discounts[$discount['name']] = $discount; |
|
579 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount($discount['initial_discount']); |
|
580 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']); |
|
581 | 581 | } |
582 | 582 | |
583 | 583 | /** |
@@ -585,12 +585,12 @@ discard block |
||
585 | 585 | * |
586 | 586 | * @since 1.0.19 |
587 | 587 | */ |
588 | - public function remove_discount( $name ) { |
|
588 | + public function remove_discount($name) { |
|
589 | 589 | |
590 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
591 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
592 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
593 | - unset( $this->discounts[ $name ] ); |
|
590 | + if (isset($this->discounts[$name])) { |
|
591 | + $this->totals['discount']['initial'] -= $this->discounts[$name]['initial_discount']; |
|
592 | + $this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount']; |
|
593 | + unset($this->discounts[$name]); |
|
594 | 594 | } |
595 | 595 | |
596 | 596 | } |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | * @return bool |
603 | 603 | */ |
604 | 604 | public function has_discount_code() { |
605 | - return ! empty( $this->discounts['discount_code'] ); |
|
605 | + return !empty($this->discounts['discount_code']); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -659,13 +659,13 @@ discard block |
||
659 | 659 | */ |
660 | 660 | public function process_fees() { |
661 | 661 | |
662 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
662 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
663 | 663 | |
664 | - foreach ( $fees_processor->fees as $fee ) { |
|
665 | - $this->add_fee( $fee ); |
|
664 | + foreach ($fees_processor->fees as $fee) { |
|
665 | + $this->add_fee($fee); |
|
666 | 666 | } |
667 | 667 | |
668 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
668 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -674,11 +674,11 @@ discard block |
||
674 | 674 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
675 | 675 | * @since 1.0.19 |
676 | 676 | */ |
677 | - public function add_fee( $fee ) { |
|
677 | + public function add_fee($fee) { |
|
678 | 678 | |
679 | - $this->fees[ $fee['name'] ] = $fee; |
|
680 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
681 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
679 | + $this->fees[$fee['name']] = $fee; |
|
680 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
681 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
682 | 682 | |
683 | 683 | } |
684 | 684 | |
@@ -687,12 +687,12 @@ discard block |
||
687 | 687 | * |
688 | 688 | * @since 1.0.19 |
689 | 689 | */ |
690 | - public function remove_fee( $name ) { |
|
690 | + public function remove_fee($name) { |
|
691 | 691 | |
692 | - if ( isset( $this->fees[ $name ] ) ) { |
|
693 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
694 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
695 | - unset( $this->fees[ $name ] ); |
|
692 | + if (isset($this->fees[$name])) { |
|
693 | + $this->totals['fees']['initial'] -= $this->fees[$name]['initial_fee']; |
|
694 | + $this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee']; |
|
695 | + unset($this->fees[$name]); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | } |
@@ -731,7 +731,7 @@ discard block |
||
731 | 731 | * @since 1.0.19 |
732 | 732 | */ |
733 | 733 | public function has_fees() { |
734 | - return count( $this->fees ) !== 0; |
|
734 | + return count($this->fees) !== 0; |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /* |
@@ -749,7 +749,7 @@ discard block |
||
749 | 749 | * @since 1.0.19 |
750 | 750 | */ |
751 | 751 | public function is_initial_fetch() { |
752 | - return empty( $this->data['initial_state'] ); |
|
752 | + return empty($this->data['initial_state']); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | */ |
760 | 760 | public function get_total() { |
761 | 761 | $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
762 | - return max( $total, 0 ); |
|
762 | + return max($total, 0); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function get_recurring_total() { |
771 | 771 | $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
772 | - return max( $total, 0 ); |
|
772 | + return max($total, 0); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /** |
@@ -781,12 +781,12 @@ discard block |
||
781 | 781 | $initial = $this->get_total(); |
782 | 782 | $recurring = $this->get_recurring_total(); |
783 | 783 | |
784 | - if ( $this->has_recurring == 0 ) { |
|
784 | + if ($this->has_recurring == 0) { |
|
785 | 785 | $recurring = 0; |
786 | 786 | } |
787 | 787 | |
788 | 788 | $collect = $initial > 0 || $recurring > 0; |
789 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
789 | + return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -795,7 +795,7 @@ discard block |
||
795 | 795 | * @since 1.0.19 |
796 | 796 | */ |
797 | 797 | public function get_billing_email() { |
798 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
798 | + return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this); |
|
799 | 799 | } |
800 | 800 | |
801 | 801 | /** |
@@ -805,7 +805,7 @@ discard block |
||
805 | 805 | */ |
806 | 806 | public function has_billing_email() { |
807 | 807 | $billing_email = $this->get_billing_email(); |
808 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
808 | + return !empty($billing_email) && is_email($billing_email); |
|
809 | 809 | } |
810 | 810 | |
811 | 811 | /** |
@@ -835,8 +835,8 @@ discard block |
||
835 | 835 | * @since 1.0.19 |
836 | 836 | * @return mixed|null |
837 | 837 | */ |
838 | - public function get_field( $field, $sub_array_key = null ) { |
|
839 | - return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
838 | + public function get_field($field, $sub_array_key = null) { |
|
839 | + return getpaid_get_array_field($this->data, $field, $sub_array_key); |
|
840 | 840 | } |
841 | 841 | |
842 | 842 | /** |
@@ -844,8 +844,8 @@ discard block |
||
844 | 844 | * |
845 | 845 | * @since 1.0.19 |
846 | 846 | */ |
847 | - public function is_required_field_set( $field ) { |
|
848 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
847 | + public function is_required_field_set($field) { |
|
848 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
@@ -853,8 +853,8 @@ discard block |
||
853 | 853 | * |
854 | 854 | * @since 1.0.19 |
855 | 855 | */ |
856 | - public function format_amount( $amount ) { |
|
857 | - return wpinv_price( $amount, $this->get_currency() ); |
|
856 | + public function format_amount($amount) { |
|
857 | + return wpinv_price($amount, $this->get_currency()); |
|
858 | 858 | } |
859 | 859 | |
860 | 860 | } |