@@ -12,438 +12,438 @@ |
||
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 ); |
|
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 | - return 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}' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ), |
|
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( $invoice->get_type() ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_type() ) ), |
|
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 | - } |
|
151 | - |
|
152 | - /** |
|
153 | - * Helper function to send an email. |
|
154 | - * |
|
155 | - * @param WPInv_Invoice $invoice |
|
156 | - * @param GetPaid_Notification_Email $email |
|
157 | - * @param string $type |
|
158 | - * @param string|array $recipients |
|
159 | - * @param array $extra_args Extra template args. |
|
160 | - */ |
|
161 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
162 | - |
|
163 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
164 | - |
|
165 | - $mailer = new GetPaid_Notification_Email_Sender(); |
|
166 | - $merge_tags = $email->get_merge_tags(); |
|
167 | - |
|
168 | - $result = $mailer->send( |
|
169 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
170 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
171 | - $email->get_content( $merge_tags, $extra_args ), |
|
172 | - $email->get_attachments() |
|
173 | - ); |
|
174 | - |
|
175 | - // Maybe send a copy to the admin. |
|
176 | - if ( $email->include_admin_bcc() ) { |
|
177 | - $mailer->send( |
|
178 | - wpinv_get_admin_email(), |
|
179 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
180 | - $email->get_content( $merge_tags ), |
|
181 | - $email->get_attachments() |
|
182 | - ); |
|
183 | - } |
|
184 | - |
|
185 | - if ( ! $result ) { |
|
186 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
187 | - } |
|
188 | - |
|
189 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
190 | - |
|
191 | - return $result; |
|
192 | - } |
|
193 | - |
|
194 | - /** |
|
195 | - * Also send emails to any cc users. |
|
196 | - * |
|
197 | - * @param array $recipients |
|
198 | - * @param GetPaid_Notification_Email $email |
|
199 | - */ |
|
200 | - public function filter_email_recipients( $recipients, $email ) { |
|
201 | - |
|
202 | - if ( ! $email->is_admin_email() ) { |
|
203 | - $cc = $email->object->get_email_cc(); |
|
204 | - |
|
205 | - if ( ! empty( $cc ) ) { |
|
206 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
207 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
208 | - } |
|
209 | - |
|
210 | - } |
|
211 | - |
|
212 | - return $recipients; |
|
213 | - |
|
214 | - } |
|
215 | - |
|
216 | - /** |
|
217 | - * Sends a new invoice notification. |
|
218 | - * |
|
219 | - * @param WPInv_Invoice $invoice |
|
220 | - */ |
|
221 | - public function new_invoice( $invoice ) { |
|
222 | - |
|
223 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
224 | - $recipient = wpinv_get_admin_email(); |
|
225 | - |
|
226 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
227 | - |
|
228 | - } |
|
229 | - |
|
230 | - /** |
|
231 | - * Sends a cancelled invoice notification. |
|
232 | - * |
|
233 | - * @param WPInv_Invoice $invoice |
|
234 | - */ |
|
235 | - public function cancelled_invoice( $invoice ) { |
|
236 | - |
|
237 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
238 | - $recipient = wpinv_get_admin_email(); |
|
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 ); |
|
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 | + return 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}' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ), |
|
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( $invoice->get_type() ), |
|
144 | + '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_type() ) ), |
|
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 | + } |
|
151 | + |
|
152 | + /** |
|
153 | + * Helper function to send an email. |
|
154 | + * |
|
155 | + * @param WPInv_Invoice $invoice |
|
156 | + * @param GetPaid_Notification_Email $email |
|
157 | + * @param string $type |
|
158 | + * @param string|array $recipients |
|
159 | + * @param array $extra_args Extra template args. |
|
160 | + */ |
|
161 | + public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
162 | + |
|
163 | + do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
164 | + |
|
165 | + $mailer = new GetPaid_Notification_Email_Sender(); |
|
166 | + $merge_tags = $email->get_merge_tags(); |
|
167 | + |
|
168 | + $result = $mailer->send( |
|
169 | + apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
170 | + $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
171 | + $email->get_content( $merge_tags, $extra_args ), |
|
172 | + $email->get_attachments() |
|
173 | + ); |
|
174 | + |
|
175 | + // Maybe send a copy to the admin. |
|
176 | + if ( $email->include_admin_bcc() ) { |
|
177 | + $mailer->send( |
|
178 | + wpinv_get_admin_email(), |
|
179 | + $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
180 | + $email->get_content( $merge_tags ), |
|
181 | + $email->get_attachments() |
|
182 | + ); |
|
183 | + } |
|
184 | + |
|
185 | + if ( ! $result ) { |
|
186 | + $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
187 | + } |
|
188 | + |
|
189 | + do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
190 | + |
|
191 | + return $result; |
|
192 | + } |
|
193 | + |
|
194 | + /** |
|
195 | + * Also send emails to any cc users. |
|
196 | + * |
|
197 | + * @param array $recipients |
|
198 | + * @param GetPaid_Notification_Email $email |
|
199 | + */ |
|
200 | + public function filter_email_recipients( $recipients, $email ) { |
|
201 | + |
|
202 | + if ( ! $email->is_admin_email() ) { |
|
203 | + $cc = $email->object->get_email_cc(); |
|
204 | + |
|
205 | + if ( ! empty( $cc ) ) { |
|
206 | + $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
207 | + $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
208 | + } |
|
209 | + |
|
210 | + } |
|
211 | + |
|
212 | + return $recipients; |
|
213 | + |
|
214 | + } |
|
215 | + |
|
216 | + /** |
|
217 | + * Sends a new invoice notification. |
|
218 | + * |
|
219 | + * @param WPInv_Invoice $invoice |
|
220 | + */ |
|
221 | + public function new_invoice( $invoice ) { |
|
222 | + |
|
223 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
224 | + $recipient = wpinv_get_admin_email(); |
|
225 | + |
|
226 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
227 | + |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Sends a cancelled invoice notification. |
|
232 | + * |
|
233 | + * @param WPInv_Invoice $invoice |
|
234 | + */ |
|
235 | + public function cancelled_invoice( $invoice ) { |
|
236 | + |
|
237 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
238 | + $recipient = wpinv_get_admin_email(); |
|
239 | 239 | |
240 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
240 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
241 | 241 | |
242 | - } |
|
242 | + } |
|
243 | 243 | |
244 | - /** |
|
245 | - * Sends a failed invoice notification. |
|
246 | - * |
|
247 | - * @param WPInv_Invoice $invoice |
|
248 | - */ |
|
249 | - public function failed_invoice( $invoice ) { |
|
244 | + /** |
|
245 | + * Sends a failed invoice notification. |
|
246 | + * |
|
247 | + * @param WPInv_Invoice $invoice |
|
248 | + */ |
|
249 | + public function failed_invoice( $invoice ) { |
|
250 | 250 | |
251 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
252 | - $recipient = wpinv_get_admin_email(); |
|
253 | - |
|
254 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
251 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
252 | + $recipient = wpinv_get_admin_email(); |
|
253 | + |
|
254 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
255 | 255 | |
256 | - } |
|
256 | + } |
|
257 | 257 | |
258 | - /** |
|
259 | - * Sends a notification whenever an invoice is put on hold. |
|
260 | - * |
|
261 | - * @param WPInv_Invoice $invoice |
|
262 | - */ |
|
263 | - public function onhold_invoice( $invoice ) { |
|
258 | + /** |
|
259 | + * Sends a notification whenever an invoice is put on hold. |
|
260 | + * |
|
261 | + * @param WPInv_Invoice $invoice |
|
262 | + */ |
|
263 | + public function onhold_invoice( $invoice ) { |
|
264 | 264 | |
265 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
266 | - $recipient = $invoice->get_email(); |
|
265 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
266 | + $recipient = $invoice->get_email(); |
|
267 | 267 | |
268 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
268 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
269 | 269 | |
270 | - } |
|
270 | + } |
|
271 | 271 | |
272 | - /** |
|
273 | - * Sends a notification whenever an invoice is marked as processing payment. |
|
274 | - * |
|
275 | - * @param WPInv_Invoice $invoice |
|
276 | - */ |
|
277 | - public function processing_invoice( $invoice ) { |
|
272 | + /** |
|
273 | + * Sends a notification whenever an invoice is marked as processing payment. |
|
274 | + * |
|
275 | + * @param WPInv_Invoice $invoice |
|
276 | + */ |
|
277 | + public function processing_invoice( $invoice ) { |
|
278 | 278 | |
279 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
280 | - $recipient = $invoice->get_email(); |
|
279 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
280 | + $recipient = $invoice->get_email(); |
|
281 | 281 | |
282 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
282 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
283 | 283 | |
284 | - } |
|
284 | + } |
|
285 | 285 | |
286 | - /** |
|
287 | - * Sends a notification whenever an invoice is paid. |
|
288 | - * |
|
289 | - * @param WPInv_Invoice $invoice |
|
290 | - */ |
|
291 | - public function completed_invoice( $invoice ) { |
|
286 | + /** |
|
287 | + * Sends a notification whenever an invoice is paid. |
|
288 | + * |
|
289 | + * @param WPInv_Invoice $invoice |
|
290 | + */ |
|
291 | + public function completed_invoice( $invoice ) { |
|
292 | 292 | |
293 | - // (Maybe) abort if it is a renewal invoice. |
|
294 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
295 | - return; |
|
296 | - } |
|
293 | + // (Maybe) abort if it is a renewal invoice. |
|
294 | + if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
295 | + return; |
|
296 | + } |
|
297 | 297 | |
298 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
299 | - $recipient = $invoice->get_email(); |
|
298 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
299 | + $recipient = $invoice->get_email(); |
|
300 | 300 | |
301 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
301 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
302 | 302 | |
303 | - } |
|
303 | + } |
|
304 | 304 | |
305 | - /** |
|
306 | - * Sends a notification whenever an invoice is refunded. |
|
307 | - * |
|
308 | - * @param WPInv_Invoice $invoice |
|
309 | - */ |
|
310 | - public function refunded_invoice( $invoice ) { |
|
305 | + /** |
|
306 | + * Sends a notification whenever an invoice is refunded. |
|
307 | + * |
|
308 | + * @param WPInv_Invoice $invoice |
|
309 | + */ |
|
310 | + public function refunded_invoice( $invoice ) { |
|
311 | 311 | |
312 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
313 | - $recipient = $invoice->get_email(); |
|
312 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
313 | + $recipient = $invoice->get_email(); |
|
314 | 314 | |
315 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
315 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
316 | 316 | |
317 | - } |
|
317 | + } |
|
318 | 318 | |
319 | - /** |
|
320 | - * Notifies a user about new invoices |
|
321 | - * |
|
322 | - * @param WPInv_Invoice $invoice |
|
323 | - */ |
|
324 | - public function user_invoice( $invoice ) { |
|
319 | + /** |
|
320 | + * Notifies a user about new invoices |
|
321 | + * |
|
322 | + * @param WPInv_Invoice $invoice |
|
323 | + */ |
|
324 | + public function user_invoice( $invoice ) { |
|
325 | 325 | |
326 | - // Only send this email for invoices created via the admin page. |
|
327 | - if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
328 | - return; |
|
329 | - } |
|
326 | + // Only send this email for invoices created via the admin page. |
|
327 | + if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
328 | + return; |
|
329 | + } |
|
330 | 330 | |
331 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
332 | - $recipient = $invoice->get_email(); |
|
331 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
332 | + $recipient = $invoice->get_email(); |
|
333 | 333 | |
334 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
334 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
335 | 335 | |
336 | - } |
|
336 | + } |
|
337 | 337 | |
338 | - /** |
|
339 | - * Checks if an invoice is a payment form invoice. |
|
340 | - * |
|
341 | - * @param int $invoice |
|
342 | - * @return bool |
|
343 | - */ |
|
344 | - public function is_payment_form_invoice( $invoice ) { |
|
345 | - return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
346 | - } |
|
338 | + /** |
|
339 | + * Checks if an invoice is a payment form invoice. |
|
340 | + * |
|
341 | + * @param int $invoice |
|
342 | + * @return bool |
|
343 | + */ |
|
344 | + public function is_payment_form_invoice( $invoice ) { |
|
345 | + return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
346 | + } |
|
347 | 347 | |
348 | - /** |
|
349 | - * Notifies admin about new invoice notes |
|
350 | - * |
|
351 | - * @param WPInv_Invoice $invoice |
|
352 | - * @param string $note |
|
353 | - */ |
|
354 | - public function user_note( $invoice, $note ) { |
|
348 | + /** |
|
349 | + * Notifies admin about new invoice notes |
|
350 | + * |
|
351 | + * @param WPInv_Invoice $invoice |
|
352 | + * @param string $note |
|
353 | + */ |
|
354 | + public function user_note( $invoice, $note ) { |
|
355 | 355 | |
356 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
357 | - $recipient = $invoice->get_email(); |
|
358 | - |
|
359 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
360 | - |
|
361 | - } |
|
356 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
357 | + $recipient = $invoice->get_email(); |
|
358 | + |
|
359 | + return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
360 | + |
|
361 | + } |
|
362 | 362 | |
363 | - /** |
|
364 | - * (Force) Sends overdue notices. |
|
365 | - * |
|
366 | - * @param WPInv_Invoice $invoice |
|
367 | - */ |
|
368 | - public function force_send_overdue_notice( $invoice ) { |
|
369 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
370 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
371 | - } |
|
372 | - |
|
373 | - /** |
|
374 | - * Sends overdue notices. |
|
375 | - * |
|
376 | - * @TODO: Create an invoices query class. |
|
377 | - */ |
|
378 | - public function overdue() { |
|
379 | - global $wpdb; |
|
380 | - |
|
381 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
382 | - |
|
383 | - // Fetch reminder days. |
|
384 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
385 | - |
|
386 | - // Abort if non is set. |
|
387 | - if ( empty( $reminder_days ) ) { |
|
388 | - return; |
|
389 | - } |
|
390 | - |
|
391 | - // Retrieve date query. |
|
392 | - $date_query = $this->get_date_query( $reminder_days ); |
|
393 | - |
|
394 | - // Invoices table. |
|
395 | - $table = $wpdb->prefix . 'getpaid_invoices'; |
|
396 | - |
|
397 | - // Fetch invoices. |
|
398 | - $invoices = $wpdb->get_col( |
|
399 | - "SELECT posts.ID FROM $wpdb->posts as posts |
|
363 | + /** |
|
364 | + * (Force) Sends overdue notices. |
|
365 | + * |
|
366 | + * @param WPInv_Invoice $invoice |
|
367 | + */ |
|
368 | + public function force_send_overdue_notice( $invoice ) { |
|
369 | + $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
370 | + return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
371 | + } |
|
372 | + |
|
373 | + /** |
|
374 | + * Sends overdue notices. |
|
375 | + * |
|
376 | + * @TODO: Create an invoices query class. |
|
377 | + */ |
|
378 | + public function overdue() { |
|
379 | + global $wpdb; |
|
380 | + |
|
381 | + $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
382 | + |
|
383 | + // Fetch reminder days. |
|
384 | + $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
385 | + |
|
386 | + // Abort if non is set. |
|
387 | + if ( empty( $reminder_days ) ) { |
|
388 | + return; |
|
389 | + } |
|
390 | + |
|
391 | + // Retrieve date query. |
|
392 | + $date_query = $this->get_date_query( $reminder_days ); |
|
393 | + |
|
394 | + // Invoices table. |
|
395 | + $table = $wpdb->prefix . 'getpaid_invoices'; |
|
396 | + |
|
397 | + // Fetch invoices. |
|
398 | + $invoices = $wpdb->get_col( |
|
399 | + "SELECT posts.ID FROM $wpdb->posts as posts |
|
400 | 400 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
401 | 401 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
402 | 402 | |
403 | - foreach ( $invoices as $invoice ) { |
|
403 | + foreach ( $invoices as $invoice ) { |
|
404 | 404 | |
405 | - // Only send this email for invoices created via the admin page. |
|
406 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
407 | - $invoice = new WPInv_Invoice( $invoice ); |
|
408 | - $email->object = $invoice; |
|
405 | + // Only send this email for invoices created via the admin page. |
|
406 | + if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
407 | + $invoice = new WPInv_Invoice( $invoice ); |
|
408 | + $email->object = $invoice; |
|
409 | 409 | |
410 | - if ( $invoice->needs_payment() ) { |
|
411 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
412 | - } |
|
410 | + if ( $invoice->needs_payment() ) { |
|
411 | + $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
412 | + } |
|
413 | 413 | |
414 | - } |
|
414 | + } |
|
415 | 415 | |
416 | - } |
|
416 | + } |
|
417 | 417 | |
418 | - } |
|
418 | + } |
|
419 | 419 | |
420 | - /** |
|
421 | - * Calculates the date query for an invoices query |
|
422 | - * |
|
423 | - * @param array $reminder_days |
|
424 | - * @return string |
|
425 | - */ |
|
426 | - public function get_date_query( $reminder_days ) { |
|
420 | + /** |
|
421 | + * Calculates the date query for an invoices query |
|
422 | + * |
|
423 | + * @param array $reminder_days |
|
424 | + * @return string |
|
425 | + */ |
|
426 | + public function get_date_query( $reminder_days ) { |
|
427 | 427 | |
428 | - $date_query = array( |
|
429 | - 'relation' => 'OR' |
|
430 | - ); |
|
428 | + $date_query = array( |
|
429 | + 'relation' => 'OR' |
|
430 | + ); |
|
431 | 431 | |
432 | - foreach ( $reminder_days as $days ) { |
|
433 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
432 | + foreach ( $reminder_days as $days ) { |
|
433 | + $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
434 | 434 | |
435 | - $date_query[] = array( |
|
436 | - 'year' => $date['year'], |
|
437 | - 'month' => $date['month'], |
|
438 | - 'day' => $date['day'], |
|
439 | - ); |
|
435 | + $date_query[] = array( |
|
436 | + 'year' => $date['year'], |
|
437 | + 'month' => $date['month'], |
|
438 | + 'day' => $date['day'], |
|
439 | + ); |
|
440 | 440 | |
441 | - } |
|
441 | + } |
|
442 | 442 | |
443 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
443 | + $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
444 | 444 | |
445 | - return $date_query->get_sql(); |
|
445 | + return $date_query->get_sql(); |
|
446 | 446 | |
447 | - } |
|
447 | + } |
|
448 | 448 | |
449 | 449 | } |
@@ -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 ); |
|
85 | + do_action('getpaid_invoice_init_email_type_hook', $type); |
|
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,32 +119,32 @@ 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 | return 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}' => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ), |
|
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( $invoice->get_type() ), |
|
144 | - '{invoice_label}' => sanitize_text_field( ucfirst( $invoice->get_type() ) ), |
|
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}' => wpinv_price(wpinv_format_amount($invoice->get_total())), |
|
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($invoice->get_type()), |
|
144 | + '{invoice_label}' => sanitize_text_field(ucfirst($invoice->get_type())), |
|
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 | 150 | } |
@@ -158,35 +158,35 @@ discard block |
||
158 | 158 | * @param string|array $recipients |
159 | 159 | * @param array $extra_args Extra template args. |
160 | 160 | */ |
161 | - public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) { |
|
161 | + public function send_email($invoice, $email, $type, $recipients, $extra_args = array()) { |
|
162 | 162 | |
163 | - do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email ); |
|
163 | + do_action('getpaid_before_send_invoice_notification', $type, $invoice, $email); |
|
164 | 164 | |
165 | 165 | $mailer = new GetPaid_Notification_Email_Sender(); |
166 | 166 | $merge_tags = $email->get_merge_tags(); |
167 | 167 | |
168 | 168 | $result = $mailer->send( |
169 | - apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
170 | - $email->add_merge_tags( $email->get_subject(), $merge_tags ), |
|
171 | - $email->get_content( $merge_tags, $extra_args ), |
|
169 | + apply_filters('getpaid_invoice_email_recipients', wpinv_parse_list($recipients), $email), |
|
170 | + $email->add_merge_tags($email->get_subject(), $merge_tags), |
|
171 | + $email->get_content($merge_tags, $extra_args), |
|
172 | 172 | $email->get_attachments() |
173 | 173 | ); |
174 | 174 | |
175 | 175 | // Maybe send a copy to the admin. |
176 | - if ( $email->include_admin_bcc() ) { |
|
176 | + if ($email->include_admin_bcc()) { |
|
177 | 177 | $mailer->send( |
178 | 178 | wpinv_get_admin_email(), |
179 | - $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ), |
|
180 | - $email->get_content( $merge_tags ), |
|
179 | + $email->add_merge_tags($email->get_subject() . __(' - ADMIN BCC COPY', 'invoicing'), $merge_tags), |
|
180 | + $email->get_content($merge_tags), |
|
181 | 181 | $email->get_attachments() |
182 | 182 | ); |
183 | 183 | } |
184 | 184 | |
185 | - if ( ! $result ) { |
|
186 | - $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
185 | + if (!$result) { |
|
186 | + $invoice->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
187 | 187 | } |
188 | 188 | |
189 | - do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email ); |
|
189 | + do_action('getpaid_after_send_invoice_notification', $type, $invoice, $email); |
|
190 | 190 | |
191 | 191 | return $result; |
192 | 192 | } |
@@ -197,14 +197,14 @@ discard block |
||
197 | 197 | * @param array $recipients |
198 | 198 | * @param GetPaid_Notification_Email $email |
199 | 199 | */ |
200 | - public function filter_email_recipients( $recipients, $email ) { |
|
200 | + public function filter_email_recipients($recipients, $email) { |
|
201 | 201 | |
202 | - if ( ! $email->is_admin_email() ) { |
|
202 | + if (!$email->is_admin_email()) { |
|
203 | 203 | $cc = $email->object->get_email_cc(); |
204 | 204 | |
205 | - if ( ! empty( $cc ) ) { |
|
206 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
207 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
205 | + if (!empty($cc)) { |
|
206 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
207 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | } |
@@ -218,12 +218,12 @@ discard block |
||
218 | 218 | * |
219 | 219 | * @param WPInv_Invoice $invoice |
220 | 220 | */ |
221 | - public function new_invoice( $invoice ) { |
|
221 | + public function new_invoice($invoice) { |
|
222 | 222 | |
223 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
223 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
224 | 224 | $recipient = wpinv_get_admin_email(); |
225 | 225 | |
226 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
226 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
227 | 227 | |
228 | 228 | } |
229 | 229 | |
@@ -232,12 +232,12 @@ discard block |
||
232 | 232 | * |
233 | 233 | * @param WPInv_Invoice $invoice |
234 | 234 | */ |
235 | - public function cancelled_invoice( $invoice ) { |
|
235 | + public function cancelled_invoice($invoice) { |
|
236 | 236 | |
237 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
237 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
238 | 238 | $recipient = wpinv_get_admin_email(); |
239 | 239 | |
240 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
240 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
241 | 241 | |
242 | 242 | } |
243 | 243 | |
@@ -246,12 +246,12 @@ discard block |
||
246 | 246 | * |
247 | 247 | * @param WPInv_Invoice $invoice |
248 | 248 | */ |
249 | - public function failed_invoice( $invoice ) { |
|
249 | + public function failed_invoice($invoice) { |
|
250 | 250 | |
251 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
251 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
252 | 252 | $recipient = wpinv_get_admin_email(); |
253 | 253 | |
254 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
254 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
255 | 255 | |
256 | 256 | } |
257 | 257 | |
@@ -260,12 +260,12 @@ discard block |
||
260 | 260 | * |
261 | 261 | * @param WPInv_Invoice $invoice |
262 | 262 | */ |
263 | - public function onhold_invoice( $invoice ) { |
|
263 | + public function onhold_invoice($invoice) { |
|
264 | 264 | |
265 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
265 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
266 | 266 | $recipient = $invoice->get_email(); |
267 | 267 | |
268 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
268 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
269 | 269 | |
270 | 270 | } |
271 | 271 | |
@@ -274,12 +274,12 @@ discard block |
||
274 | 274 | * |
275 | 275 | * @param WPInv_Invoice $invoice |
276 | 276 | */ |
277 | - public function processing_invoice( $invoice ) { |
|
277 | + public function processing_invoice($invoice) { |
|
278 | 278 | |
279 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
279 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
280 | 280 | $recipient = $invoice->get_email(); |
281 | 281 | |
282 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
282 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
283 | 283 | |
284 | 284 | } |
285 | 285 | |
@@ -288,17 +288,17 @@ discard block |
||
288 | 288 | * |
289 | 289 | * @param WPInv_Invoice $invoice |
290 | 290 | */ |
291 | - public function completed_invoice( $invoice ) { |
|
291 | + public function completed_invoice($invoice) { |
|
292 | 292 | |
293 | 293 | // (Maybe) abort if it is a renewal invoice. |
294 | - if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) { |
|
294 | + if ($invoice->is_renewal() && !wpinv_get_option('email_completed_invoice_renewal_active', false)) { |
|
295 | 295 | return; |
296 | 296 | } |
297 | 297 | |
298 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
298 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
299 | 299 | $recipient = $invoice->get_email(); |
300 | 300 | |
301 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
301 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
302 | 302 | |
303 | 303 | } |
304 | 304 | |
@@ -307,12 +307,12 @@ discard block |
||
307 | 307 | * |
308 | 308 | * @param WPInv_Invoice $invoice |
309 | 309 | */ |
310 | - public function refunded_invoice( $invoice ) { |
|
310 | + public function refunded_invoice($invoice) { |
|
311 | 311 | |
312 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
312 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
313 | 313 | $recipient = $invoice->get_email(); |
314 | 314 | |
315 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
315 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
316 | 316 | |
317 | 317 | } |
318 | 318 | |
@@ -321,17 +321,17 @@ discard block |
||
321 | 321 | * |
322 | 322 | * @param WPInv_Invoice $invoice |
323 | 323 | */ |
324 | - public function user_invoice( $invoice ) { |
|
324 | + public function user_invoice($invoice) { |
|
325 | 325 | |
326 | 326 | // Only send this email for invoices created via the admin page. |
327 | - if ( $this->is_payment_form_invoice( $invoice->get_id() ) ) { |
|
327 | + if ($this->is_payment_form_invoice($invoice->get_id())) { |
|
328 | 328 | return; |
329 | 329 | } |
330 | 330 | |
331 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
331 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
332 | 332 | $recipient = $invoice->get_email(); |
333 | 333 | |
334 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient ); |
|
334 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient); |
|
335 | 335 | |
336 | 336 | } |
337 | 337 | |
@@ -341,8 +341,8 @@ discard block |
||
341 | 341 | * @param int $invoice |
342 | 342 | * @return bool |
343 | 343 | */ |
344 | - public function is_payment_form_invoice( $invoice ) { |
|
345 | - return empty( $_GET['getpaid-admin-action'] ) && 'payment_form' == get_post_meta( $invoice, 'wpinv_created_via', true ); |
|
344 | + public function is_payment_form_invoice($invoice) { |
|
345 | + return empty($_GET['getpaid-admin-action']) && 'payment_form' == get_post_meta($invoice, 'wpinv_created_via', true); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | /** |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | * @param WPInv_Invoice $invoice |
352 | 352 | * @param string $note |
353 | 353 | */ |
354 | - public function user_note( $invoice, $note ) { |
|
354 | + public function user_note($invoice, $note) { |
|
355 | 355 | |
356 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $invoice ); |
|
356 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $invoice); |
|
357 | 357 | $recipient = $invoice->get_email(); |
358 | 358 | |
359 | - return $this->send_email( $invoice, $email, __FUNCTION__, $recipient, array( 'customer_note' => $note ) ); |
|
359 | + return $this->send_email($invoice, $email, __FUNCTION__, $recipient, array('customer_note' => $note)); |
|
360 | 360 | |
361 | 361 | } |
362 | 362 | |
@@ -365,9 +365,9 @@ discard block |
||
365 | 365 | * |
366 | 366 | * @param WPInv_Invoice $invoice |
367 | 367 | */ |
368 | - public function force_send_overdue_notice( $invoice ) { |
|
369 | - $email = new GetPaid_Notification_Email( 'overdue', $invoice ); |
|
370 | - return $this->send_email( $invoice, $email, 'overdue', $invoice->get_email() ); |
|
368 | + public function force_send_overdue_notice($invoice) { |
|
369 | + $email = new GetPaid_Notification_Email('overdue', $invoice); |
|
370 | + return $this->send_email($invoice, $email, 'overdue', $invoice->get_email()); |
|
371 | 371 | } |
372 | 372 | |
373 | 373 | /** |
@@ -378,37 +378,37 @@ discard block |
||
378 | 378 | public function overdue() { |
379 | 379 | global $wpdb; |
380 | 380 | |
381 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
381 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
382 | 382 | |
383 | 383 | // Fetch reminder days. |
384 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
384 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
385 | 385 | |
386 | 386 | // Abort if non is set. |
387 | - if ( empty( $reminder_days ) ) { |
|
387 | + if (empty($reminder_days)) { |
|
388 | 388 | return; |
389 | 389 | } |
390 | 390 | |
391 | 391 | // Retrieve date query. |
392 | - $date_query = $this->get_date_query( $reminder_days ); |
|
392 | + $date_query = $this->get_date_query($reminder_days); |
|
393 | 393 | |
394 | 394 | // Invoices table. |
395 | 395 | $table = $wpdb->prefix . 'getpaid_invoices'; |
396 | 396 | |
397 | 397 | // Fetch invoices. |
398 | - $invoices = $wpdb->get_col( |
|
398 | + $invoices = $wpdb->get_col( |
|
399 | 399 | "SELECT posts.ID FROM $wpdb->posts as posts |
400 | 400 | LEFT JOIN $table as invoices ON invoices.post_id = posts.ID |
401 | 401 | WHERE posts.post_type = 'wpi_invoice' AND posts.post_status = 'wpi-pending' $date_query"); |
402 | 402 | |
403 | - foreach ( $invoices as $invoice ) { |
|
403 | + foreach ($invoices as $invoice) { |
|
404 | 404 | |
405 | 405 | // Only send this email for invoices created via the admin page. |
406 | - if ( ! $this->is_payment_form_invoice( $invoice ) ) { |
|
407 | - $invoice = new WPInv_Invoice( $invoice ); |
|
406 | + if (!$this->is_payment_form_invoice($invoice)) { |
|
407 | + $invoice = new WPInv_Invoice($invoice); |
|
408 | 408 | $email->object = $invoice; |
409 | 409 | |
410 | - if ( $invoice->needs_payment() ) { |
|
411 | - $this->send_email( $invoice, $email, __FUNCTION__, $invoice->get_email() ); |
|
410 | + if ($invoice->needs_payment()) { |
|
411 | + $this->send_email($invoice, $email, __FUNCTION__, $invoice->get_email()); |
|
412 | 412 | } |
413 | 413 | |
414 | 414 | } |
@@ -423,14 +423,14 @@ discard block |
||
423 | 423 | * @param array $reminder_days |
424 | 424 | * @return string |
425 | 425 | */ |
426 | - public function get_date_query( $reminder_days ) { |
|
426 | + public function get_date_query($reminder_days) { |
|
427 | 427 | |
428 | 428 | $date_query = array( |
429 | 429 | 'relation' => 'OR' |
430 | 430 | ); |
431 | 431 | |
432 | - foreach ( $reminder_days as $days ) { |
|
433 | - $date = date_parse( date( 'Y-m-d', strtotime( "-$days days", current_time( 'timestamp' ) ) ) ); |
|
432 | + foreach ($reminder_days as $days) { |
|
433 | + $date = date_parse(date('Y-m-d', strtotime("-$days days", current_time('timestamp')))); |
|
434 | 434 | |
435 | 435 | $date_query[] = array( |
436 | 436 | 'year' => $date['year'], |
@@ -440,7 +440,7 @@ discard block |
||
440 | 440 | |
441 | 441 | } |
442 | 442 | |
443 | - $date_query = new WP_Date_Query( $date_query, 'invoices.due_date' ); |
|
443 | + $date_query = new WP_Date_Query($date_query, 'invoices.due_date'); |
|
444 | 444 | |
445 | 445 | return $date_query->get_sql(); |
446 | 446 |
@@ -13,30 +13,30 @@ discard block |
||
13 | 13 | class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway { |
14 | 14 | |
15 | 15 | /** |
16 | - * Payment method id. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Payment method id. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id = 'manual'; |
21 | 21 | |
22 | 22 | /** |
23 | - * An array of features that this gateway supports. |
|
24 | - * |
|
25 | - * @var array |
|
26 | - */ |
|
23 | + * An array of features that this gateway supports. |
|
24 | + * |
|
25 | + * @var array |
|
26 | + */ |
|
27 | 27 | protected $supports = array( 'subscription' ); |
28 | 28 | |
29 | 29 | /** |
30 | - * Payment method order. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - public $order = 11; |
|
30 | + * Payment method order. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + public $order = 11; |
|
35 | 35 | |
36 | 36 | /** |
37 | - * Class constructor. |
|
38 | - */ |
|
39 | - public function __construct() { |
|
37 | + * Class constructor. |
|
38 | + */ |
|
39 | + public function __construct() { |
|
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | 42 | $this->title = __( 'Manual Payment', 'invoicing' ); |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
49 | - * Process Payment. |
|
50 | - * |
|
51 | - * |
|
52 | - * @param WPInv_Invoice $invoice Invoice. |
|
53 | - * @param array $submission_data Posted checkout fields. |
|
54 | - * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
55 | - * @return array |
|
56 | - */ |
|
57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
49 | + * Process Payment. |
|
50 | + * |
|
51 | + * |
|
52 | + * @param WPInv_Invoice $invoice Invoice. |
|
53 | + * @param array $submission_data Posted checkout fields. |
|
54 | + * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
|
55 | + * @return array |
|
56 | + */ |
|
57 | + public function process_payment( $invoice, $submission_data, $submission ) { |
|
58 | 58 | |
59 | 59 | // Mark it as paid. |
60 | 60 | $invoice->mark_paid(); |
@@ -68,13 +68,13 @@ discard block |
||
68 | 68 | } |
69 | 69 | |
70 | 70 | /** |
71 | - * (Maybe) renews a manual subscription profile. |
|
72 | - * |
|
73 | - * |
|
74 | - * @param bool $should_expire |
|
71 | + * (Maybe) renews a manual subscription profile. |
|
72 | + * |
|
73 | + * |
|
74 | + * @param bool $should_expire |
|
75 | 75 | * @param WPInv_Subscription $subscription |
76 | - */ |
|
77 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
76 | + */ |
|
77 | + public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
78 | 78 | |
79 | 79 | // Ensure its our subscription && it's active. |
80 | 80 | if ( 'manual' != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
@@ -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 | * Manual Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription' ); |
|
27 | + protected $supports = array('subscription'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | public function __construct() { |
40 | 40 | parent::__construct(); |
41 | 41 | |
42 | - $this->title = __( 'Manual Payment', 'invoicing' ); |
|
43 | - $this->method_title = __( 'Manual Payment', 'invoicing' ); |
|
42 | + $this->title = __('Manual Payment', 'invoicing'); |
|
43 | + $this->method_title = __('Manual Payment', 'invoicing'); |
|
44 | 44 | |
45 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
45 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -54,16 +54,16 @@ discard block |
||
54 | 54 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
55 | 55 | * @return array |
56 | 56 | */ |
57 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
57 | + public function process_payment($invoice, $submission_data, $submission) { |
|
58 | 58 | |
59 | 59 | // Mark it as paid. |
60 | 60 | $invoice->mark_paid(); |
61 | 61 | |
62 | 62 | // (Maybe) activate subscription. |
63 | - getpaid_activate_invoice_subscription( $invoice ); |
|
63 | + getpaid_activate_invoice_subscription($invoice); |
|
64 | 64 | |
65 | 65 | // Send to the success page. |
66 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
66 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
67 | 67 | |
68 | 68 | } |
69 | 69 | |
@@ -74,15 +74,15 @@ discard block |
||
74 | 74 | * @param bool $should_expire |
75 | 75 | * @param WPInv_Subscription $subscription |
76 | 76 | */ |
77 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
77 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
78 | 78 | |
79 | 79 | // Ensure its our subscription && it's active. |
80 | - if ( 'manual' != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
80 | + if ('manual' != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
81 | 81 | return $should_expire; |
82 | 82 | } |
83 | 83 | |
84 | 84 | // If this is the last renewal, complete the subscription. |
85 | - if ( $subscription->is_last_renewal() ) { |
|
85 | + if ($subscription->is_last_renewal()) { |
|
86 | 86 | $subscription->complete(); |
87 | 87 | return false; |
88 | 88 | } |
@@ -15,125 +15,125 @@ discard block |
||
15 | 15 | */ |
16 | 16 | class WPInv_Subscription extends GetPaid_Data { |
17 | 17 | |
18 | - /** |
|
19 | - * Which data store to load. |
|
20 | - * |
|
21 | - * @var string |
|
22 | - */ |
|
23 | - protected $data_store_name = 'subscription'; |
|
24 | - |
|
25 | - /** |
|
26 | - * This is the name of this object type. |
|
27 | - * |
|
28 | - * @var string |
|
29 | - */ |
|
30 | - protected $object_type = 'subscription'; |
|
31 | - |
|
32 | - /** |
|
33 | - * Item Data array. This is the core item data exposed in APIs. |
|
34 | - * |
|
35 | - * @since 1.0.19 |
|
36 | - * @var array |
|
37 | - */ |
|
38 | - protected $data = array( |
|
39 | - 'customer_id' => 0, |
|
40 | - 'frequency' => 1, |
|
41 | - 'period' => 'D', |
|
42 | - 'initial_amount' => null, |
|
43 | - 'recurring_amount' => null, |
|
44 | - 'bill_times' => 0, |
|
45 | - 'transaction_id' => '', |
|
46 | - 'parent_payment_id' => null, |
|
47 | - 'product_id' => 0, |
|
48 | - 'created' => '0000-00-00 00:00:00', |
|
49 | - 'expiration' => '0000-00-00 00:00:00', |
|
50 | - 'trial_period' => '', |
|
51 | - 'status' => 'pending', |
|
52 | - 'profile_id' => '', |
|
53 | - 'gateway' => '', |
|
54 | - 'customer' => '', |
|
55 | - ); |
|
56 | - |
|
57 | - /** |
|
58 | - * Stores the status transition information. |
|
59 | - * |
|
60 | - * @since 1.0.19 |
|
61 | - * @var bool |
|
62 | - */ |
|
63 | - protected $status_transition = false; |
|
64 | - |
|
65 | - /** |
|
66 | - * Get the subscription if ID is passed, otherwise the subscription is new and empty. |
|
67 | - * |
|
68 | - * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
|
69 | - * @param bool $deprecated |
|
70 | - */ |
|
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
72 | - |
|
73 | - parent::__construct( $subscription ); |
|
74 | - |
|
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( ! empty( $subscription->id ) ) { |
|
80 | - $this->set_id( $subscription->id ); |
|
81 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
82 | - $this->set_id( $subscription_id ); |
|
83 | - } else { |
|
84 | - $this->set_object_read( true ); |
|
85 | - } |
|
86 | - |
|
87 | - // Load the datastore. |
|
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
89 | - |
|
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
92 | - } |
|
93 | - |
|
94 | - } |
|
95 | - |
|
96 | - /** |
|
97 | - * Given an invoice id, profile id, transaction id, it returns the subscription's id. |
|
98 | - * |
|
99 | - * |
|
100 | - * @static |
|
101 | - * @param string $value |
|
102 | - * @param string $field Either invoice_id, transaction_id or profile_id. |
|
103 | - * @since 1.0.19 |
|
104 | - * @return int |
|
105 | - */ |
|
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
18 | + /** |
|
19 | + * Which data store to load. |
|
20 | + * |
|
21 | + * @var string |
|
22 | + */ |
|
23 | + protected $data_store_name = 'subscription'; |
|
24 | + |
|
25 | + /** |
|
26 | + * This is the name of this object type. |
|
27 | + * |
|
28 | + * @var string |
|
29 | + */ |
|
30 | + protected $object_type = 'subscription'; |
|
31 | + |
|
32 | + /** |
|
33 | + * Item Data array. This is the core item data exposed in APIs. |
|
34 | + * |
|
35 | + * @since 1.0.19 |
|
36 | + * @var array |
|
37 | + */ |
|
38 | + protected $data = array( |
|
39 | + 'customer_id' => 0, |
|
40 | + 'frequency' => 1, |
|
41 | + 'period' => 'D', |
|
42 | + 'initial_amount' => null, |
|
43 | + 'recurring_amount' => null, |
|
44 | + 'bill_times' => 0, |
|
45 | + 'transaction_id' => '', |
|
46 | + 'parent_payment_id' => null, |
|
47 | + 'product_id' => 0, |
|
48 | + 'created' => '0000-00-00 00:00:00', |
|
49 | + 'expiration' => '0000-00-00 00:00:00', |
|
50 | + 'trial_period' => '', |
|
51 | + 'status' => 'pending', |
|
52 | + 'profile_id' => '', |
|
53 | + 'gateway' => '', |
|
54 | + 'customer' => '', |
|
55 | + ); |
|
56 | + |
|
57 | + /** |
|
58 | + * Stores the status transition information. |
|
59 | + * |
|
60 | + * @since 1.0.19 |
|
61 | + * @var bool |
|
62 | + */ |
|
63 | + protected $status_transition = false; |
|
64 | + |
|
65 | + /** |
|
66 | + * Get the subscription if ID is passed, otherwise the subscription is new and empty. |
|
67 | + * |
|
68 | + * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
|
69 | + * @param bool $deprecated |
|
70 | + */ |
|
71 | + function __construct( $subscription = 0, $deprecated = false ) { |
|
72 | + |
|
73 | + parent::__construct( $subscription ); |
|
74 | + |
|
75 | + if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | + $this->set_id( $subscription ); |
|
77 | + } elseif ( $subscription instanceof self ) { |
|
78 | + $this->set_id( $subscription->get_id() ); |
|
79 | + } elseif ( ! empty( $subscription->id ) ) { |
|
80 | + $this->set_id( $subscription->id ); |
|
81 | + } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
82 | + $this->set_id( $subscription_id ); |
|
83 | + } else { |
|
84 | + $this->set_object_read( true ); |
|
85 | + } |
|
86 | + |
|
87 | + // Load the datastore. |
|
88 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
89 | + |
|
90 | + if ( $this->get_id() > 0 ) { |
|
91 | + $this->data_store->read( $this ); |
|
92 | + } |
|
93 | + |
|
94 | + } |
|
95 | + |
|
96 | + /** |
|
97 | + * Given an invoice id, profile id, transaction id, it returns the subscription's id. |
|
98 | + * |
|
99 | + * |
|
100 | + * @static |
|
101 | + * @param string $value |
|
102 | + * @param string $field Either invoice_id, transaction_id or profile_id. |
|
103 | + * @since 1.0.19 |
|
104 | + * @return int |
|
105 | + */ |
|
106 | + public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | - // Trim the value. |
|
110 | - $value = trim( $value ); |
|
109 | + // Trim the value. |
|
110 | + $value = trim( $value ); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
113 | - return 0; |
|
114 | - } |
|
112 | + if ( empty( $value ) ) { |
|
113 | + return 0; |
|
114 | + } |
|
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
117 | - $field = 'parent_payment_id'; |
|
118 | - } |
|
116 | + if ( 'invoice_id' == $field ) { |
|
117 | + $field = 'parent_payment_id'; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | // Valid fields. |
121 | 121 | $fields = array( |
122 | - 'parent_payment_id', |
|
123 | - 'transaction_id', |
|
124 | - 'profile_id' |
|
125 | - ); |
|
126 | - |
|
127 | - // Ensure a field has been passed. |
|
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
129 | - return 0; |
|
130 | - } |
|
131 | - |
|
132 | - // Maybe retrieve from the cache. |
|
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
135 | - return $subscription_id; |
|
136 | - } |
|
122 | + 'parent_payment_id', |
|
123 | + 'transaction_id', |
|
124 | + 'profile_id' |
|
125 | + ); |
|
126 | + |
|
127 | + // Ensure a field has been passed. |
|
128 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
129 | + return 0; |
|
130 | + } |
|
131 | + |
|
132 | + // Maybe retrieve from the cache. |
|
133 | + $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | + if ( ! empty( $subscription_id ) ) { |
|
135 | + return $subscription_id; |
|
136 | + } |
|
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
@@ -141,34 +141,34 @@ discard block |
||
141 | 141 | $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
145 | - return 0; |
|
146 | - } |
|
144 | + if ( empty( $subscription_id ) ) { |
|
145 | + return 0; |
|
146 | + } |
|
147 | 147 | |
148 | - // Update the cache with our data. |
|
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
148 | + // Update the cache with our data. |
|
149 | + wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
150 | 150 | |
151 | - return $subscription_id; |
|
152 | - } |
|
151 | + return $subscription_id; |
|
152 | + } |
|
153 | 153 | |
154 | - /** |
|
154 | + /** |
|
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
162 | - } |
|
158 | + wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | + wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | + wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | + wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
162 | + } |
|
163 | 163 | |
164 | - /** |
|
164 | + /** |
|
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | 167 | public function _isset( $key ) { |
168 | 168 | return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
169 | - } |
|
169 | + } |
|
170 | 170 | |
171 | - /* |
|
171 | + /* |
|
172 | 172 | |-------------------------------------------------------------------------- |
173 | 173 | | CRUD methods |
174 | 174 | |-------------------------------------------------------------------------- |
@@ -177,545 +177,545 @@ discard block |
||
177 | 177 | | |
178 | 178 | */ |
179 | 179 | |
180 | - /* |
|
180 | + /* |
|
181 | 181 | |-------------------------------------------------------------------------- |
182 | 182 | | Getters |
183 | 183 | |-------------------------------------------------------------------------- |
184 | 184 | */ |
185 | 185 | |
186 | - /** |
|
187 | - * Get customer id. |
|
188 | - * |
|
189 | - * @since 1.0.19 |
|
190 | - * @param string $context View or edit context. |
|
191 | - * @return int |
|
192 | - */ |
|
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
195 | - } |
|
196 | - |
|
197 | - /** |
|
198 | - * Get customer information. |
|
199 | - * |
|
200 | - * @since 1.0.19 |
|
201 | - * @param string $context View or edit context. |
|
202 | - * @return WP_User|false WP_User object on success, false on failure. |
|
203 | - */ |
|
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
206 | - } |
|
207 | - |
|
208 | - /** |
|
209 | - * Get parent invoice id. |
|
210 | - * |
|
211 | - * @since 1.0.19 |
|
212 | - * @param string $context View or edit context. |
|
213 | - * @return int |
|
214 | - */ |
|
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
217 | - } |
|
218 | - |
|
219 | - /** |
|
220 | - * Alias for self::get_parent_invoice_id(). |
|
221 | - * |
|
222 | - * @since 1.0.19 |
|
223 | - * @param string $context View or edit context. |
|
224 | - * @return int |
|
225 | - */ |
|
186 | + /** |
|
187 | + * Get customer id. |
|
188 | + * |
|
189 | + * @since 1.0.19 |
|
190 | + * @param string $context View or edit context. |
|
191 | + * @return int |
|
192 | + */ |
|
193 | + public function get_customer_id( $context = 'view' ) { |
|
194 | + return (int) $this->get_prop( 'customer_id', $context ); |
|
195 | + } |
|
196 | + |
|
197 | + /** |
|
198 | + * Get customer information. |
|
199 | + * |
|
200 | + * @since 1.0.19 |
|
201 | + * @param string $context View or edit context. |
|
202 | + * @return WP_User|false WP_User object on success, false on failure. |
|
203 | + */ |
|
204 | + public function get_customer( $context = 'view' ) { |
|
205 | + return get_userdata( $this->get_customer_id( $context ) ); |
|
206 | + } |
|
207 | + |
|
208 | + /** |
|
209 | + * Get parent invoice id. |
|
210 | + * |
|
211 | + * @since 1.0.19 |
|
212 | + * @param string $context View or edit context. |
|
213 | + * @return int |
|
214 | + */ |
|
215 | + public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | + return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Alias for self::get_parent_invoice_id(). |
|
221 | + * |
|
222 | + * @since 1.0.19 |
|
223 | + * @param string $context View or edit context. |
|
224 | + * @return int |
|
225 | + */ |
|
226 | 226 | public function get_parent_payment_id( $context = 'view' ) { |
227 | 227 | return $this->get_parent_invoice_id( $context ); |
228 | - } |
|
228 | + } |
|
229 | + |
|
230 | + /** |
|
231 | + * Alias for self::get_parent_invoice_id(). |
|
232 | + * |
|
233 | + * @since 1.0.0 |
|
234 | + * @return int |
|
235 | + */ |
|
236 | + public function get_original_payment_id( $context = 'view' ) { |
|
237 | + return $this->get_parent_invoice_id( $context ); |
|
238 | + } |
|
239 | + |
|
240 | + /** |
|
241 | + * Get parent invoice. |
|
242 | + * |
|
243 | + * @since 1.0.19 |
|
244 | + * @param string $context View or edit context. |
|
245 | + * @return WPInv_Invoice |
|
246 | + */ |
|
247 | + public function get_parent_invoice( $context = 'view' ) { |
|
248 | + return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
249 | + } |
|
250 | + |
|
251 | + /** |
|
252 | + * Alias for self::get_parent_invoice(). |
|
253 | + * |
|
254 | + * @since 1.0.19 |
|
255 | + * @param string $context View or edit context. |
|
256 | + * @return WPInv_Invoice |
|
257 | + */ |
|
258 | + public function get_parent_payment( $context = 'view' ) { |
|
259 | + return $this->get_parent_invoice( $context ); |
|
260 | + } |
|
261 | + |
|
262 | + /** |
|
263 | + * Get subscription's product id. |
|
264 | + * |
|
265 | + * @since 1.0.19 |
|
266 | + * @param string $context View or edit context. |
|
267 | + * @return int |
|
268 | + */ |
|
269 | + public function get_product_id( $context = 'view' ) { |
|
270 | + return (int) $this->get_prop( 'product_id', $context ); |
|
271 | + } |
|
272 | + |
|
273 | + /** |
|
274 | + * Get the subscription product. |
|
275 | + * |
|
276 | + * @since 1.0.19 |
|
277 | + * @param string $context View or edit context. |
|
278 | + * @return WPInv_Item |
|
279 | + */ |
|
280 | + public function get_product( $context = 'view' ) { |
|
281 | + return new WPInv_Item( $this->get_product_id( $context ) ); |
|
282 | + } |
|
283 | + |
|
284 | + /** |
|
285 | + * Get parent invoice's gateway. |
|
286 | + * |
|
287 | + * Here for backwards compatibility. |
|
288 | + * |
|
289 | + * @since 1.0.19 |
|
290 | + * @param string $context View or edit context. |
|
291 | + * @return string |
|
292 | + */ |
|
293 | + public function get_gateway( $context = 'view' ) { |
|
294 | + return $this->get_parent_invoice( $context )->get_gateway(); |
|
295 | + } |
|
296 | + |
|
297 | + /** |
|
298 | + * Get the period of a renewal. |
|
299 | + * |
|
300 | + * @since 1.0.19 |
|
301 | + * @param string $context View or edit context. |
|
302 | + * @return string |
|
303 | + */ |
|
304 | + public function get_period( $context = 'view' ) { |
|
305 | + return $this->get_prop( 'period', $context ); |
|
306 | + } |
|
307 | + |
|
308 | + /** |
|
309 | + * Get number of periods each renewal is valid for. |
|
310 | + * |
|
311 | + * @since 1.0.19 |
|
312 | + * @param string $context View or edit context. |
|
313 | + * @return int |
|
314 | + */ |
|
315 | + public function get_frequency( $context = 'view' ) { |
|
316 | + return (int) $this->get_prop( 'frequency', $context ); |
|
317 | + } |
|
318 | + |
|
319 | + /** |
|
320 | + * Get the initial amount for the subscription. |
|
321 | + * |
|
322 | + * @since 1.0.19 |
|
323 | + * @param string $context View or edit context. |
|
324 | + * @return float |
|
325 | + */ |
|
326 | + public function get_initial_amount( $context = 'view' ) { |
|
327 | + return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
328 | + } |
|
329 | + |
|
330 | + /** |
|
331 | + * Get the recurring amount for the subscription. |
|
332 | + * |
|
333 | + * @since 1.0.19 |
|
334 | + * @param string $context View or edit context. |
|
335 | + * @return float |
|
336 | + */ |
|
337 | + public function get_recurring_amount( $context = 'view' ) { |
|
338 | + return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Get number of times that this subscription can be renewed. |
|
343 | + * |
|
344 | + * @since 1.0.19 |
|
345 | + * @param string $context View or edit context. |
|
346 | + * @return int |
|
347 | + */ |
|
348 | + public function get_bill_times( $context = 'view' ) { |
|
349 | + return (int) $this->get_prop( 'bill_times', $context ); |
|
350 | + } |
|
351 | + |
|
352 | + /** |
|
353 | + * Get transaction id of this subscription's parent invoice. |
|
354 | + * |
|
355 | + * @since 1.0.19 |
|
356 | + * @param string $context View or edit context. |
|
357 | + * @return string |
|
358 | + */ |
|
359 | + public function get_transaction_id( $context = 'view' ) { |
|
360 | + return $this->get_prop( 'transaction_id', $context ); |
|
361 | + } |
|
362 | + |
|
363 | + /** |
|
364 | + * Get the date that the subscription was created. |
|
365 | + * |
|
366 | + * @since 1.0.19 |
|
367 | + * @param string $context View or edit context. |
|
368 | + * @return string |
|
369 | + */ |
|
370 | + public function get_created( $context = 'view' ) { |
|
371 | + return $this->get_prop( 'created', $context ); |
|
372 | + } |
|
373 | + |
|
374 | + /** |
|
375 | + * Alias for self::get_created(). |
|
376 | + * |
|
377 | + * @since 1.0.19 |
|
378 | + * @param string $context View or edit context. |
|
379 | + * @return string |
|
380 | + */ |
|
381 | + public function get_date_created( $context = 'view' ) { |
|
382 | + return $this->get_created( $context ); |
|
383 | + } |
|
384 | + |
|
385 | + /** |
|
386 | + * Retrieves the creation date in a timestamp |
|
387 | + * |
|
388 | + * @since 1.0.0 |
|
389 | + * @return int |
|
390 | + */ |
|
391 | + public function get_time_created() { |
|
392 | + $created = $this->get_date_created(); |
|
393 | + return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
394 | + } |
|
395 | + |
|
396 | + /** |
|
397 | + * Get GMT date when the subscription was created. |
|
398 | + * |
|
399 | + * @since 1.0.19 |
|
400 | + * @param string $context View or edit context. |
|
401 | + * @return string |
|
402 | + */ |
|
403 | + public function get_date_created_gmt( $context = 'view' ) { |
|
404 | + $date = $this->get_date_created( $context ); |
|
405 | + |
|
406 | + if ( $date ) { |
|
407 | + $date = get_gmt_from_date( $date ); |
|
408 | + } |
|
409 | + return $date; |
|
410 | + } |
|
411 | + |
|
412 | + /** |
|
413 | + * Get the date that the subscription will renew. |
|
414 | + * |
|
415 | + * @since 1.0.19 |
|
416 | + * @param string $context View or edit context. |
|
417 | + * @return string |
|
418 | + */ |
|
419 | + public function get_next_renewal_date( $context = 'view' ) { |
|
420 | + return $this->get_prop( 'expiration', $context ); |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * Alias for self::get_next_renewal_date(). |
|
425 | + * |
|
426 | + * @since 1.0.19 |
|
427 | + * @param string $context View or edit context. |
|
428 | + * @return string |
|
429 | + */ |
|
430 | + public function get_expiration( $context = 'view' ) { |
|
431 | + return $this->get_next_renewal_date( $context ); |
|
432 | + } |
|
433 | + |
|
434 | + /** |
|
435 | + * Retrieves the expiration date in a timestamp |
|
436 | + * |
|
437 | + * @since 1.0.0 |
|
438 | + * @return int |
|
439 | + */ |
|
440 | + public function get_expiration_time() { |
|
441 | + $expiration = $this->get_expiration(); |
|
442 | + |
|
443 | + if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | + return current_time( 'timestamp' ); |
|
445 | + } |
|
446 | + |
|
447 | + $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | + return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
449 | + } |
|
450 | + |
|
451 | + /** |
|
452 | + * Get GMT date when the subscription will renew. |
|
453 | + * |
|
454 | + * @since 1.0.19 |
|
455 | + * @param string $context View or edit context. |
|
456 | + * @return string |
|
457 | + */ |
|
458 | + public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | + $date = $this->get_next_renewal_date( $context ); |
|
460 | + |
|
461 | + if ( $date ) { |
|
462 | + $date = get_gmt_from_date( $date ); |
|
463 | + } |
|
464 | + return $date; |
|
465 | + } |
|
466 | + |
|
467 | + /** |
|
468 | + * Get the subscription's trial period. |
|
469 | + * |
|
470 | + * @since 1.0.19 |
|
471 | + * @param string $context View or edit context. |
|
472 | + * @return string |
|
473 | + */ |
|
474 | + public function get_trial_period( $context = 'view' ) { |
|
475 | + return $this->get_prop( 'trial_period', $context ); |
|
476 | + } |
|
477 | + |
|
478 | + /** |
|
479 | + * Get the subscription's status. |
|
480 | + * |
|
481 | + * @since 1.0.19 |
|
482 | + * @param string $context View or edit context. |
|
483 | + * @return string |
|
484 | + */ |
|
485 | + public function get_status( $context = 'view' ) { |
|
486 | + return $this->get_prop( 'status', $context ); |
|
487 | + } |
|
488 | + |
|
489 | + /** |
|
490 | + * Get the subscription's profile id. |
|
491 | + * |
|
492 | + * @since 1.0.19 |
|
493 | + * @param string $context View or edit context. |
|
494 | + * @return string |
|
495 | + */ |
|
496 | + public function get_profile_id( $context = 'view' ) { |
|
497 | + return $this->get_prop( 'profile_id', $context ); |
|
498 | + } |
|
499 | + |
|
500 | + /* |
|
501 | + |-------------------------------------------------------------------------- |
|
502 | + | Setters |
|
503 | + |-------------------------------------------------------------------------- |
|
504 | + */ |
|
505 | + |
|
506 | + /** |
|
507 | + * Set customer id. |
|
508 | + * |
|
509 | + * @since 1.0.19 |
|
510 | + * @param int $value The customer's id. |
|
511 | + */ |
|
512 | + public function set_customer_id( $value ) { |
|
513 | + $this->set_prop( 'customer_id', (int) $value ); |
|
514 | + } |
|
515 | + |
|
516 | + /** |
|
517 | + * Set parent invoice id. |
|
518 | + * |
|
519 | + * @since 1.0.19 |
|
520 | + * @param int $value The parent invoice id. |
|
521 | + */ |
|
522 | + public function set_parent_invoice_id( $value ) { |
|
523 | + $this->set_prop( 'parent_payment_id', (int) $value ); |
|
524 | + } |
|
525 | + |
|
526 | + /** |
|
527 | + * Alias for self::set_parent_invoice_id(). |
|
528 | + * |
|
529 | + * @since 1.0.19 |
|
530 | + * @param int $value The parent invoice id. |
|
531 | + */ |
|
532 | + public function set_parent_payment_id( $value ) { |
|
533 | + $this->set_parent_invoice_id( $value ); |
|
534 | + } |
|
535 | + |
|
536 | + /** |
|
537 | + * Alias for self::set_parent_invoice_id(). |
|
538 | + * |
|
539 | + * @since 1.0.19 |
|
540 | + * @param int $value The parent invoice id. |
|
541 | + */ |
|
542 | + public function set_original_payment_id( $value ) { |
|
543 | + $this->set_parent_invoice_id( $value ); |
|
544 | + } |
|
545 | + |
|
546 | + /** |
|
547 | + * Set subscription's product id. |
|
548 | + * |
|
549 | + * @since 1.0.19 |
|
550 | + * @param int $value The subscription product id. |
|
551 | + */ |
|
552 | + public function set_product_id( $value ) { |
|
553 | + $this->set_prop( 'product_id', (int) $value ); |
|
554 | + } |
|
555 | + |
|
556 | + /** |
|
557 | + * Set the period of a renewal. |
|
558 | + * |
|
559 | + * @since 1.0.19 |
|
560 | + * @param string $value The renewal period. |
|
561 | + */ |
|
562 | + public function set_period( $value ) { |
|
563 | + $this->set_prop( 'period', $value ); |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Set number of periods each renewal is valid for. |
|
568 | + * |
|
569 | + * @since 1.0.19 |
|
570 | + * @param int $value The subscription frequency. |
|
571 | + */ |
|
572 | + public function set_frequency( $value ) { |
|
573 | + $value = empty( $value ) ? 1 : (int) $value; |
|
574 | + $this->set_prop( 'frequency', absint( $value ) ); |
|
575 | + } |
|
576 | + |
|
577 | + /** |
|
578 | + * Set the initial amount for the subscription. |
|
579 | + * |
|
580 | + * @since 1.0.19 |
|
581 | + * @param float $value The initial subcription amount. |
|
582 | + */ |
|
583 | + public function set_initial_amount( $value ) { |
|
584 | + $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
585 | + } |
|
586 | + |
|
587 | + /** |
|
588 | + * Set the recurring amount for the subscription. |
|
589 | + * |
|
590 | + * @since 1.0.19 |
|
591 | + * @param float $value The recurring subcription amount. |
|
592 | + */ |
|
593 | + public function set_recurring_amount( $value ) { |
|
594 | + $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
595 | + } |
|
596 | + |
|
597 | + /** |
|
598 | + * Set number of times that this subscription can be renewed. |
|
599 | + * |
|
600 | + * @since 1.0.19 |
|
601 | + * @param int $value Bill times. |
|
602 | + */ |
|
603 | + public function set_bill_times( $value ) { |
|
604 | + $this->set_prop( 'bill_times', (int) $value ); |
|
605 | + } |
|
229 | 606 | |
230 | - /** |
|
231 | - * Alias for self::get_parent_invoice_id(). |
|
607 | + /** |
|
608 | + * Get transaction id of this subscription's parent invoice. |
|
232 | 609 | * |
233 | - * @since 1.0.0 |
|
234 | - * @return int |
|
610 | + * @since 1.0.19 |
|
611 | + * @param string $value Bill times. |
|
235 | 612 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
613 | + public function set_transaction_id( $value ) { |
|
614 | + $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
238 | 615 | } |
239 | 616 | |
240 | - /** |
|
241 | - * Get parent invoice. |
|
242 | - * |
|
243 | - * @since 1.0.19 |
|
244 | - * @param string $context View or edit context. |
|
245 | - * @return WPInv_Invoice |
|
246 | - */ |
|
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
249 | - } |
|
250 | - |
|
251 | - /** |
|
252 | - * Alias for self::get_parent_invoice(). |
|
253 | - * |
|
254 | - * @since 1.0.19 |
|
255 | - * @param string $context View or edit context. |
|
256 | - * @return WPInv_Invoice |
|
257 | - */ |
|
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
260 | - } |
|
261 | - |
|
262 | - /** |
|
263 | - * Get subscription's product id. |
|
264 | - * |
|
265 | - * @since 1.0.19 |
|
266 | - * @param string $context View or edit context. |
|
267 | - * @return int |
|
268 | - */ |
|
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
271 | - } |
|
272 | - |
|
273 | - /** |
|
274 | - * Get the subscription product. |
|
275 | - * |
|
276 | - * @since 1.0.19 |
|
277 | - * @param string $context View or edit context. |
|
278 | - * @return WPInv_Item |
|
279 | - */ |
|
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
282 | - } |
|
283 | - |
|
284 | - /** |
|
285 | - * Get parent invoice's gateway. |
|
286 | - * |
|
287 | - * Here for backwards compatibility. |
|
288 | - * |
|
289 | - * @since 1.0.19 |
|
290 | - * @param string $context View or edit context. |
|
291 | - * @return string |
|
292 | - */ |
|
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
295 | - } |
|
296 | - |
|
297 | - /** |
|
298 | - * Get the period of a renewal. |
|
299 | - * |
|
300 | - * @since 1.0.19 |
|
301 | - * @param string $context View or edit context. |
|
302 | - * @return string |
|
303 | - */ |
|
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
306 | - } |
|
307 | - |
|
308 | - /** |
|
309 | - * Get number of periods each renewal is valid for. |
|
310 | - * |
|
311 | - * @since 1.0.19 |
|
312 | - * @param string $context View or edit context. |
|
313 | - * @return int |
|
314 | - */ |
|
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
317 | - } |
|
318 | - |
|
319 | - /** |
|
320 | - * Get the initial amount for the subscription. |
|
321 | - * |
|
322 | - * @since 1.0.19 |
|
323 | - * @param string $context View or edit context. |
|
324 | - * @return float |
|
325 | - */ |
|
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
328 | - } |
|
329 | - |
|
330 | - /** |
|
331 | - * Get the recurring amount for the subscription. |
|
332 | - * |
|
333 | - * @since 1.0.19 |
|
334 | - * @param string $context View or edit context. |
|
335 | - * @return float |
|
336 | - */ |
|
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Get number of times that this subscription can be renewed. |
|
343 | - * |
|
344 | - * @since 1.0.19 |
|
345 | - * @param string $context View or edit context. |
|
346 | - * @return int |
|
347 | - */ |
|
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
350 | - } |
|
351 | - |
|
352 | - /** |
|
353 | - * Get transaction id of this subscription's parent invoice. |
|
354 | - * |
|
355 | - * @since 1.0.19 |
|
356 | - * @param string $context View or edit context. |
|
357 | - * @return string |
|
358 | - */ |
|
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
361 | - } |
|
362 | - |
|
363 | - /** |
|
364 | - * Get the date that the subscription was created. |
|
365 | - * |
|
366 | - * @since 1.0.19 |
|
367 | - * @param string $context View or edit context. |
|
368 | - * @return string |
|
369 | - */ |
|
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
372 | - } |
|
373 | - |
|
374 | - /** |
|
375 | - * Alias for self::get_created(). |
|
376 | - * |
|
377 | - * @since 1.0.19 |
|
378 | - * @param string $context View or edit context. |
|
379 | - * @return string |
|
380 | - */ |
|
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
383 | - } |
|
384 | - |
|
385 | - /** |
|
386 | - * Retrieves the creation date in a timestamp |
|
387 | - * |
|
388 | - * @since 1.0.0 |
|
389 | - * @return int |
|
390 | - */ |
|
391 | - public function get_time_created() { |
|
392 | - $created = $this->get_date_created(); |
|
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
394 | - } |
|
395 | - |
|
396 | - /** |
|
397 | - * Get GMT date when the subscription was created. |
|
398 | - * |
|
399 | - * @since 1.0.19 |
|
400 | - * @param string $context View or edit context. |
|
401 | - * @return string |
|
402 | - */ |
|
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
617 | + /** |
|
618 | + * Set date when this subscription started. |
|
619 | + * |
|
620 | + * @since 1.0.19 |
|
621 | + * @param string $value strtotime compliant date. |
|
622 | + */ |
|
623 | + public function set_created( $value ) { |
|
624 | + $date = strtotime( $value ); |
|
405 | 625 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
626 | + if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | + $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
628 | + return; |
|
408 | 629 | } |
409 | - return $date; |
|
410 | - } |
|
411 | - |
|
412 | - /** |
|
413 | - * Get the date that the subscription will renew. |
|
414 | - * |
|
415 | - * @since 1.0.19 |
|
416 | - * @param string $context View or edit context. |
|
417 | - * @return string |
|
418 | - */ |
|
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Alias for self::get_next_renewal_date(). |
|
425 | - * |
|
426 | - * @since 1.0.19 |
|
427 | - * @param string $context View or edit context. |
|
428 | - * @return string |
|
429 | - */ |
|
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
432 | - } |
|
433 | - |
|
434 | - /** |
|
435 | - * Retrieves the expiration date in a timestamp |
|
436 | - * |
|
437 | - * @since 1.0.0 |
|
438 | - * @return int |
|
439 | - */ |
|
440 | - public function get_expiration_time() { |
|
441 | - $expiration = $this->get_expiration(); |
|
442 | - |
|
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
445 | - } |
|
446 | - |
|
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
449 | - } |
|
450 | - |
|
451 | - /** |
|
452 | - * Get GMT date when the subscription will renew. |
|
453 | - * |
|
454 | - * @since 1.0.19 |
|
455 | - * @param string $context View or edit context. |
|
456 | - * @return string |
|
457 | - */ |
|
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
460 | 630 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
463 | - } |
|
464 | - return $date; |
|
465 | - } |
|
466 | - |
|
467 | - /** |
|
468 | - * Get the subscription's trial period. |
|
469 | - * |
|
470 | - * @since 1.0.19 |
|
471 | - * @param string $context View or edit context. |
|
472 | - * @return string |
|
473 | - */ |
|
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
476 | - } |
|
477 | - |
|
478 | - /** |
|
479 | - * Get the subscription's status. |
|
480 | - * |
|
481 | - * @since 1.0.19 |
|
482 | - * @param string $context View or edit context. |
|
483 | - * @return string |
|
484 | - */ |
|
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
487 | - } |
|
488 | - |
|
489 | - /** |
|
490 | - * Get the subscription's profile id. |
|
491 | - * |
|
492 | - * @since 1.0.19 |
|
493 | - * @param string $context View or edit context. |
|
494 | - * @return string |
|
495 | - */ |
|
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
498 | - } |
|
499 | - |
|
500 | - /* |
|
501 | - |-------------------------------------------------------------------------- |
|
502 | - | Setters |
|
503 | - |-------------------------------------------------------------------------- |
|
504 | - */ |
|
631 | + $this->set_prop( 'created', '' ); |
|
505 | 632 | |
506 | - /** |
|
507 | - * Set customer id. |
|
508 | - * |
|
509 | - * @since 1.0.19 |
|
510 | - * @param int $value The customer's id. |
|
511 | - */ |
|
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
514 | - } |
|
515 | - |
|
516 | - /** |
|
517 | - * Set parent invoice id. |
|
518 | - * |
|
519 | - * @since 1.0.19 |
|
520 | - * @param int $value The parent invoice id. |
|
521 | - */ |
|
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
524 | - } |
|
525 | - |
|
526 | - /** |
|
527 | - * Alias for self::set_parent_invoice_id(). |
|
528 | - * |
|
529 | - * @since 1.0.19 |
|
530 | - * @param int $value The parent invoice id. |
|
531 | - */ |
|
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
534 | - } |
|
633 | + } |
|
535 | 634 | |
536 | - /** |
|
537 | - * Alias for self::set_parent_invoice_id(). |
|
635 | + /** |
|
636 | + * Alias for self::set_created(). |
|
538 | 637 | * |
539 | 638 | * @since 1.0.19 |
540 | - * @param int $value The parent invoice id. |
|
639 | + * @param string $value strtotime compliant date. |
|
541 | 640 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
544 | - } |
|
545 | - |
|
546 | - /** |
|
547 | - * Set subscription's product id. |
|
548 | - * |
|
549 | - * @since 1.0.19 |
|
550 | - * @param int $value The subscription product id. |
|
551 | - */ |
|
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
554 | - } |
|
555 | - |
|
556 | - /** |
|
557 | - * Set the period of a renewal. |
|
558 | - * |
|
559 | - * @since 1.0.19 |
|
560 | - * @param string $value The renewal period. |
|
561 | - */ |
|
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Set number of periods each renewal is valid for. |
|
568 | - * |
|
569 | - * @since 1.0.19 |
|
570 | - * @param int $value The subscription frequency. |
|
571 | - */ |
|
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
575 | - } |
|
576 | - |
|
577 | - /** |
|
578 | - * Set the initial amount for the subscription. |
|
579 | - * |
|
580 | - * @since 1.0.19 |
|
581 | - * @param float $value The initial subcription amount. |
|
582 | - */ |
|
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
585 | - } |
|
586 | - |
|
587 | - /** |
|
588 | - * Set the recurring amount for the subscription. |
|
589 | - * |
|
590 | - * @since 1.0.19 |
|
591 | - * @param float $value The recurring subcription amount. |
|
592 | - */ |
|
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
595 | - } |
|
596 | - |
|
597 | - /** |
|
598 | - * Set number of times that this subscription can be renewed. |
|
599 | - * |
|
600 | - * @since 1.0.19 |
|
601 | - * @param int $value Bill times. |
|
602 | - */ |
|
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
605 | - } |
|
606 | - |
|
607 | - /** |
|
608 | - * Get transaction id of this subscription's parent invoice. |
|
609 | - * |
|
610 | - * @since 1.0.19 |
|
611 | - * @param string $value Bill times. |
|
612 | - */ |
|
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
615 | - } |
|
616 | - |
|
617 | - /** |
|
618 | - * Set date when this subscription started. |
|
619 | - * |
|
620 | - * @since 1.0.19 |
|
621 | - * @param string $value strtotime compliant date. |
|
622 | - */ |
|
623 | - public function set_created( $value ) { |
|
641 | + public function set_date_created( $value ) { |
|
642 | + $this->set_created( $value ); |
|
643 | + } |
|
644 | + |
|
645 | + /** |
|
646 | + * Set the date that the subscription will renew. |
|
647 | + * |
|
648 | + * @since 1.0.19 |
|
649 | + * @param string $value strtotime compliant date. |
|
650 | + */ |
|
651 | + public function set_next_renewal_date( $value ) { |
|
624 | 652 | $date = strtotime( $value ); |
625 | 653 | |
626 | 654 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
655 | + $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
628 | 656 | return; |
629 | 657 | } |
630 | 658 | |
631 | - $this->set_prop( 'created', '' ); |
|
659 | + $this->set_prop( 'expiration', '' ); |
|
660 | + |
|
661 | + } |
|
632 | 662 | |
633 | - } |
|
663 | + /** |
|
664 | + * Alias for self::set_next_renewal_date(). |
|
665 | + * |
|
666 | + * @since 1.0.19 |
|
667 | + * @param string $value strtotime compliant date. |
|
668 | + */ |
|
669 | + public function set_expiration( $value ) { |
|
670 | + $this->set_next_renewal_date( $value ); |
|
671 | + } |
|
634 | 672 | |
635 | - /** |
|
636 | - * Alias for self::set_created(). |
|
637 | - * |
|
638 | - * @since 1.0.19 |
|
639 | - * @param string $value strtotime compliant date. |
|
640 | - */ |
|
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
673 | + /** |
|
674 | + * Set the subscription's trial period. |
|
675 | + * |
|
676 | + * @since 1.0.19 |
|
677 | + * @param string $value trial period e.g 1 year. |
|
678 | + */ |
|
679 | + public function set_trial_period( $value ) { |
|
680 | + $this->set_prop( 'trial_period', $value ); |
|
643 | 681 | } |
644 | 682 | |
645 | - /** |
|
646 | - * Set the date that the subscription will renew. |
|
647 | - * |
|
648 | - * @since 1.0.19 |
|
649 | - * @param string $value strtotime compliant date. |
|
650 | - */ |
|
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
683 | + /** |
|
684 | + * Set the subscription's status. |
|
685 | + * |
|
686 | + * @since 1.0.19 |
|
687 | + * @param string $new_status New subscription status. |
|
688 | + */ |
|
689 | + public function set_status( $new_status ) { |
|
653 | 690 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
691 | + // Abort if this is not a valid status; |
|
692 | + if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
656 | 693 | return; |
657 | - } |
|
658 | - |
|
659 | - $this->set_prop( 'expiration', '' ); |
|
660 | - |
|
661 | - } |
|
662 | - |
|
663 | - /** |
|
664 | - * Alias for self::set_next_renewal_date(). |
|
665 | - * |
|
666 | - * @since 1.0.19 |
|
667 | - * @param string $value strtotime compliant date. |
|
668 | - */ |
|
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
671 | - } |
|
672 | - |
|
673 | - /** |
|
674 | - * Set the subscription's trial period. |
|
675 | - * |
|
676 | - * @since 1.0.19 |
|
677 | - * @param string $value trial period e.g 1 year. |
|
678 | - */ |
|
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
681 | - } |
|
682 | - |
|
683 | - /** |
|
684 | - * Set the subscription's status. |
|
685 | - * |
|
686 | - * @since 1.0.19 |
|
687 | - * @param string $new_status New subscription status. |
|
688 | - */ |
|
689 | - public function set_status( $new_status ) { |
|
690 | - |
|
691 | - // Abort if this is not a valid status; |
|
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
693 | - return; |
|
694 | - } |
|
695 | - |
|
696 | - $old_status = $this->get_status(); |
|
697 | - $this->set_prop( 'status', $new_status ); |
|
698 | - |
|
699 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
700 | - $this->status_transition = array( |
|
701 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
702 | - 'to' => $new_status, |
|
703 | - ); |
|
704 | - } |
|
705 | - |
|
706 | - } |
|
707 | - |
|
708 | - /** |
|
709 | - * Set the subscription's (remote) profile id. |
|
710 | - * |
|
711 | - * @since 1.0.19 |
|
712 | - * @param string $value the remote profile id. |
|
713 | - */ |
|
714 | - public function set_profile_id( $value ) { |
|
715 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
716 | - } |
|
717 | - |
|
718 | - /* |
|
694 | + } |
|
695 | + |
|
696 | + $old_status = $this->get_status(); |
|
697 | + $this->set_prop( 'status', $new_status ); |
|
698 | + |
|
699 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
700 | + $this->status_transition = array( |
|
701 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
702 | + 'to' => $new_status, |
|
703 | + ); |
|
704 | + } |
|
705 | + |
|
706 | + } |
|
707 | + |
|
708 | + /** |
|
709 | + * Set the subscription's (remote) profile id. |
|
710 | + * |
|
711 | + * @since 1.0.19 |
|
712 | + * @param string $value the remote profile id. |
|
713 | + */ |
|
714 | + public function set_profile_id( $value ) { |
|
715 | + $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
716 | + } |
|
717 | + |
|
718 | + /* |
|
719 | 719 | |-------------------------------------------------------------------------- |
720 | 720 | | Boolean methods |
721 | 721 | |-------------------------------------------------------------------------- |
@@ -724,55 +724,55 @@ discard block |
||
724 | 724 | | |
725 | 725 | */ |
726 | 726 | |
727 | - /** |
|
727 | + /** |
|
728 | 728 | * Checks if the subscription has a given status. |
729 | - * |
|
730 | - * @param string|array String or array of strings to check for. |
|
731 | - * @return bool |
|
729 | + * |
|
730 | + * @param string|array String or array of strings to check for. |
|
731 | + * @return bool |
|
732 | 732 | */ |
733 | 733 | public function has_status( $status ) { |
734 | 734 | return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
735 | - } |
|
735 | + } |
|
736 | 736 | |
737 | - /** |
|
737 | + /** |
|
738 | 738 | * Checks if the subscription has a trial period. |
739 | - * |
|
740 | - * @return bool |
|
739 | + * |
|
740 | + * @return bool |
|
741 | 741 | */ |
742 | 742 | public function has_trial_period() { |
743 | - $period = $this->get_trial_period(); |
|
743 | + $period = $this->get_trial_period(); |
|
744 | 744 | return ! empty( $period ); |
745 | - } |
|
746 | - |
|
747 | - /** |
|
748 | - * Is the subscription active? |
|
749 | - * |
|
750 | - * @return bool |
|
751 | - */ |
|
752 | - public function is_active() { |
|
753 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
754 | - } |
|
755 | - |
|
756 | - /** |
|
757 | - * Is the subscription expired? |
|
758 | - * |
|
759 | - * @return bool |
|
760 | - */ |
|
761 | - public function is_expired() { |
|
762 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
763 | - } |
|
764 | - |
|
765 | - /** |
|
766 | - * Is this the last renewals? |
|
767 | - * |
|
768 | - * @return bool |
|
769 | - */ |
|
770 | - public function is_last_renewal() { |
|
771 | - $max_bills = $this->get_bill_times(); |
|
772 | - return ! empty( $max_bills ) && $max_bills >= $this->get_times_billed(); |
|
773 | - } |
|
774 | - |
|
775 | - /* |
|
745 | + } |
|
746 | + |
|
747 | + /** |
|
748 | + * Is the subscription active? |
|
749 | + * |
|
750 | + * @return bool |
|
751 | + */ |
|
752 | + public function is_active() { |
|
753 | + return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
754 | + } |
|
755 | + |
|
756 | + /** |
|
757 | + * Is the subscription expired? |
|
758 | + * |
|
759 | + * @return bool |
|
760 | + */ |
|
761 | + public function is_expired() { |
|
762 | + return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
763 | + } |
|
764 | + |
|
765 | + /** |
|
766 | + * Is this the last renewals? |
|
767 | + * |
|
768 | + * @return bool |
|
769 | + */ |
|
770 | + public function is_last_renewal() { |
|
771 | + $max_bills = $this->get_bill_times(); |
|
772 | + return ! empty( $max_bills ) && $max_bills >= $this->get_times_billed(); |
|
773 | + } |
|
774 | + |
|
775 | + /* |
|
776 | 776 | |-------------------------------------------------------------------------- |
777 | 777 | | Additional methods |
778 | 778 | |-------------------------------------------------------------------------- |
@@ -781,27 +781,27 @@ discard block |
||
781 | 781 | | |
782 | 782 | */ |
783 | 783 | |
784 | - /** |
|
785 | - * Backwards compatibilty. |
|
786 | - */ |
|
787 | - public function create( $data = array() ) { |
|
784 | + /** |
|
785 | + * Backwards compatibilty. |
|
786 | + */ |
|
787 | + public function create( $data = array() ) { |
|
788 | 788 | |
789 | - // Set the properties. |
|
790 | - if ( is_array( $data ) ) { |
|
791 | - $this->set_props( $data ); |
|
792 | - } |
|
789 | + // Set the properties. |
|
790 | + if ( is_array( $data ) ) { |
|
791 | + $this->set_props( $data ); |
|
792 | + } |
|
793 | 793 | |
794 | - // Save the item. |
|
795 | - return $this->save(); |
|
794 | + // Save the item. |
|
795 | + return $this->save(); |
|
796 | 796 | |
797 | - } |
|
797 | + } |
|
798 | 798 | |
799 | - /** |
|
800 | - * Backwards compatibilty. |
|
801 | - */ |
|
802 | - public function update( $args = array() ) { |
|
803 | - return $this->create( $args ); |
|
804 | - } |
|
799 | + /** |
|
800 | + * Backwards compatibilty. |
|
801 | + */ |
|
802 | + public function update( $args = array() ) { |
|
803 | + return $this->create( $args ); |
|
804 | + } |
|
805 | 805 | |
806 | 806 | /** |
807 | 807 | * Retrieve renewal payments for a subscription |
@@ -811,15 +811,15 @@ discard block |
||
811 | 811 | */ |
812 | 812 | public function get_child_payments() { |
813 | 813 | return get_posts( |
814 | - array( |
|
815 | - 'post_parent' => $this->get_parent_payment_id(), |
|
816 | - 'numberposts' => -1, |
|
817 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
818 | - 'orderby' => 'ID', |
|
819 | - 'order' => 'DESC', |
|
820 | - 'post_type' => 'wpi_invoice' |
|
821 | - ) |
|
822 | - ); |
|
814 | + array( |
|
815 | + 'post_parent' => $this->get_parent_payment_id(), |
|
816 | + 'numberposts' => -1, |
|
817 | + 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
818 | + 'orderby' => 'ID', |
|
819 | + 'order' => 'DESC', |
|
820 | + 'post_type' => 'wpi_invoice' |
|
821 | + ) |
|
822 | + ); |
|
823 | 823 | } |
824 | 824 | |
825 | 825 | /** |
@@ -829,16 +829,16 @@ discard block |
||
829 | 829 | * @return int |
830 | 830 | */ |
831 | 831 | public function get_total_payments() { |
832 | - global $wpdb; |
|
832 | + global $wpdb; |
|
833 | 833 | |
834 | - $count = (int) $wpdb->get_var( |
|
835 | - $wpdb->prepare( |
|
836 | - "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent=%d AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )", |
|
837 | - $this->get_parent_invoice_id() |
|
838 | - ) |
|
839 | - ); |
|
834 | + $count = (int) $wpdb->get_var( |
|
835 | + $wpdb->prepare( |
|
836 | + "SELECT COUNT(ID) FROM $wpdb->posts WHERE post_parent=%d AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )", |
|
837 | + $this->get_parent_invoice_id() |
|
838 | + ) |
|
839 | + ); |
|
840 | 840 | |
841 | - // Maybe include parent invoice. |
|
841 | + // Maybe include parent invoice. |
|
842 | 842 | if ( ! $this->get_parent_payment()->is_paid() ) { |
843 | 843 | $count++; |
844 | 844 | } |
@@ -867,57 +867,57 @@ discard block |
||
867 | 867 | * |
868 | 868 | * @since 2.4 |
869 | 869 | * @param array $args Array of values for the payment, including amount and transaction ID |
870 | - * @param WPInv_Invoice $invoice If adding an existing invoice. |
|
870 | + * @param WPInv_Invoice $invoice If adding an existing invoice. |
|
871 | 871 | * @return bool |
872 | 872 | */ |
873 | 873 | public function add_payment( $args = array(), $invoice = false ) { |
874 | 874 | |
875 | - // Process each payment once. |
|
875 | + // Process each payment once. |
|
876 | 876 | if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
877 | 877 | return false; |
878 | 878 | } |
879 | 879 | |
880 | - // Are we creating a new invoice? |
|
881 | - if ( empty( $invoice ) ) { |
|
882 | - $invoice = $this->create_payment(); |
|
880 | + // Are we creating a new invoice? |
|
881 | + if ( empty( $invoice ) ) { |
|
882 | + $invoice = $this->create_payment(); |
|
883 | 883 | |
884 | - if ( empty( $invoice ) ) { |
|
885 | - return false; |
|
886 | - } |
|
884 | + if ( empty( $invoice ) ) { |
|
885 | + return false; |
|
886 | + } |
|
887 | 887 | |
888 | - $invoice->set_status( 'wpi-renewal' ); |
|
888 | + $invoice->set_status( 'wpi-renewal' ); |
|
889 | 889 | |
890 | - } |
|
890 | + } |
|
891 | 891 | |
892 | - // Maybe set a transaction id. |
|
893 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
894 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
895 | - } |
|
892 | + // Maybe set a transaction id. |
|
893 | + if ( ! empty( $args['transaction_id'] ) ) { |
|
894 | + $invoice->set_transaction_id( $args['transaction_id'] ); |
|
895 | + } |
|
896 | 896 | |
897 | - // Set the completed date. |
|
898 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
897 | + // Set the completed date. |
|
898 | + $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
899 | 899 | |
900 | - // And the gateway. |
|
901 | - if ( ! empty( $args['gateway'] ) ) { |
|
902 | - $invoice->set_gateway( $args['gateway'] ); |
|
903 | - } |
|
900 | + // And the gateway. |
|
901 | + if ( ! empty( $args['gateway'] ) ) { |
|
902 | + $invoice->set_gateway( $args['gateway'] ); |
|
903 | + } |
|
904 | 904 | |
905 | - $invoice->save(); |
|
905 | + $invoice->save(); |
|
906 | 906 | |
907 | - if ( ! $invoice->get_id() ) { |
|
908 | - return 0; |
|
909 | - } |
|
907 | + if ( ! $invoice->get_id() ) { |
|
908 | + return 0; |
|
909 | + } |
|
910 | 910 | |
911 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
912 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
911 | + do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
912 | + do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
913 | 913 | do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
914 | 914 | |
915 | 915 | update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
916 | 916 | |
917 | 917 | return $invoice->get_id(); |
918 | - } |
|
918 | + } |
|
919 | 919 | |
920 | - /** |
|
920 | + /** |
|
921 | 921 | * Creates a new invoice and returns it. |
922 | 922 | * |
923 | 923 | * @since 1.0.19 |
@@ -925,104 +925,104 @@ discard block |
||
925 | 925 | */ |
926 | 926 | public function create_payment() { |
927 | 927 | |
928 | - $parent_invoice = $this->get_parent_payment(); |
|
929 | - |
|
930 | - if ( ! $parent_invoice->get_id() ) { |
|
931 | - return false; |
|
932 | - } |
|
933 | - |
|
934 | - // Duplicate the parent invoice. |
|
935 | - $invoice = new WPInv_Invoice(); |
|
936 | - $invoice->set_props( $parent_invoice->get_data() ); |
|
937 | - $invoice->set_id( 0 ); |
|
938 | - $invoice->set_items( $parent_invoice->get_items() ); |
|
939 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
940 | - $invoice->set_transaction_id( '' ); |
|
941 | - $invoice->set_key( $invoice->generate_key( 'renewal_' ) ); |
|
942 | - $invoice->set_number( '' ); |
|
943 | - $invoice->set_completed_date( '' ); |
|
944 | - $invoice->set_status( 'wpi-pending' ); |
|
945 | - $invoice->recalculate_total(); |
|
946 | - $invoice->save(); |
|
947 | - |
|
948 | - return $invoice->get_id() ? $invoice : false; |
|
949 | - } |
|
950 | - |
|
951 | - /** |
|
952 | - * Renews or completes a subscription |
|
953 | - * |
|
954 | - * @since 1.0.0 |
|
955 | - * @return int The subscription's id |
|
956 | - */ |
|
957 | - public function renew() { |
|
958 | - |
|
959 | - // Complete subscription if applicable |
|
960 | - if ( $this->is_last_renewal() ) { |
|
961 | - return $this->complete(); |
|
962 | - } |
|
963 | - |
|
964 | - // Calculate new expiration |
|
965 | - $frequency = $this->get_frequency(); |
|
966 | - $period = $this->get_period(); |
|
967 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
968 | - |
|
969 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
970 | - $this->set_status( 'active' ); |
|
971 | - return $this->save(); |
|
972 | - |
|
973 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
974 | - |
|
975 | - } |
|
976 | - |
|
977 | - /** |
|
978 | - * Marks a subscription as completed |
|
979 | - * |
|
980 | - * Subscription is completed when the number of payments matches the billing_times field |
|
981 | - * |
|
982 | - * @since 1.0.0 |
|
983 | - * @return int|bool Subscription id or false if the subscription is cancelled. |
|
984 | - */ |
|
985 | - public function complete() { |
|
986 | - |
|
987 | - // Only mark a subscription as complete if it's not already cancelled. |
|
988 | - if ( $this->has_status( 'cancelled' ) ) { |
|
989 | - return false; |
|
990 | - } |
|
991 | - |
|
992 | - $this->set_status( 'completed' ); |
|
993 | - return $this->save(); |
|
994 | - |
|
995 | - } |
|
996 | - |
|
997 | - /** |
|
998 | - * Marks a subscription as expired |
|
999 | - * |
|
1000 | - * @since 1.0.0 |
|
1001 | - * @param bool $check_expiration |
|
1002 | - * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
|
1003 | - */ |
|
1004 | - public function expire( $check_expiration = false ) { |
|
1005 | - |
|
1006 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1007 | - // Do not mark as expired since real expiration date is in the future |
|
1008 | - return false; |
|
1009 | - } |
|
1010 | - |
|
1011 | - $this->set_status( 'expired' ); |
|
1012 | - return $this->save(); |
|
1013 | - |
|
1014 | - } |
|
1015 | - |
|
1016 | - /** |
|
1017 | - * Marks a subscription as failing |
|
1018 | - * |
|
1019 | - * @since 2.4.2 |
|
1020 | - * @return int Subscription id. |
|
1021 | - */ |
|
1022 | - public function failing() { |
|
1023 | - $this->set_status( 'failing' ); |
|
1024 | - return $this->save(); |
|
1025 | - } |
|
928 | + $parent_invoice = $this->get_parent_payment(); |
|
929 | + |
|
930 | + if ( ! $parent_invoice->get_id() ) { |
|
931 | + return false; |
|
932 | + } |
|
933 | + |
|
934 | + // Duplicate the parent invoice. |
|
935 | + $invoice = new WPInv_Invoice(); |
|
936 | + $invoice->set_props( $parent_invoice->get_data() ); |
|
937 | + $invoice->set_id( 0 ); |
|
938 | + $invoice->set_items( $parent_invoice->get_items() ); |
|
939 | + $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
940 | + $invoice->set_transaction_id( '' ); |
|
941 | + $invoice->set_key( $invoice->generate_key( 'renewal_' ) ); |
|
942 | + $invoice->set_number( '' ); |
|
943 | + $invoice->set_completed_date( '' ); |
|
944 | + $invoice->set_status( 'wpi-pending' ); |
|
945 | + $invoice->recalculate_total(); |
|
946 | + $invoice->save(); |
|
947 | + |
|
948 | + return $invoice->get_id() ? $invoice : false; |
|
949 | + } |
|
950 | + |
|
951 | + /** |
|
952 | + * Renews or completes a subscription |
|
953 | + * |
|
954 | + * @since 1.0.0 |
|
955 | + * @return int The subscription's id |
|
956 | + */ |
|
957 | + public function renew() { |
|
958 | + |
|
959 | + // Complete subscription if applicable |
|
960 | + if ( $this->is_last_renewal() ) { |
|
961 | + return $this->complete(); |
|
962 | + } |
|
963 | + |
|
964 | + // Calculate new expiration |
|
965 | + $frequency = $this->get_frequency(); |
|
966 | + $period = $this->get_period(); |
|
967 | + $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
968 | + |
|
969 | + $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
970 | + $this->set_status( 'active' ); |
|
971 | + return $this->save(); |
|
972 | + |
|
973 | + do_action( 'getpaid_subscription_renewed', $this ); |
|
974 | + |
|
975 | + } |
|
976 | + |
|
977 | + /** |
|
978 | + * Marks a subscription as completed |
|
979 | + * |
|
980 | + * Subscription is completed when the number of payments matches the billing_times field |
|
981 | + * |
|
982 | + * @since 1.0.0 |
|
983 | + * @return int|bool Subscription id or false if the subscription is cancelled. |
|
984 | + */ |
|
985 | + public function complete() { |
|
986 | + |
|
987 | + // Only mark a subscription as complete if it's not already cancelled. |
|
988 | + if ( $this->has_status( 'cancelled' ) ) { |
|
989 | + return false; |
|
990 | + } |
|
991 | + |
|
992 | + $this->set_status( 'completed' ); |
|
993 | + return $this->save(); |
|
994 | + |
|
995 | + } |
|
996 | + |
|
997 | + /** |
|
998 | + * Marks a subscription as expired |
|
999 | + * |
|
1000 | + * @since 1.0.0 |
|
1001 | + * @param bool $check_expiration |
|
1002 | + * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
|
1003 | + */ |
|
1004 | + public function expire( $check_expiration = false ) { |
|
1005 | + |
|
1006 | + if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1007 | + // Do not mark as expired since real expiration date is in the future |
|
1008 | + return false; |
|
1009 | + } |
|
1010 | + |
|
1011 | + $this->set_status( 'expired' ); |
|
1012 | + return $this->save(); |
|
1013 | + |
|
1014 | + } |
|
1015 | + |
|
1016 | + /** |
|
1017 | + * Marks a subscription as failing |
|
1018 | + * |
|
1019 | + * @since 2.4.2 |
|
1020 | + * @return int Subscription id. |
|
1021 | + */ |
|
1022 | + public function failing() { |
|
1023 | + $this->set_status( 'failing' ); |
|
1024 | + return $this->save(); |
|
1025 | + } |
|
1026 | 1026 | |
1027 | 1027 | /** |
1028 | 1028 | * Marks a subscription as cancelled |
@@ -1031,19 +1031,19 @@ discard block |
||
1031 | 1031 | * @return int Subscription id. |
1032 | 1032 | */ |
1033 | 1033 | public function cancel() { |
1034 | - $this->set_status( 'cancelled' ); |
|
1035 | - return $this->save(); |
|
1034 | + $this->set_status( 'cancelled' ); |
|
1035 | + return $this->save(); |
|
1036 | 1036 | } |
1037 | 1037 | |
1038 | - /** |
|
1039 | - * Determines if a subscription can be cancelled both locally and with a payment processor. |
|
1040 | - * |
|
1041 | - * @since 1.0.0 |
|
1042 | - * @return bool |
|
1043 | - */ |
|
1044 | - public function can_cancel() { |
|
1045 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1046 | - } |
|
1038 | + /** |
|
1039 | + * Determines if a subscription can be cancelled both locally and with a payment processor. |
|
1040 | + * |
|
1041 | + * @since 1.0.0 |
|
1042 | + * @return bool |
|
1043 | + */ |
|
1044 | + public function can_cancel() { |
|
1045 | + return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1046 | + } |
|
1047 | 1047 | |
1048 | 1048 | /** |
1049 | 1049 | * Returns an array of subscription statuses that can be cancelled |
@@ -1056,93 +1056,93 @@ discard block |
||
1056 | 1056 | return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
1057 | 1057 | } |
1058 | 1058 | |
1059 | - /** |
|
1060 | - * Retrieves the URL to cancel subscription |
|
1061 | - * |
|
1062 | - * @since 1.0.0 |
|
1063 | - * @return string |
|
1064 | - */ |
|
1065 | - public function get_cancel_url() { |
|
1066 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1067 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1068 | - } |
|
1069 | - |
|
1070 | - /** |
|
1071 | - * Retrieves the URL to view a subscription |
|
1072 | - * |
|
1073 | - * @since 1.0.19 |
|
1074 | - * @return string |
|
1075 | - */ |
|
1076 | - public function get_view_url() { |
|
1077 | - $url = add_query_arg( 'subscription', $this->get_id(), get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1078 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1079 | - } |
|
1080 | - |
|
1081 | - /** |
|
1082 | - * Determines if subscription can be manually renewed |
|
1083 | - * |
|
1084 | - * This method is filtered by payment gateways in order to return true on subscriptions |
|
1085 | - * that can be renewed manually |
|
1086 | - * |
|
1087 | - * @since 2.5 |
|
1088 | - * @return bool |
|
1089 | - */ |
|
1090 | - public function can_renew() { |
|
1091 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1092 | - } |
|
1093 | - |
|
1094 | - /** |
|
1095 | - * Retrieves the URL to renew a subscription |
|
1096 | - * |
|
1097 | - * @since 2.5 |
|
1098 | - * @return string |
|
1099 | - */ |
|
1100 | - public function get_renew_url() { |
|
1101 | - $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1102 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1103 | - } |
|
1104 | - |
|
1105 | - /** |
|
1106 | - * Determines if subscription can have their payment method updated |
|
1107 | - * |
|
1108 | - * @since 1.0.0 |
|
1109 | - * @return bool |
|
1110 | - */ |
|
1111 | - public function can_update() { |
|
1112 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1113 | - } |
|
1114 | - |
|
1115 | - /** |
|
1116 | - * Retrieves the URL to update subscription |
|
1117 | - * |
|
1118 | - * @since 1.0.0 |
|
1119 | - * @return string |
|
1120 | - */ |
|
1121 | - public function get_update_url() { |
|
1122 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1123 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1124 | - } |
|
1125 | - |
|
1126 | - /** |
|
1127 | - * Retrieves the subscription status label |
|
1128 | - * |
|
1129 | - * @since 1.0.0 |
|
1130 | - * @return string |
|
1131 | - */ |
|
1132 | - public function get_status_label() { |
|
1133 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1134 | - } |
|
1135 | - |
|
1136 | - /** |
|
1137 | - * Retrieves the subscription status class |
|
1138 | - * |
|
1139 | - * @since 1.0.19 |
|
1140 | - * @return string |
|
1141 | - */ |
|
1142 | - public function get_status_class() { |
|
1143 | - $statuses = getpaid_get_subscription_status_classes(); |
|
1144 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary'; |
|
1145 | - } |
|
1059 | + /** |
|
1060 | + * Retrieves the URL to cancel subscription |
|
1061 | + * |
|
1062 | + * @since 1.0.0 |
|
1063 | + * @return string |
|
1064 | + */ |
|
1065 | + public function get_cancel_url() { |
|
1066 | + $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1067 | + return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1068 | + } |
|
1069 | + |
|
1070 | + /** |
|
1071 | + * Retrieves the URL to view a subscription |
|
1072 | + * |
|
1073 | + * @since 1.0.19 |
|
1074 | + * @return string |
|
1075 | + */ |
|
1076 | + public function get_view_url() { |
|
1077 | + $url = add_query_arg( 'subscription', $this->get_id(), get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1078 | + return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1079 | + } |
|
1080 | + |
|
1081 | + /** |
|
1082 | + * Determines if subscription can be manually renewed |
|
1083 | + * |
|
1084 | + * This method is filtered by payment gateways in order to return true on subscriptions |
|
1085 | + * that can be renewed manually |
|
1086 | + * |
|
1087 | + * @since 2.5 |
|
1088 | + * @return bool |
|
1089 | + */ |
|
1090 | + public function can_renew() { |
|
1091 | + return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1092 | + } |
|
1093 | + |
|
1094 | + /** |
|
1095 | + * Retrieves the URL to renew a subscription |
|
1096 | + * |
|
1097 | + * @since 2.5 |
|
1098 | + * @return string |
|
1099 | + */ |
|
1100 | + public function get_renew_url() { |
|
1101 | + $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1102 | + return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1103 | + } |
|
1104 | + |
|
1105 | + /** |
|
1106 | + * Determines if subscription can have their payment method updated |
|
1107 | + * |
|
1108 | + * @since 1.0.0 |
|
1109 | + * @return bool |
|
1110 | + */ |
|
1111 | + public function can_update() { |
|
1112 | + return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1113 | + } |
|
1114 | + |
|
1115 | + /** |
|
1116 | + * Retrieves the URL to update subscription |
|
1117 | + * |
|
1118 | + * @since 1.0.0 |
|
1119 | + * @return string |
|
1120 | + */ |
|
1121 | + public function get_update_url() { |
|
1122 | + $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1123 | + return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1124 | + } |
|
1125 | + |
|
1126 | + /** |
|
1127 | + * Retrieves the subscription status label |
|
1128 | + * |
|
1129 | + * @since 1.0.0 |
|
1130 | + * @return string |
|
1131 | + */ |
|
1132 | + public function get_status_label() { |
|
1133 | + return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1134 | + } |
|
1135 | + |
|
1136 | + /** |
|
1137 | + * Retrieves the subscription status class |
|
1138 | + * |
|
1139 | + * @since 1.0.19 |
|
1140 | + * @return string |
|
1141 | + */ |
|
1142 | + public function get_status_class() { |
|
1143 | + $statuses = getpaid_get_subscription_status_classes(); |
|
1144 | + return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary'; |
|
1145 | + } |
|
1146 | 1146 | |
1147 | 1147 | /** |
1148 | 1148 | * Retrieves the subscription status label |
@@ -1152,11 +1152,11 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public function get_status_label_html() { |
1154 | 1154 | |
1155 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1156 | - $class = esc_attr( $this->get_status_class() ); |
|
1157 | - $status = sanitize_html_class( $this->get_status_label() ); |
|
1155 | + $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1156 | + $class = esc_attr( $this->get_status_class() ); |
|
1157 | + $status = sanitize_html_class( $this->get_status_label() ); |
|
1158 | 1158 | |
1159 | - return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded $class $status'>$status_label</span></span>"; |
|
1159 | + return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded $class $status'>$status_label</span></span>"; |
|
1160 | 1160 | } |
1161 | 1161 | |
1162 | 1162 | /** |
@@ -1167,75 +1167,75 @@ discard block |
||
1167 | 1167 | * @return bool |
1168 | 1168 | */ |
1169 | 1169 | public function payment_exists( $txn_id = '' ) { |
1170 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1170 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1171 | 1171 | return ! empty( $invoice_id ); |
1172 | - } |
|
1173 | - |
|
1174 | - /** |
|
1175 | - * Handle the status transition. |
|
1176 | - */ |
|
1177 | - protected function status_transition() { |
|
1178 | - $status_transition = $this->status_transition; |
|
1179 | - |
|
1180 | - // Reset status transition variable. |
|
1181 | - $this->status_transition = false; |
|
1182 | - |
|
1183 | - if ( $status_transition ) { |
|
1184 | - try { |
|
1185 | - |
|
1186 | - // Fire a hook for the status change. |
|
1187 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1188 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1189 | - |
|
1190 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1191 | - |
|
1192 | - /* translators: 1: old subscription status 2: new subscription status */ |
|
1193 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1194 | - |
|
1195 | - // Note the transition occurred. |
|
1196 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1197 | - |
|
1198 | - // Fire another hook. |
|
1199 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1200 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1201 | - |
|
1202 | - } else { |
|
1203 | - /* translators: %s: new invoice status */ |
|
1204 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1205 | - |
|
1206 | - // Note the transition occurred. |
|
1207 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1208 | - |
|
1209 | - } |
|
1210 | - } catch ( Exception $e ) { |
|
1211 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1212 | - } |
|
1213 | - } |
|
1214 | - |
|
1215 | - } |
|
1216 | - |
|
1217 | - /** |
|
1218 | - * Save data to the database. |
|
1219 | - * |
|
1220 | - * @since 1.0.19 |
|
1221 | - * @return int subscription ID |
|
1222 | - */ |
|
1223 | - public function save() { |
|
1224 | - parent::save(); |
|
1225 | - $this->status_transition(); |
|
1226 | - return $this->get_id(); |
|
1227 | - } |
|
1228 | - |
|
1229 | - /** |
|
1230 | - * Activates a subscription. |
|
1231 | - * |
|
1232 | - * @since 1.0.19 |
|
1233 | - * @return int subscription ID |
|
1234 | - */ |
|
1235 | - public function activate() { |
|
1236 | - $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
|
1237 | - $this->set_status( $status ); |
|
1238 | - return $this->save(); |
|
1239 | - } |
|
1172 | + } |
|
1173 | + |
|
1174 | + /** |
|
1175 | + * Handle the status transition. |
|
1176 | + */ |
|
1177 | + protected function status_transition() { |
|
1178 | + $status_transition = $this->status_transition; |
|
1179 | + |
|
1180 | + // Reset status transition variable. |
|
1181 | + $this->status_transition = false; |
|
1182 | + |
|
1183 | + if ( $status_transition ) { |
|
1184 | + try { |
|
1185 | + |
|
1186 | + // Fire a hook for the status change. |
|
1187 | + do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1188 | + do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1189 | + |
|
1190 | + if ( ! empty( $status_transition['from'] ) ) { |
|
1191 | + |
|
1192 | + /* translators: 1: old subscription status 2: new subscription status */ |
|
1193 | + $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1194 | + |
|
1195 | + // Note the transition occurred. |
|
1196 | + $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1197 | + |
|
1198 | + // Fire another hook. |
|
1199 | + do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1200 | + do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1201 | + |
|
1202 | + } else { |
|
1203 | + /* translators: %s: new invoice status */ |
|
1204 | + $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1205 | + |
|
1206 | + // Note the transition occurred. |
|
1207 | + $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1208 | + |
|
1209 | + } |
|
1210 | + } catch ( Exception $e ) { |
|
1211 | + $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1212 | + } |
|
1213 | + } |
|
1214 | + |
|
1215 | + } |
|
1216 | + |
|
1217 | + /** |
|
1218 | + * Save data to the database. |
|
1219 | + * |
|
1220 | + * @since 1.0.19 |
|
1221 | + * @return int subscription ID |
|
1222 | + */ |
|
1223 | + public function save() { |
|
1224 | + parent::save(); |
|
1225 | + $this->status_transition(); |
|
1226 | + return $this->get_id(); |
|
1227 | + } |
|
1228 | + |
|
1229 | + /** |
|
1230 | + * Activates a subscription. |
|
1231 | + * |
|
1232 | + * @since 1.0.19 |
|
1233 | + * @return int subscription ID |
|
1234 | + */ |
|
1235 | + public function activate() { |
|
1236 | + $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
|
1237 | + $this->set_status( $status ); |
|
1238 | + return $this->save(); |
|
1239 | + } |
|
1240 | 1240 | |
1241 | 1241 | } |
@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * The Subscription Class |
@@ -68,27 +68,27 @@ discard block |
||
68 | 68 | * @param int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read. |
69 | 69 | * @param bool $deprecated |
70 | 70 | */ |
71 | - function __construct( $subscription = 0, $deprecated = false ) { |
|
71 | + function __construct($subscription = 0, $deprecated = false) { |
|
72 | 72 | |
73 | - parent::__construct( $subscription ); |
|
73 | + parent::__construct($subscription); |
|
74 | 74 | |
75 | - if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) { |
|
76 | - $this->set_id( $subscription ); |
|
77 | - } elseif ( $subscription instanceof self ) { |
|
78 | - $this->set_id( $subscription->get_id() ); |
|
79 | - } elseif ( ! empty( $subscription->id ) ) { |
|
80 | - $this->set_id( $subscription->id ); |
|
81 | - } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
82 | - $this->set_id( $subscription_id ); |
|
75 | + if (!$deprecated && !empty($subscription) && is_numeric($subscription)) { |
|
76 | + $this->set_id($subscription); |
|
77 | + } elseif ($subscription instanceof self) { |
|
78 | + $this->set_id($subscription->get_id()); |
|
79 | + } elseif (!empty($subscription->id)) { |
|
80 | + $this->set_id($subscription->id); |
|
81 | + } elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
82 | + $this->set_id($subscription_id); |
|
83 | 83 | } else { |
84 | - $this->set_object_read( true ); |
|
84 | + $this->set_object_read(true); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | // Load the datastore. |
88 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
88 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
89 | 89 | |
90 | - if ( $this->get_id() > 0 ) { |
|
91 | - $this->data_store->read( $this ); |
|
90 | + if ($this->get_id() > 0) { |
|
91 | + $this->data_store->read($this); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | } |
@@ -103,17 +103,17 @@ discard block |
||
103 | 103 | * @since 1.0.19 |
104 | 104 | * @return int |
105 | 105 | */ |
106 | - public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) { |
|
106 | + public static function get_subscription_id_by_field($value, $field = 'profile_id') { |
|
107 | 107 | global $wpdb; |
108 | 108 | |
109 | 109 | // Trim the value. |
110 | - $value = trim( $value ); |
|
110 | + $value = trim($value); |
|
111 | 111 | |
112 | - if ( empty( $value ) ) { |
|
112 | + if (empty($value)) { |
|
113 | 113 | return 0; |
114 | 114 | } |
115 | 115 | |
116 | - if ( 'invoice_id' == $field ) { |
|
116 | + if ('invoice_id' == $field) { |
|
117 | 117 | $field = 'parent_payment_id'; |
118 | 118 | } |
119 | 119 | |
@@ -125,28 +125,28 @@ discard block |
||
125 | 125 | ); |
126 | 126 | |
127 | 127 | // Ensure a field has been passed. |
128 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
128 | + if (empty($field) || !in_array($field, $fields)) { |
|
129 | 129 | return 0; |
130 | 130 | } |
131 | 131 | |
132 | 132 | // Maybe retrieve from the cache. |
133 | - $subscription_id = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
134 | - if ( ! empty( $subscription_id ) ) { |
|
133 | + $subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
134 | + if (!empty($subscription_id)) { |
|
135 | 135 | return $subscription_id; |
136 | 136 | } |
137 | 137 | |
138 | 138 | // Fetch from the db. |
139 | 139 | $table = $wpdb->prefix . 'wpinv_subscriptions'; |
140 | 140 | $subscription_id = (int) $wpdb->get_var( |
141 | - $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
141 | + $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
142 | 142 | ); |
143 | 143 | |
144 | - if ( empty( $subscription_id ) ) { |
|
144 | + if (empty($subscription_id)) { |
|
145 | 145 | return 0; |
146 | 146 | } |
147 | 147 | |
148 | 148 | // Update the cache with our data. |
149 | - wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" ); |
|
149 | + wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids"); |
|
150 | 150 | |
151 | 151 | return $subscription_id; |
152 | 152 | } |
@@ -155,17 +155,17 @@ discard block |
||
155 | 155 | * Clears the subscription's cache. |
156 | 156 | */ |
157 | 157 | public function clear_cache() { |
158 | - wp_cache_delete( $this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids' ); |
|
159 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids' ); |
|
160 | - wp_cache_delete( $this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids' ); |
|
161 | - wp_cache_delete( $this->get_id(), 'getpaid_subscriptions' ); |
|
158 | + wp_cache_delete($this->get_parent_payment_id(), 'getpaid_subscription_parent_payment_ids_to_subscription_ids'); |
|
159 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_subscription_transaction_ids_to_subscription_ids'); |
|
160 | + wp_cache_delete($this->get_profile_id(), 'getpaid_subscription_profile_ids_to_subscription_ids'); |
|
161 | + wp_cache_delete($this->get_id(), 'getpaid_subscriptions'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
165 | 165 | * Checks if a subscription key is set. |
166 | 166 | */ |
167 | - public function _isset( $key ) { |
|
168 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
167 | + public function _isset($key) { |
|
168 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | /* |
@@ -190,8 +190,8 @@ discard block |
||
190 | 190 | * @param string $context View or edit context. |
191 | 191 | * @return int |
192 | 192 | */ |
193 | - public function get_customer_id( $context = 'view' ) { |
|
194 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
193 | + public function get_customer_id($context = 'view') { |
|
194 | + return (int) $this->get_prop('customer_id', $context); |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | /** |
@@ -201,8 +201,8 @@ discard block |
||
201 | 201 | * @param string $context View or edit context. |
202 | 202 | * @return WP_User|false WP_User object on success, false on failure. |
203 | 203 | */ |
204 | - public function get_customer( $context = 'view' ) { |
|
205 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
204 | + public function get_customer($context = 'view') { |
|
205 | + return get_userdata($this->get_customer_id($context)); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /** |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param string $context View or edit context. |
213 | 213 | * @return int |
214 | 214 | */ |
215 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
216 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
215 | + public function get_parent_invoice_id($context = 'view') { |
|
216 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | * @param string $context View or edit context. |
224 | 224 | * @return int |
225 | 225 | */ |
226 | - public function get_parent_payment_id( $context = 'view' ) { |
|
227 | - return $this->get_parent_invoice_id( $context ); |
|
226 | + public function get_parent_payment_id($context = 'view') { |
|
227 | + return $this->get_parent_invoice_id($context); |
|
228 | 228 | } |
229 | 229 | |
230 | 230 | /** |
@@ -233,8 +233,8 @@ discard block |
||
233 | 233 | * @since 1.0.0 |
234 | 234 | * @return int |
235 | 235 | */ |
236 | - public function get_original_payment_id( $context = 'view' ) { |
|
237 | - return $this->get_parent_invoice_id( $context ); |
|
236 | + public function get_original_payment_id($context = 'view') { |
|
237 | + return $this->get_parent_invoice_id($context); |
|
238 | 238 | } |
239 | 239 | |
240 | 240 | /** |
@@ -244,8 +244,8 @@ discard block |
||
244 | 244 | * @param string $context View or edit context. |
245 | 245 | * @return WPInv_Invoice |
246 | 246 | */ |
247 | - public function get_parent_invoice( $context = 'view' ) { |
|
248 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
247 | + public function get_parent_invoice($context = 'view') { |
|
248 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
249 | 249 | } |
250 | 250 | |
251 | 251 | /** |
@@ -255,8 +255,8 @@ discard block |
||
255 | 255 | * @param string $context View or edit context. |
256 | 256 | * @return WPInv_Invoice |
257 | 257 | */ |
258 | - public function get_parent_payment( $context = 'view' ) { |
|
259 | - return $this->get_parent_invoice( $context ); |
|
258 | + public function get_parent_payment($context = 'view') { |
|
259 | + return $this->get_parent_invoice($context); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | * @param string $context View or edit context. |
267 | 267 | * @return int |
268 | 268 | */ |
269 | - public function get_product_id( $context = 'view' ) { |
|
270 | - return (int) $this->get_prop( 'product_id', $context ); |
|
269 | + public function get_product_id($context = 'view') { |
|
270 | + return (int) $this->get_prop('product_id', $context); |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | /** |
@@ -277,8 +277,8 @@ discard block |
||
277 | 277 | * @param string $context View or edit context. |
278 | 278 | * @return WPInv_Item |
279 | 279 | */ |
280 | - public function get_product( $context = 'view' ) { |
|
281 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
280 | + public function get_product($context = 'view') { |
|
281 | + return new WPInv_Item($this->get_product_id($context)); |
|
282 | 282 | } |
283 | 283 | |
284 | 284 | /** |
@@ -290,8 +290,8 @@ discard block |
||
290 | 290 | * @param string $context View or edit context. |
291 | 291 | * @return string |
292 | 292 | */ |
293 | - public function get_gateway( $context = 'view' ) { |
|
294 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
293 | + public function get_gateway($context = 'view') { |
|
294 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | /** |
@@ -301,8 +301,8 @@ discard block |
||
301 | 301 | * @param string $context View or edit context. |
302 | 302 | * @return string |
303 | 303 | */ |
304 | - public function get_period( $context = 'view' ) { |
|
305 | - return $this->get_prop( 'period', $context ); |
|
304 | + public function get_period($context = 'view') { |
|
305 | + return $this->get_prop('period', $context); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -312,8 +312,8 @@ discard block |
||
312 | 312 | * @param string $context View or edit context. |
313 | 313 | * @return int |
314 | 314 | */ |
315 | - public function get_frequency( $context = 'view' ) { |
|
316 | - return (int) $this->get_prop( 'frequency', $context ); |
|
315 | + public function get_frequency($context = 'view') { |
|
316 | + return (int) $this->get_prop('frequency', $context); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -323,8 +323,8 @@ discard block |
||
323 | 323 | * @param string $context View or edit context. |
324 | 324 | * @return float |
325 | 325 | */ |
326 | - public function get_initial_amount( $context = 'view' ) { |
|
327 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
326 | + public function get_initial_amount($context = 'view') { |
|
327 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
328 | 328 | } |
329 | 329 | |
330 | 330 | /** |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | * @param string $context View or edit context. |
335 | 335 | * @return float |
336 | 336 | */ |
337 | - public function get_recurring_amount( $context = 'view' ) { |
|
338 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
337 | + public function get_recurring_amount($context = 'view') { |
|
338 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
339 | 339 | } |
340 | 340 | |
341 | 341 | /** |
@@ -345,8 +345,8 @@ discard block |
||
345 | 345 | * @param string $context View or edit context. |
346 | 346 | * @return int |
347 | 347 | */ |
348 | - public function get_bill_times( $context = 'view' ) { |
|
349 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
348 | + public function get_bill_times($context = 'view') { |
|
349 | + return (int) $this->get_prop('bill_times', $context); |
|
350 | 350 | } |
351 | 351 | |
352 | 352 | /** |
@@ -356,8 +356,8 @@ discard block |
||
356 | 356 | * @param string $context View or edit context. |
357 | 357 | * @return string |
358 | 358 | */ |
359 | - public function get_transaction_id( $context = 'view' ) { |
|
360 | - return $this->get_prop( 'transaction_id', $context ); |
|
359 | + public function get_transaction_id($context = 'view') { |
|
360 | + return $this->get_prop('transaction_id', $context); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | /** |
@@ -367,8 +367,8 @@ discard block |
||
367 | 367 | * @param string $context View or edit context. |
368 | 368 | * @return string |
369 | 369 | */ |
370 | - public function get_created( $context = 'view' ) { |
|
371 | - return $this->get_prop( 'created', $context ); |
|
370 | + public function get_created($context = 'view') { |
|
371 | + return $this->get_prop('created', $context); |
|
372 | 372 | } |
373 | 373 | |
374 | 374 | /** |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | * @param string $context View or edit context. |
379 | 379 | * @return string |
380 | 380 | */ |
381 | - public function get_date_created( $context = 'view' ) { |
|
382 | - return $this->get_created( $context ); |
|
381 | + public function get_date_created($context = 'view') { |
|
382 | + return $this->get_created($context); |
|
383 | 383 | } |
384 | 384 | |
385 | 385 | /** |
@@ -390,7 +390,7 @@ discard block |
||
390 | 390 | */ |
391 | 391 | public function get_time_created() { |
392 | 392 | $created = $this->get_date_created(); |
393 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
393 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | /** |
@@ -400,11 +400,11 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public function get_date_created_gmt( $context = 'view' ) { |
|
404 | - $date = $this->get_date_created( $context ); |
|
403 | + public function get_date_created_gmt($context = 'view') { |
|
404 | + $date = $this->get_date_created($context); |
|
405 | 405 | |
406 | - if ( $date ) { |
|
407 | - $date = get_gmt_from_date( $date ); |
|
406 | + if ($date) { |
|
407 | + $date = get_gmt_from_date($date); |
|
408 | 408 | } |
409 | 409 | return $date; |
410 | 410 | } |
@@ -416,8 +416,8 @@ discard block |
||
416 | 416 | * @param string $context View or edit context. |
417 | 417 | * @return string |
418 | 418 | */ |
419 | - public function get_next_renewal_date( $context = 'view' ) { |
|
420 | - return $this->get_prop( 'expiration', $context ); |
|
419 | + public function get_next_renewal_date($context = 'view') { |
|
420 | + return $this->get_prop('expiration', $context); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | /** |
@@ -427,8 +427,8 @@ discard block |
||
427 | 427 | * @param string $context View or edit context. |
428 | 428 | * @return string |
429 | 429 | */ |
430 | - public function get_expiration( $context = 'view' ) { |
|
431 | - return $this->get_next_renewal_date( $context ); |
|
430 | + public function get_expiration($context = 'view') { |
|
431 | + return $this->get_next_renewal_date($context); |
|
432 | 432 | } |
433 | 433 | |
434 | 434 | /** |
@@ -440,12 +440,12 @@ discard block |
||
440 | 440 | public function get_expiration_time() { |
441 | 441 | $expiration = $this->get_expiration(); |
442 | 442 | |
443 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
444 | - return current_time( 'timestamp' ); |
|
443 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
444 | + return current_time('timestamp'); |
|
445 | 445 | } |
446 | 446 | |
447 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
448 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
447 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
448 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
449 | 449 | } |
450 | 450 | |
451 | 451 | /** |
@@ -455,11 +455,11 @@ discard block |
||
455 | 455 | * @param string $context View or edit context. |
456 | 456 | * @return string |
457 | 457 | */ |
458 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
459 | - $date = $this->get_next_renewal_date( $context ); |
|
458 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
459 | + $date = $this->get_next_renewal_date($context); |
|
460 | 460 | |
461 | - if ( $date ) { |
|
462 | - $date = get_gmt_from_date( $date ); |
|
461 | + if ($date) { |
|
462 | + $date = get_gmt_from_date($date); |
|
463 | 463 | } |
464 | 464 | return $date; |
465 | 465 | } |
@@ -471,8 +471,8 @@ discard block |
||
471 | 471 | * @param string $context View or edit context. |
472 | 472 | * @return string |
473 | 473 | */ |
474 | - public function get_trial_period( $context = 'view' ) { |
|
475 | - return $this->get_prop( 'trial_period', $context ); |
|
474 | + public function get_trial_period($context = 'view') { |
|
475 | + return $this->get_prop('trial_period', $context); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
@@ -482,8 +482,8 @@ discard block |
||
482 | 482 | * @param string $context View or edit context. |
483 | 483 | * @return string |
484 | 484 | */ |
485 | - public function get_status( $context = 'view' ) { |
|
486 | - return $this->get_prop( 'status', $context ); |
|
485 | + public function get_status($context = 'view') { |
|
486 | + return $this->get_prop('status', $context); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | /** |
@@ -493,8 +493,8 @@ discard block |
||
493 | 493 | * @param string $context View or edit context. |
494 | 494 | * @return string |
495 | 495 | */ |
496 | - public function get_profile_id( $context = 'view' ) { |
|
497 | - return $this->get_prop( 'profile_id', $context ); |
|
496 | + public function get_profile_id($context = 'view') { |
|
497 | + return $this->get_prop('profile_id', $context); |
|
498 | 498 | } |
499 | 499 | |
500 | 500 | /* |
@@ -509,8 +509,8 @@ discard block |
||
509 | 509 | * @since 1.0.19 |
510 | 510 | * @param int $value The customer's id. |
511 | 511 | */ |
512 | - public function set_customer_id( $value ) { |
|
513 | - $this->set_prop( 'customer_id', (int) $value ); |
|
512 | + public function set_customer_id($value) { |
|
513 | + $this->set_prop('customer_id', (int) $value); |
|
514 | 514 | } |
515 | 515 | |
516 | 516 | /** |
@@ -519,8 +519,8 @@ discard block |
||
519 | 519 | * @since 1.0.19 |
520 | 520 | * @param int $value The parent invoice id. |
521 | 521 | */ |
522 | - public function set_parent_invoice_id( $value ) { |
|
523 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
522 | + public function set_parent_invoice_id($value) { |
|
523 | + $this->set_prop('parent_payment_id', (int) $value); |
|
524 | 524 | } |
525 | 525 | |
526 | 526 | /** |
@@ -529,8 +529,8 @@ discard block |
||
529 | 529 | * @since 1.0.19 |
530 | 530 | * @param int $value The parent invoice id. |
531 | 531 | */ |
532 | - public function set_parent_payment_id( $value ) { |
|
533 | - $this->set_parent_invoice_id( $value ); |
|
532 | + public function set_parent_payment_id($value) { |
|
533 | + $this->set_parent_invoice_id($value); |
|
534 | 534 | } |
535 | 535 | |
536 | 536 | /** |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * @since 1.0.19 |
540 | 540 | * @param int $value The parent invoice id. |
541 | 541 | */ |
542 | - public function set_original_payment_id( $value ) { |
|
543 | - $this->set_parent_invoice_id( $value ); |
|
542 | + public function set_original_payment_id($value) { |
|
543 | + $this->set_parent_invoice_id($value); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -549,8 +549,8 @@ discard block |
||
549 | 549 | * @since 1.0.19 |
550 | 550 | * @param int $value The subscription product id. |
551 | 551 | */ |
552 | - public function set_product_id( $value ) { |
|
553 | - $this->set_prop( 'product_id', (int) $value ); |
|
552 | + public function set_product_id($value) { |
|
553 | + $this->set_prop('product_id', (int) $value); |
|
554 | 554 | } |
555 | 555 | |
556 | 556 | /** |
@@ -559,8 +559,8 @@ discard block |
||
559 | 559 | * @since 1.0.19 |
560 | 560 | * @param string $value The renewal period. |
561 | 561 | */ |
562 | - public function set_period( $value ) { |
|
563 | - $this->set_prop( 'period', $value ); |
|
562 | + public function set_period($value) { |
|
563 | + $this->set_prop('period', $value); |
|
564 | 564 | } |
565 | 565 | |
566 | 566 | /** |
@@ -569,9 +569,9 @@ discard block |
||
569 | 569 | * @since 1.0.19 |
570 | 570 | * @param int $value The subscription frequency. |
571 | 571 | */ |
572 | - public function set_frequency( $value ) { |
|
573 | - $value = empty( $value ) ? 1 : (int) $value; |
|
574 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
572 | + public function set_frequency($value) { |
|
573 | + $value = empty($value) ? 1 : (int) $value; |
|
574 | + $this->set_prop('frequency', absint($value)); |
|
575 | 575 | } |
576 | 576 | |
577 | 577 | /** |
@@ -580,8 +580,8 @@ discard block |
||
580 | 580 | * @since 1.0.19 |
581 | 581 | * @param float $value The initial subcription amount. |
582 | 582 | */ |
583 | - public function set_initial_amount( $value ) { |
|
584 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
583 | + public function set_initial_amount($value) { |
|
584 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | /** |
@@ -590,8 +590,8 @@ discard block |
||
590 | 590 | * @since 1.0.19 |
591 | 591 | * @param float $value The recurring subcription amount. |
592 | 592 | */ |
593 | - public function set_recurring_amount( $value ) { |
|
594 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
593 | + public function set_recurring_amount($value) { |
|
594 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
595 | 595 | } |
596 | 596 | |
597 | 597 | /** |
@@ -600,8 +600,8 @@ discard block |
||
600 | 600 | * @since 1.0.19 |
601 | 601 | * @param int $value Bill times. |
602 | 602 | */ |
603 | - public function set_bill_times( $value ) { |
|
604 | - $this->set_prop( 'bill_times', (int) $value ); |
|
603 | + public function set_bill_times($value) { |
|
604 | + $this->set_prop('bill_times', (int) $value); |
|
605 | 605 | } |
606 | 606 | |
607 | 607 | /** |
@@ -610,8 +610,8 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param string $value Bill times. |
612 | 612 | */ |
613 | - public function set_transaction_id( $value ) { |
|
614 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
613 | + public function set_transaction_id($value) { |
|
614 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
615 | 615 | } |
616 | 616 | |
617 | 617 | /** |
@@ -620,15 +620,15 @@ discard block |
||
620 | 620 | * @since 1.0.19 |
621 | 621 | * @param string $value strtotime compliant date. |
622 | 622 | */ |
623 | - public function set_created( $value ) { |
|
624 | - $date = strtotime( $value ); |
|
623 | + public function set_created($value) { |
|
624 | + $date = strtotime($value); |
|
625 | 625 | |
626 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
627 | - $this->set_prop( 'created', date( 'Y-m-d H:i:s', $date ) ); |
|
626 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
627 | + $this->set_prop('created', date('Y-m-d H:i:s', $date)); |
|
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - $this->set_prop( 'created', '' ); |
|
631 | + $this->set_prop('created', ''); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | |
@@ -638,8 +638,8 @@ discard block |
||
638 | 638 | * @since 1.0.19 |
639 | 639 | * @param string $value strtotime compliant date. |
640 | 640 | */ |
641 | - public function set_date_created( $value ) { |
|
642 | - $this->set_created( $value ); |
|
641 | + public function set_date_created($value) { |
|
642 | + $this->set_created($value); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -648,15 +648,15 @@ discard block |
||
648 | 648 | * @since 1.0.19 |
649 | 649 | * @param string $value strtotime compliant date. |
650 | 650 | */ |
651 | - public function set_next_renewal_date( $value ) { |
|
652 | - $date = strtotime( $value ); |
|
651 | + public function set_next_renewal_date($value) { |
|
652 | + $date = strtotime($value); |
|
653 | 653 | |
654 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
655 | - $this->set_prop( 'expiration', date( 'Y-m-d H:i:s', $date ) ); |
|
654 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
655 | + $this->set_prop('expiration', date('Y-m-d H:i:s', $date)); |
|
656 | 656 | return; |
657 | 657 | } |
658 | 658 | |
659 | - $this->set_prop( 'expiration', '' ); |
|
659 | + $this->set_prop('expiration', ''); |
|
660 | 660 | |
661 | 661 | } |
662 | 662 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @since 1.0.19 |
667 | 667 | * @param string $value strtotime compliant date. |
668 | 668 | */ |
669 | - public function set_expiration( $value ) { |
|
670 | - $this->set_next_renewal_date( $value ); |
|
669 | + public function set_expiration($value) { |
|
670 | + $this->set_next_renewal_date($value); |
|
671 | 671 | } |
672 | 672 | |
673 | 673 | /** |
@@ -676,8 +676,8 @@ discard block |
||
676 | 676 | * @since 1.0.19 |
677 | 677 | * @param string $value trial period e.g 1 year. |
678 | 678 | */ |
679 | - public function set_trial_period( $value ) { |
|
680 | - $this->set_prop( 'trial_period', $value ); |
|
679 | + public function set_trial_period($value) { |
|
680 | + $this->set_prop('trial_period', $value); |
|
681 | 681 | } |
682 | 682 | |
683 | 683 | /** |
@@ -686,19 +686,19 @@ discard block |
||
686 | 686 | * @since 1.0.19 |
687 | 687 | * @param string $new_status New subscription status. |
688 | 688 | */ |
689 | - public function set_status( $new_status ) { |
|
689 | + public function set_status($new_status) { |
|
690 | 690 | |
691 | 691 | // Abort if this is not a valid status; |
692 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
692 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
693 | 693 | return; |
694 | 694 | } |
695 | 695 | |
696 | 696 | $old_status = $this->get_status(); |
697 | - $this->set_prop( 'status', $new_status ); |
|
697 | + $this->set_prop('status', $new_status); |
|
698 | 698 | |
699 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
699 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
700 | 700 | $this->status_transition = array( |
701 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
701 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
702 | 702 | 'to' => $new_status, |
703 | 703 | ); |
704 | 704 | } |
@@ -711,8 +711,8 @@ discard block |
||
711 | 711 | * @since 1.0.19 |
712 | 712 | * @param string $value the remote profile id. |
713 | 713 | */ |
714 | - public function set_profile_id( $value ) { |
|
715 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
714 | + public function set_profile_id($value) { |
|
715 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
716 | 716 | } |
717 | 717 | |
718 | 718 | /* |
@@ -730,8 +730,8 @@ discard block |
||
730 | 730 | * @param string|array String or array of strings to check for. |
731 | 731 | * @return bool |
732 | 732 | */ |
733 | - public function has_status( $status ) { |
|
734 | - return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
|
733 | + public function has_status($status) { |
|
734 | + return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status))); |
|
735 | 735 | } |
736 | 736 | |
737 | 737 | /** |
@@ -741,7 +741,7 @@ discard block |
||
741 | 741 | */ |
742 | 742 | public function has_trial_period() { |
743 | 743 | $period = $this->get_trial_period(); |
744 | - return ! empty( $period ); |
|
744 | + return !empty($period); |
|
745 | 745 | } |
746 | 746 | |
747 | 747 | /** |
@@ -750,7 +750,7 @@ discard block |
||
750 | 750 | * @return bool |
751 | 751 | */ |
752 | 752 | public function is_active() { |
753 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
753 | + return $this->has_status('active trialling') && !$this->is_expired(); |
|
754 | 754 | } |
755 | 755 | |
756 | 756 | /** |
@@ -759,7 +759,7 @@ discard block |
||
759 | 759 | * @return bool |
760 | 760 | */ |
761 | 761 | public function is_expired() { |
762 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'mysql' ) ); |
|
762 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('mysql')); |
|
763 | 763 | } |
764 | 764 | |
765 | 765 | /** |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | */ |
770 | 770 | public function is_last_renewal() { |
771 | 771 | $max_bills = $this->get_bill_times(); |
772 | - return ! empty( $max_bills ) && $max_bills >= $this->get_times_billed(); |
|
772 | + return !empty($max_bills) && $max_bills >= $this->get_times_billed(); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | /* |
@@ -784,11 +784,11 @@ discard block |
||
784 | 784 | /** |
785 | 785 | * Backwards compatibilty. |
786 | 786 | */ |
787 | - public function create( $data = array() ) { |
|
787 | + public function create($data = array()) { |
|
788 | 788 | |
789 | 789 | // Set the properties. |
790 | - if ( is_array( $data ) ) { |
|
791 | - $this->set_props( $data ); |
|
790 | + if (is_array($data)) { |
|
791 | + $this->set_props($data); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | // Save the item. |
@@ -799,8 +799,8 @@ discard block |
||
799 | 799 | /** |
800 | 800 | * Backwards compatibilty. |
801 | 801 | */ |
802 | - public function update( $args = array() ) { |
|
803 | - return $this->create( $args ); |
|
802 | + public function update($args = array()) { |
|
803 | + return $this->create($args); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | /** |
@@ -814,7 +814,7 @@ discard block |
||
814 | 814 | array( |
815 | 815 | 'post_parent' => $this->get_parent_payment_id(), |
816 | 816 | 'numberposts' => -1, |
817 | - 'post_status' => array( 'publish', 'wpi-processing', 'wpi-renewal' ), |
|
817 | + 'post_status' => array('publish', 'wpi-processing', 'wpi-renewal'), |
|
818 | 818 | 'orderby' => 'ID', |
819 | 819 | 'order' => 'DESC', |
820 | 820 | 'post_type' => 'wpi_invoice' |
@@ -839,7 +839,7 @@ discard block |
||
839 | 839 | ); |
840 | 840 | |
841 | 841 | // Maybe include parent invoice. |
842 | - if ( ! $this->get_parent_payment()->is_paid() ) { |
|
842 | + if (!$this->get_parent_payment()->is_paid()) { |
|
843 | 843 | $count++; |
844 | 844 | } |
845 | 845 | |
@@ -855,7 +855,7 @@ discard block |
||
855 | 855 | public function get_times_billed() { |
856 | 856 | $times_billed = $this->get_total_payments(); |
857 | 857 | |
858 | - if ( $this->has_trial_period() && $times_billed > 0 ) { |
|
858 | + if ($this->has_trial_period() && $times_billed > 0) { |
|
859 | 859 | $times_billed--; |
860 | 860 | } |
861 | 861 | |
@@ -870,49 +870,49 @@ discard block |
||
870 | 870 | * @param WPInv_Invoice $invoice If adding an existing invoice. |
871 | 871 | * @return bool |
872 | 872 | */ |
873 | - public function add_payment( $args = array(), $invoice = false ) { |
|
873 | + public function add_payment($args = array(), $invoice = false) { |
|
874 | 874 | |
875 | 875 | // Process each payment once. |
876 | - if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) { |
|
876 | + if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) { |
|
877 | 877 | return false; |
878 | 878 | } |
879 | 879 | |
880 | 880 | // Are we creating a new invoice? |
881 | - if ( empty( $invoice ) ) { |
|
881 | + if (empty($invoice)) { |
|
882 | 882 | $invoice = $this->create_payment(); |
883 | 883 | |
884 | - if ( empty( $invoice ) ) { |
|
884 | + if (empty($invoice)) { |
|
885 | 885 | return false; |
886 | 886 | } |
887 | 887 | |
888 | - $invoice->set_status( 'wpi-renewal' ); |
|
888 | + $invoice->set_status('wpi-renewal'); |
|
889 | 889 | |
890 | 890 | } |
891 | 891 | |
892 | 892 | // Maybe set a transaction id. |
893 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
894 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
893 | + if (!empty($args['transaction_id'])) { |
|
894 | + $invoice->set_transaction_id($args['transaction_id']); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | // Set the completed date. |
898 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
898 | + $invoice->set_completed_date(current_time('mysql')); |
|
899 | 899 | |
900 | 900 | // And the gateway. |
901 | - if ( ! empty( $args['gateway'] ) ) { |
|
902 | - $invoice->set_gateway( $args['gateway'] ); |
|
901 | + if (!empty($args['gateway'])) { |
|
902 | + $invoice->set_gateway($args['gateway']); |
|
903 | 903 | } |
904 | 904 | |
905 | 905 | $invoice->save(); |
906 | 906 | |
907 | - if ( ! $invoice->get_id() ) { |
|
907 | + if (!$invoice->get_id()) { |
|
908 | 908 | return 0; |
909 | 909 | } |
910 | 910 | |
911 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
912 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
913 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
911 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
912 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
913 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
914 | 914 | |
915 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
915 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
916 | 916 | |
917 | 917 | return $invoice->get_id(); |
918 | 918 | } |
@@ -927,21 +927,21 @@ discard block |
||
927 | 927 | |
928 | 928 | $parent_invoice = $this->get_parent_payment(); |
929 | 929 | |
930 | - if ( ! $parent_invoice->get_id() ) { |
|
930 | + if (!$parent_invoice->get_id()) { |
|
931 | 931 | return false; |
932 | 932 | } |
933 | 933 | |
934 | 934 | // Duplicate the parent invoice. |
935 | 935 | $invoice = new WPInv_Invoice(); |
936 | - $invoice->set_props( $parent_invoice->get_data() ); |
|
937 | - $invoice->set_id( 0 ); |
|
938 | - $invoice->set_items( $parent_invoice->get_items() ); |
|
939 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
940 | - $invoice->set_transaction_id( '' ); |
|
941 | - $invoice->set_key( $invoice->generate_key( 'renewal_' ) ); |
|
942 | - $invoice->set_number( '' ); |
|
943 | - $invoice->set_completed_date( '' ); |
|
944 | - $invoice->set_status( 'wpi-pending' ); |
|
936 | + $invoice->set_props($parent_invoice->get_data()); |
|
937 | + $invoice->set_id(0); |
|
938 | + $invoice->set_items($parent_invoice->get_items()); |
|
939 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
940 | + $invoice->set_transaction_id(''); |
|
941 | + $invoice->set_key($invoice->generate_key('renewal_')); |
|
942 | + $invoice->set_number(''); |
|
943 | + $invoice->set_completed_date(''); |
|
944 | + $invoice->set_status('wpi-pending'); |
|
945 | 945 | $invoice->recalculate_total(); |
946 | 946 | $invoice->save(); |
947 | 947 | |
@@ -957,20 +957,20 @@ discard block |
||
957 | 957 | public function renew() { |
958 | 958 | |
959 | 959 | // Complete subscription if applicable |
960 | - if ( $this->is_last_renewal() ) { |
|
960 | + if ($this->is_last_renewal()) { |
|
961 | 961 | return $this->complete(); |
962 | 962 | } |
963 | 963 | |
964 | 964 | // Calculate new expiration |
965 | 965 | $frequency = $this->get_frequency(); |
966 | 966 | $period = $this->get_period(); |
967 | - $new_expiration = strtotime( "+ $frequency $period", $this->get_expiration_time() ); |
|
967 | + $new_expiration = strtotime("+ $frequency $period", $this->get_expiration_time()); |
|
968 | 968 | |
969 | - $this->set_expiration( date( 'Y-m-d H:i:s',$new_expiration ) ); |
|
970 | - $this->set_status( 'active' ); |
|
969 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
970 | + $this->set_status('active'); |
|
971 | 971 | return $this->save(); |
972 | 972 | |
973 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
973 | + do_action('getpaid_subscription_renewed', $this); |
|
974 | 974 | |
975 | 975 | } |
976 | 976 | |
@@ -985,11 +985,11 @@ discard block |
||
985 | 985 | public function complete() { |
986 | 986 | |
987 | 987 | // Only mark a subscription as complete if it's not already cancelled. |
988 | - if ( $this->has_status( 'cancelled' ) ) { |
|
988 | + if ($this->has_status('cancelled')) { |
|
989 | 989 | return false; |
990 | 990 | } |
991 | 991 | |
992 | - $this->set_status( 'completed' ); |
|
992 | + $this->set_status('completed'); |
|
993 | 993 | return $this->save(); |
994 | 994 | |
995 | 995 | } |
@@ -1001,14 +1001,14 @@ discard block |
||
1001 | 1001 | * @param bool $check_expiration |
1002 | 1002 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
1003 | 1003 | */ |
1004 | - public function expire( $check_expiration = false ) { |
|
1004 | + public function expire($check_expiration = false) { |
|
1005 | 1005 | |
1006 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
1006 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
1007 | 1007 | // Do not mark as expired since real expiration date is in the future |
1008 | 1008 | return false; |
1009 | 1009 | } |
1010 | 1010 | |
1011 | - $this->set_status( 'expired' ); |
|
1011 | + $this->set_status('expired'); |
|
1012 | 1012 | return $this->save(); |
1013 | 1013 | |
1014 | 1014 | } |
@@ -1020,7 +1020,7 @@ discard block |
||
1020 | 1020 | * @return int Subscription id. |
1021 | 1021 | */ |
1022 | 1022 | public function failing() { |
1023 | - $this->set_status( 'failing' ); |
|
1023 | + $this->set_status('failing'); |
|
1024 | 1024 | return $this->save(); |
1025 | 1025 | } |
1026 | 1026 | |
@@ -1031,7 +1031,7 @@ discard block |
||
1031 | 1031 | * @return int Subscription id. |
1032 | 1032 | */ |
1033 | 1033 | public function cancel() { |
1034 | - $this->set_status( 'cancelled' ); |
|
1034 | + $this->set_status('cancelled'); |
|
1035 | 1035 | return $this->save(); |
1036 | 1036 | } |
1037 | 1037 | |
@@ -1042,7 +1042,7 @@ discard block |
||
1042 | 1042 | * @return bool |
1043 | 1043 | */ |
1044 | 1044 | public function can_cancel() { |
1045 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
1045 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
1046 | 1046 | } |
1047 | 1047 | |
1048 | 1048 | /** |
@@ -1053,7 +1053,7 @@ discard block |
||
1053 | 1053 | * @return array |
1054 | 1054 | */ |
1055 | 1055 | public function get_cancellable_statuses() { |
1056 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
1056 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
1057 | 1057 | } |
1058 | 1058 | |
1059 | 1059 | /** |
@@ -1063,8 +1063,8 @@ discard block |
||
1063 | 1063 | * @return string |
1064 | 1064 | */ |
1065 | 1065 | public function get_cancel_url() { |
1066 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
1067 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
1066 | + $url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url()); |
|
1067 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
1068 | 1068 | } |
1069 | 1069 | |
1070 | 1070 | /** |
@@ -1074,8 +1074,8 @@ discard block |
||
1074 | 1074 | * @return string |
1075 | 1075 | */ |
1076 | 1076 | public function get_view_url() { |
1077 | - $url = add_query_arg( 'subscription', $this->get_id(), get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
1078 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
1077 | + $url = add_query_arg('subscription', $this->get_id(), get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
1078 | + return apply_filters('getpaid_get_subscription_view_url', $url, $this); |
|
1079 | 1079 | } |
1080 | 1080 | |
1081 | 1081 | /** |
@@ -1088,7 +1088,7 @@ discard block |
||
1088 | 1088 | * @return bool |
1089 | 1089 | */ |
1090 | 1090 | public function can_renew() { |
1091 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
1091 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
1092 | 1092 | } |
1093 | 1093 | |
1094 | 1094 | /** |
@@ -1098,8 +1098,8 @@ discard block |
||
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | 1100 | public function get_renew_url() { |
1101 | - $url = wp_nonce_url( add_query_arg( array( 'getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id ) ), 'getpaid-nonce' ); |
|
1102 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
1101 | + $url = wp_nonce_url(add_query_arg(array('getpaid-action' => 'renew_subscription', 'sub_id' => $this->get_id)), 'getpaid-nonce'); |
|
1102 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
1103 | 1103 | } |
1104 | 1104 | |
1105 | 1105 | /** |
@@ -1109,7 +1109,7 @@ discard block |
||
1109 | 1109 | * @return bool |
1110 | 1110 | */ |
1111 | 1111 | public function can_update() { |
1112 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
1112 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
1113 | 1113 | } |
1114 | 1114 | |
1115 | 1115 | /** |
@@ -1119,8 +1119,8 @@ discard block |
||
1119 | 1119 | * @return string |
1120 | 1120 | */ |
1121 | 1121 | public function get_update_url() { |
1122 | - $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->get_id() ) ); |
|
1123 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
1122 | + $url = add_query_arg(array('action' => 'update', 'subscription_id' => $this->get_id())); |
|
1123 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
1124 | 1124 | } |
1125 | 1125 | |
1126 | 1126 | /** |
@@ -1130,7 +1130,7 @@ discard block |
||
1130 | 1130 | * @return string |
1131 | 1131 | */ |
1132 | 1132 | public function get_status_label() { |
1133 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
1133 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
1134 | 1134 | } |
1135 | 1135 | |
1136 | 1136 | /** |
@@ -1141,7 +1141,7 @@ discard block |
||
1141 | 1141 | */ |
1142 | 1142 | public function get_status_class() { |
1143 | 1143 | $statuses = getpaid_get_subscription_status_classes(); |
1144 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'text-white bg-secondary'; |
|
1144 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'text-white bg-secondary'; |
|
1145 | 1145 | } |
1146 | 1146 | |
1147 | 1147 | /** |
@@ -1152,9 +1152,9 @@ discard block |
||
1152 | 1152 | */ |
1153 | 1153 | public function get_status_label_html() { |
1154 | 1154 | |
1155 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
1156 | - $class = esc_attr( $this->get_status_class() ); |
|
1157 | - $status = sanitize_html_class( $this->get_status_label() ); |
|
1155 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
1156 | + $class = esc_attr($this->get_status_class()); |
|
1157 | + $status = sanitize_html_class($this->get_status_label()); |
|
1158 | 1158 | |
1159 | 1159 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded $class $status'>$status_label</span></span>"; |
1160 | 1160 | } |
@@ -1166,9 +1166,9 @@ discard block |
||
1166 | 1166 | * @param string $txn_id The transaction ID from the merchant processor |
1167 | 1167 | * @return bool |
1168 | 1168 | */ |
1169 | - public function payment_exists( $txn_id = '' ) { |
|
1170 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
1171 | - return ! empty( $invoice_id ); |
|
1169 | + public function payment_exists($txn_id = '') { |
|
1170 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
1171 | + return !empty($invoice_id); |
|
1172 | 1172 | } |
1173 | 1173 | |
1174 | 1174 | /** |
@@ -1180,35 +1180,35 @@ discard block |
||
1180 | 1180 | // Reset status transition variable. |
1181 | 1181 | $this->status_transition = false; |
1182 | 1182 | |
1183 | - if ( $status_transition ) { |
|
1183 | + if ($status_transition) { |
|
1184 | 1184 | try { |
1185 | 1185 | |
1186 | 1186 | // Fire a hook for the status change. |
1187 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
1188 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
1187 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
1188 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
1189 | 1189 | |
1190 | - if ( ! empty( $status_transition['from'] ) ) { |
|
1190 | + if (!empty($status_transition['from'])) { |
|
1191 | 1191 | |
1192 | 1192 | /* translators: 1: old subscription status 2: new subscription status */ |
1193 | - $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1193 | + $transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1194 | 1194 | |
1195 | 1195 | // Note the transition occurred. |
1196 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1196 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1197 | 1197 | |
1198 | 1198 | // Fire another hook. |
1199 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
1200 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
1199 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
1200 | + do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
1201 | 1201 | |
1202 | 1202 | } else { |
1203 | 1203 | /* translators: %s: new invoice status */ |
1204 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
1204 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
1205 | 1205 | |
1206 | 1206 | // Note the transition occurred. |
1207 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
1207 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
1208 | 1208 | |
1209 | 1209 | } |
1210 | - } catch ( Exception $e ) { |
|
1211 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
1210 | + } catch (Exception $e) { |
|
1211 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
1212 | 1212 | } |
1213 | 1213 | } |
1214 | 1214 | |
@@ -1234,7 +1234,7 @@ discard block |
||
1234 | 1234 | */ |
1235 | 1235 | public function activate() { |
1236 | 1236 | $status = 'trialling' == $this->get_status() ? 'trialling' : 'active'; |
1237 | - $this->set_status( $status ); |
|
1237 | + $this->set_status($status); |
|
1238 | 1238 | return $this->save(); |
1239 | 1239 | } |
1240 | 1240 |
@@ -13,36 +13,36 @@ discard block |
||
13 | 13 | class GetPaid_Notification_Email { |
14 | 14 | |
15 | 15 | /** |
16 | - * Contains the type of this notification email. |
|
17 | - * |
|
18 | - * @var string |
|
19 | - */ |
|
16 | + * Contains the type of this notification email. |
|
17 | + * |
|
18 | + * @var string |
|
19 | + */ |
|
20 | 20 | public $id; |
21 | 21 | |
22 | 22 | /** |
23 | - * Contains any object to use in filters. |
|
24 | - * |
|
25 | - * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription |
|
26 | - */ |
|
23 | + * Contains any object to use in filters. |
|
24 | + * |
|
25 | + * @var false|WPInv_Invoice|WPInv_Item|WPInv_Subscription |
|
26 | + */ |
|
27 | 27 | public $object; |
28 | 28 | |
29 | 29 | /** |
30 | - * Class constructor. |
|
31 | - * |
|
30 | + * Class constructor. |
|
31 | + * |
|
32 | 32 | * @param string $id Email Type. |
33 | 33 | * @param mixed $object Optional. Associated object. |
34 | - */ |
|
35 | - public function __construct( $id, $object = false ) { |
|
34 | + */ |
|
35 | + public function __construct( $id, $object = false ) { |
|
36 | 36 | $this->id = $id; |
37 | 37 | $this->object = $object; |
38 | 38 | } |
39 | 39 | |
40 | 40 | /** |
41 | - * Retrieves an option |
|
42 | - * |
|
41 | + * Retrieves an option |
|
42 | + * |
|
43 | 43 | * @return mixed |
44 | - */ |
|
45 | - public function get_option( $key ) { |
|
44 | + */ |
|
45 | + public function get_option( $key ) { |
|
46 | 46 | |
47 | 47 | $key = "email_{$this->id}_$key"; |
48 | 48 | $value = wpinv_get_option( $key, null ); |
@@ -60,80 +60,80 @@ discard block |
||
60 | 60 | } |
61 | 61 | |
62 | 62 | /** |
63 | - * Retrieves the email body. |
|
64 | - * |
|
63 | + * Retrieves the email body. |
|
64 | + * |
|
65 | 65 | * @return string |
66 | - */ |
|
67 | - public function get_body() { |
|
66 | + */ |
|
67 | + public function get_body() { |
|
68 | 68 | $body = $this->get_option( 'body' ); |
69 | 69 | return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object ); |
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
73 | - * Retrieves the email subject. |
|
74 | - * |
|
73 | + * Retrieves the email subject. |
|
74 | + * |
|
75 | 75 | * @return string |
76 | - */ |
|
77 | - public function get_subject() { |
|
76 | + */ |
|
77 | + public function get_subject() { |
|
78 | 78 | $subject = $this->get_option( 'subject' ); |
79 | 79 | return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object ); |
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
83 | - * Retrieves the email heading. |
|
84 | - * |
|
83 | + * Retrieves the email heading. |
|
84 | + * |
|
85 | 85 | * @return string |
86 | - */ |
|
87 | - public function get_heading() { |
|
86 | + */ |
|
87 | + public function get_heading() { |
|
88 | 88 | $heading = $this->get_option( 'heading' ); |
89 | 89 | return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object ); |
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
93 | - * Checks if an email is active. |
|
94 | - * |
|
93 | + * Checks if an email is active. |
|
94 | + * |
|
95 | 95 | * @return bool |
96 | - */ |
|
97 | - public function is_active() { |
|
96 | + */ |
|
97 | + public function is_active() { |
|
98 | 98 | $is_active = ! empty( $this->get_option( 'active' ) ); |
99 | 99 | return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object ); |
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
103 | - * Checks if the site's admin should receive email notifications. |
|
104 | - * |
|
103 | + * Checks if the site's admin should receive email notifications. |
|
104 | + * |
|
105 | 105 | * @return bool |
106 | - */ |
|
107 | - public function include_admin_bcc() { |
|
106 | + */ |
|
107 | + public function include_admin_bcc() { |
|
108 | 108 | $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) ); |
109 | 109 | return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object ); |
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
113 | - * Checks whether this email should be sent to the customer or admin. |
|
114 | - * |
|
113 | + * Checks whether this email should be sent to the customer or admin. |
|
114 | + * |
|
115 | 115 | * @return bool |
116 | - */ |
|
117 | - public function is_admin_email() { |
|
116 | + */ |
|
117 | + public function is_admin_email() { |
|
118 | 118 | $is_admin_email = in_array( $this->id, array( 'new_invoice', 'cancelled_invoice', 'failed_invoice' ) ); |
119 | 119 | return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object ); |
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
123 | - * Returns email attachments. |
|
124 | - * |
|
123 | + * Returns email attachments. |
|
124 | + * |
|
125 | 125 | * @return array |
126 | - */ |
|
127 | - public function get_attachments() { |
|
126 | + */ |
|
127 | + public function get_attachments() { |
|
128 | 128 | return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object ); |
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
132 | - * Returns an array of merge tags. |
|
133 | - * |
|
132 | + * Returns an array of merge tags. |
|
133 | + * |
|
134 | 134 | * @return array |
135 | - */ |
|
136 | - public function get_merge_tags() { |
|
135 | + */ |
|
136 | + public function get_merge_tags() { |
|
137 | 137 | |
138 | 138 | $merge_tags = array( |
139 | 139 | '{site_title}' => wpinv_get_blogname(), |
@@ -144,13 +144,13 @@ discard block |
||
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
147 | - * Adds merge tags to a text. |
|
148 | - * |
|
147 | + * Adds merge tags to a text. |
|
148 | + * |
|
149 | 149 | * @param string string $text |
150 | 150 | * @param array $merge_tags |
151 | 151 | * @return string |
152 | - */ |
|
153 | - public function add_merge_tags( $text, $merge_tags = array() ) { |
|
152 | + */ |
|
153 | + public function add_merge_tags( $text, $merge_tags = array() ) { |
|
154 | 154 | |
155 | 155 | foreach ( $merge_tags as $key => $value ) { |
156 | 156 | $text = str_replace( $key, $value, $text ); |
@@ -160,13 +160,13 @@ discard block |
||
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
163 | - * Returns the email content |
|
164 | - * |
|
163 | + * Returns the email content |
|
164 | + * |
|
165 | 165 | * @param array $merge_tags |
166 | 166 | * @param array $extra_args Extra template args |
167 | 167 | * @return string |
168 | - */ |
|
169 | - public function get_content( $merge_tags = array(), $extra_args = array() ) { |
|
168 | + */ |
|
169 | + public function get_content( $merge_tags = array(), $extra_args = array() ) { |
|
170 | 170 | |
171 | 171 | $content = wpinv_get_template_html( |
172 | 172 | "emails/wpinv-email-{$this->id}.php", |
@@ -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 | * Represents a single email type. |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | * @param string $id Email Type. |
33 | 33 | * @param mixed $object Optional. Associated object. |
34 | 34 | */ |
35 | - public function __construct( $id, $object = false ) { |
|
35 | + public function __construct($id, $object = false) { |
|
36 | 36 | $this->id = $id; |
37 | 37 | $this->object = $object; |
38 | 38 | } |
@@ -42,18 +42,18 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @return mixed |
44 | 44 | */ |
45 | - public function get_option( $key ) { |
|
45 | + public function get_option($key) { |
|
46 | 46 | |
47 | 47 | $key = "email_{$this->id}_$key"; |
48 | - $value = wpinv_get_option( $key, null ); |
|
49 | - if ( is_null( $value ) ) { |
|
48 | + $value = wpinv_get_option($key, null); |
|
49 | + if (is_null($value)) { |
|
50 | 50 | $options = wpinv_get_emails(); |
51 | 51 | |
52 | - if ( ! isset( $options[ $this->id ] ) || ! isset( $options[ $this->id ][ $key ] ) ) { |
|
52 | + if (!isset($options[$this->id]) || !isset($options[$this->id][$key])) { |
|
53 | 53 | return ''; |
54 | 54 | } |
55 | 55 | |
56 | - $value = isset( $options[ $this->id ][ $key ]['std'] ) ? $options[ $this->id ][ $key ]['std'] : ''; |
|
56 | + $value = isset($options[$this->id][$key]['std']) ? $options[$this->id][$key]['std'] : ''; |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | return $value; |
@@ -65,8 +65,8 @@ discard block |
||
65 | 65 | * @return string |
66 | 66 | */ |
67 | 67 | public function get_body() { |
68 | - $body = $this->get_option( 'body' ); |
|
69 | - return apply_filters( 'getpaid_get_email_body', $body, $this->id, $this->object ); |
|
68 | + $body = $this->get_option('body'); |
|
69 | + return apply_filters('getpaid_get_email_body', $body, $this->id, $this->object); |
|
70 | 70 | } |
71 | 71 | |
72 | 72 | /** |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @return string |
76 | 76 | */ |
77 | 77 | public function get_subject() { |
78 | - $subject = $this->get_option( 'subject' ); |
|
79 | - return apply_filters( 'getpaid_get_email_subject', $subject, $this->id, $this->object ); |
|
78 | + $subject = $this->get_option('subject'); |
|
79 | + return apply_filters('getpaid_get_email_subject', $subject, $this->id, $this->object); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | /** |
@@ -85,8 +85,8 @@ discard block |
||
85 | 85 | * @return string |
86 | 86 | */ |
87 | 87 | public function get_heading() { |
88 | - $heading = $this->get_option( 'heading' ); |
|
89 | - return apply_filters( 'getpaid_get_email_heading', $heading, $this->id, $this->object ); |
|
88 | + $heading = $this->get_option('heading'); |
|
89 | + return apply_filters('getpaid_get_email_heading', $heading, $this->id, $this->object); |
|
90 | 90 | } |
91 | 91 | |
92 | 92 | /** |
@@ -95,8 +95,8 @@ discard block |
||
95 | 95 | * @return bool |
96 | 96 | */ |
97 | 97 | public function is_active() { |
98 | - $is_active = ! empty( $this->get_option( 'active' ) ); |
|
99 | - return apply_filters( 'getpaid_email_type_is_active', $is_active, $this->id, $this->object ); |
|
98 | + $is_active = !empty($this->get_option('active')); |
|
99 | + return apply_filters('getpaid_email_type_is_active', $is_active, $this->id, $this->object); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | public function include_admin_bcc() { |
108 | - $include_admin_bcc = ! empty( $this->get_option( 'admin_bcc' ) ); |
|
109 | - return apply_filters( 'getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object ); |
|
108 | + $include_admin_bcc = !empty($this->get_option('admin_bcc')); |
|
109 | + return apply_filters('getpaid_email_type_include_admin_bcc', $include_admin_bcc, $this->id, $this->object); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -115,8 +115,8 @@ discard block |
||
115 | 115 | * @return bool |
116 | 116 | */ |
117 | 117 | public function is_admin_email() { |
118 | - $is_admin_email = in_array( $this->id, array( 'new_invoice', 'cancelled_invoice', 'failed_invoice' ) ); |
|
119 | - return apply_filters( 'getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object ); |
|
118 | + $is_admin_email = in_array($this->id, array('new_invoice', 'cancelled_invoice', 'failed_invoice')); |
|
119 | + return apply_filters('getpaid_email_type_is_admin_email', $is_admin_email, $this->id, $this->object); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @return array |
126 | 126 | */ |
127 | 127 | public function get_attachments() { |
128 | - return apply_filters( 'getpaid_get_email_attachments', array(), $this->id, $this->object ); |
|
128 | + return apply_filters('getpaid_get_email_attachments', array(), $this->id, $this->object); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | |
138 | 138 | $merge_tags = array( |
139 | 139 | '{site_title}' => wpinv_get_blogname(), |
140 | - '{date}' => getpaid_format_date_value( current_time( 'mysql' ) ), |
|
140 | + '{date}' => getpaid_format_date_value(current_time('mysql')), |
|
141 | 141 | ); |
142 | 142 | |
143 | - return apply_filters( 'getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id ); |
|
143 | + return apply_filters('getpaid_get_email_merge_tags', $merge_tags, $this->object, $this->id); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | /** |
@@ -150,13 +150,13 @@ discard block |
||
150 | 150 | * @param array $merge_tags |
151 | 151 | * @return string |
152 | 152 | */ |
153 | - public function add_merge_tags( $text, $merge_tags = array() ) { |
|
153 | + public function add_merge_tags($text, $merge_tags = array()) { |
|
154 | 154 | |
155 | - foreach ( $merge_tags as $key => $value ) { |
|
156 | - $text = str_replace( $key, $value, $text ); |
|
155 | + foreach ($merge_tags as $key => $value) { |
|
156 | + $text = str_replace($key, $value, $text); |
|
157 | 157 | } |
158 | 158 | |
159 | - return wptexturize( $text ); |
|
159 | + return wptexturize($text); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * @param array $extra_args Extra template args |
167 | 167 | * @return string |
168 | 168 | */ |
169 | - public function get_content( $merge_tags = array(), $extra_args = array() ) { |
|
169 | + public function get_content($merge_tags = array(), $extra_args = array()) { |
|
170 | 170 | |
171 | 171 | $content = wpinv_get_template_html( |
172 | 172 | "emails/wpinv-email-{$this->id}.php", |
@@ -176,15 +176,15 @@ discard block |
||
176 | 176 | 'invoice' => $this->object, // Backwards compat. |
177 | 177 | 'object' => $this->object, |
178 | 178 | 'email_type' => $this->id, |
179 | - 'email_heading' => $this->add_merge_tags( $this->get_heading(), $merge_tags ), |
|
179 | + 'email_heading' => $this->add_merge_tags($this->get_heading(), $merge_tags), |
|
180 | 180 | 'sent_to_admin' => $this->is_admin_email(), |
181 | 181 | 'plain_text' => false, |
182 | - 'message_body' => wpautop( $this->add_merge_tags( $this->get_body(), $merge_tags ) ), |
|
182 | + 'message_body' => wpautop($this->add_merge_tags($this->get_body(), $merge_tags)), |
|
183 | 183 | ) |
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | |
187 | - return wpinv_email_style_body( $content ); |
|
187 | + return wpinv_email_style_body($content); |
|
188 | 188 | } |
189 | 189 | |
190 | 190 | } |
@@ -8,24 +8,24 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | // Prepare the due date reminder options. |
14 | 14 | $overdue_days_options = array(); |
15 | -$overdue_days_options['0'] = __( 'On the Due Date', 'invoicing' ); |
|
16 | -$overdue_days_options['1'] = __( '1 day after Due Date', 'invoicing' ); |
|
15 | +$overdue_days_options['0'] = __('On the Due Date', 'invoicing'); |
|
16 | +$overdue_days_options['1'] = __('1 day after Due Date', 'invoicing'); |
|
17 | 17 | |
18 | -for ( $i = 2; $i <= 10; $i++ ) { |
|
19 | - $overdue_days_options["$i"] = wp_sprintf( __( '%d days after Due Date', 'invoicing' ), $i ); |
|
18 | +for ($i = 2; $i <= 10; $i++) { |
|
19 | + $overdue_days_options["$i"] = wp_sprintf(__('%d days after Due Date', 'invoicing'), $i); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | // Prepare up coming renewal reminder options. |
23 | 23 | $renewal_days_options = array(); |
24 | -$renewal_days_options['0'] = __( 'On the renewal date', 'invoicing' ); |
|
25 | -$renewal_days_options['1'] = __( '1 day before the renewal date', 'invoicing' ); |
|
24 | +$renewal_days_options['0'] = __('On the renewal date', 'invoicing'); |
|
25 | +$renewal_days_options['1'] = __('1 day before the renewal date', 'invoicing'); |
|
26 | 26 | |
27 | -for ( $i = 2; $i <= 10; $i++ ) { |
|
28 | - $renewal_days_options["$i"] = wp_sprintf( __( '%d days before the renewal date', 'invoicing' ), $i ); |
|
27 | +for ($i = 2; $i <= 10; $i++) { |
|
28 | + $renewal_days_options["$i"] = wp_sprintf(__('%d days before the renewal date', 'invoicing'), $i); |
|
29 | 29 | } |
30 | 30 | |
31 | 31 | // Default, built-in gateways |
@@ -34,45 +34,45 @@ discard block |
||
34 | 34 | |
35 | 35 | 'email_new_invoice_header' => array( |
36 | 36 | 'id' => 'email_new_invoice_header', |
37 | - 'name' => '<h3>' . __( 'New Invoice', 'invoicing' ) . '</h3>', |
|
38 | - 'desc' => __( 'These emails are sent to the site admin whenever there is a new invoice.', 'invoicing' ), |
|
37 | + 'name' => '<h3>' . __('New Invoice', 'invoicing') . '</h3>', |
|
38 | + 'desc' => __('These emails are sent to the site admin whenever there is a new invoice.', 'invoicing'), |
|
39 | 39 | 'type' => 'header', |
40 | 40 | ), |
41 | 41 | |
42 | 42 | 'email_new_invoice_active' => array( |
43 | 43 | 'id' => 'email_new_invoice_active', |
44 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
45 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
44 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
45 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
46 | 46 | 'type' => 'checkbox', |
47 | 47 | 'std' => 1 |
48 | 48 | ), |
49 | 49 | |
50 | 50 | 'email_new_invoice_subject' => array( |
51 | 51 | 'id' => 'email_new_invoice_subject', |
52 | - 'name' => __( 'Subject', 'invoicing' ), |
|
53 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
52 | + 'name' => __('Subject', 'invoicing'), |
|
53 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
54 | 54 | 'help-tip' => true, |
55 | 55 | 'type' => 'text', |
56 | - 'std' => __( '[{site_title}] We sent your invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing' ), |
|
56 | + 'std' => __('[{site_title}] We sent your invoice ({invoice_number}) for {invoice_total} {invoice_currency}', 'invoicing'), |
|
57 | 57 | 'size' => 'large' |
58 | 58 | ), |
59 | 59 | |
60 | 60 | 'email_new_invoice_heading' => array( |
61 | 61 | 'id' => 'email_new_invoice_heading', |
62 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
63 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
62 | + 'name' => __('Email Heading', 'invoicing'), |
|
63 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
64 | 64 | 'help-tip' => true, |
65 | 65 | 'type' => 'text', |
66 | - 'std' => __( 'Invoice sent', 'invoicing' ), |
|
66 | + 'std' => __('Invoice sent', 'invoicing'), |
|
67 | 67 | 'size' => 'large' |
68 | 68 | ), |
69 | 69 | |
70 | 70 | 'email_new_invoice_body' => array( |
71 | 71 | 'id' => 'email_new_invoice_body', |
72 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
73 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
72 | + 'name' => __('Email Content', 'invoicing'), |
|
73 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
74 | 74 | 'type' => 'rich_editor', |
75 | - 'std' => __( '<p>We sent your invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency}.</p>', 'invoicing' ), |
|
75 | + 'std' => __('<p>We sent your invoice <a href="{invoice_link}">({invoice_number})</a> to {name} for {invoice_total} {invoice_currency}.</p>', 'invoicing'), |
|
76 | 76 | 'class' => 'large', |
77 | 77 | 'size' => '10' |
78 | 78 | ), |
@@ -82,45 +82,45 @@ discard block |
||
82 | 82 | |
83 | 83 | 'email_cancelled_invoice_header' => array( |
84 | 84 | 'id' => 'email_cancelled_invoice_header', |
85 | - 'name' => '<h3>' . __( 'Cancelled Invoice', 'invoicing' ) . '</h3>', |
|
86 | - 'desc' => __( 'These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing' ), |
|
85 | + 'name' => '<h3>' . __('Cancelled Invoice', 'invoicing') . '</h3>', |
|
86 | + 'desc' => __('These emails are sent to the site admin whenever invoices are cancelled.', 'invoicing'), |
|
87 | 87 | 'type' => 'header', |
88 | 88 | ), |
89 | 89 | |
90 | 90 | 'email_cancelled_invoice_active' => array( |
91 | 91 | 'id' => 'email_cancelled_invoice_active', |
92 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
93 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
92 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
93 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
94 | 94 | 'type' => 'checkbox', |
95 | 95 | 'std' => 1 |
96 | 96 | ), |
97 | 97 | |
98 | 98 | 'email_cancelled_invoice_subject' => array( |
99 | 99 | 'id' => 'email_cancelled_invoice_subject', |
100 | - 'name' => __( 'Subject', 'invoicing' ), |
|
101 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
100 | + 'name' => __('Subject', 'invoicing'), |
|
101 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
102 | 102 | 'help-tip' => true, |
103 | 103 | 'type' => 'text', |
104 | - 'std' => __( '[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing' ), |
|
104 | + 'std' => __('[{site_title}] Cancelled invoice ({invoice_number})', 'invoicing'), |
|
105 | 105 | 'size' => 'large' |
106 | 106 | ), |
107 | 107 | |
108 | 108 | 'email_cancelled_invoice_heading' => array( |
109 | 109 | 'id' => 'email_cancelled_invoice_heading', |
110 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
111 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
110 | + 'name' => __('Email Heading', 'invoicing'), |
|
111 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
112 | 112 | 'help-tip' => true, |
113 | 113 | 'type' => 'text', |
114 | - 'std' => __( 'Cancelled Invoice', 'invoicing' ), |
|
114 | + 'std' => __('Cancelled Invoice', 'invoicing'), |
|
115 | 115 | 'size' => 'large' |
116 | 116 | ), |
117 | 117 | |
118 | 118 | 'email_cancelled_invoice_body' => array( |
119 | 119 | 'id' => 'email_cancelled_invoice_body', |
120 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
121 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
120 | + 'name' => __('Email Content', 'invoicing'), |
|
121 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
122 | 122 | 'type' => 'rich_editor', |
123 | - 'std' => __( '<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled.</p>', 'invoicing' ), |
|
123 | + 'std' => __('<p>The invoice <a href="{invoice_link}">#{invoice_number}</a> created for {name} on {site_title} has been cancelled.</p>', 'invoicing'), |
|
124 | 124 | 'class' => 'large', |
125 | 125 | 'size' => '10' |
126 | 126 | ), |
@@ -131,45 +131,45 @@ discard block |
||
131 | 131 | |
132 | 132 | 'email_failed_invoice_header' => array( |
133 | 133 | 'id' => 'email_failed_invoice_header', |
134 | - 'name' => '<h3>' . __( 'Failed Invoice', 'invoicing' ) . '</h3>', |
|
135 | - 'desc' => __( 'Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing' ), |
|
134 | + 'name' => '<h3>' . __('Failed Invoice', 'invoicing') . '</h3>', |
|
135 | + 'desc' => __('Failed invoice emails are sent to the site admin when invoice payments fail.', 'invoicing'), |
|
136 | 136 | 'type' => 'header', |
137 | 137 | ), |
138 | 138 | |
139 | 139 | 'email_failed_invoice_active' => array( |
140 | 140 | 'id' => 'email_failed_invoice_active', |
141 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
142 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
141 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
142 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
143 | 143 | 'type' => 'checkbox', |
144 | 144 | 'std' => 1 |
145 | 145 | ), |
146 | 146 | |
147 | 147 | 'email_failed_invoice_subject' => array( |
148 | 148 | 'id' => 'email_failed_invoice_subject', |
149 | - 'name' => __( 'Subject', 'invoicing' ), |
|
150 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
149 | + 'name' => __('Subject', 'invoicing'), |
|
150 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
151 | 151 | 'help-tip' => true, |
152 | 152 | 'type' => 'text', |
153 | - 'std' => __( '[{site_title}] Failed invoice ({invoice_number})', 'invoicing' ), |
|
153 | + 'std' => __('[{site_title}] Failed invoice ({invoice_number})', 'invoicing'), |
|
154 | 154 | 'size' => 'large' |
155 | 155 | ), |
156 | 156 | |
157 | 157 | 'email_failed_invoice_heading' => array( |
158 | 158 | 'id' => 'email_failed_invoice_heading', |
159 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
160 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
159 | + 'name' => __('Email Heading', 'invoicing'), |
|
160 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
161 | 161 | 'help-tip' => true, |
162 | 162 | 'type' => 'text', |
163 | - 'std' => __( 'Failed invoice', 'invoicing' ), |
|
163 | + 'std' => __('Failed invoice', 'invoicing'), |
|
164 | 164 | 'size' => 'large' |
165 | 165 | ), |
166 | 166 | |
167 | 167 | 'email_failed_invoice_body' => array( |
168 | 168 | 'id' => 'email_failed_invoice_body', |
169 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
170 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
169 | + 'name' => __('Email Content', 'invoicing'), |
|
170 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
171 | 171 | 'type' => 'rich_editor', |
172 | - 'std' => __( '<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through.</p>', 'invoicing' ), |
|
172 | + 'std' => __('<p>Payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title} has failed to go through.</p>', 'invoicing'), |
|
173 | 173 | 'class' => 'large', |
174 | 174 | 'size' => '10' |
175 | 175 | ), |
@@ -179,53 +179,53 @@ discard block |
||
179 | 179 | |
180 | 180 | 'email_onhold_invoice_header' => array( |
181 | 181 | 'id' => 'email_onhold_invoice_header', |
182 | - 'name' => '<h3>' . __( 'On Hold Invoice', 'invoicing' ) . '</h3>', |
|
183 | - 'desc' => __( 'These emails are sent to customers whenever their invoices are held.', 'invoicing' ), |
|
182 | + 'name' => '<h3>' . __('On Hold Invoice', 'invoicing') . '</h3>', |
|
183 | + 'desc' => __('These emails are sent to customers whenever their invoices are held.', 'invoicing'), |
|
184 | 184 | 'type' => 'header', |
185 | 185 | ), |
186 | 186 | |
187 | 187 | 'email_onhold_invoice_active' => array( |
188 | 188 | 'id' => 'email_onhold_invoice_active', |
189 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
190 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
189 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
190 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
191 | 191 | 'type' => 'checkbox', |
192 | 192 | 'std' => 1 |
193 | 193 | ), |
194 | 194 | |
195 | 195 | 'email_onhold_invoice_admin_bcc' => array( |
196 | 196 | 'id' => 'email_onhold_invoice_admin_bcc', |
197 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
198 | - 'desc' => __( 'Check if you want to send this notification email to site Admin.', 'invoicing' ), |
|
197 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
198 | + 'desc' => __('Check if you want to send this notification email to site Admin.', 'invoicing'), |
|
199 | 199 | 'type' => 'checkbox', |
200 | 200 | 'std' => 1 |
201 | 201 | ), |
202 | 202 | |
203 | 203 | 'email_onhold_invoice_subject' => array( |
204 | 204 | 'id' => 'email_onhold_invoice_subject', |
205 | - 'name' => __( 'Subject', 'invoicing' ), |
|
206 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
205 | + 'name' => __('Subject', 'invoicing'), |
|
206 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
207 | 207 | 'help-tip' => true, |
208 | 208 | 'type' => 'text', |
209 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
209 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
210 | 210 | 'size' => 'large' |
211 | 211 | ), |
212 | 212 | |
213 | 213 | 'email_onhold_invoice_heading' => array( |
214 | 214 | 'id' => 'email_onhold_invoice_heading', |
215 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
216 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
215 | + 'name' => __('Email Heading', 'invoicing'), |
|
216 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
217 | 217 | 'help-tip' => true, |
218 | 218 | 'type' => 'text', |
219 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
219 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
220 | 220 | 'size' => 'large' |
221 | 221 | ), |
222 | 222 | |
223 | 223 | 'email_onhold_invoice_body' => array( |
224 | 224 | 'id' => 'email_onhold_invoice_body', |
225 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
226 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
225 | + 'name' => __('Email Content', 'invoicing'), |
|
226 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
227 | 227 | 'type' => 'rich_editor', |
228 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment.</p>', 'invoicing' ), |
|
228 | + 'std' => __('<p>Hi {name},</p><p>Your invoice is on-hold and will be processed when we receive your payment.</p>', 'invoicing'), |
|
229 | 229 | 'class' => 'large', |
230 | 230 | 'size' => '10' |
231 | 231 | ), |
@@ -236,53 +236,53 @@ discard block |
||
236 | 236 | |
237 | 237 | 'email_processing_invoice_header' => array( |
238 | 238 | 'id' => 'email_processing_invoice_header', |
239 | - 'name' => '<h3>' . __( 'Processing Invoice', 'invoicing' ) . '</h3>', |
|
240 | - 'desc' => __( 'These emails are sent to users whenever payments for their invoices are processing.', 'invoicing' ), |
|
239 | + 'name' => '<h3>' . __('Processing Invoice', 'invoicing') . '</h3>', |
|
240 | + 'desc' => __('These emails are sent to users whenever payments for their invoices are processing.', 'invoicing'), |
|
241 | 241 | 'type' => 'header', |
242 | 242 | ), |
243 | 243 | |
244 | 244 | 'email_processing_invoice_active' => array( |
245 | 245 | 'id' => 'email_processing_invoice_active', |
246 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
247 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
246 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
247 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
248 | 248 | 'type' => 'checkbox', |
249 | 249 | 'std' => 1 |
250 | 250 | ), |
251 | 251 | |
252 | 252 | 'email_processing_invoice_admin_bcc' => array( |
253 | 253 | 'id' => 'email_processing_invoice_admin_bcc', |
254 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
255 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
254 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
255 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
256 | 256 | 'type' => 'checkbox', |
257 | 257 | 'std' => 1 |
258 | 258 | ), |
259 | 259 | |
260 | 260 | 'email_processing_invoice_subject' => array( |
261 | 261 | 'id' => 'email_processing_invoice_subject', |
262 | - 'name' => __( 'Subject', 'invoicing' ), |
|
263 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
262 | + 'name' => __('Subject', 'invoicing'), |
|
263 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
264 | 264 | 'help-tip' => true, |
265 | 265 | 'type' => 'text', |
266 | - 'std' => __( '[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing' ), |
|
266 | + 'std' => __('[{site_title}] Your invoice receipt from {invoice_date}', 'invoicing'), |
|
267 | 267 | 'size' => 'large' |
268 | 268 | ), |
269 | 269 | |
270 | 270 | 'email_processing_invoice_heading' => array( |
271 | 271 | 'id' => 'email_processing_invoice_heading', |
272 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
273 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
272 | + 'name' => __('Email Heading', 'invoicing'), |
|
273 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
274 | 274 | 'help-tip' => true, |
275 | 275 | 'type' => 'text', |
276 | - 'std' => __( 'Thank you for your invoice', 'invoicing' ), |
|
276 | + 'std' => __('Thank you for your invoice', 'invoicing'), |
|
277 | 277 | 'size' => 'large' |
278 | 278 | ), |
279 | 279 | |
280 | 280 | 'email_processing_invoice_body' => array( |
281 | 281 | 'id' => 'email_processing_invoice_body', |
282 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
283 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
282 | + 'name' => __('Email Content', 'invoicing'), |
|
283 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
284 | 284 | 'type' => 'rich_editor', |
285 | - 'std' => __( '<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}.</p>', 'invoicing' ), |
|
285 | + 'std' => __('<p>Hi {name},</p><p>I would like to let you know that we have received and are currently processing your payment for the invoice <a href="{invoice_link}">#{invoice_number}</a> on {site_title}.</p>', 'invoicing'), |
|
286 | 286 | 'class' => 'large', |
287 | 287 | 'size' => '10' |
288 | 288 | ), |
@@ -293,61 +293,61 @@ discard block |
||
293 | 293 | |
294 | 294 | 'email_completed_invoice_header' => array( |
295 | 295 | 'id' => 'email_completed_invoice_header', |
296 | - 'name' => '<h3>' . __( 'Paid Invoice', 'invoicing' ) . '</h3>', |
|
297 | - 'desc' => __( 'These emails are sent to customers when their invoices are marked as paid.', 'invoicing' ), |
|
296 | + 'name' => '<h3>' . __('Paid Invoice', 'invoicing') . '</h3>', |
|
297 | + 'desc' => __('These emails are sent to customers when their invoices are marked as paid.', 'invoicing'), |
|
298 | 298 | 'type' => 'header', |
299 | 299 | ), |
300 | 300 | |
301 | 301 | 'email_completed_invoice_active' => array( |
302 | 302 | 'id' => 'email_completed_invoice_active', |
303 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
304 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
303 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
304 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
305 | 305 | 'type' => 'checkbox', |
306 | 306 | 'std' => 1 |
307 | 307 | ), |
308 | 308 | |
309 | 309 | 'email_completed_invoice_renewal_active' => array( |
310 | 310 | 'id' => 'email_completed_invoice_renewal_active', |
311 | - 'name' => __( 'Enable renewal notification', 'invoicing' ), |
|
312 | - 'desc' => __( 'Should this email be sent for renewals too?', 'invoicing' ), |
|
311 | + 'name' => __('Enable renewal notification', 'invoicing'), |
|
312 | + 'desc' => __('Should this email be sent for renewals too?', 'invoicing'), |
|
313 | 313 | 'type' => 'checkbox', |
314 | 314 | 'std' => 1 |
315 | 315 | ), |
316 | 316 | |
317 | 317 | 'email_completed_invoice_admin_bcc' => array( |
318 | 318 | 'id' => 'email_completed_invoice_admin_bcc', |
319 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
320 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
319 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
320 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
321 | 321 | 'type' => 'checkbox', |
322 | 322 | 'std' => 1, |
323 | 323 | ), |
324 | 324 | |
325 | 325 | 'email_completed_invoice_subject' => array( |
326 | 326 | 'id' => 'email_completed_invoice_subject', |
327 | - 'name' => __( 'Subject', 'invoicing' ), |
|
328 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
327 | + 'name' => __('Subject', 'invoicing'), |
|
328 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
329 | 329 | 'help-tip' => true, |
330 | 330 | 'type' => 'text', |
331 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing' ), |
|
331 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been paid', 'invoicing'), |
|
332 | 332 | 'size' => 'large' |
333 | 333 | ), |
334 | 334 | |
335 | 335 | 'email_completed_invoice_heading' => array( |
336 | 336 | 'id' => 'email_completed_invoice_heading', |
337 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
338 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
337 | + 'name' => __('Email Heading', 'invoicing'), |
|
338 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
339 | 339 | 'help-tip' => true, |
340 | 340 | 'type' => 'text', |
341 | - 'std' => __( 'Your invoice has been paid', 'invoicing' ), |
|
341 | + 'std' => __('Your invoice has been paid', 'invoicing'), |
|
342 | 342 | 'size' => 'large' |
343 | 343 | ), |
344 | 344 | |
345 | 345 | 'email_completed_invoice_body' => array( |
346 | 346 | 'id' => 'email_completed_invoice_body', |
347 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
348 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
347 | + 'name' => __('Email Content', 'invoicing'), |
|
348 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
349 | 349 | 'type' => 'rich_editor', |
350 | - 'std' => __( '<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing' ), |
|
350 | + 'std' => __('<p>Hi {name},</p><p>Your recent invoice on {site_title} has been paid.</p>', 'invoicing'), |
|
351 | 351 | 'class' => 'large', |
352 | 352 | 'size' => '10' |
353 | 353 | ), |
@@ -358,53 +358,53 @@ discard block |
||
358 | 358 | |
359 | 359 | 'email_refunded_invoice_header' => array( |
360 | 360 | 'id' => 'email_refunded_invoice_header', |
361 | - 'name' => '<h3>' . __( 'Refunded Invoice', 'invoicing' ) . '</h3>', |
|
362 | - 'desc' => __( 'These emails are sent to users when their invoices are marked as refunded.', 'invoicing' ), |
|
361 | + 'name' => '<h3>' . __('Refunded Invoice', 'invoicing') . '</h3>', |
|
362 | + 'desc' => __('These emails are sent to users when their invoices are marked as refunded.', 'invoicing'), |
|
363 | 363 | 'type' => 'header', |
364 | 364 | ), |
365 | 365 | |
366 | 366 | 'email_refunded_invoice_active' => array( |
367 | 367 | 'id' => 'email_refunded_invoice_active', |
368 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
369 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
368 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
369 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
370 | 370 | 'type' => 'checkbox', |
371 | 371 | 'std' => 1 |
372 | 372 | ), |
373 | 373 | |
374 | 374 | 'email_refunded_invoice_admin_bcc' => array( |
375 | 375 | 'id' => 'email_refunded_invoice_admin_bcc', |
376 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
377 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
376 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
377 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
378 | 378 | 'type' => 'checkbox', |
379 | 379 | 'std' => 1 |
380 | 380 | ), |
381 | 381 | |
382 | 382 | 'email_refunded_invoice_subject' => array( |
383 | 383 | 'id' => 'email_refunded_invoice_subject', |
384 | - 'name' => __( 'Subject', 'invoicing' ), |
|
385 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
384 | + 'name' => __('Subject', 'invoicing'), |
|
385 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
386 | 386 | 'help-tip' => true, |
387 | 387 | 'type' => 'text', |
388 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing' ), |
|
388 | + 'std' => __('[{site_title}] Your invoice from {invoice_date} has been refunded', 'invoicing'), |
|
389 | 389 | 'size' => 'large' |
390 | 390 | ), |
391 | 391 | |
392 | 392 | 'email_refunded_invoice_heading' => array( |
393 | 393 | 'id' => 'email_refunded_invoice_heading', |
394 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
395 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
394 | + 'name' => __('Email Heading', 'invoicing'), |
|
395 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
396 | 396 | 'help-tip' => true, |
397 | 397 | 'type' => 'text', |
398 | - 'std' => __( 'Your invoice has been refunded', 'invoicing' ), |
|
398 | + 'std' => __('Your invoice has been refunded', 'invoicing'), |
|
399 | 399 | 'size' => 'large' |
400 | 400 | ), |
401 | 401 | |
402 | 402 | 'email_refunded_invoice_body' => array( |
403 | 403 | 'id' => 'email_refunded_invoice_body', |
404 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
405 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
404 | + 'name' => __('Email Content', 'invoicing'), |
|
405 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
406 | 406 | 'type' => 'rich_editor', |
407 | - 'std' => __( '<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing' ), |
|
407 | + 'std' => __('<p>Hi {name},</p><p>Your invoice on {site_title} has been refunded.</p>', 'invoicing'), |
|
408 | 408 | 'class' => 'large', |
409 | 409 | 'size' => '10' |
410 | 410 | ), |
@@ -415,53 +415,53 @@ discard block |
||
415 | 415 | |
416 | 416 | 'email_user_invoice_header' => array( |
417 | 417 | 'id' => 'email_user_invoice_header', |
418 | - 'name' => '<h3>' . __( 'Customer Invoice', 'invoicing' ) . '</h3>', |
|
419 | - 'desc' => __( 'These emails are sent to customers containing their invoice information and payment links.', 'invoicing' ), |
|
418 | + 'name' => '<h3>' . __('Customer Invoice', 'invoicing') . '</h3>', |
|
419 | + 'desc' => __('These emails are sent to customers containing their invoice information and payment links.', 'invoicing'), |
|
420 | 420 | 'type' => 'header', |
421 | 421 | ), |
422 | 422 | |
423 | 423 | 'email_user_invoice_active' => array( |
424 | 424 | 'id' => 'email_user_invoice_active', |
425 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
426 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
425 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
426 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
427 | 427 | 'type' => 'checkbox', |
428 | 428 | 'std' => 1 |
429 | 429 | ), |
430 | 430 | |
431 | 431 | 'email_user_invoice_admin_bcc' => array( |
432 | 432 | 'id' => 'email_user_invoice_admin_bcc', |
433 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
434 | - 'desc' => __( 'Check if you want to send a copy of this notification email to to the site admin.', 'invoicing' ), |
|
433 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
434 | + 'desc' => __('Check if you want to send a copy of this notification email to to the site admin.', 'invoicing'), |
|
435 | 435 | 'type' => 'checkbox', |
436 | 436 | 'std' => 0 |
437 | 437 | ), |
438 | 438 | |
439 | 439 | 'email_user_invoice_subject' => array( |
440 | 440 | 'id' => 'email_user_invoice_subject', |
441 | - 'name' => __( 'Subject', 'invoicing' ), |
|
442 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
441 | + 'name' => __('Subject', 'invoicing'), |
|
442 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
443 | 443 | 'help-tip' => true, |
444 | 444 | 'type' => 'text', |
445 | - 'std' => __( '[{site_title}] Your invoice from {invoice_date}', 'invoicing' ), |
|
445 | + 'std' => __('[{site_title}] Your invoice from {invoice_date}', 'invoicing'), |
|
446 | 446 | 'size' => 'large' |
447 | 447 | ), |
448 | 448 | |
449 | 449 | 'email_user_invoice_heading' => array( |
450 | 450 | 'id' => 'email_user_invoice_heading', |
451 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
452 | - 'desc' => __( 'Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing' ), |
|
451 | + 'name' => __('Email Heading', 'invoicing'), |
|
452 | + 'desc' => __('Enter the main heading contained within the email notification for the invoice receipt email.', 'invoicing'), |
|
453 | 453 | 'help-tip' => true, |
454 | 454 | 'type' => 'text', |
455 | - 'std' => __( 'Your invoice {invoice_number} details', 'invoicing' ), |
|
455 | + 'std' => __('Your invoice {invoice_number} details', 'invoicing'), |
|
456 | 456 | 'size' => 'large' |
457 | 457 | ), |
458 | 458 | |
459 | 459 | 'email_user_invoice_body' => array( |
460 | 460 | 'id' => 'email_user_invoice_body', |
461 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
462 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
461 | + 'name' => __('Email Content', 'invoicing'), |
|
462 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
463 | 463 | 'type' => 'rich_editor', |
464 | - 'std' => __( '<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing' ), |
|
464 | + 'std' => __('<p>Hi {name},</p><p>An invoice of {invoice_total} has been created for you on {site_title}. You can <a href="{invoice_link}">view</a> or <a href="{invoice_pay_link}">pay</a> the invoice. Please reply to this email if you have any questions about the invoice.', 'invoicing'), |
|
465 | 465 | 'class' => 'large', |
466 | 466 | 'size' => '10' |
467 | 467 | ), |
@@ -471,53 +471,53 @@ discard block |
||
471 | 471 | |
472 | 472 | 'email_user_note_header' => array( |
473 | 473 | 'id' => 'email_user_note_header', |
474 | - 'name' => '<h3>' . __( 'Customer Note', 'invoicing' ) . '</h3>', |
|
475 | - 'desc' => __( 'These emails are sent when you add a customer note to an invoice/quote.', 'invoicing' ), |
|
474 | + 'name' => '<h3>' . __('Customer Note', 'invoicing') . '</h3>', |
|
475 | + 'desc' => __('These emails are sent when you add a customer note to an invoice/quote.', 'invoicing'), |
|
476 | 476 | 'type' => 'header', |
477 | 477 | ), |
478 | 478 | |
479 | 479 | 'email_user_note_active' => array( |
480 | 480 | 'id' => 'email_user_note_active', |
481 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
482 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
481 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
482 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
483 | 483 | 'type' => 'checkbox', |
484 | 484 | 'std' => 1 |
485 | 485 | ), |
486 | 486 | |
487 | 487 | 'email_user_note_admin_bcc' => array( |
488 | 488 | 'id' => 'email_user_note_admin_bcc', |
489 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
490 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
489 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
490 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
491 | 491 | 'type' => 'checkbox', |
492 | 492 | 'std' => 0 |
493 | 493 | ), |
494 | 494 | |
495 | 495 | 'email_user_note_subject' => array( |
496 | 496 | 'id' => 'email_user_note_subject', |
497 | - 'name' => __( 'Subject', 'invoicing' ), |
|
498 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
497 | + 'name' => __('Subject', 'invoicing'), |
|
498 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
499 | 499 | 'help-tip' => true, |
500 | 500 | 'type' => 'text', |
501 | - 'std' => __( '[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing' ), |
|
501 | + 'std' => __('[{site_title}] Note added to your {invoice_label} #{invoice_number} from {invoice_date}', 'invoicing'), |
|
502 | 502 | 'size' => 'large' |
503 | 503 | ), |
504 | 504 | |
505 | 505 | 'email_user_note_heading' => array( |
506 | 506 | 'id' => 'email_user_note_heading', |
507 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
508 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
507 | + 'name' => __('Email Heading', 'invoicing'), |
|
508 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
509 | 509 | 'help-tip' => true, |
510 | 510 | 'type' => 'text', |
511 | - 'std' => __( 'A note has been added to your {invoice_label}', 'invoicing' ), |
|
511 | + 'std' => __('A note has been added to your {invoice_label}', 'invoicing'), |
|
512 | 512 | 'size' => 'large' |
513 | 513 | ), |
514 | 514 | |
515 | 515 | 'email_user_note_body' => array( |
516 | 516 | 'id' => 'email_user_note_body', |
517 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
518 | - 'desc' => __( 'The content of the email (wildcards and HTML are allowed).', 'invoicing' ), |
|
517 | + 'name' => __('Email Content', 'invoicing'), |
|
518 | + 'desc' => __('The content of the email (wildcards and HTML are allowed).', 'invoicing'), |
|
519 | 519 | 'type' => 'rich_editor', |
520 | - 'std' => __( '<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing' ), |
|
520 | + 'std' => __('<p>Hi {name},</p><p>Following note has been added to your {invoice_label}:</p><blockquote class="wpinv-note">{customer_note}</blockquote>', 'invoicing'), |
|
521 | 521 | 'class' => 'large', |
522 | 522 | 'size' => '10' |
523 | 523 | ), |
@@ -528,63 +528,63 @@ discard block |
||
528 | 528 | |
529 | 529 | 'email_overdue_header' => array( |
530 | 530 | 'id' => 'email_overdue_header', |
531 | - 'name' => '<h3>' . __( 'Payment Reminder', 'invoicing' ) . '</h3>', |
|
532 | - 'desc' => __( 'Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing' ), |
|
531 | + 'name' => '<h3>' . __('Payment Reminder', 'invoicing') . '</h3>', |
|
532 | + 'desc' => __('Payment reminder emails are sent to customers whenever their invoices are due.', 'invoicing'), |
|
533 | 533 | 'type' => 'header', |
534 | 534 | ), |
535 | 535 | |
536 | 536 | 'email_overdue_active' => array( |
537 | 537 | 'id' => 'email_overdue_active', |
538 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
539 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
538 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
539 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
540 | 540 | 'type' => 'checkbox', |
541 | 541 | 'std' => 1 |
542 | 542 | ), |
543 | 543 | |
544 | 544 | 'email_overdue_admin_bcc' => array( |
545 | 545 | 'id' => 'email_overdue_admin_bcc', |
546 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
547 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
546 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
547 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
548 | 548 | 'type' => 'checkbox', |
549 | 549 | 'std' => 0 |
550 | 550 | ), |
551 | 551 | |
552 | 552 | 'email_overdue_days' => array( |
553 | 553 | 'id' => 'email_overdue_days', |
554 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
555 | - 'desc' => __( 'Check when you would like payment reminders sent out.', 'invoicing' ), |
|
554 | + 'name' => __('When to Send', 'invoicing'), |
|
555 | + 'desc' => __('Check when you would like payment reminders sent out.', 'invoicing'), |
|
556 | 556 | 'help-tip' => true, |
557 | - 'std' => array( '1' ), |
|
557 | + 'std' => array('1'), |
|
558 | 558 | 'type' => 'multicheck', |
559 | 559 | 'options' => $overdue_days_options, |
560 | 560 | ), |
561 | 561 | |
562 | 562 | 'email_overdue_subject' => array( |
563 | 563 | 'id' => 'email_overdue_subject', |
564 | - 'name' => __( 'Subject', 'invoicing' ), |
|
565 | - 'desc' => __( 'Enter the subject line for the invoice receipt email.', 'invoicing' ), |
|
564 | + 'name' => __('Subject', 'invoicing'), |
|
565 | + 'desc' => __('Enter the subject line for the invoice receipt email.', 'invoicing'), |
|
566 | 566 | 'help-tip' => true, |
567 | 567 | 'type' => 'text', |
568 | - 'std' => __( '[{site_title}] Payment Reminder', 'invoicing' ), |
|
568 | + 'std' => __('[{site_title}] Payment Reminder', 'invoicing'), |
|
569 | 569 | 'size' => 'large' |
570 | 570 | ), |
571 | 571 | |
572 | 572 | 'email_overdue_heading' => array( |
573 | 573 | 'id' => 'email_overdue_heading', |
574 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
575 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
574 | + 'name' => __('Email Heading', 'invoicing'), |
|
575 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
576 | 576 | 'help-tip' => true, |
577 | 577 | 'type' => 'text', |
578 | - 'std' => __( 'Payment reminder for your invoice', 'invoicing' ), |
|
578 | + 'std' => __('Payment reminder for your invoice', 'invoicing'), |
|
579 | 579 | 'size' => 'large' |
580 | 580 | ), |
581 | 581 | |
582 | 582 | 'email_overdue_body' => array( |
583 | 583 | 'id' => 'email_overdue_body', |
584 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
585 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
584 | + 'name' => __('Email Content', 'invoicing'), |
|
585 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
586 | 586 | 'type' => 'rich_editor', |
587 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing' ), |
|
587 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your invoice <a href="{invoice_link}">#{invoice_number}</a> {is_was} due on {invoice_due_date}.</p><p>The total of this invoice is {invoice_total}</p><p>To view / pay now for this invoice please use the following link: <a class="btn btn-success" href="{invoice_link}">View / Pay</a></p>', 'invoicing'), |
|
588 | 588 | 'class' => 'large', |
589 | 589 | 'size' => 10, |
590 | 590 | ), |
@@ -595,63 +595,63 @@ discard block |
||
595 | 595 | |
596 | 596 | 'email_renewal_reminder_header' => array( |
597 | 597 | 'id' => 'email_renewal_reminder_header', |
598 | - 'name' => '<h3>' . __( 'Renewal Reminder', 'invoicing' ) . '</h3>', |
|
599 | - 'desc' => __( 'These emails are sent to customers whenever their subscription is about to expire.', 'invoicing' ), |
|
598 | + 'name' => '<h3>' . __('Renewal Reminder', 'invoicing') . '</h3>', |
|
599 | + 'desc' => __('These emails are sent to customers whenever their subscription is about to expire.', 'invoicing'), |
|
600 | 600 | 'type' => 'header', |
601 | 601 | ), |
602 | 602 | |
603 | 603 | 'email_renewal_reminder_active' => array( |
604 | 604 | 'id' => 'email_renewal_reminder_active', |
605 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
606 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
605 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
606 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
607 | 607 | 'type' => 'checkbox', |
608 | 608 | 'std' => 0 |
609 | 609 | ), |
610 | 610 | |
611 | 611 | 'email_renewal_reminder_admin_bcc' => array( |
612 | 612 | 'id' => 'email_renewal_reminder_admin_bcc', |
613 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
614 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
613 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
614 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
615 | 615 | 'type' => 'checkbox', |
616 | 616 | 'std' => 0 |
617 | 617 | ), |
618 | 618 | |
619 | 619 | 'email_renewal_reminder_days' => array( |
620 | 620 | 'id' => 'email_renewal_reminder_days', |
621 | - 'name' => __( 'When to Send', 'invoicing' ), |
|
622 | - 'desc' => __( 'Check when you would like renewal reminders sent out.', 'invoicing' ), |
|
621 | + 'name' => __('When to Send', 'invoicing'), |
|
622 | + 'desc' => __('Check when you would like renewal reminders sent out.', 'invoicing'), |
|
623 | 623 | 'help-tip' => true, |
624 | - 'std' => array( '1', '5', '10' ), |
|
624 | + 'std' => array('1', '5', '10'), |
|
625 | 625 | 'type' => 'multicheck', |
626 | 626 | 'options' => $renewal_days_options, |
627 | 627 | ), |
628 | 628 | |
629 | 629 | 'email_renewal_reminder_subject' => array( |
630 | 630 | 'id' => 'email_renewal_reminder_subject', |
631 | - 'name' => __( 'Subject', 'invoicing' ), |
|
632 | - 'desc' => __( 'Enter the subject line for the email.', 'invoicing' ), |
|
631 | + 'name' => __('Subject', 'invoicing'), |
|
632 | + 'desc' => __('Enter the subject line for the email.', 'invoicing'), |
|
633 | 633 | 'help-tip' => true, |
634 | 634 | 'type' => 'text', |
635 | - 'std' => __( '[{site_title}] Renewal Reminder', 'invoicing' ), |
|
635 | + 'std' => __('[{site_title}] Renewal Reminder', 'invoicing'), |
|
636 | 636 | 'size' => 'large' |
637 | 637 | ), |
638 | 638 | |
639 | 639 | 'email_renewal_reminder_heading' => array( |
640 | 640 | 'id' => 'email_renewal_reminder_heading', |
641 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
642 | - 'desc' => __( 'Enter the main heading contained within the email notification.', 'invoicing' ), |
|
641 | + 'name' => __('Email Heading', 'invoicing'), |
|
642 | + 'desc' => __('Enter the main heading contained within the email notification.', 'invoicing'), |
|
643 | 643 | 'help-tip' => true, |
644 | 644 | 'type' => 'text', |
645 | - 'std' => __( 'Upcoming renewal reminder', 'invoicing' ), |
|
645 | + 'std' => __('Upcoming renewal reminder', 'invoicing'), |
|
646 | 646 | 'size' => 'large' |
647 | 647 | ), |
648 | 648 | |
649 | 649 | 'email_renewal_reminder_body' => array( |
650 | 650 | 'id' => 'email_renewal_reminder_body', |
651 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
652 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
651 | + 'name' => __('Email Content', 'invoicing'), |
|
652 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
653 | 653 | 'type' => 'rich_editor', |
654 | - 'std' => __( '<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing' ), |
|
654 | + 'std' => __('<p>Hi {full_name},</p><p>This is just a friendly reminder that your subscription for invoice <a href="{invoice_link}">#{invoice_number}</a> will renew on {subscription_renewal_date}.</p>', 'invoicing'), |
|
655 | 655 | 'class' => 'large', |
656 | 656 | 'size' => 10, |
657 | 657 | ), |
@@ -662,53 +662,53 @@ discard block |
||
662 | 662 | |
663 | 663 | 'email_subscription_trial_header' => array( |
664 | 664 | 'id' => 'email_subscription_trial_header', |
665 | - 'name' => '<h3>' . __( 'Trial Started', 'invoicing' ) . '</h3>', |
|
666 | - 'desc' => __( 'These emails are sent when a customer starts a subscription trial.', 'invoicing' ), |
|
665 | + 'name' => '<h3>' . __('Trial Started', 'invoicing') . '</h3>', |
|
666 | + 'desc' => __('These emails are sent when a customer starts a subscription trial.', 'invoicing'), |
|
667 | 667 | 'type' => 'header', |
668 | 668 | ), |
669 | 669 | |
670 | 670 | 'email_subscription_trial_active' => array( |
671 | 671 | 'id' => 'email_subscription_trial_active', |
672 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
673 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
672 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
673 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
674 | 674 | 'type' => 'checkbox', |
675 | 675 | 'std' => 0 |
676 | 676 | ), |
677 | 677 | |
678 | 678 | 'email_subscription_trial_bcc' => array( |
679 | 679 | 'id' => 'email_subscription_trial_admin_bcc', |
680 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
681 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
680 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
681 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
682 | 682 | 'type' => 'checkbox', |
683 | 683 | 'std' => 0 |
684 | 684 | ), |
685 | 685 | |
686 | 686 | 'email_subscription_trial_subject' => array( |
687 | 687 | 'id' => 'email_subscription_trial_subject', |
688 | - 'name' => __( 'Subject', 'invoicing' ), |
|
689 | - 'desc' => __( 'Enter the subject line for the subscription trial email.', 'invoicing' ), |
|
688 | + 'name' => __('Subject', 'invoicing'), |
|
689 | + 'desc' => __('Enter the subject line for the subscription trial email.', 'invoicing'), |
|
690 | 690 | 'help-tip' => true, |
691 | 691 | 'type' => 'text', |
692 | - 'std' => __( '[{site_title}] Trial Started', 'invoicing' ), |
|
692 | + 'std' => __('[{site_title}] Trial Started', 'invoicing'), |
|
693 | 693 | 'size' => 'large' |
694 | 694 | ), |
695 | 695 | |
696 | 696 | 'email_subscription_trial_heading' => array( |
697 | 697 | 'id' => 'email_subscription_trial_heading', |
698 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
699 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
698 | + 'name' => __('Email Heading', 'invoicing'), |
|
699 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
700 | 700 | 'help-tip' => true, |
701 | 701 | 'type' => 'text', |
702 | - 'std' => __( 'Trial Started', 'invoicing' ), |
|
702 | + 'std' => __('Trial Started', 'invoicing'), |
|
703 | 703 | 'size' => 'large' |
704 | 704 | ), |
705 | 705 | |
706 | 706 | 'email_subscription_trial_body' => array( |
707 | 707 | 'id' => 'email_trial_body', |
708 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
709 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
708 | + 'name' => __('Email Content', 'invoicing'), |
|
709 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
710 | 710 | 'type' => 'rich_editor', |
711 | - 'std' => __( '<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing' ), |
|
711 | + 'std' => __('<p>Hi {first_name},</p><p>Your trial for {subscription_name} is now active and will renew on {subscription_renewal_date}.</p>', 'invoicing'), |
|
712 | 712 | 'class' => 'large', |
713 | 713 | 'size' => 10, |
714 | 714 | ), |
@@ -718,53 +718,53 @@ discard block |
||
718 | 718 | |
719 | 719 | 'email_subscription_cancelled_header' => array( |
720 | 720 | 'id' => 'email_subscription_cancelled_header', |
721 | - 'name' => '<h3>' . __( 'Subscription Cancelled', 'invoicing' ) . '</h3>', |
|
722 | - 'desc' => __( 'These emails are sent when a customer cancels their subscription.', 'invoicing' ), |
|
721 | + 'name' => '<h3>' . __('Subscription Cancelled', 'invoicing') . '</h3>', |
|
722 | + 'desc' => __('These emails are sent when a customer cancels their subscription.', 'invoicing'), |
|
723 | 723 | 'type' => 'header', |
724 | 724 | ), |
725 | 725 | |
726 | 726 | 'email_subscription_cancelled_active' => array( |
727 | 727 | 'id' => 'email_subscription_cancelled_active', |
728 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
729 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
728 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
729 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
730 | 730 | 'type' => 'checkbox', |
731 | 731 | 'std' => 1 |
732 | 732 | ), |
733 | 733 | |
734 | 734 | 'email_subscription_cancelled_bcc' => array( |
735 | 735 | 'id' => 'email_subscription_cancelled_admin_bcc', |
736 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
737 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
736 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
737 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
738 | 738 | 'type' => 'checkbox', |
739 | 739 | 'std' => 1 |
740 | 740 | ), |
741 | 741 | |
742 | 742 | 'email_subscription_cancelled_subject' => array( |
743 | 743 | 'id' => 'email_subscription_cancelled_subject', |
744 | - 'name' => __( 'Subject', 'invoicing' ), |
|
745 | - 'desc' => __( 'Enter the subject line for the subscription cancelled email.', 'invoicing' ), |
|
744 | + 'name' => __('Subject', 'invoicing'), |
|
745 | + 'desc' => __('Enter the subject line for the subscription cancelled email.', 'invoicing'), |
|
746 | 746 | 'help-tip' => true, |
747 | 747 | 'type' => 'text', |
748 | - 'std' => __( '[{site_title}] Subscription Cancelled', 'invoicing' ), |
|
748 | + 'std' => __('[{site_title}] Subscription Cancelled', 'invoicing'), |
|
749 | 749 | 'size' => 'large' |
750 | 750 | ), |
751 | 751 | |
752 | 752 | 'email_subscription_cancelled_heading' => array( |
753 | 753 | 'id' => 'email_subscription_complete_heading', |
754 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
755 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
754 | + 'name' => __('Email Heading', 'invoicing'), |
|
755 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
756 | 756 | 'help-tip' => true, |
757 | 757 | 'type' => 'text', |
758 | - 'std' => __( 'Subscription Cancelled', 'invoicing' ), |
|
758 | + 'std' => __('Subscription Cancelled', 'invoicing'), |
|
759 | 759 | 'size' => 'large' |
760 | 760 | ), |
761 | 761 | |
762 | 762 | 'email_subscription_cancelled_body' => array( |
763 | 763 | 'id' => 'email_cancelled_body', |
764 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
765 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
764 | + 'name' => __('Email Content', 'invoicing'), |
|
765 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
766 | 766 | 'type' => 'rich_editor', |
767 | - 'std' => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing' ), |
|
767 | + 'std' => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has been cancelled and will no longer renew.</p>', 'invoicing'), |
|
768 | 768 | 'class' => 'large', |
769 | 769 | 'size' => 10, |
770 | 770 | ), |
@@ -774,53 +774,53 @@ discard block |
||
774 | 774 | |
775 | 775 | 'email_subscription_expired_header' => array( |
776 | 776 | 'id' => 'email_subscription_expired_header', |
777 | - 'name' => '<h3>' . __( 'Subscription Expired', 'invoicing' ) . '</h3>', |
|
778 | - 'desc' => __( "These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing' ), |
|
777 | + 'name' => '<h3>' . __('Subscription Expired', 'invoicing') . '</h3>', |
|
778 | + 'desc' => __("These emails are sent when a customer's subscription expires and automatic renewal fails.", 'invoicing'), |
|
779 | 779 | 'type' => 'header', |
780 | 780 | ), |
781 | 781 | |
782 | 782 | 'email_subscription_expired_active' => array( |
783 | 783 | 'id' => 'email_subscription_expired_active', |
784 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
785 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
784 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
785 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
786 | 786 | 'type' => 'checkbox', |
787 | 787 | 'std' => 1 |
788 | 788 | ), |
789 | 789 | |
790 | 790 | 'email_subscription_expired_bcc' => array( |
791 | 791 | 'id' => 'email_subscription_expired_admin_bcc', |
792 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
793 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
792 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
793 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
794 | 794 | 'type' => 'checkbox', |
795 | 795 | 'std' => 1 |
796 | 796 | ), |
797 | 797 | |
798 | 798 | 'email_subscription_expired_subject' => array( |
799 | 799 | 'id' => 'email_subscription_expired_subject', |
800 | - 'name' => __( 'Subject', 'invoicing' ), |
|
801 | - 'desc' => __( 'Enter the subject line for the subscription expired email.', 'invoicing' ), |
|
800 | + 'name' => __('Subject', 'invoicing'), |
|
801 | + 'desc' => __('Enter the subject line for the subscription expired email.', 'invoicing'), |
|
802 | 802 | 'help-tip' => true, |
803 | 803 | 'type' => 'text', |
804 | - 'std' => __( '[{site_title}] Subscription Expired', 'invoicing' ), |
|
804 | + 'std' => __('[{site_title}] Subscription Expired', 'invoicing'), |
|
805 | 805 | 'size' => 'large' |
806 | 806 | ), |
807 | 807 | |
808 | 808 | 'email_subscription_expired_heading' => array( |
809 | 809 | 'id' => 'email_subscription_expired_heading', |
810 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
811 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
810 | + 'name' => __('Email Heading', 'invoicing'), |
|
811 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
812 | 812 | 'type' => 'text', |
813 | - 'std' => __( 'Subscription Expired', 'invoicing' ), |
|
813 | + 'std' => __('Subscription Expired', 'invoicing'), |
|
814 | 814 | 'help-tip' => true, |
815 | 815 | 'size' => 'large' |
816 | 816 | ), |
817 | 817 | |
818 | 818 | 'email_subscription_expired_body' => array( |
819 | 819 | 'id' => 'email_expired_body', |
820 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
821 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
820 | + 'name' => __('Email Content', 'invoicing'), |
|
821 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
822 | 822 | 'type' => 'rich_editor', |
823 | - 'std' => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing' ), |
|
823 | + 'std' => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} has expired.</p>', 'invoicing'), |
|
824 | 824 | 'class' => 'large', |
825 | 825 | 'size' => 10, |
826 | 826 | ), |
@@ -830,53 +830,53 @@ discard block |
||
830 | 830 | |
831 | 831 | 'email_subscription_complete_header' => array( |
832 | 832 | 'id' => 'email_subscription_complete_header', |
833 | - 'name' => '<h3>' . __( 'Subscription Complete', 'invoicing' ) . '</h3>', |
|
834 | - 'desc' => __( 'These emails are sent when a customer completes their subscription.', 'invoicing' ), |
|
833 | + 'name' => '<h3>' . __('Subscription Complete', 'invoicing') . '</h3>', |
|
834 | + 'desc' => __('These emails are sent when a customer completes their subscription.', 'invoicing'), |
|
835 | 835 | 'type' => 'header', |
836 | 836 | ), |
837 | 837 | |
838 | 838 | 'email_subscription_complete_active' => array( |
839 | 839 | 'id' => 'email_subscription_complete_active', |
840 | - 'name' => __( 'Enable/Disable', 'invoicing' ), |
|
841 | - 'desc' => __( 'Enable this email notification', 'invoicing' ), |
|
840 | + 'name' => __('Enable/Disable', 'invoicing'), |
|
841 | + 'desc' => __('Enable this email notification', 'invoicing'), |
|
842 | 842 | 'type' => 'checkbox', |
843 | 843 | 'std' => 1 |
844 | 844 | ), |
845 | 845 | |
846 | 846 | 'email_subscription_complete_bcc' => array( |
847 | 847 | 'id' => 'email_subscription_complete_admin_bcc', |
848 | - 'name' => __( 'Enable Admin BCC', 'invoicing' ), |
|
849 | - 'desc' => __( 'Check if you want to send a copy of this notification email to the site admin.', 'invoicing' ), |
|
848 | + 'name' => __('Enable Admin BCC', 'invoicing'), |
|
849 | + 'desc' => __('Check if you want to send a copy of this notification email to the site admin.', 'invoicing'), |
|
850 | 850 | 'type' => 'checkbox', |
851 | 851 | 'std' => 1 |
852 | 852 | ), |
853 | 853 | |
854 | 854 | 'email_subscription_complete_subject' => array( |
855 | 855 | 'id' => 'email_subscription_complete_subject', |
856 | - 'name' => __( 'Subject', 'invoicing' ), |
|
857 | - 'desc' => __( 'Enter the subject line for the subscription complete email.', 'invoicing' ), |
|
856 | + 'name' => __('Subject', 'invoicing'), |
|
857 | + 'desc' => __('Enter the subject line for the subscription complete email.', 'invoicing'), |
|
858 | 858 | 'help-tip' => true, |
859 | 859 | 'type' => 'text', |
860 | - 'std' => __( '[{site_title}] Subscription Complete', 'invoicing' ), |
|
860 | + 'std' => __('[{site_title}] Subscription Complete', 'invoicing'), |
|
861 | 861 | 'size' => 'large' |
862 | 862 | ), |
863 | 863 | |
864 | 864 | 'email_subscription_complete_heading' => array( |
865 | 865 | 'id' => 'email_subscription_complete_heading', |
866 | - 'name' => __( 'Email Heading', 'invoicing' ), |
|
867 | - 'desc' => __( 'Enter the main heading of this email.', 'invoicing' ), |
|
866 | + 'name' => __('Email Heading', 'invoicing'), |
|
867 | + 'desc' => __('Enter the main heading of this email.', 'invoicing'), |
|
868 | 868 | 'help-tip' => true, |
869 | 869 | 'type' => 'text', |
870 | - 'std' => __( 'Subscription Complete', 'invoicing' ), |
|
870 | + 'std' => __('Subscription Complete', 'invoicing'), |
|
871 | 871 | 'size' => 'large' |
872 | 872 | ), |
873 | 873 | |
874 | 874 | 'email_subscription_complete_body' => array( |
875 | 875 | 'id' => 'email_complete_body', |
876 | - 'name' => __( 'Email Content', 'invoicing' ), |
|
877 | - 'desc' => __( 'The content of the email.', 'invoicing' ), |
|
876 | + 'name' => __('Email Content', 'invoicing'), |
|
877 | + 'desc' => __('The content of the email.', 'invoicing'), |
|
878 | 878 | 'type' => 'rich_editor', |
879 | - 'std' => __( '<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing' ), |
|
879 | + 'std' => __('<p>Hi {first_name},</p><p>Your subscription for {subscription_name} is now complete.</p>', 'invoicing'), |
|
880 | 880 | 'class' => 'large', |
881 | 881 | 'size' => 10, |
882 | 882 | ), |
@@ -13,616 +13,616 @@ 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 | - |
|
29 | - // Invoice table columns. |
|
30 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
32 | - |
|
33 | - // Items table columns. |
|
34 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
40 | - |
|
41 | - // Payment forms columns. |
|
42 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
45 | - |
|
46 | - // Discount table columns. |
|
47 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
48 | - |
|
49 | - // Deleting posts. |
|
50 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * Post updated messages. |
|
56 | - */ |
|
57 | - public static function post_updated_messages( $messages ) { |
|
58 | - global $post; |
|
59 | - |
|
60 | - $messages['wpi_discount'] = array( |
|
61 | - 0 => '', |
|
62 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
72 | - ); |
|
73 | - |
|
74 | - $messages['wpi_payment_form'] = array( |
|
75 | - 0 => '', |
|
76 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
86 | - ); |
|
87 | - |
|
88 | - return $messages; |
|
89 | - |
|
90 | - } |
|
91 | - |
|
92 | - /** |
|
93 | - * Post row actions. |
|
94 | - */ |
|
95 | - public static function post_row_actions( $actions, $post ) { |
|
96 | - |
|
97 | - $post = get_post( $post ); |
|
98 | - |
|
99 | - // We do not want to edit the default payment form. |
|
100 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | - unset( $actions['trash'] ); |
|
102 | - unset( $actions['inline hide-if-no-js'] ); |
|
103 | - } |
|
104 | - |
|
105 | - return $actions; |
|
106 | - } |
|
107 | - |
|
108 | - /** |
|
109 | - * Returns an array of invoice table columns. |
|
110 | - */ |
|
111 | - public static function invoice_columns( $columns ) { |
|
112 | - |
|
113 | - $columns = array( |
|
114 | - 'cb' => $columns['cb'], |
|
115 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | - 'status' => __( 'Status', 'invoicing' ), |
|
121 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
122 | - ); |
|
123 | - |
|
124 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
125 | - } |
|
126 | - |
|
127 | - /** |
|
128 | - * Displays invoice table columns. |
|
129 | - */ |
|
130 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
131 | - |
|
132 | - $invoice = new WPInv_Invoice( $post_id ); |
|
133 | - |
|
134 | - switch ( $column_name ) { |
|
135 | - |
|
136 | - case 'invoice_date' : |
|
137 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | - $date = getpaid_format_date_value( $date_time ); |
|
139 | - echo "<span title='$date_time'>$date</span>"; |
|
140 | - break; |
|
141 | - |
|
142 | - case 'amount' : |
|
143 | - |
|
144 | - $amount = $invoice->get_total(); |
|
145 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
146 | - |
|
147 | - if ( $invoice->is_refunded() ) { |
|
148 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
149 | - echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
|
150 | - } else { |
|
151 | - |
|
152 | - $discount = $invoice->get_total_discount(); |
|
153 | - |
|
154 | - if ( ! empty( $discount ) ) { |
|
155 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
156 | - echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
|
157 | - } else { |
|
158 | - echo $formated_amount; |
|
159 | - } |
|
160 | - |
|
161 | - } |
|
162 | - |
|
163 | - break; |
|
164 | - |
|
165 | - case 'status' : |
|
166 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
168 | - |
|
169 | - // If it is paid, show the gateway title. |
|
170 | - if ( $invoice->is_paid() ) { |
|
171 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
16 | + * Hook in methods. |
|
17 | + */ |
|
18 | + public static function init() { |
|
173 | 19 | |
174 | - echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
175 | - } else { |
|
176 | - echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
177 | - } |
|
20 | + // Init metaboxes. |
|
21 | + GetPaid_Metaboxes::init(); |
|
178 | 22 | |
179 | - // If it is not paid, display the overdue and view status. |
|
180 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
23 | + // Filter the post updated messages. |
|
24 | + add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' ); |
|
181 | 25 | |
182 | - // Invoice view status. |
|
183 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
185 | - } else { |
|
186 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
187 | - } |
|
26 | + // Filter post actions. |
|
27 | + add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 ); |
|
188 | 28 | |
189 | - // Display the overview status. |
|
190 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
191 | - $due_date = $invoice->get_due_date(); |
|
192 | - $fomatted = getpaid_format_date( $due_date ); |
|
29 | + // Invoice table columns. |
|
30 | + add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | + add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
193 | 32 | |
194 | - if ( ! empty( $fomatted ) ) { |
|
195 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
196 | - echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
197 | - } |
|
198 | - } |
|
33 | + // Items table columns. |
|
34 | + add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | + add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | + add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | + add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | + add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | + add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
199 | 40 | |
200 | - } |
|
41 | + // Payment forms columns. |
|
42 | + add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | + add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
201 | 45 | |
202 | - break; |
|
46 | + // Discount table columns. |
|
47 | + add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
203 | 48 | |
204 | - case 'recurring': |
|
49 | + // Deleting posts. |
|
50 | + add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | + add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
52 | + } |
|
205 | 53 | |
206 | - if ( $invoice->is_recurring() ) { |
|
207 | - echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
208 | - } else { |
|
209 | - echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
210 | - } |
|
211 | - break; |
|
54 | + /** |
|
55 | + * Post updated messages. |
|
56 | + */ |
|
57 | + public static function post_updated_messages( $messages ) { |
|
58 | + global $post; |
|
59 | + |
|
60 | + $messages['wpi_discount'] = array( |
|
61 | + 0 => '', |
|
62 | + 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | + 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | + 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | + 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | + 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | + 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | + 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
72 | + ); |
|
73 | + |
|
74 | + $messages['wpi_payment_form'] = array( |
|
75 | + 0 => '', |
|
76 | + 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | + 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | + 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | + 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | + 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | + 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | + 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | + 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | + 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | + 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
86 | + ); |
|
87 | + |
|
88 | + return $messages; |
|
89 | + |
|
90 | + } |
|
91 | + |
|
92 | + /** |
|
93 | + * Post row actions. |
|
94 | + */ |
|
95 | + public static function post_row_actions( $actions, $post ) { |
|
96 | + |
|
97 | + $post = get_post( $post ); |
|
98 | + |
|
99 | + // We do not want to edit the default payment form. |
|
100 | + if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | + unset( $actions['trash'] ); |
|
102 | + unset( $actions['inline hide-if-no-js'] ); |
|
103 | + } |
|
104 | + |
|
105 | + return $actions; |
|
106 | + } |
|
107 | + |
|
108 | + /** |
|
109 | + * Returns an array of invoice table columns. |
|
110 | + */ |
|
111 | + public static function invoice_columns( $columns ) { |
|
112 | + |
|
113 | + $columns = array( |
|
114 | + 'cb' => $columns['cb'], |
|
115 | + 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | + 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | + 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | + 'status' => __( 'Status', 'invoicing' ), |
|
121 | + 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
122 | + ); |
|
123 | + |
|
124 | + return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
125 | + } |
|
126 | + |
|
127 | + /** |
|
128 | + * Displays invoice table columns. |
|
129 | + */ |
|
130 | + public static function display_invoice_columns( $column_name, $post_id ) { |
|
131 | + |
|
132 | + $invoice = new WPInv_Invoice( $post_id ); |
|
133 | + |
|
134 | + switch ( $column_name ) { |
|
135 | + |
|
136 | + case 'invoice_date' : |
|
137 | + $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | + $date = getpaid_format_date_value( $date_time ); |
|
139 | + echo "<span title='$date_time'>$date</span>"; |
|
140 | + break; |
|
141 | + |
|
142 | + case 'amount' : |
|
143 | + |
|
144 | + $amount = $invoice->get_total(); |
|
145 | + $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
146 | + |
|
147 | + if ( $invoice->is_refunded() ) { |
|
148 | + $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
149 | + echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
|
150 | + } else { |
|
151 | + |
|
152 | + $discount = $invoice->get_total_discount(); |
|
153 | + |
|
154 | + if ( ! empty( $discount ) ) { |
|
155 | + $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
156 | + echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
|
157 | + } else { |
|
158 | + echo $formated_amount; |
|
159 | + } |
|
160 | + |
|
161 | + } |
|
162 | + |
|
163 | + break; |
|
164 | + |
|
165 | + case 'status' : |
|
166 | + $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | + $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
168 | + |
|
169 | + // If it is paid, show the gateway title. |
|
170 | + if ( $invoice->is_paid() ) { |
|
171 | + $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | + $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
212 | 173 | |
213 | - case 'number' : |
|
174 | + echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
|
175 | + } else { |
|
176 | + echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>"; |
|
177 | + } |
|
214 | 178 | |
215 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
179 | + // If it is not paid, display the overdue and view status. |
|
180 | + if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
218 | 181 | |
219 | - echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
182 | + // Invoice view status. |
|
183 | + if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | + echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
185 | + } else { |
|
186 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
187 | + } |
|
220 | 188 | |
221 | - break; |
|
189 | + // Display the overview status. |
|
190 | + if ( wpinv_get_option( 'overdue_active' ) ) { |
|
191 | + $due_date = $invoice->get_due_date(); |
|
192 | + $fomatted = getpaid_format_date( $due_date ); |
|
222 | 193 | |
223 | - case 'customer' : |
|
194 | + if ( ! empty( $fomatted ) ) { |
|
195 | + $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
196 | + echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
|
197 | + } |
|
198 | + } |
|
199 | + |
|
200 | + } |
|
201 | + |
|
202 | + break; |
|
203 | + |
|
204 | + case 'recurring': |
|
205 | + |
|
206 | + if ( $invoice->is_recurring() ) { |
|
207 | + echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
|
208 | + } else { |
|
209 | + echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
|
210 | + } |
|
211 | + break; |
|
212 | + |
|
213 | + case 'number' : |
|
214 | + |
|
215 | + $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | + $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | + $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
218 | + |
|
219 | + echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
|
220 | + |
|
221 | + break; |
|
222 | + |
|
223 | + case 'customer' : |
|
224 | 224 | |
225 | - $customer_name = $invoice->get_user_full_name(); |
|
225 | + $customer_name = $invoice->get_user_full_name(); |
|
226 | 226 | |
227 | - if ( empty( $customer_name ) ) { |
|
228 | - $customer_name = $invoice->get_email(); |
|
229 | - } |
|
227 | + if ( empty( $customer_name ) ) { |
|
228 | + $customer_name = $invoice->get_email(); |
|
229 | + } |
|
230 | 230 | |
231 | - if ( ! empty( $customer_name ) ) { |
|
232 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
234 | - echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
235 | - } else { |
|
236 | - echo '<div>—</div>'; |
|
237 | - } |
|
231 | + if ( ! empty( $customer_name ) ) { |
|
232 | + $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | + $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
234 | + echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
|
235 | + } else { |
|
236 | + echo '<div>—</div>'; |
|
237 | + } |
|
238 | + |
|
239 | + break; |
|
240 | + |
|
241 | + case 'wpi_actions' : |
|
242 | + |
|
243 | + if ( $invoice->is_draft() ) { |
|
244 | + return; |
|
245 | + } |
|
246 | + |
|
247 | + $url = esc_url( $invoice->get_view_url() ); |
|
248 | + $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
249 | + echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
|
250 | + |
|
251 | + $url = esc_url( |
|
252 | + wp_nonce_url( |
|
253 | + add_query_arg( |
|
254 | + array( |
|
255 | + 'getpaid-admin-action' => 'send_invoice', |
|
256 | + 'invoice_id' => $invoice->get_id() |
|
257 | + ) |
|
258 | + ), |
|
259 | + 'getpaid-nonce', |
|
260 | + 'getpaid-nonce' |
|
261 | + ) |
|
262 | + ); |
|
263 | + |
|
264 | + $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
265 | + echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
|
266 | + |
|
267 | + break; |
|
268 | + } |
|
238 | 269 | |
239 | - break; |
|
270 | + } |
|
240 | 271 | |
241 | - case 'wpi_actions' : |
|
242 | - |
|
243 | - if ( $invoice->is_draft() ) { |
|
244 | - return; |
|
245 | - } |
|
246 | - |
|
247 | - $url = esc_url( $invoice->get_view_url() ); |
|
248 | - $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
249 | - echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
|
272 | + /** |
|
273 | + * Returns an array of payment forms table columns. |
|
274 | + */ |
|
275 | + public static function payment_form_columns( $columns ) { |
|
250 | 276 | |
251 | - $url = esc_url( |
|
252 | - wp_nonce_url( |
|
253 | - add_query_arg( |
|
254 | - array( |
|
255 | - 'getpaid-admin-action' => 'send_invoice', |
|
256 | - 'invoice_id' => $invoice->get_id() |
|
257 | - ) |
|
258 | - ), |
|
259 | - 'getpaid-nonce', |
|
260 | - 'getpaid-nonce' |
|
261 | - ) |
|
262 | - ); |
|
277 | + $columns = array( |
|
278 | + 'cb' => $columns['cb'], |
|
279 | + 'title' => __( 'Name', 'invoicing' ), |
|
280 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | + 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | + 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | + 'items' => __( 'Items', 'invoicing' ), |
|
284 | + 'date' => __( 'Date', 'invoicing' ), |
|
285 | + ); |
|
263 | 286 | |
264 | - $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
265 | - echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
|
287 | + return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
266 | 288 | |
267 | - break; |
|
268 | - } |
|
289 | + } |
|
269 | 290 | |
270 | - } |
|
291 | + /** |
|
292 | + * Displays payment form table columns. |
|
293 | + */ |
|
294 | + public static function display_payment_form_columns( $column_name, $post_id ) { |
|
271 | 295 | |
272 | - /** |
|
273 | - * Returns an array of payment forms table columns. |
|
274 | - */ |
|
275 | - public static function payment_form_columns( $columns ) { |
|
296 | + // Retrieve the payment form. |
|
297 | + $form = new GetPaid_Payment_Form( $post_id ); |
|
276 | 298 | |
277 | - $columns = array( |
|
278 | - 'cb' => $columns['cb'], |
|
279 | - 'title' => __( 'Name', 'invoicing' ), |
|
280 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | - 'items' => __( 'Items', 'invoicing' ), |
|
284 | - 'date' => __( 'Date', 'invoicing' ), |
|
285 | - ); |
|
299 | + switch ( $column_name ) { |
|
286 | 300 | |
287 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
301 | + case 'earnings' : |
|
302 | + echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
303 | + break; |
|
288 | 304 | |
289 | - } |
|
305 | + case 'refunds' : |
|
306 | + echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
307 | + break; |
|
290 | 308 | |
291 | - /** |
|
292 | - * Displays payment form table columns. |
|
293 | - */ |
|
294 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
309 | + case 'refunds' : |
|
310 | + echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
311 | + break; |
|
295 | 312 | |
296 | - // Retrieve the payment form. |
|
297 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
313 | + case 'shortcode' : |
|
298 | 314 | |
299 | - switch ( $column_name ) { |
|
315 | + if ( $form->is_default() ) { |
|
316 | + echo '—'; |
|
317 | + } else { |
|
318 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
319 | + } |
|
300 | 320 | |
301 | - case 'earnings' : |
|
302 | - echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
303 | - break; |
|
321 | + break; |
|
304 | 322 | |
305 | - case 'refunds' : |
|
306 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
307 | - break; |
|
323 | + case 'items' : |
|
308 | 324 | |
309 | - case 'refunds' : |
|
310 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
311 | - break; |
|
325 | + $items = $form->get_items(); |
|
312 | 326 | |
313 | - case 'shortcode' : |
|
327 | + if ( $form->is_default() || empty( $items ) ) { |
|
328 | + echo '—'; |
|
329 | + return; |
|
330 | + } |
|
314 | 331 | |
315 | - if ( $form->is_default() ) { |
|
316 | - echo '—'; |
|
317 | - } else { |
|
318 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
319 | - } |
|
332 | + $_items = array(); |
|
320 | 333 | |
321 | - break; |
|
334 | + foreach ( $items as $item ) { |
|
335 | + $url = $item->get_edit_url(); |
|
322 | 336 | |
323 | - case 'items' : |
|
337 | + if ( empty( $url ) ) { |
|
338 | + $_items[] = sanitize_text_field( $item->get_name() ); |
|
339 | + } else { |
|
340 | + $_items[] = sprintf( |
|
341 | + '<a href="%s">%s</a>', |
|
342 | + esc_url( $url ), |
|
343 | + sanitize_text_field( $item->get_name() ) |
|
344 | + ); |
|
345 | + } |
|
324 | 346 | |
325 | - $items = $form->get_items(); |
|
347 | + } |
|
326 | 348 | |
327 | - if ( $form->is_default() || empty( $items ) ) { |
|
328 | - echo '—'; |
|
329 | - return; |
|
330 | - } |
|
349 | + echo implode( '<br>', $_items ); |
|
331 | 350 | |
332 | - $_items = array(); |
|
351 | + break; |
|
333 | 352 | |
334 | - foreach ( $items as $item ) { |
|
335 | - $url = $item->get_edit_url(); |
|
353 | + } |
|
336 | 354 | |
337 | - if ( empty( $url ) ) { |
|
338 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
339 | - } else { |
|
340 | - $_items[] = sprintf( |
|
341 | - '<a href="%s">%s</a>', |
|
342 | - esc_url( $url ), |
|
343 | - sanitize_text_field( $item->get_name() ) |
|
344 | - ); |
|
345 | - } |
|
355 | + } |
|
346 | 356 | |
347 | - } |
|
357 | + /** |
|
358 | + * Filters post states. |
|
359 | + */ |
|
360 | + public static function filter_payment_form_state( $post_states, $post ) { |
|
348 | 361 | |
349 | - echo implode( '<br>', $_items ); |
|
362 | + if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | + $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
364 | + } |
|
365 | + |
|
366 | + return $post_states; |
|
350 | 367 | |
351 | - break; |
|
368 | + } |
|
352 | 369 | |
353 | - } |
|
370 | + /** |
|
371 | + * Returns an array of coupon table columns. |
|
372 | + */ |
|
373 | + public static function discount_columns( $columns ) { |
|
374 | + |
|
375 | + $columns = array( |
|
376 | + 'cb' => $columns['cb'], |
|
377 | + 'title' => __( 'Name', 'invoicing' ), |
|
378 | + 'code' => __( 'Code', 'invoicing' ), |
|
379 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | + 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | + 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
383 | + ); |
|
384 | + |
|
385 | + return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
386 | + } |
|
354 | 387 | |
355 | - } |
|
388 | + /** |
|
389 | + * Filters post states. |
|
390 | + */ |
|
391 | + public static function filter_discount_state( $post_states, $post ) { |
|
356 | 392 | |
357 | - /** |
|
358 | - * Filters post states. |
|
359 | - */ |
|
360 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
393 | + if ( 'wpi_discount' == $post->post_type ) { |
|
361 | 394 | |
362 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
364 | - } |
|
365 | - |
|
366 | - return $post_states; |
|
395 | + $discount = new WPInv_Discount( $post ); |
|
367 | 396 | |
368 | - } |
|
397 | + $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
369 | 398 | |
370 | - /** |
|
371 | - * Returns an array of coupon table columns. |
|
372 | - */ |
|
373 | - public static function discount_columns( $columns ) { |
|
399 | + if ( $status != 'publish' ) { |
|
400 | + return array( |
|
401 | + 'discount_status' => wpinv_discount_status( $status ), |
|
402 | + ); |
|
403 | + } |
|
374 | 404 | |
375 | - $columns = array( |
|
376 | - 'cb' => $columns['cb'], |
|
377 | - 'title' => __( 'Name', 'invoicing' ), |
|
378 | - 'code' => __( 'Code', 'invoicing' ), |
|
379 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
383 | - ); |
|
405 | + return array(); |
|
384 | 406 | |
385 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
386 | - } |
|
407 | + } |
|
387 | 408 | |
388 | - /** |
|
389 | - * Filters post states. |
|
390 | - */ |
|
391 | - public static function filter_discount_state( $post_states, $post ) { |
|
409 | + return $post_states; |
|
392 | 410 | |
393 | - if ( 'wpi_discount' == $post->post_type ) { |
|
411 | + } |
|
394 | 412 | |
395 | - $discount = new WPInv_Discount( $post ); |
|
413 | + /** |
|
414 | + * Returns an array of items table columns. |
|
415 | + */ |
|
416 | + public static function item_columns( $columns ) { |
|
417 | + global $wpinv_euvat; |
|
418 | + |
|
419 | + $columns = array( |
|
420 | + 'cb' => $columns['cb'], |
|
421 | + 'title' => __( 'Name', 'invoicing' ), |
|
422 | + 'price' => __( 'Price', 'invoicing' ), |
|
423 | + 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | + 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | + 'type' => __( 'Type', 'invoicing' ), |
|
426 | + 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
427 | + ); |
|
428 | + |
|
429 | + if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | + unset( $columns['vat_rule'] ); |
|
431 | + } |
|
396 | 432 | |
397 | - $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
|
433 | + if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | + unset( $columns['vat_class'] ); |
|
435 | + } |
|
398 | 436 | |
399 | - if ( $status != 'publish' ) { |
|
400 | - return array( |
|
401 | - 'discount_status' => wpinv_discount_status( $status ), |
|
402 | - ); |
|
403 | - } |
|
437 | + return apply_filters( 'wpi_item_table_columns', $columns ); |
|
438 | + } |
|
404 | 439 | |
405 | - return array(); |
|
440 | + /** |
|
441 | + * Returns an array of sortable items table columns. |
|
442 | + */ |
|
443 | + public static function sortable_item_columns( $columns ) { |
|
444 | + |
|
445 | + return array_merge( |
|
446 | + $columns, |
|
447 | + array( |
|
448 | + 'price' => 'price', |
|
449 | + 'vat_rule' => 'vat_rule', |
|
450 | + 'vat_class' => 'vat_class', |
|
451 | + 'type' => 'type', |
|
452 | + ) |
|
453 | + ); |
|
454 | + |
|
455 | + } |
|
406 | 456 | |
407 | - } |
|
457 | + /** |
|
458 | + * Displays items table columns. |
|
459 | + */ |
|
460 | + public static function display_item_columns( $column_name, $post_id ) { |
|
461 | + global $wpinv_euvat; |
|
408 | 462 | |
409 | - return $post_states; |
|
463 | + $item = new WPInv_Item( $post_id ); |
|
410 | 464 | |
411 | - } |
|
465 | + switch ( $column_name ) { |
|
412 | 466 | |
413 | - /** |
|
414 | - * Returns an array of items table columns. |
|
415 | - */ |
|
416 | - public static function item_columns( $columns ) { |
|
417 | - global $wpinv_euvat; |
|
467 | + case 'price' : |
|
418 | 468 | |
419 | - $columns = array( |
|
420 | - 'cb' => $columns['cb'], |
|
421 | - 'title' => __( 'Name', 'invoicing' ), |
|
422 | - 'price' => __( 'Price', 'invoicing' ), |
|
423 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | - 'type' => __( 'Type', 'invoicing' ), |
|
426 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
427 | - ); |
|
469 | + if ( ! $item->is_recurring() ) { |
|
470 | + echo $item->get_the_price(); |
|
471 | + break; |
|
472 | + } |
|
428 | 473 | |
429 | - if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | - unset( $columns['vat_rule'] ); |
|
431 | - } |
|
474 | + $price = wp_sprintf( |
|
475 | + __( '%s / %s', 'invoicing' ), |
|
476 | + $item->get_the_price(), |
|
477 | + getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
478 | + ); |
|
432 | 479 | |
433 | - if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | - unset( $columns['vat_class'] ); |
|
435 | - } |
|
480 | + if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
481 | + echo $price; |
|
482 | + break; |
|
483 | + } |
|
436 | 484 | |
437 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
438 | - } |
|
485 | + echo $item->get_the_initial_price(); |
|
439 | 486 | |
440 | - /** |
|
441 | - * Returns an array of sortable items table columns. |
|
442 | - */ |
|
443 | - public static function sortable_item_columns( $columns ) { |
|
487 | + echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
488 | + break; |
|
444 | 489 | |
445 | - return array_merge( |
|
446 | - $columns, |
|
447 | - array( |
|
448 | - 'price' => 'price', |
|
449 | - 'vat_rule' => 'vat_rule', |
|
450 | - 'vat_class' => 'vat_class', |
|
451 | - 'type' => 'type', |
|
452 | - ) |
|
453 | - ); |
|
490 | + case 'vat_rule' : |
|
491 | + echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
492 | + break; |
|
454 | 493 | |
455 | - } |
|
494 | + case 'vat_class' : |
|
495 | + echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
496 | + break; |
|
456 | 497 | |
457 | - /** |
|
458 | - * Displays items table columns. |
|
459 | - */ |
|
460 | - public static function display_item_columns( $column_name, $post_id ) { |
|
461 | - global $wpinv_euvat; |
|
498 | + case 'shortcode' : |
|
499 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | + break; |
|
462 | 501 | |
463 | - $item = new WPInv_Item( $post_id ); |
|
502 | + case 'type' : |
|
503 | + echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | + break; |
|
464 | 505 | |
465 | - switch ( $column_name ) { |
|
506 | + } |
|
466 | 507 | |
467 | - case 'price' : |
|
508 | + } |
|
468 | 509 | |
469 | - if ( ! $item->is_recurring() ) { |
|
470 | - echo $item->get_the_price(); |
|
471 | - break; |
|
472 | - } |
|
510 | + /** |
|
511 | + * Lets users filter items using taxes. |
|
512 | + */ |
|
513 | + public static function add_item_filters( $post_type ) { |
|
514 | + $wpinv_euvat = getpaid_tax(); |
|
515 | + |
|
516 | + // Abort if we're not dealing with items. |
|
517 | + if ( $post_type != 'wpi_item' ) { |
|
518 | + return; |
|
519 | + } |
|
520 | + |
|
521 | + // Filter by vat rules. |
|
522 | + if ( $wpinv_euvat->allow_vat_rules() ) { |
|
523 | + |
|
524 | + // Sanitize selected vat rule. |
|
525 | + $vat_rule = ''; |
|
526 | + $vat_rules = $wpinv_euvat->get_rules(); |
|
527 | + if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | + $vat_rule = $_GET['vat_rule']; |
|
529 | + } |
|
530 | + |
|
531 | + // Filter by VAT rule. |
|
532 | + echo wpinv_html_select( |
|
533 | + array( |
|
534 | + 'options' => array_merge( |
|
535 | + array( |
|
536 | + '' => __( 'All VAT rules', 'invoicing' ) |
|
537 | + ), |
|
538 | + $vat_rules |
|
539 | + ), |
|
540 | + 'name' => 'vat_rule', |
|
541 | + 'id' => 'vat_rule', |
|
542 | + 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
543 | + 'show_option_all' => false, |
|
544 | + 'show_option_none' => false, |
|
545 | + 'class' => 'gdmbx2-text-medium', |
|
546 | + ) |
|
547 | + ); |
|
548 | + |
|
549 | + // Filter by VAT class. |
|
550 | + } |
|
473 | 551 | |
474 | - $price = wp_sprintf( |
|
475 | - __( '%s / %s', 'invoicing' ), |
|
476 | - $item->get_the_price(), |
|
477 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
478 | - ); |
|
552 | + // Filter by vat class. |
|
553 | + if ( $wpinv_euvat->allow_vat_classes() ) { |
|
554 | + |
|
555 | + // Sanitize selected vat rule. |
|
556 | + $vat_class = ''; |
|
557 | + $vat_classes = $wpinv_euvat->get_all_classes(); |
|
558 | + if ( isset( $_GET['vat_class'] ) ) { |
|
559 | + $vat_class = $_GET['vat_class']; |
|
560 | + } |
|
561 | + |
|
562 | + echo wpinv_html_select( |
|
563 | + array( |
|
564 | + 'options' => array_merge( |
|
565 | + array( |
|
566 | + '' => __( 'All VAT classes', 'invoicing' ) |
|
567 | + ), |
|
568 | + $vat_classes |
|
569 | + ), |
|
570 | + 'name' => 'vat_class', |
|
571 | + 'id' => 'vat_class', |
|
572 | + 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
573 | + 'show_option_all' => false, |
|
574 | + 'show_option_none' => false, |
|
575 | + 'class' => 'gdmbx2-text-medium', |
|
576 | + ) |
|
577 | + ); |
|
479 | 578 | |
480 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
481 | - echo $price; |
|
482 | - break; |
|
483 | - } |
|
579 | + } |
|
484 | 580 | |
485 | - echo $item->get_the_initial_price(); |
|
581 | + // Filter by item type. |
|
582 | + $type = ''; |
|
583 | + if ( isset( $_GET['type'] ) ) { |
|
584 | + $type = $_GET['type']; |
|
585 | + } |
|
486 | 586 | |
487 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
488 | - break; |
|
587 | + echo wpinv_html_select( |
|
588 | + array( |
|
589 | + 'options' => array_merge( |
|
590 | + array( |
|
591 | + '' => __( 'All item types', 'invoicing' ) |
|
592 | + ), |
|
593 | + wpinv_get_item_types() |
|
594 | + ), |
|
595 | + 'name' => 'type', |
|
596 | + 'id' => 'type', |
|
597 | + 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
598 | + 'show_option_all' => false, |
|
599 | + 'show_option_none' => false, |
|
600 | + 'class' => 'gdmbx2-text-medium', |
|
601 | + ) |
|
602 | + ); |
|
603 | + |
|
604 | + } |
|
489 | 605 | |
490 | - case 'vat_rule' : |
|
491 | - echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
492 | - break; |
|
606 | + /** |
|
607 | + * Filters the item query. |
|
608 | + */ |
|
609 | + public static function filter_item_query( $query ) { |
|
493 | 610 | |
494 | - case 'vat_class' : |
|
495 | - echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
496 | - break; |
|
611 | + // modify the query only if it admin and main query. |
|
612 | + if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
613 | + return $query; |
|
614 | + } |
|
497 | 615 | |
498 | - case 'shortcode' : |
|
499 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | - break; |
|
616 | + // we want to modify the query for our items. |
|
617 | + if ( 'wpi_item' != $query->query['post_type'] ){ |
|
618 | + return $query; |
|
619 | + } |
|
501 | 620 | |
502 | - case 'type' : |
|
503 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | - break; |
|
621 | + if ( empty( $query->query_vars['meta_query'] ) ) { |
|
622 | + $query->query_vars['meta_query'] = array(); |
|
623 | + } |
|
505 | 624 | |
506 | - } |
|
507 | - |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * Lets users filter items using taxes. |
|
512 | - */ |
|
513 | - public static function add_item_filters( $post_type ) { |
|
514 | - $wpinv_euvat = getpaid_tax(); |
|
515 | - |
|
516 | - // Abort if we're not dealing with items. |
|
517 | - if ( $post_type != 'wpi_item' ) { |
|
518 | - return; |
|
519 | - } |
|
520 | - |
|
521 | - // Filter by vat rules. |
|
522 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
523 | - |
|
524 | - // Sanitize selected vat rule. |
|
525 | - $vat_rule = ''; |
|
526 | - $vat_rules = $wpinv_euvat->get_rules(); |
|
527 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | - $vat_rule = $_GET['vat_rule']; |
|
529 | - } |
|
530 | - |
|
531 | - // Filter by VAT rule. |
|
532 | - echo wpinv_html_select( |
|
533 | - array( |
|
534 | - 'options' => array_merge( |
|
535 | - array( |
|
536 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
537 | - ), |
|
538 | - $vat_rules |
|
539 | - ), |
|
540 | - 'name' => 'vat_rule', |
|
541 | - 'id' => 'vat_rule', |
|
542 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
543 | - 'show_option_all' => false, |
|
544 | - 'show_option_none' => false, |
|
545 | - 'class' => 'gdmbx2-text-medium', |
|
546 | - ) |
|
547 | - ); |
|
548 | - |
|
549 | - // Filter by VAT class. |
|
550 | - } |
|
551 | - |
|
552 | - // Filter by vat class. |
|
553 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
554 | - |
|
555 | - // Sanitize selected vat rule. |
|
556 | - $vat_class = ''; |
|
557 | - $vat_classes = $wpinv_euvat->get_all_classes(); |
|
558 | - if ( isset( $_GET['vat_class'] ) ) { |
|
559 | - $vat_class = $_GET['vat_class']; |
|
560 | - } |
|
561 | - |
|
562 | - echo wpinv_html_select( |
|
563 | - array( |
|
564 | - 'options' => array_merge( |
|
565 | - array( |
|
566 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
567 | - ), |
|
568 | - $vat_classes |
|
569 | - ), |
|
570 | - 'name' => 'vat_class', |
|
571 | - 'id' => 'vat_class', |
|
572 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
573 | - 'show_option_all' => false, |
|
574 | - 'show_option_none' => false, |
|
575 | - 'class' => 'gdmbx2-text-medium', |
|
576 | - ) |
|
577 | - ); |
|
578 | - |
|
579 | - } |
|
580 | - |
|
581 | - // Filter by item type. |
|
582 | - $type = ''; |
|
583 | - if ( isset( $_GET['type'] ) ) { |
|
584 | - $type = $_GET['type']; |
|
585 | - } |
|
586 | - |
|
587 | - echo wpinv_html_select( |
|
588 | - array( |
|
589 | - 'options' => array_merge( |
|
590 | - array( |
|
591 | - '' => __( 'All item types', 'invoicing' ) |
|
592 | - ), |
|
593 | - wpinv_get_item_types() |
|
594 | - ), |
|
595 | - 'name' => 'type', |
|
596 | - 'id' => 'type', |
|
597 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
598 | - 'show_option_all' => false, |
|
599 | - 'show_option_none' => false, |
|
600 | - 'class' => 'gdmbx2-text-medium', |
|
601 | - ) |
|
602 | - ); |
|
603 | - |
|
604 | - } |
|
605 | - |
|
606 | - /** |
|
607 | - * Filters the item query. |
|
608 | - */ |
|
609 | - public static function filter_item_query( $query ) { |
|
610 | - |
|
611 | - // modify the query only if it admin and main query. |
|
612 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
613 | - return $query; |
|
614 | - } |
|
615 | - |
|
616 | - // we want to modify the query for our items. |
|
617 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
618 | - return $query; |
|
619 | - } |
|
620 | - |
|
621 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
622 | - $query->query_vars['meta_query'] = array(); |
|
623 | - } |
|
624 | - |
|
625 | - // Filter vat rule type |
|
625 | + // Filter vat rule type |
|
626 | 626 | if ( ! empty( $_GET['vat_rule'] ) ) { |
627 | 627 | $query->query_vars['meta_query'][] = array( |
628 | 628 | 'key' => '_wpinv_vat_rule', |
@@ -647,94 +647,94 @@ discard block |
||
647 | 647 | 'value' => sanitize_text_field( $_GET['type'] ), |
648 | 648 | 'compare' => '=' |
649 | 649 | ); |
650 | - } |
|
651 | - |
|
652 | - } |
|
653 | - |
|
654 | - /** |
|
655 | - * Reorders items. |
|
656 | - */ |
|
657 | - public static function reorder_items( $vars ) { |
|
658 | - global $typenow; |
|
659 | - |
|
660 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
661 | - return $vars; |
|
662 | - } |
|
663 | - |
|
664 | - // By item type. |
|
665 | - if ( 'type' == $vars['orderby'] ) { |
|
666 | - return array_merge( |
|
667 | - $vars, |
|
668 | - array( |
|
669 | - 'meta_key' => '_wpinv_type', |
|
670 | - 'orderby' => 'meta_value' |
|
671 | - ) |
|
672 | - ); |
|
673 | - } |
|
674 | - |
|
675 | - // By vat class. |
|
676 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
677 | - return array_merge( |
|
678 | - $vars, |
|
679 | - array( |
|
680 | - 'meta_key' => '_wpinv_vat_class', |
|
681 | - 'orderby' => 'meta_value' |
|
682 | - ) |
|
683 | - ); |
|
684 | - } |
|
685 | - |
|
686 | - // By vat rule. |
|
687 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
688 | - return array_merge( |
|
689 | - $vars, |
|
690 | - array( |
|
691 | - 'meta_key' => '_wpinv_vat_rule', |
|
692 | - 'orderby' => 'meta_value' |
|
693 | - ) |
|
694 | - ); |
|
695 | - } |
|
696 | - |
|
697 | - // By price. |
|
698 | - if ( 'price' == $vars['orderby'] ) { |
|
699 | - return array_merge( |
|
700 | - $vars, |
|
701 | - array( |
|
702 | - 'meta_key' => '_wpinv_price', |
|
703 | - 'orderby' => 'meta_value_num' |
|
704 | - ) |
|
705 | - ); |
|
706 | - } |
|
707 | - |
|
708 | - return $vars; |
|
709 | - |
|
710 | - } |
|
711 | - |
|
712 | - /** |
|
713 | - * Fired when deleting a post. |
|
714 | - */ |
|
715 | - public static function delete_post( $post_id ) { |
|
716 | - |
|
717 | - switch ( get_post_type( $post_id ) ) { |
|
718 | - |
|
719 | - case 'wpi_item' : |
|
720 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
721 | - break; |
|
722 | - |
|
723 | - case 'wpi_payment_form' : |
|
724 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
725 | - break; |
|
726 | - |
|
727 | - case 'wpi_discount' : |
|
728 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
729 | - break; |
|
730 | - |
|
731 | - case 'wpi_invoice' : |
|
732 | - $invoice = new WPInv_Invoice( $post_id ); |
|
733 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
736 | - break; |
|
737 | - } |
|
738 | - } |
|
650 | + } |
|
651 | + |
|
652 | + } |
|
653 | + |
|
654 | + /** |
|
655 | + * Reorders items. |
|
656 | + */ |
|
657 | + public static function reorder_items( $vars ) { |
|
658 | + global $typenow; |
|
659 | + |
|
660 | + if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
661 | + return $vars; |
|
662 | + } |
|
663 | + |
|
664 | + // By item type. |
|
665 | + if ( 'type' == $vars['orderby'] ) { |
|
666 | + return array_merge( |
|
667 | + $vars, |
|
668 | + array( |
|
669 | + 'meta_key' => '_wpinv_type', |
|
670 | + 'orderby' => 'meta_value' |
|
671 | + ) |
|
672 | + ); |
|
673 | + } |
|
674 | + |
|
675 | + // By vat class. |
|
676 | + if ( 'vat_class' == $vars['orderby'] ) { |
|
677 | + return array_merge( |
|
678 | + $vars, |
|
679 | + array( |
|
680 | + 'meta_key' => '_wpinv_vat_class', |
|
681 | + 'orderby' => 'meta_value' |
|
682 | + ) |
|
683 | + ); |
|
684 | + } |
|
685 | + |
|
686 | + // By vat rule. |
|
687 | + if ( 'vat_rule' == $vars['orderby'] ) { |
|
688 | + return array_merge( |
|
689 | + $vars, |
|
690 | + array( |
|
691 | + 'meta_key' => '_wpinv_vat_rule', |
|
692 | + 'orderby' => 'meta_value' |
|
693 | + ) |
|
694 | + ); |
|
695 | + } |
|
696 | + |
|
697 | + // By price. |
|
698 | + if ( 'price' == $vars['orderby'] ) { |
|
699 | + return array_merge( |
|
700 | + $vars, |
|
701 | + array( |
|
702 | + 'meta_key' => '_wpinv_price', |
|
703 | + 'orderby' => 'meta_value_num' |
|
704 | + ) |
|
705 | + ); |
|
706 | + } |
|
707 | + |
|
708 | + return $vars; |
|
709 | + |
|
710 | + } |
|
711 | + |
|
712 | + /** |
|
713 | + * Fired when deleting a post. |
|
714 | + */ |
|
715 | + public static function delete_post( $post_id ) { |
|
716 | + |
|
717 | + switch ( get_post_type( $post_id ) ) { |
|
718 | + |
|
719 | + case 'wpi_item' : |
|
720 | + do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
721 | + break; |
|
722 | + |
|
723 | + case 'wpi_payment_form' : |
|
724 | + do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
725 | + break; |
|
726 | + |
|
727 | + case 'wpi_discount' : |
|
728 | + do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
729 | + break; |
|
730 | + |
|
731 | + case 'wpi_invoice' : |
|
732 | + $invoice = new WPInv_Invoice( $post_id ); |
|
733 | + do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | + $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | + $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
736 | + break; |
|
737 | + } |
|
738 | + } |
|
739 | 739 | |
740 | 740 | } |
@@ -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,68 +21,68 @@ 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 ); |
|
27 | + add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2); |
|
28 | 28 | |
29 | 29 | // Invoice table columns. |
30 | - add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 ); |
|
31 | - add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 ); |
|
30 | + add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100); |
|
31 | + add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2); |
|
32 | 32 | |
33 | 33 | // Items table columns. |
34 | - add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 ); |
|
35 | - add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 ); |
|
36 | - add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 ); |
|
37 | - add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 ); |
|
38 | - add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 ); |
|
39 | - add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 ); |
|
34 | + add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100); |
|
35 | + add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20); |
|
36 | + add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2); |
|
37 | + add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100); |
|
38 | + add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100); |
|
39 | + add_action('request', array(__CLASS__, 'reorder_items'), 100); |
|
40 | 40 | |
41 | 41 | // Payment forms columns. |
42 | - add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 ); |
|
43 | - add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 ); |
|
44 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 ); |
|
42 | + add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100); |
|
43 | + add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2); |
|
44 | + add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2); |
|
45 | 45 | |
46 | 46 | // Discount table columns. |
47 | - add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 ); |
|
47 | + add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100); |
|
48 | 48 | |
49 | 49 | // Deleting posts. |
50 | - add_action( 'delete_post', array( __CLASS__, 'delete_post' ) ); |
|
51 | - add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 ); |
|
50 | + add_action('delete_post', array(__CLASS__, 'delete_post')); |
|
51 | + add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | /** |
55 | 55 | * Post updated messages. |
56 | 56 | */ |
57 | - public static function post_updated_messages( $messages ) { |
|
57 | + public static function post_updated_messages($messages) { |
|
58 | 58 | global $post; |
59 | 59 | |
60 | 60 | $messages['wpi_discount'] = array( |
61 | 61 | 0 => '', |
62 | - 1 => __( 'Discount updated.', 'invoicing' ), |
|
63 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
64 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
65 | - 4 => __( 'Discount updated.', 'invoicing' ), |
|
66 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
67 | - 6 => __( 'Discount updated.', 'invoicing' ), |
|
68 | - 7 => __( 'Discount saved.', 'invoicing' ), |
|
69 | - 8 => __( 'Discount submitted.', 'invoicing' ), |
|
70 | - 9 => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
71 | - 10 => __( 'Discount draft updated.', 'invoicing' ), |
|
62 | + 1 => __('Discount updated.', 'invoicing'), |
|
63 | + 2 => __('Custom field updated.', 'invoicing'), |
|
64 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
65 | + 4 => __('Discount updated.', 'invoicing'), |
|
66 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
67 | + 6 => __('Discount updated.', 'invoicing'), |
|
68 | + 7 => __('Discount saved.', 'invoicing'), |
|
69 | + 8 => __('Discount submitted.', 'invoicing'), |
|
70 | + 9 => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
71 | + 10 => __('Discount draft updated.', 'invoicing'), |
|
72 | 72 | ); |
73 | 73 | |
74 | 74 | $messages['wpi_payment_form'] = array( |
75 | 75 | 0 => '', |
76 | - 1 => __( 'Payment Form updated.', 'invoicing' ), |
|
77 | - 2 => __( 'Custom field updated.', 'invoicing' ), |
|
78 | - 3 => __( 'Custom field deleted.', 'invoicing' ), |
|
79 | - 4 => __( 'Payment Form updated.', 'invoicing' ), |
|
80 | - 5 => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false, |
|
81 | - 6 => __( 'Payment Form updated.', 'invoicing' ), |
|
82 | - 7 => __( 'Payment Form saved.', 'invoicing' ), |
|
83 | - 8 => __( 'Payment Form submitted.', 'invoicing' ), |
|
84 | - 9 => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ), |
|
85 | - 10 => __( 'Payment Form draft updated.', 'invoicing' ), |
|
76 | + 1 => __('Payment Form updated.', 'invoicing'), |
|
77 | + 2 => __('Custom field updated.', 'invoicing'), |
|
78 | + 3 => __('Custom field deleted.', 'invoicing'), |
|
79 | + 4 => __('Payment Form updated.', 'invoicing'), |
|
80 | + 5 => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false, |
|
81 | + 6 => __('Payment Form updated.', 'invoicing'), |
|
82 | + 7 => __('Payment Form saved.', 'invoicing'), |
|
83 | + 8 => __('Payment Form submitted.', 'invoicing'), |
|
84 | + 9 => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))), |
|
85 | + 10 => __('Payment Form draft updated.', 'invoicing'), |
|
86 | 86 | ); |
87 | 87 | |
88 | 88 | return $messages; |
@@ -92,14 +92,14 @@ discard block |
||
92 | 92 | /** |
93 | 93 | * Post row actions. |
94 | 94 | */ |
95 | - public static function post_row_actions( $actions, $post ) { |
|
95 | + public static function post_row_actions($actions, $post) { |
|
96 | 96 | |
97 | - $post = get_post( $post ); |
|
97 | + $post = get_post($post); |
|
98 | 98 | |
99 | 99 | // We do not want to edit the default payment form. |
100 | - if ( 'wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form() ) { |
|
101 | - unset( $actions['trash'] ); |
|
102 | - unset( $actions['inline hide-if-no-js'] ); |
|
100 | + if ('wpi_payment_form' == $post->post_type && $post->ID == wpinv_get_default_payment_form()) { |
|
101 | + unset($actions['trash']); |
|
102 | + unset($actions['inline hide-if-no-js']); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | return $actions; |
@@ -108,51 +108,51 @@ discard block |
||
108 | 108 | /** |
109 | 109 | * Returns an array of invoice table columns. |
110 | 110 | */ |
111 | - public static function invoice_columns( $columns ) { |
|
111 | + public static function invoice_columns($columns) { |
|
112 | 112 | |
113 | 113 | $columns = array( |
114 | 114 | 'cb' => $columns['cb'], |
115 | - 'number' => __( 'Invoice', 'invoicing' ), |
|
116 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
117 | - 'invoice_date' => __( 'Date', 'invoicing' ), |
|
118 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
119 | - 'recurring' => __( 'Recurring', 'invoicing' ), |
|
120 | - 'status' => __( 'Status', 'invoicing' ), |
|
121 | - 'wpi_actions' => __( 'Actions', 'invoicing' ), |
|
115 | + 'number' => __('Invoice', 'invoicing'), |
|
116 | + 'customer' => __('Customer', 'invoicing'), |
|
117 | + 'invoice_date' => __('Date', 'invoicing'), |
|
118 | + 'amount' => __('Amount', 'invoicing'), |
|
119 | + 'recurring' => __('Recurring', 'invoicing'), |
|
120 | + 'status' => __('Status', 'invoicing'), |
|
121 | + 'wpi_actions' => __('Actions', 'invoicing'), |
|
122 | 122 | ); |
123 | 123 | |
124 | - return apply_filters( 'wpi_invoice_table_columns', $columns ); |
|
124 | + return apply_filters('wpi_invoice_table_columns', $columns); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | 128 | * Displays invoice table columns. |
129 | 129 | */ |
130 | - public static function display_invoice_columns( $column_name, $post_id ) { |
|
130 | + public static function display_invoice_columns($column_name, $post_id) { |
|
131 | 131 | |
132 | - $invoice = new WPInv_Invoice( $post_id ); |
|
132 | + $invoice = new WPInv_Invoice($post_id); |
|
133 | 133 | |
134 | - switch ( $column_name ) { |
|
134 | + switch ($column_name) { |
|
135 | 135 | |
136 | 136 | case 'invoice_date' : |
137 | - $date_time = esc_attr( $invoice->get_created_date() ); |
|
138 | - $date = getpaid_format_date_value( $date_time ); |
|
137 | + $date_time = esc_attr($invoice->get_created_date()); |
|
138 | + $date = getpaid_format_date_value($date_time); |
|
139 | 139 | echo "<span title='$date_time'>$date</span>"; |
140 | 140 | break; |
141 | 141 | |
142 | 142 | case 'amount' : |
143 | 143 | |
144 | 144 | $amount = $invoice->get_total(); |
145 | - $formated_amount = wpinv_price( wpinv_format_amount( $amount ), $invoice->get_currency() ); |
|
145 | + $formated_amount = wpinv_price(wpinv_format_amount($amount), $invoice->get_currency()); |
|
146 | 146 | |
147 | - if ( $invoice->is_refunded() ) { |
|
148 | - $refunded_amount = wpinv_price( wpinv_format_amount( 0 ), $invoice->get_currency() ); |
|
147 | + if ($invoice->is_refunded()) { |
|
148 | + $refunded_amount = wpinv_price(wpinv_format_amount(0), $invoice->get_currency()); |
|
149 | 149 | echo "<del>$formated_amount</del><ins>$refunded_amount</ins>"; |
150 | 150 | } else { |
151 | 151 | |
152 | 152 | $discount = $invoice->get_total_discount(); |
153 | 153 | |
154 | - if ( ! empty( $discount ) ) { |
|
155 | - $new_amount = wpinv_price( wpinv_format_amount( $amount + $discount ), $invoice->get_currency() ); |
|
154 | + if (!empty($discount)) { |
|
155 | + $new_amount = wpinv_price(wpinv_format_amount($amount + $discount), $invoice->get_currency()); |
|
156 | 156 | echo "<del>$new_amount</del><ins>$formated_amount</ins>"; |
157 | 157 | } else { |
158 | 158 | echo $formated_amount; |
@@ -163,13 +163,13 @@ discard block |
||
163 | 163 | break; |
164 | 164 | |
165 | 165 | case 'status' : |
166 | - $status = sanitize_text_field( $invoice->get_status() ); |
|
167 | - $status_label = sanitize_text_field( $invoice->get_status_nicename() ); |
|
166 | + $status = sanitize_text_field($invoice->get_status()); |
|
167 | + $status_label = sanitize_text_field($invoice->get_status_nicename()); |
|
168 | 168 | |
169 | 169 | // If it is paid, show the gateway title. |
170 | - if ( $invoice->is_paid() ) { |
|
171 | - $gateway = sanitize_text_field( $invoice->get_gateway_title() ); |
|
172 | - $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway ); |
|
170 | + if ($invoice->is_paid()) { |
|
171 | + $gateway = sanitize_text_field($invoice->get_gateway_title()); |
|
172 | + $gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), $gateway); |
|
173 | 173 | |
174 | 174 | echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>"; |
175 | 175 | } else { |
@@ -177,22 +177,22 @@ discard block |
||
177 | 177 | } |
178 | 178 | |
179 | 179 | // If it is not paid, display the overdue and view status. |
180 | - if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) { |
|
180 | + if (!$invoice->is_paid() && !$invoice->is_refunded()) { |
|
181 | 181 | |
182 | 182 | // Invoice view status. |
183 | - if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) { |
|
184 | - echo ' <i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>'; |
|
183 | + if (wpinv_is_invoice_viewed($invoice->get_id())) { |
|
184 | + echo ' <i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>'; |
|
185 | 185 | } else { |
186 | - echo ' <i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>'; |
|
186 | + echo ' <i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>'; |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | // Display the overview status. |
190 | - if ( wpinv_get_option( 'overdue_active' ) ) { |
|
190 | + if (wpinv_get_option('overdue_active')) { |
|
191 | 191 | $due_date = $invoice->get_due_date(); |
192 | - $fomatted = getpaid_format_date( $due_date ); |
|
192 | + $fomatted = getpaid_format_date($due_date); |
|
193 | 193 | |
194 | - if ( ! empty( $fomatted ) ) { |
|
195 | - $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted ); |
|
194 | + if (!empty($fomatted)) { |
|
195 | + $date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted); |
|
196 | 196 | echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>"; |
197 | 197 | } |
198 | 198 | } |
@@ -203,7 +203,7 @@ discard block |
||
203 | 203 | |
204 | 204 | case 'recurring': |
205 | 205 | |
206 | - if ( $invoice->is_recurring() ) { |
|
206 | + if ($invoice->is_recurring()) { |
|
207 | 207 | echo '<i class="fa fa-check" style="color:#43850a;"></i>'; |
208 | 208 | } else { |
209 | 209 | echo '<i class="fa fa-times" style="color:#616161;"></i>'; |
@@ -212,9 +212,9 @@ discard block |
||
212 | 212 | |
213 | 213 | case 'number' : |
214 | 214 | |
215 | - $edit_link = esc_url( get_edit_post_link( $invoice->get_id() ) ); |
|
216 | - $invoice_number = sanitize_text_field( $invoice->get_number() ); |
|
217 | - $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' ); |
|
215 | + $edit_link = esc_url(get_edit_post_link($invoice->get_id())); |
|
216 | + $invoice_number = sanitize_text_field($invoice->get_number()); |
|
217 | + $invoice_details = esc_attr__('View Invoice Details', 'invoicing'); |
|
218 | 218 | |
219 | 219 | echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>"; |
220 | 220 | |
@@ -224,13 +224,13 @@ discard block |
||
224 | 224 | |
225 | 225 | $customer_name = $invoice->get_user_full_name(); |
226 | 226 | |
227 | - if ( empty( $customer_name ) ) { |
|
227 | + if (empty($customer_name)) { |
|
228 | 228 | $customer_name = $invoice->get_email(); |
229 | 229 | } |
230 | 230 | |
231 | - if ( ! empty( $customer_name ) ) { |
|
232 | - $customer_details = esc_attr__( 'View Customer Details', 'invoicing' ); |
|
233 | - $view_link = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) ); |
|
231 | + if (!empty($customer_name)) { |
|
232 | + $customer_details = esc_attr__('View Customer Details', 'invoicing'); |
|
233 | + $view_link = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php'))); |
|
234 | 234 | echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>"; |
235 | 235 | } else { |
236 | 236 | echo '<div>—</div>'; |
@@ -240,12 +240,12 @@ discard block |
||
240 | 240 | |
241 | 241 | case 'wpi_actions' : |
242 | 242 | |
243 | - if ( $invoice->is_draft() ) { |
|
243 | + if ($invoice->is_draft()) { |
|
244 | 244 | return; |
245 | 245 | } |
246 | 246 | |
247 | - $url = esc_url( $invoice->get_view_url() ); |
|
248 | - $print = esc_attr__( 'Print invoice', 'invoicing' ); |
|
247 | + $url = esc_url($invoice->get_view_url()); |
|
248 | + $print = esc_attr__('Print invoice', 'invoicing'); |
|
249 | 249 | echo " <a href='$url' title='$print' target='_blank' style='color:#757575'><i class='fa fa-print' style='font-size: 1.4em;'></i></a>"; |
250 | 250 | |
251 | 251 | $url = esc_url( |
@@ -261,7 +261,7 @@ discard block |
||
261 | 261 | ) |
262 | 262 | ); |
263 | 263 | |
264 | - $send = esc_attr__( 'Send invoice to customer', 'invoicing' ); |
|
264 | + $send = esc_attr__('Send invoice to customer', 'invoicing'); |
|
265 | 265 | echo " <a href='$url' title='$send' style='color:#757575'><i class='fa fa-envelope' style='font-size: 1.4em;'></i></a>"; |
266 | 266 | |
267 | 267 | break; |
@@ -272,50 +272,50 @@ discard block |
||
272 | 272 | /** |
273 | 273 | * Returns an array of payment forms table columns. |
274 | 274 | */ |
275 | - public static function payment_form_columns( $columns ) { |
|
275 | + public static function payment_form_columns($columns) { |
|
276 | 276 | |
277 | 277 | $columns = array( |
278 | 278 | 'cb' => $columns['cb'], |
279 | - 'title' => __( 'Name', 'invoicing' ), |
|
280 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
281 | - 'earnings' => __( 'Revenue', 'invoicing' ), |
|
282 | - 'refunds' => __( 'Refunded', 'invoicing' ), |
|
283 | - 'items' => __( 'Items', 'invoicing' ), |
|
284 | - 'date' => __( 'Date', 'invoicing' ), |
|
279 | + 'title' => __('Name', 'invoicing'), |
|
280 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
281 | + 'earnings' => __('Revenue', 'invoicing'), |
|
282 | + 'refunds' => __('Refunded', 'invoicing'), |
|
283 | + 'items' => __('Items', 'invoicing'), |
|
284 | + 'date' => __('Date', 'invoicing'), |
|
285 | 285 | ); |
286 | 286 | |
287 | - return apply_filters( 'wpi_payment_form_table_columns', $columns ); |
|
287 | + return apply_filters('wpi_payment_form_table_columns', $columns); |
|
288 | 288 | |
289 | 289 | } |
290 | 290 | |
291 | 291 | /** |
292 | 292 | * Displays payment form table columns. |
293 | 293 | */ |
294 | - public static function display_payment_form_columns( $column_name, $post_id ) { |
|
294 | + public static function display_payment_form_columns($column_name, $post_id) { |
|
295 | 295 | |
296 | 296 | // Retrieve the payment form. |
297 | - $form = new GetPaid_Payment_Form( $post_id ); |
|
297 | + $form = new GetPaid_Payment_Form($post_id); |
|
298 | 298 | |
299 | - switch ( $column_name ) { |
|
299 | + switch ($column_name) { |
|
300 | 300 | |
301 | 301 | case 'earnings' : |
302 | - echo wpinv_price( wpinv_format_amount( $form->get_earned() ) ); |
|
302 | + echo wpinv_price(wpinv_format_amount($form->get_earned())); |
|
303 | 303 | break; |
304 | 304 | |
305 | 305 | case 'refunds' : |
306 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
306 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
307 | 307 | break; |
308 | 308 | |
309 | 309 | case 'refunds' : |
310 | - echo wpinv_price( wpinv_format_amount( $form->get_refunded() ) ); |
|
310 | + echo wpinv_price(wpinv_format_amount($form->get_refunded())); |
|
311 | 311 | break; |
312 | 312 | |
313 | 313 | case 'shortcode' : |
314 | 314 | |
315 | - if ( $form->is_default() ) { |
|
315 | + if ($form->is_default()) { |
|
316 | 316 | echo '—'; |
317 | 317 | } else { |
318 | - echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>'; |
|
318 | + echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>'; |
|
319 | 319 | } |
320 | 320 | |
321 | 321 | break; |
@@ -324,29 +324,29 @@ discard block |
||
324 | 324 | |
325 | 325 | $items = $form->get_items(); |
326 | 326 | |
327 | - if ( $form->is_default() || empty( $items ) ) { |
|
327 | + if ($form->is_default() || empty($items)) { |
|
328 | 328 | echo '—'; |
329 | 329 | return; |
330 | 330 | } |
331 | 331 | |
332 | 332 | $_items = array(); |
333 | 333 | |
334 | - foreach ( $items as $item ) { |
|
334 | + foreach ($items as $item) { |
|
335 | 335 | $url = $item->get_edit_url(); |
336 | 336 | |
337 | - if ( empty( $url ) ) { |
|
338 | - $_items[] = sanitize_text_field( $item->get_name() ); |
|
337 | + if (empty($url)) { |
|
338 | + $_items[] = sanitize_text_field($item->get_name()); |
|
339 | 339 | } else { |
340 | 340 | $_items[] = sprintf( |
341 | 341 | '<a href="%s">%s</a>', |
342 | - esc_url( $url ), |
|
343 | - sanitize_text_field( $item->get_name() ) |
|
342 | + esc_url($url), |
|
343 | + sanitize_text_field($item->get_name()) |
|
344 | 344 | ); |
345 | 345 | } |
346 | 346 | |
347 | 347 | } |
348 | 348 | |
349 | - echo implode( '<br>', $_items ); |
|
349 | + echo implode('<br>', $_items); |
|
350 | 350 | |
351 | 351 | break; |
352 | 352 | |
@@ -357,10 +357,10 @@ discard block |
||
357 | 357 | /** |
358 | 358 | * Filters post states. |
359 | 359 | */ |
360 | - public static function filter_payment_form_state( $post_states, $post ) { |
|
360 | + public static function filter_payment_form_state($post_states, $post) { |
|
361 | 361 | |
362 | - if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) { |
|
363 | - $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' ); |
|
362 | + if ('wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID) { |
|
363 | + $post_states['default_form'] = __('Default Payment Form', 'invoicing'); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | return $post_states; |
@@ -370,35 +370,35 @@ discard block |
||
370 | 370 | /** |
371 | 371 | * Returns an array of coupon table columns. |
372 | 372 | */ |
373 | - public static function discount_columns( $columns ) { |
|
373 | + public static function discount_columns($columns) { |
|
374 | 374 | |
375 | 375 | $columns = array( |
376 | 376 | 'cb' => $columns['cb'], |
377 | - 'title' => __( 'Name', 'invoicing' ), |
|
378 | - 'code' => __( 'Code', 'invoicing' ), |
|
379 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
380 | - 'usage' => __( 'Usage / Limit', 'invoicing' ), |
|
381 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
382 | - 'expiry_date' => __( 'Expiry Date', 'invoicing' ), |
|
377 | + 'title' => __('Name', 'invoicing'), |
|
378 | + 'code' => __('Code', 'invoicing'), |
|
379 | + 'amount' => __('Amount', 'invoicing'), |
|
380 | + 'usage' => __('Usage / Limit', 'invoicing'), |
|
381 | + 'start_date' => __('Start Date', 'invoicing'), |
|
382 | + 'expiry_date' => __('Expiry Date', 'invoicing'), |
|
383 | 383 | ); |
384 | 384 | |
385 | - return apply_filters( 'wpi_discount_table_columns', $columns ); |
|
385 | + return apply_filters('wpi_discount_table_columns', $columns); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
389 | 389 | * Filters post states. |
390 | 390 | */ |
391 | - public static function filter_discount_state( $post_states, $post ) { |
|
391 | + public static function filter_discount_state($post_states, $post) { |
|
392 | 392 | |
393 | - if ( 'wpi_discount' == $post->post_type ) { |
|
393 | + if ('wpi_discount' == $post->post_type) { |
|
394 | 394 | |
395 | - $discount = new WPInv_Discount( $post ); |
|
395 | + $discount = new WPInv_Discount($post); |
|
396 | 396 | |
397 | 397 | $status = $discount->is_expired() ? 'expired' : $discount->get_status(); |
398 | 398 | |
399 | - if ( $status != 'publish' ) { |
|
399 | + if ($status != 'publish') { |
|
400 | 400 | return array( |
401 | - 'discount_status' => wpinv_discount_status( $status ), |
|
401 | + 'discount_status' => wpinv_discount_status($status), |
|
402 | 402 | ); |
403 | 403 | } |
404 | 404 | |
@@ -413,34 +413,34 @@ discard block |
||
413 | 413 | /** |
414 | 414 | * Returns an array of items table columns. |
415 | 415 | */ |
416 | - public static function item_columns( $columns ) { |
|
416 | + public static function item_columns($columns) { |
|
417 | 417 | global $wpinv_euvat; |
418 | 418 | |
419 | 419 | $columns = array( |
420 | 420 | 'cb' => $columns['cb'], |
421 | - 'title' => __( 'Name', 'invoicing' ), |
|
422 | - 'price' => __( 'Price', 'invoicing' ), |
|
423 | - 'vat_rule' => __( 'VAT rule', 'invoicing' ), |
|
424 | - 'vat_class' => __( 'VAT class', 'invoicing' ), |
|
425 | - 'type' => __( 'Type', 'invoicing' ), |
|
426 | - 'shortcode' => __( 'Shortcode', 'invoicing' ), |
|
421 | + 'title' => __('Name', 'invoicing'), |
|
422 | + 'price' => __('Price', 'invoicing'), |
|
423 | + 'vat_rule' => __('VAT rule', 'invoicing'), |
|
424 | + 'vat_class' => __('VAT class', 'invoicing'), |
|
425 | + 'type' => __('Type', 'invoicing'), |
|
426 | + 'shortcode' => __('Shortcode', 'invoicing'), |
|
427 | 427 | ); |
428 | 428 | |
429 | - if ( ! $wpinv_euvat->allow_vat_rules() ) { |
|
430 | - unset( $columns['vat_rule'] ); |
|
429 | + if (!$wpinv_euvat->allow_vat_rules()) { |
|
430 | + unset($columns['vat_rule']); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( ! $wpinv_euvat->allow_vat_classes() ) { |
|
434 | - unset( $columns['vat_class'] ); |
|
433 | + if (!$wpinv_euvat->allow_vat_classes()) { |
|
434 | + unset($columns['vat_class']); |
|
435 | 435 | } |
436 | 436 | |
437 | - return apply_filters( 'wpi_item_table_columns', $columns ); |
|
437 | + return apply_filters('wpi_item_table_columns', $columns); |
|
438 | 438 | } |
439 | 439 | |
440 | 440 | /** |
441 | 441 | * Returns an array of sortable items table columns. |
442 | 442 | */ |
443 | - public static function sortable_item_columns( $columns ) { |
|
443 | + public static function sortable_item_columns($columns) { |
|
444 | 444 | |
445 | 445 | return array_merge( |
446 | 446 | $columns, |
@@ -457,50 +457,50 @@ discard block |
||
457 | 457 | /** |
458 | 458 | * Displays items table columns. |
459 | 459 | */ |
460 | - public static function display_item_columns( $column_name, $post_id ) { |
|
460 | + public static function display_item_columns($column_name, $post_id) { |
|
461 | 461 | global $wpinv_euvat; |
462 | 462 | |
463 | - $item = new WPInv_Item( $post_id ); |
|
463 | + $item = new WPInv_Item($post_id); |
|
464 | 464 | |
465 | - switch ( $column_name ) { |
|
465 | + switch ($column_name) { |
|
466 | 466 | |
467 | 467 | case 'price' : |
468 | 468 | |
469 | - if ( ! $item->is_recurring() ) { |
|
469 | + if (!$item->is_recurring()) { |
|
470 | 470 | echo $item->get_the_price(); |
471 | 471 | break; |
472 | 472 | } |
473 | 473 | |
474 | 474 | $price = wp_sprintf( |
475 | - __( '%s / %s', 'invoicing' ), |
|
475 | + __('%s / %s', 'invoicing'), |
|
476 | 476 | $item->get_the_price(), |
477 | - getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' ) |
|
477 | + getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '') |
|
478 | 478 | ); |
479 | 479 | |
480 | - if ( $item->get_the_price() == $item->get_the_initial_price() ) { |
|
480 | + if ($item->get_the_price() == $item->get_the_initial_price()) { |
|
481 | 481 | echo $price; |
482 | 482 | break; |
483 | 483 | } |
484 | 484 | |
485 | 485 | echo $item->get_the_initial_price(); |
486 | 486 | |
487 | - echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price ) .'</span>'; |
|
487 | + echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>'; |
|
488 | 488 | break; |
489 | 489 | |
490 | 490 | case 'vat_rule' : |
491 | - echo $wpinv_euvat->item_rule_label( $item->get_id() ); |
|
491 | + echo $wpinv_euvat->item_rule_label($item->get_id()); |
|
492 | 492 | break; |
493 | 493 | |
494 | 494 | case 'vat_class' : |
495 | - echo $wpinv_euvat->item_class_label( $item->get_id() ); |
|
495 | + echo $wpinv_euvat->item_class_label($item->get_id()); |
|
496 | 496 | break; |
497 | 497 | |
498 | 498 | case 'shortcode' : |
499 | - echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
499 | + echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>'; |
|
500 | 500 | break; |
501 | 501 | |
502 | 502 | case 'type' : |
503 | - echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
503 | + echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>'; |
|
504 | 504 | break; |
505 | 505 | |
506 | 506 | } |
@@ -510,22 +510,22 @@ discard block |
||
510 | 510 | /** |
511 | 511 | * Lets users filter items using taxes. |
512 | 512 | */ |
513 | - public static function add_item_filters( $post_type ) { |
|
513 | + public static function add_item_filters($post_type) { |
|
514 | 514 | $wpinv_euvat = getpaid_tax(); |
515 | 515 | |
516 | 516 | // Abort if we're not dealing with items. |
517 | - if ( $post_type != 'wpi_item' ) { |
|
517 | + if ($post_type != 'wpi_item') { |
|
518 | 518 | return; |
519 | 519 | } |
520 | 520 | |
521 | 521 | // Filter by vat rules. |
522 | - if ( $wpinv_euvat->allow_vat_rules() ) { |
|
522 | + if ($wpinv_euvat->allow_vat_rules()) { |
|
523 | 523 | |
524 | 524 | // Sanitize selected vat rule. |
525 | 525 | $vat_rule = ''; |
526 | 526 | $vat_rules = $wpinv_euvat->get_rules(); |
527 | - if ( isset( $_GET['vat_rule'] ) ) { |
|
528 | - $vat_rule = $_GET['vat_rule']; |
|
527 | + if (isset($_GET['vat_rule'])) { |
|
528 | + $vat_rule = $_GET['vat_rule']; |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | // Filter by VAT rule. |
@@ -533,13 +533,13 @@ discard block |
||
533 | 533 | array( |
534 | 534 | 'options' => array_merge( |
535 | 535 | array( |
536 | - '' => __( 'All VAT rules', 'invoicing' ) |
|
536 | + '' => __('All VAT rules', 'invoicing') |
|
537 | 537 | ), |
538 | 538 | $vat_rules |
539 | 539 | ), |
540 | 540 | 'name' => 'vat_rule', |
541 | 541 | 'id' => 'vat_rule', |
542 | - 'selected' => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '', |
|
542 | + 'selected' => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '', |
|
543 | 543 | 'show_option_all' => false, |
544 | 544 | 'show_option_none' => false, |
545 | 545 | 'class' => 'gdmbx2-text-medium', |
@@ -550,26 +550,26 @@ discard block |
||
550 | 550 | } |
551 | 551 | |
552 | 552 | // Filter by vat class. |
553 | - if ( $wpinv_euvat->allow_vat_classes() ) { |
|
553 | + if ($wpinv_euvat->allow_vat_classes()) { |
|
554 | 554 | |
555 | 555 | // Sanitize selected vat rule. |
556 | 556 | $vat_class = ''; |
557 | 557 | $vat_classes = $wpinv_euvat->get_all_classes(); |
558 | - if ( isset( $_GET['vat_class'] ) ) { |
|
559 | - $vat_class = $_GET['vat_class']; |
|
558 | + if (isset($_GET['vat_class'])) { |
|
559 | + $vat_class = $_GET['vat_class']; |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | echo wpinv_html_select( |
563 | 563 | array( |
564 | 564 | 'options' => array_merge( |
565 | 565 | array( |
566 | - '' => __( 'All VAT classes', 'invoicing' ) |
|
566 | + '' => __('All VAT classes', 'invoicing') |
|
567 | 567 | ), |
568 | 568 | $vat_classes |
569 | 569 | ), |
570 | 570 | 'name' => 'vat_class', |
571 | 571 | 'id' => 'vat_class', |
572 | - 'selected' => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '', |
|
572 | + 'selected' => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '', |
|
573 | 573 | 'show_option_all' => false, |
574 | 574 | 'show_option_none' => false, |
575 | 575 | 'class' => 'gdmbx2-text-medium', |
@@ -579,22 +579,22 @@ discard block |
||
579 | 579 | } |
580 | 580 | |
581 | 581 | // Filter by item type. |
582 | - $type = ''; |
|
583 | - if ( isset( $_GET['type'] ) ) { |
|
584 | - $type = $_GET['type']; |
|
582 | + $type = ''; |
|
583 | + if (isset($_GET['type'])) { |
|
584 | + $type = $_GET['type']; |
|
585 | 585 | } |
586 | 586 | |
587 | 587 | echo wpinv_html_select( |
588 | 588 | array( |
589 | 589 | 'options' => array_merge( |
590 | 590 | array( |
591 | - '' => __( 'All item types', 'invoicing' ) |
|
591 | + '' => __('All item types', 'invoicing') |
|
592 | 592 | ), |
593 | 593 | wpinv_get_item_types() |
594 | 594 | ), |
595 | 595 | 'name' => 'type', |
596 | 596 | 'id' => 'type', |
597 | - 'selected' => in_array( $type, wpinv_item_types() ) ? $type : '', |
|
597 | + 'selected' => in_array($type, wpinv_item_types()) ? $type : '', |
|
598 | 598 | 'show_option_all' => false, |
599 | 599 | 'show_option_none' => false, |
600 | 600 | 'class' => 'gdmbx2-text-medium', |
@@ -606,45 +606,45 @@ discard block |
||
606 | 606 | /** |
607 | 607 | * Filters the item query. |
608 | 608 | */ |
609 | - public static function filter_item_query( $query ) { |
|
609 | + public static function filter_item_query($query) { |
|
610 | 610 | |
611 | 611 | // modify the query only if it admin and main query. |
612 | - if ( ! ( is_admin() && $query->is_main_query() ) ){ |
|
612 | + if (!(is_admin() && $query->is_main_query())) { |
|
613 | 613 | return $query; |
614 | 614 | } |
615 | 615 | |
616 | 616 | // we want to modify the query for our items. |
617 | - if ( 'wpi_item' != $query->query['post_type'] ){ |
|
617 | + if ('wpi_item' != $query->query['post_type']) { |
|
618 | 618 | return $query; |
619 | 619 | } |
620 | 620 | |
621 | - if ( empty( $query->query_vars['meta_query'] ) ) { |
|
621 | + if (empty($query->query_vars['meta_query'])) { |
|
622 | 622 | $query->query_vars['meta_query'] = array(); |
623 | 623 | } |
624 | 624 | |
625 | 625 | // Filter vat rule type |
626 | - if ( ! empty( $_GET['vat_rule'] ) ) { |
|
626 | + if (!empty($_GET['vat_rule'])) { |
|
627 | 627 | $query->query_vars['meta_query'][] = array( |
628 | 628 | 'key' => '_wpinv_vat_rule', |
629 | - 'value' => sanitize_text_field( $_GET['vat_rule'] ), |
|
629 | + 'value' => sanitize_text_field($_GET['vat_rule']), |
|
630 | 630 | 'compare' => '=' |
631 | 631 | ); |
632 | 632 | } |
633 | 633 | |
634 | 634 | // Filter vat class |
635 | - if ( ! empty( $_GET['vat_class'] ) ) { |
|
635 | + if (!empty($_GET['vat_class'])) { |
|
636 | 636 | $query->query_vars['meta_query'][] = array( |
637 | 637 | 'key' => '_wpinv_vat_class', |
638 | - 'value' => sanitize_text_field( $_GET['vat_class'] ), |
|
638 | + 'value' => sanitize_text_field($_GET['vat_class']), |
|
639 | 639 | 'compare' => '=' |
640 | 640 | ); |
641 | 641 | } |
642 | 642 | |
643 | 643 | // Filter item type |
644 | - if ( ! empty( $_GET['type'] ) ) { |
|
644 | + if (!empty($_GET['type'])) { |
|
645 | 645 | $query->query_vars['meta_query'][] = array( |
646 | 646 | 'key' => '_wpinv_type', |
647 | - 'value' => sanitize_text_field( $_GET['type'] ), |
|
647 | + 'value' => sanitize_text_field($_GET['type']), |
|
648 | 648 | 'compare' => '=' |
649 | 649 | ); |
650 | 650 | } |
@@ -654,15 +654,15 @@ discard block |
||
654 | 654 | /** |
655 | 655 | * Reorders items. |
656 | 656 | */ |
657 | - public static function reorder_items( $vars ) { |
|
657 | + public static function reorder_items($vars) { |
|
658 | 658 | global $typenow; |
659 | 659 | |
660 | - if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) { |
|
660 | + if ('wpi_item' !== $typenow || empty($vars['orderby'])) { |
|
661 | 661 | return $vars; |
662 | 662 | } |
663 | 663 | |
664 | 664 | // By item type. |
665 | - if ( 'type' == $vars['orderby'] ) { |
|
665 | + if ('type' == $vars['orderby']) { |
|
666 | 666 | return array_merge( |
667 | 667 | $vars, |
668 | 668 | array( |
@@ -673,7 +673,7 @@ discard block |
||
673 | 673 | } |
674 | 674 | |
675 | 675 | // By vat class. |
676 | - if ( 'vat_class' == $vars['orderby'] ) { |
|
676 | + if ('vat_class' == $vars['orderby']) { |
|
677 | 677 | return array_merge( |
678 | 678 | $vars, |
679 | 679 | array( |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | } |
685 | 685 | |
686 | 686 | // By vat rule. |
687 | - if ( 'vat_rule' == $vars['orderby'] ) { |
|
687 | + if ('vat_rule' == $vars['orderby']) { |
|
688 | 688 | return array_merge( |
689 | 689 | $vars, |
690 | 690 | array( |
@@ -695,7 +695,7 @@ discard block |
||
695 | 695 | } |
696 | 696 | |
697 | 697 | // By price. |
698 | - if ( 'price' == $vars['orderby'] ) { |
|
698 | + if ('price' == $vars['orderby']) { |
|
699 | 699 | return array_merge( |
700 | 700 | $vars, |
701 | 701 | array( |
@@ -712,27 +712,27 @@ discard block |
||
712 | 712 | /** |
713 | 713 | * Fired when deleting a post. |
714 | 714 | */ |
715 | - public static function delete_post( $post_id ) { |
|
715 | + public static function delete_post($post_id) { |
|
716 | 716 | |
717 | - switch ( get_post_type( $post_id ) ) { |
|
717 | + switch (get_post_type($post_id)) { |
|
718 | 718 | |
719 | 719 | case 'wpi_item' : |
720 | - do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) ); |
|
720 | + do_action("getpaid_before_delete_item", new WPInv_Item($post_id)); |
|
721 | 721 | break; |
722 | 722 | |
723 | 723 | case 'wpi_payment_form' : |
724 | - do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) ); |
|
724 | + do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id)); |
|
725 | 725 | break; |
726 | 726 | |
727 | 727 | case 'wpi_discount' : |
728 | - do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) ); |
|
728 | + do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id)); |
|
729 | 729 | break; |
730 | 730 | |
731 | 731 | case 'wpi_invoice' : |
732 | - $invoice = new WPInv_Invoice( $post_id ); |
|
733 | - do_action( "getpaid_before_delete_invoice", $invoice ); |
|
734 | - $invoice->get_data_store()->delete_items( $invoice ); |
|
735 | - $invoice->get_data_store()->delete_special_fields( $invoice ); |
|
732 | + $invoice = new WPInv_Invoice($post_id); |
|
733 | + do_action("getpaid_before_delete_invoice", $invoice); |
|
734 | + $invoice->get_data_store()->delete_items($invoice); |
|
735 | + $invoice->get_data_store()->delete_special_fields($invoice); |
|
736 | 736 | break; |
737 | 737 | } |
738 | 738 | } |
@@ -13,282 +13,282 @@ |
||
13 | 13 | class GetPaid_Subscription_Notification_Emails { |
14 | 14 | |
15 | 15 | /** |
16 | - * The array of subscription email actions. |
|
17 | - * |
|
18 | - * @param array |
|
19 | - */ |
|
20 | - public $subscription_actions; |
|
16 | + * The array of subscription email actions. |
|
17 | + * |
|
18 | + * @param array |
|
19 | + */ |
|
20 | + public $subscription_actions; |
|
21 | 21 | |
22 | 22 | /** |
23 | - * Class constructor |
|
23 | + * Class constructor |
|
24 | 24 | * |
25 | - */ |
|
26 | - public function __construct() { |
|
27 | - |
|
28 | - $this->subscription_actions = apply_filters( |
|
29 | - 'getpaid_notification_email_subscription_triggers', |
|
30 | - array( |
|
31 | - 'getpaid_subscription_trialling' => 'subscription_trial', |
|
32 | - 'getpaid_subscription_cancelled' => 'subscription_cancelled', |
|
33 | - 'getpaid_subscription_expired' => 'subscription_expired', |
|
34 | - 'getpaid_subscription_completed' => 'subscription_complete', |
|
35 | - 'getpaid_daily_maintenance' => 'renewal_reminder', |
|
36 | - ) |
|
37 | - ); |
|
38 | - |
|
39 | - $this->init_hooks(); |
|
25 | + */ |
|
26 | + public function __construct() { |
|
27 | + |
|
28 | + $this->subscription_actions = apply_filters( |
|
29 | + 'getpaid_notification_email_subscription_triggers', |
|
30 | + array( |
|
31 | + 'getpaid_subscription_trialling' => 'subscription_trial', |
|
32 | + 'getpaid_subscription_cancelled' => 'subscription_cancelled', |
|
33 | + 'getpaid_subscription_expired' => 'subscription_expired', |
|
34 | + 'getpaid_subscription_completed' => 'subscription_complete', |
|
35 | + 'getpaid_daily_maintenance' => 'renewal_reminder', |
|
36 | + ) |
|
37 | + ); |
|
38 | + |
|
39 | + $this->init_hooks(); |
|
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | /** |
44 | - * Registers email hooks. |
|
45 | - */ |
|
46 | - public function init_hooks() { |
|
47 | - |
|
48 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | - foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
50 | - |
|
51 | - $email = new GetPaid_Notification_Email( $email_type ); |
|
52 | - |
|
53 | - if ( ! $email->is_active() ) { |
|
54 | - continue; |
|
55 | - } |
|
56 | - |
|
57 | - if ( method_exists( $this, $email_type ) ) { |
|
58 | - add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
59 | - continue; |
|
60 | - } |
|
61 | - |
|
62 | - do_action( 'getpaid_subscription_notification_email_register_hook', $email ); |
|
63 | - |
|
64 | - } |
|
65 | - |
|
66 | - } |
|
67 | - |
|
68 | - /** |
|
69 | - * Filters subscription merge tags. |
|
70 | - * |
|
71 | - * @param array $merge_tags |
|
72 | - * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
73 | - */ |
|
74 | - public function subscription_merge_tags( $merge_tags, $object ) { |
|
75 | - |
|
76 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
77 | - $merge_tags = array_merge( |
|
78 | - $merge_tags, |
|
79 | - $this->get_subscription_merge_tags( $object ) |
|
80 | - ); |
|
81 | - } |
|
82 | - |
|
83 | - return $merge_tags; |
|
84 | - |
|
85 | - } |
|
86 | - |
|
87 | - /** |
|
88 | - * Generates subscription merge tags. |
|
89 | - * |
|
90 | - * @param WPInv_Subscription $subscription |
|
91 | - * @return array |
|
92 | - */ |
|
93 | - public function get_subscription_merge_tags( $subscription ) { |
|
94 | - |
|
95 | - // Abort if it does not exist. |
|
96 | - if ( ! $subscription->get_id() ) { |
|
97 | - return array(); |
|
98 | - } |
|
99 | - |
|
100 | - $invoice = $subscription->get_parent_invoice(); |
|
101 | - return array( |
|
102 | - '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | - '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | - '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | - '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | - '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | - '{subscription_recurring_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
108 | - '{subscription_initial_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $invoice->get_currency() ), |
|
109 | - '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
110 | - '{subscription_bill_times}' => $subscription->get_bill_times(), |
|
111 | - '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
112 | - ); |
|
113 | - |
|
114 | - } |
|
115 | - |
|
116 | - /** |
|
117 | - * Checks if we should send a notification for a subscription. |
|
118 | - * |
|
119 | - * @param WPInv_Invoice $invoice |
|
120 | - * @return bool |
|
121 | - */ |
|
122 | - public function should_send_notification( $invoice ) { |
|
123 | - return 0 != $invoice->get_id(); |
|
124 | - } |
|
125 | - |
|
126 | - /** |
|
127 | - * Returns notification recipients. |
|
128 | - * |
|
129 | - * @param WPInv_Invoice $invoice |
|
130 | - * @return array |
|
131 | - */ |
|
132 | - public function get_recipients( $invoice ) { |
|
133 | - $recipients = array( $invoice->get_email() ); |
|
134 | - |
|
135 | - $cc = $invoice->get_email_cc(); |
|
136 | - |
|
137 | - if ( ! empty( $cc ) ) { |
|
138 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
140 | - } |
|
141 | - |
|
142 | - return $recipients; |
|
143 | - } |
|
144 | - |
|
145 | - /** |
|
146 | - * Helper function to send an email. |
|
147 | - * |
|
148 | - * @param WPInv_Subscription $subscription |
|
149 | - * @param GetPaid_Notification_Email $email |
|
150 | - * @param string $type |
|
151 | - * @param array $extra_args Extra template args. |
|
152 | - */ |
|
153 | - public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
154 | - |
|
155 | - // Abort in case the parent invoice does not exist. |
|
156 | - $invoice = $subscription->get_parent_invoice(); |
|
157 | - if ( ! $this->should_send_notification( $invoice ) ) { |
|
158 | - return; |
|
159 | - } |
|
160 | - |
|
161 | - do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
162 | - |
|
163 | - $recipients = $this->get_recipients( $invoice ); |
|
164 | - $mailer = new GetPaid_Notification_Email_Sender(); |
|
165 | - $merge_tags = $email->get_merge_tags(); |
|
166 | - $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | - $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
168 | - $attachments = $email->get_attachments(); |
|
169 | - |
|
170 | - $result = $mailer->send( |
|
171 | - apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
172 | - $subject, |
|
173 | - $content, |
|
174 | - $attachments |
|
175 | - ); |
|
176 | - |
|
177 | - // Maybe send a copy to the admin. |
|
178 | - if ( $email->include_admin_bcc() ) { |
|
179 | - $mailer->send( |
|
180 | - wpinv_get_admin_email(), |
|
181 | - $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
182 | - $content, |
|
183 | - $attachments |
|
184 | - ); |
|
185 | - } |
|
186 | - |
|
187 | - if ( ! $result ) { |
|
188 | - $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
189 | - } |
|
190 | - |
|
191 | - do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
192 | - |
|
193 | - } |
|
44 | + * Registers email hooks. |
|
45 | + */ |
|
46 | + public function init_hooks() { |
|
47 | + |
|
48 | + add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | + foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
50 | + |
|
51 | + $email = new GetPaid_Notification_Email( $email_type ); |
|
52 | + |
|
53 | + if ( ! $email->is_active() ) { |
|
54 | + continue; |
|
55 | + } |
|
56 | + |
|
57 | + if ( method_exists( $this, $email_type ) ) { |
|
58 | + add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
59 | + continue; |
|
60 | + } |
|
61 | + |
|
62 | + do_action( 'getpaid_subscription_notification_email_register_hook', $email ); |
|
63 | + |
|
64 | + } |
|
65 | + |
|
66 | + } |
|
194 | 67 | |
195 | 68 | /** |
196 | - * Sends a new trial notification. |
|
197 | - * |
|
198 | - * @param WPInv_Subscription $subscription |
|
199 | - */ |
|
200 | - public function subscription_trial( $subscription ) { |
|
69 | + * Filters subscription merge tags. |
|
70 | + * |
|
71 | + * @param array $merge_tags |
|
72 | + * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
|
73 | + */ |
|
74 | + public function subscription_merge_tags( $merge_tags, $object ) { |
|
201 | 75 | |
202 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
76 | + if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
77 | + $merge_tags = array_merge( |
|
78 | + $merge_tags, |
|
79 | + $this->get_subscription_merge_tags( $object ) |
|
80 | + ); |
|
81 | + } |
|
204 | 82 | |
205 | - } |
|
83 | + return $merge_tags; |
|
206 | 84 | |
207 | - /** |
|
208 | - * Sends a cancelled subscription notification. |
|
209 | - * |
|
210 | - * @param WPInv_Subscription $subscription |
|
211 | - */ |
|
212 | - public function subscription_cancelled( $subscription ) { |
|
85 | + } |
|
213 | 86 | |
214 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
87 | + /** |
|
88 | + * Generates subscription merge tags. |
|
89 | + * |
|
90 | + * @param WPInv_Subscription $subscription |
|
91 | + * @return array |
|
92 | + */ |
|
93 | + public function get_subscription_merge_tags( $subscription ) { |
|
94 | + |
|
95 | + // Abort if it does not exist. |
|
96 | + if ( ! $subscription->get_id() ) { |
|
97 | + return array(); |
|
98 | + } |
|
99 | + |
|
100 | + $invoice = $subscription->get_parent_invoice(); |
|
101 | + return array( |
|
102 | + '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | + '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | + '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | + '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | + '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | + '{subscription_recurring_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
108 | + '{subscription_initial_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $invoice->get_currency() ), |
|
109 | + '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
110 | + '{subscription_bill_times}' => $subscription->get_bill_times(), |
|
111 | + '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
112 | + ); |
|
216 | 113 | |
217 | - } |
|
114 | + } |
|
218 | 115 | |
219 | - /** |
|
220 | - * Sends a subscription expired notification. |
|
221 | - * |
|
222 | - * @param WPInv_Subscription $subscription |
|
223 | - */ |
|
224 | - public function subscription_expired( $subscription ) { |
|
116 | + /** |
|
117 | + * Checks if we should send a notification for a subscription. |
|
118 | + * |
|
119 | + * @param WPInv_Invoice $invoice |
|
120 | + * @return bool |
|
121 | + */ |
|
122 | + public function should_send_notification( $invoice ) { |
|
123 | + return 0 != $invoice->get_id(); |
|
124 | + } |
|
225 | 125 | |
226 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
126 | + /** |
|
127 | + * Returns notification recipients. |
|
128 | + * |
|
129 | + * @param WPInv_Invoice $invoice |
|
130 | + * @return array |
|
131 | + */ |
|
132 | + public function get_recipients( $invoice ) { |
|
133 | + $recipients = array( $invoice->get_email() ); |
|
228 | 134 | |
229 | - } |
|
135 | + $cc = $invoice->get_email_cc(); |
|
230 | 136 | |
231 | - /** |
|
232 | - * Sends a completed subscription notification. |
|
233 | - * |
|
234 | - * @param WPInv_Subscription $subscription |
|
235 | - */ |
|
236 | - public function subscription_complete( $subscription ) { |
|
137 | + if ( ! empty( $cc ) ) { |
|
138 | + $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | + $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
140 | + } |
|
237 | 141 | |
238 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
142 | + return $recipients; |
|
143 | + } |
|
240 | 144 | |
241 | - } |
|
145 | + /** |
|
146 | + * Helper function to send an email. |
|
147 | + * |
|
148 | + * @param WPInv_Subscription $subscription |
|
149 | + * @param GetPaid_Notification_Email $email |
|
150 | + * @param string $type |
|
151 | + * @param array $extra_args Extra template args. |
|
152 | + */ |
|
153 | + public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
154 | + |
|
155 | + // Abort in case the parent invoice does not exist. |
|
156 | + $invoice = $subscription->get_parent_invoice(); |
|
157 | + if ( ! $this->should_send_notification( $invoice ) ) { |
|
158 | + return; |
|
159 | + } |
|
160 | + |
|
161 | + do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
162 | + |
|
163 | + $recipients = $this->get_recipients( $invoice ); |
|
164 | + $mailer = new GetPaid_Notification_Email_Sender(); |
|
165 | + $merge_tags = $email->get_merge_tags(); |
|
166 | + $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | + $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
168 | + $attachments = $email->get_attachments(); |
|
169 | + |
|
170 | + $result = $mailer->send( |
|
171 | + apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
172 | + $subject, |
|
173 | + $content, |
|
174 | + $attachments |
|
175 | + ); |
|
176 | + |
|
177 | + // Maybe send a copy to the admin. |
|
178 | + if ( $email->include_admin_bcc() ) { |
|
179 | + $mailer->send( |
|
180 | + wpinv_get_admin_email(), |
|
181 | + $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
182 | + $content, |
|
183 | + $attachments |
|
184 | + ); |
|
185 | + } |
|
186 | + |
|
187 | + if ( ! $result ) { |
|
188 | + $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
189 | + } |
|
190 | + |
|
191 | + do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
242 | 192 | |
243 | - /** |
|
244 | - * Sends a subscription renewal reminder notification. |
|
245 | - * |
|
246 | - */ |
|
247 | - public function renewal_reminder() { |
|
193 | + } |
|
248 | 194 | |
249 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
195 | + /** |
|
196 | + * Sends a new trial notification. |
|
197 | + * |
|
198 | + * @param WPInv_Subscription $subscription |
|
199 | + */ |
|
200 | + public function subscription_trial( $subscription ) { |
|
250 | 201 | |
251 | - // Fetch reminder days. |
|
252 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
202 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
253 | 204 | |
254 | - // Abort if non is set. |
|
255 | - if ( empty( $reminder_days ) ) { |
|
256 | - return; |
|
257 | - } |
|
205 | + } |
|
258 | 206 | |
259 | - // Fetch matching subscriptions. |
|
207 | + /** |
|
208 | + * Sends a cancelled subscription notification. |
|
209 | + * |
|
210 | + * @param WPInv_Subscription $subscription |
|
211 | + */ |
|
212 | + public function subscription_cancelled( $subscription ) { |
|
213 | + |
|
214 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
216 | + |
|
217 | + } |
|
218 | + |
|
219 | + /** |
|
220 | + * Sends a subscription expired notification. |
|
221 | + * |
|
222 | + * @param WPInv_Subscription $subscription |
|
223 | + */ |
|
224 | + public function subscription_expired( $subscription ) { |
|
225 | + |
|
226 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
228 | + |
|
229 | + } |
|
230 | + |
|
231 | + /** |
|
232 | + * Sends a completed subscription notification. |
|
233 | + * |
|
234 | + * @param WPInv_Subscription $subscription |
|
235 | + */ |
|
236 | + public function subscription_complete( $subscription ) { |
|
237 | + |
|
238 | + $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
240 | + |
|
241 | + } |
|
242 | + |
|
243 | + /** |
|
244 | + * Sends a subscription renewal reminder notification. |
|
245 | + * |
|
246 | + */ |
|
247 | + public function renewal_reminder() { |
|
248 | + |
|
249 | + $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
250 | + |
|
251 | + // Fetch reminder days. |
|
252 | + $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
253 | + |
|
254 | + // Abort if non is set. |
|
255 | + if ( empty( $reminder_days ) ) { |
|
256 | + return; |
|
257 | + } |
|
258 | + |
|
259 | + // Fetch matching subscriptions. |
|
260 | 260 | $args = array( |
261 | 261 | 'number' => -1, |
262 | - 'count_total' => false, |
|
263 | - 'status' => 'trialling active', |
|
262 | + 'count_total' => false, |
|
263 | + 'status' => 'trialling active', |
|
264 | 264 | 'date_expires_query' => array( |
265 | - 'relation' => 'OR' |
|
265 | + 'relation' => 'OR' |
|
266 | 266 | ), |
267 | - ); |
|
267 | + ); |
|
268 | 268 | |
269 | - foreach ( $reminder_days as $days ) { |
|
270 | - $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
269 | + foreach ( $reminder_days as $days ) { |
|
270 | + $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
271 | 271 | |
272 | - $args['date_expires_query'][] = array( |
|
273 | - 'year' => $date['year'], |
|
274 | - 'month' => $date['month'], |
|
275 | - 'day' => $date['day'], |
|
276 | - ); |
|
272 | + $args['date_expires_query'][] = array( |
|
273 | + 'year' => $date['year'], |
|
274 | + 'month' => $date['month'], |
|
275 | + 'day' => $date['day'], |
|
276 | + ); |
|
277 | 277 | |
278 | - } |
|
278 | + } |
|
279 | 279 | |
280 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
280 | + $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
281 | 281 | |
282 | 282 | foreach ( $subscriptions as $subscription ) { |
283 | 283 | |
284 | - // Skip packages. |
|
285 | - if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
286 | - $email->object = $subscription; |
|
287 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
288 | - } |
|
284 | + // Skip packages. |
|
285 | + if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
286 | + $email->object = $subscription; |
|
287 | + $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
288 | + } |
|
289 | 289 | |
290 | - } |
|
290 | + } |
|
291 | 291 | |
292 | - } |
|
292 | + } |
|
293 | 293 | |
294 | 294 | } |
@@ -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 subscription notificaiton emails. |
@@ -45,21 +45,21 @@ discard block |
||
45 | 45 | */ |
46 | 46 | public function init_hooks() { |
47 | 47 | |
48 | - add_filter( 'getpaid_get_email_merge_tags', array( $this, 'subscription_merge_tags' ), 10, 2 ); |
|
49 | - foreach ( $this->subscription_actions as $hook => $email_type ) { |
|
48 | + add_filter('getpaid_get_email_merge_tags', array($this, 'subscription_merge_tags'), 10, 2); |
|
49 | + foreach ($this->subscription_actions as $hook => $email_type) { |
|
50 | 50 | |
51 | - $email = new GetPaid_Notification_Email( $email_type ); |
|
51 | + $email = new GetPaid_Notification_Email($email_type); |
|
52 | 52 | |
53 | - if ( ! $email->is_active() ) { |
|
53 | + if (!$email->is_active()) { |
|
54 | 54 | continue; |
55 | 55 | } |
56 | 56 | |
57 | - if ( method_exists( $this, $email_type ) ) { |
|
58 | - add_action( $hook, array( $this, $email_type ), 100, 2 ); |
|
57 | + if (method_exists($this, $email_type)) { |
|
58 | + add_action($hook, array($this, $email_type), 100, 2); |
|
59 | 59 | continue; |
60 | 60 | } |
61 | 61 | |
62 | - do_action( 'getpaid_subscription_notification_email_register_hook', $email ); |
|
62 | + do_action('getpaid_subscription_notification_email_register_hook', $email); |
|
63 | 63 | |
64 | 64 | } |
65 | 65 | |
@@ -71,12 +71,12 @@ discard block |
||
71 | 71 | * @param array $merge_tags |
72 | 72 | * @param mixed|WPInv_Invoice|WPInv_Subscription $object |
73 | 73 | */ |
74 | - public function subscription_merge_tags( $merge_tags, $object ) { |
|
74 | + public function subscription_merge_tags($merge_tags, $object) { |
|
75 | 75 | |
76 | - if ( is_a( $object, 'WPInv_Subscription' ) ) { |
|
76 | + if (is_a($object, 'WPInv_Subscription')) { |
|
77 | 77 | $merge_tags = array_merge( |
78 | 78 | $merge_tags, |
79 | - $this->get_subscription_merge_tags( $object ) |
|
79 | + $this->get_subscription_merge_tags($object) |
|
80 | 80 | ); |
81 | 81 | } |
82 | 82 | |
@@ -90,25 +90,25 @@ discard block |
||
90 | 90 | * @param WPInv_Subscription $subscription |
91 | 91 | * @return array |
92 | 92 | */ |
93 | - public function get_subscription_merge_tags( $subscription ) { |
|
93 | + public function get_subscription_merge_tags($subscription) { |
|
94 | 94 | |
95 | 95 | // Abort if it does not exist. |
96 | - if ( ! $subscription->get_id() ) { |
|
96 | + if (!$subscription->get_id()) { |
|
97 | 97 | return array(); |
98 | 98 | } |
99 | 99 | |
100 | - $invoice = $subscription->get_parent_invoice(); |
|
100 | + $invoice = $subscription->get_parent_invoice(); |
|
101 | 101 | return array( |
102 | - '{subscription_renewal_date}' => getpaid_format_date_value( $subscription->get_next_renewal_date(), __( 'Never', 'invoicing' ) ), |
|
103 | - '{subscription_created}' => getpaid_format_date_value( $subscription->get_date_created() ), |
|
104 | - '{subscription_status}' => sanitize_text_field( $subscription->get_status_label() ), |
|
105 | - '{subscription_profile_id}' => sanitize_text_field( $subscription->get_profile_id() ), |
|
106 | - '{subscription_id}' => absint( $subscription->get_id() ), |
|
107 | - '{subscription_recurring_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $invoice->get_currency() ), |
|
108 | - '{subscription_initial_amount}' => wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $invoice->get_currency() ), |
|
109 | - '{subscription_recurring_period}' => getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ), |
|
102 | + '{subscription_renewal_date}' => getpaid_format_date_value($subscription->get_next_renewal_date(), __('Never', 'invoicing')), |
|
103 | + '{subscription_created}' => getpaid_format_date_value($subscription->get_date_created()), |
|
104 | + '{subscription_status}' => sanitize_text_field($subscription->get_status_label()), |
|
105 | + '{subscription_profile_id}' => sanitize_text_field($subscription->get_profile_id()), |
|
106 | + '{subscription_id}' => absint($subscription->get_id()), |
|
107 | + '{subscription_recurring_amount}' => wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $invoice->get_currency()), |
|
108 | + '{subscription_initial_amount}' => wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $invoice->get_currency()), |
|
109 | + '{subscription_recurring_period}' => getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''), |
|
110 | 110 | '{subscription_bill_times}' => $subscription->get_bill_times(), |
111 | - '{subscription_url}' => esc_url( $subscription->get_view_url() ), |
|
111 | + '{subscription_url}' => esc_url($subscription->get_view_url()), |
|
112 | 112 | ); |
113 | 113 | |
114 | 114 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @param WPInv_Invoice $invoice |
120 | 120 | * @return bool |
121 | 121 | */ |
122 | - public function should_send_notification( $invoice ) { |
|
122 | + public function should_send_notification($invoice) { |
|
123 | 123 | return 0 != $invoice->get_id(); |
124 | 124 | } |
125 | 125 | |
@@ -129,14 +129,14 @@ discard block |
||
129 | 129 | * @param WPInv_Invoice $invoice |
130 | 130 | * @return array |
131 | 131 | */ |
132 | - public function get_recipients( $invoice ) { |
|
133 | - $recipients = array( $invoice->get_email() ); |
|
132 | + public function get_recipients($invoice) { |
|
133 | + $recipients = array($invoice->get_email()); |
|
134 | 134 | |
135 | 135 | $cc = $invoice->get_email_cc(); |
136 | 136 | |
137 | - if ( ! empty( $cc ) ) { |
|
138 | - $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) ); |
|
139 | - $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) ); |
|
137 | + if (!empty($cc)) { |
|
138 | + $cc = array_map('sanitize_email', wpinv_parse_list($cc)); |
|
139 | + $recipients = array_filter(array_unique(array_merge($recipients, $cc))); |
|
140 | 140 | } |
141 | 141 | |
142 | 142 | return $recipients; |
@@ -150,45 +150,45 @@ discard block |
||
150 | 150 | * @param string $type |
151 | 151 | * @param array $extra_args Extra template args. |
152 | 152 | */ |
153 | - public function send_email( $subscription, $email, $type, $extra_args = array() ) { |
|
153 | + public function send_email($subscription, $email, $type, $extra_args = array()) { |
|
154 | 154 | |
155 | 155 | // Abort in case the parent invoice does not exist. |
156 | 156 | $invoice = $subscription->get_parent_invoice(); |
157 | - if ( ! $this->should_send_notification( $invoice ) ) { |
|
157 | + if (!$this->should_send_notification($invoice)) { |
|
158 | 158 | return; |
159 | 159 | } |
160 | 160 | |
161 | - do_action( 'getpaid_before_send_subscription_notification', $type, $subscription, $email ); |
|
161 | + do_action('getpaid_before_send_subscription_notification', $type, $subscription, $email); |
|
162 | 162 | |
163 | - $recipients = $this->get_recipients( $invoice ); |
|
163 | + $recipients = $this->get_recipients($invoice); |
|
164 | 164 | $mailer = new GetPaid_Notification_Email_Sender(); |
165 | 165 | $merge_tags = $email->get_merge_tags(); |
166 | - $content = $email->get_content( $merge_tags, $extra_args ); |
|
167 | - $subject = $email->add_merge_tags( $email->get_subject(), $merge_tags ); |
|
166 | + $content = $email->get_content($merge_tags, $extra_args); |
|
167 | + $subject = $email->add_merge_tags($email->get_subject(), $merge_tags); |
|
168 | 168 | $attachments = $email->get_attachments(); |
169 | 169 | |
170 | 170 | $result = $mailer->send( |
171 | - apply_filters( 'getpaid_subscription_email_recipients', wpinv_parse_list( $recipients ), $email ), |
|
171 | + apply_filters('getpaid_subscription_email_recipients', wpinv_parse_list($recipients), $email), |
|
172 | 172 | $subject, |
173 | 173 | $content, |
174 | 174 | $attachments |
175 | 175 | ); |
176 | 176 | |
177 | 177 | // Maybe send a copy to the admin. |
178 | - if ( $email->include_admin_bcc() ) { |
|
178 | + if ($email->include_admin_bcc()) { |
|
179 | 179 | $mailer->send( |
180 | 180 | wpinv_get_admin_email(), |
181 | - $subject . __( ' - ADMIN BCC COPY', 'invoicing' ), |
|
181 | + $subject . __(' - ADMIN BCC COPY', 'invoicing'), |
|
182 | 182 | $content, |
183 | 183 | $attachments |
184 | 184 | ); |
185 | 185 | } |
186 | 186 | |
187 | - if ( ! $result ) { |
|
188 | - $subscription->get_parent_invoice()->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true ); |
|
187 | + if (!$result) { |
|
188 | + $subscription->get_parent_invoice()->add_note(sprintf(__('Failed sending %s notification email.', 'invoicing'), sanitize_key($type)), false, false, true); |
|
189 | 189 | } |
190 | 190 | |
191 | - do_action( 'getpaid_after_send_subscription_notification', $type, $subscription, $email ); |
|
191 | + do_action('getpaid_after_send_subscription_notification', $type, $subscription, $email); |
|
192 | 192 | |
193 | 193 | } |
194 | 194 | |
@@ -197,10 +197,10 @@ discard block |
||
197 | 197 | * |
198 | 198 | * @param WPInv_Subscription $subscription |
199 | 199 | */ |
200 | - public function subscription_trial( $subscription ) { |
|
200 | + public function subscription_trial($subscription) { |
|
201 | 201 | |
202 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
203 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
202 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
203 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
204 | 204 | |
205 | 205 | } |
206 | 206 | |
@@ -209,10 +209,10 @@ discard block |
||
209 | 209 | * |
210 | 210 | * @param WPInv_Subscription $subscription |
211 | 211 | */ |
212 | - public function subscription_cancelled( $subscription ) { |
|
212 | + public function subscription_cancelled($subscription) { |
|
213 | 213 | |
214 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
215 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
214 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
215 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
216 | 216 | |
217 | 217 | } |
218 | 218 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * |
222 | 222 | * @param WPInv_Subscription $subscription |
223 | 223 | */ |
224 | - public function subscription_expired( $subscription ) { |
|
224 | + public function subscription_expired($subscription) { |
|
225 | 225 | |
226 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
227 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
226 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
227 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
228 | 228 | |
229 | 229 | } |
230 | 230 | |
@@ -233,10 +233,10 @@ discard block |
||
233 | 233 | * |
234 | 234 | * @param WPInv_Subscription $subscription |
235 | 235 | */ |
236 | - public function subscription_complete( $subscription ) { |
|
236 | + public function subscription_complete($subscription) { |
|
237 | 237 | |
238 | - $email = new GetPaid_Notification_Email( __FUNCTION__, $subscription ); |
|
239 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
238 | + $email = new GetPaid_Notification_Email(__FUNCTION__, $subscription); |
|
239 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
240 | 240 | |
241 | 241 | } |
242 | 242 | |
@@ -246,18 +246,18 @@ discard block |
||
246 | 246 | */ |
247 | 247 | public function renewal_reminder() { |
248 | 248 | |
249 | - $email = new GetPaid_Notification_Email( __FUNCTION__ ); |
|
249 | + $email = new GetPaid_Notification_Email(__FUNCTION__); |
|
250 | 250 | |
251 | 251 | // Fetch reminder days. |
252 | - $reminder_days = array_unique( wp_parse_id_list( $email->get_option( 'days' ) ) ); |
|
252 | + $reminder_days = array_unique(wp_parse_id_list($email->get_option('days'))); |
|
253 | 253 | |
254 | 254 | // Abort if non is set. |
255 | - if ( empty( $reminder_days ) ) { |
|
255 | + if (empty($reminder_days)) { |
|
256 | 256 | return; |
257 | 257 | } |
258 | 258 | |
259 | 259 | // Fetch matching subscriptions. |
260 | - $args = array( |
|
260 | + $args = array( |
|
261 | 261 | 'number' => -1, |
262 | 262 | 'count_total' => false, |
263 | 263 | 'status' => 'trialling active', |
@@ -266,8 +266,8 @@ discard block |
||
266 | 266 | ), |
267 | 267 | ); |
268 | 268 | |
269 | - foreach ( $reminder_days as $days ) { |
|
270 | - $date = date_parse( date( 'Y-m-d', strtotime( "+$days days", current_time( 'timestamp' ) ) ) ); |
|
269 | + foreach ($reminder_days as $days) { |
|
270 | + $date = date_parse(date('Y-m-d', strtotime("+$days days", current_time('timestamp')))); |
|
271 | 271 | |
272 | 272 | $args['date_expires_query'][] = array( |
273 | 273 | 'year' => $date['year'], |
@@ -277,14 +277,14 @@ discard block |
||
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | - $subscriptions = new GetPaid_Subscriptions_Query( $args ); |
|
280 | + $subscriptions = new GetPaid_Subscriptions_Query($args); |
|
281 | 281 | |
282 | - foreach ( $subscriptions as $subscription ) { |
|
282 | + foreach ($subscriptions as $subscription) { |
|
283 | 283 | |
284 | 284 | // Skip packages. |
285 | - if ( get_post_meta( $subscription->get_product_id(), '_wpinv_type', true ) != 'package' ) { |
|
285 | + if (get_post_meta($subscription->get_product_id(), '_wpinv_type', true) != 'package') { |
|
286 | 286 | $email->object = $subscription; |
287 | - $this->send_email( $subscription, $email, __FUNCTION__ ); |
|
287 | + $this->send_email($subscription, $email, __FUNCTION__); |
|
288 | 288 | } |
289 | 289 | |
290 | 290 | } |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | * Personal data exporters. |
4 | 4 | */ |
5 | 5 | |
6 | -defined( 'ABSPATH' ) || exit; |
|
6 | +defined('ABSPATH') || exit; |
|
7 | 7 | |
8 | 8 | /** |
9 | 9 | * WPInv_Privacy_Exporters Class. |
@@ -17,38 +17,38 @@ discard block |
||
17 | 17 | * @param int $page Page. |
18 | 18 | * @return array An array of invoice data in name value pairs |
19 | 19 | */ |
20 | - public static function customer_invoice_data_exporter( $email_address, $page ) { |
|
20 | + public static function customer_invoice_data_exporter($email_address, $page) { |
|
21 | 21 | $done = false; |
22 | 22 | $page = (int) $page; |
23 | 23 | $data_to_export = array(); |
24 | 24 | |
25 | - $user = get_user_by( 'email', $email_address ); |
|
26 | - if ( ! $user instanceof WP_User ) { |
|
25 | + $user = get_user_by('email', $email_address); |
|
26 | + if (!$user instanceof WP_User) { |
|
27 | 27 | return array( |
28 | 28 | 'data' => $data_to_export, |
29 | 29 | 'done' => true, |
30 | 30 | ); |
31 | 31 | } |
32 | 32 | |
33 | - $args = array( |
|
33 | + $args = array( |
|
34 | 34 | 'limit' => 30, |
35 | 35 | 'page' => $page, |
36 | 36 | 'user' => $user->ID, |
37 | 37 | ); |
38 | 38 | |
39 | - $invoices = wpinv_get_invoices( $args ); |
|
39 | + $invoices = wpinv_get_invoices($args); |
|
40 | 40 | |
41 | - if ( 0 < count( $invoices ) ) { |
|
42 | - foreach ( $invoices as $invoice ) { |
|
41 | + if (0 < count($invoices)) { |
|
42 | + foreach ($invoices as $invoice) { |
|
43 | 43 | $data_to_export[] = array( |
44 | 44 | 'group_id' => 'customer_invoices', |
45 | - 'group_label' => __( 'Invoicing Data', 'invoicing' ), |
|
46 | - 'group_description' => __( 'Customer invoicing data.', 'invoicing' ), |
|
45 | + 'group_label' => __('Invoicing Data', 'invoicing'), |
|
46 | + 'group_description' => __('Customer invoicing data.', 'invoicing'), |
|
47 | 47 | 'item_id' => "wpinv-{$invoice->ID}", |
48 | - 'data' => self::get_customer_invoice_data( $invoice ), |
|
48 | + 'data' => self::get_customer_invoice_data($invoice), |
|
49 | 49 | ); |
50 | 50 | } |
51 | - $done = 30 > count( $invoices ); |
|
51 | + $done = 30 > count($invoices); |
|
52 | 52 | } else { |
53 | 53 | $done = true; |
54 | 54 | } |
@@ -66,59 +66,59 @@ discard block |
||
66 | 66 | * @param WPInv_Invoice $invoice invoice object. |
67 | 67 | * @return array |
68 | 68 | */ |
69 | - public static function get_customer_invoice_data( $invoice ) { |
|
69 | + public static function get_customer_invoice_data($invoice) { |
|
70 | 70 | $personal_data = array(); |
71 | 71 | |
72 | 72 | $props_to_export = array( |
73 | - 'number' => __( 'Invoice Number', 'invoicing' ), |
|
74 | - 'created_date' => __( 'Invoice Date', 'invoicing' ), |
|
75 | - 'status' => __( 'Invoice Status', 'invoicing' ), |
|
76 | - 'total' => __( 'Invoice Total', 'invoicing' ), |
|
77 | - 'items' => __( 'Invoice Items', 'invoicing' ), |
|
78 | - 'first_name' => __( 'First Name', 'invoicing' ), |
|
79 | - 'last_name' => __( 'Last Name', 'invoicing' ), |
|
80 | - 'email' => __( 'Email Address', 'invoicing' ), |
|
81 | - '_wpinv_company' => __( 'Company', 'invoicing' ), |
|
82 | - 'phone' => __( 'Phone Number', 'invoicing' ), |
|
83 | - 'address' => __( 'Address', 'invoicing' ), |
|
84 | - '_wpinv_city' => __( 'City', 'invoicing' ), |
|
85 | - '_wpinv_country' => __( 'Country', 'invoicing' ), |
|
86 | - '_wpinv_state' => __( 'State', 'invoicing' ), |
|
87 | - '_wpinv_zip' => __( 'Zip Code', 'invoicing' ), |
|
73 | + 'number' => __('Invoice Number', 'invoicing'), |
|
74 | + 'created_date' => __('Invoice Date', 'invoicing'), |
|
75 | + 'status' => __('Invoice Status', 'invoicing'), |
|
76 | + 'total' => __('Invoice Total', 'invoicing'), |
|
77 | + 'items' => __('Invoice Items', 'invoicing'), |
|
78 | + 'first_name' => __('First Name', 'invoicing'), |
|
79 | + 'last_name' => __('Last Name', 'invoicing'), |
|
80 | + 'email' => __('Email Address', 'invoicing'), |
|
81 | + '_wpinv_company' => __('Company', 'invoicing'), |
|
82 | + 'phone' => __('Phone Number', 'invoicing'), |
|
83 | + 'address' => __('Address', 'invoicing'), |
|
84 | + '_wpinv_city' => __('City', 'invoicing'), |
|
85 | + '_wpinv_country' => __('Country', 'invoicing'), |
|
86 | + '_wpinv_state' => __('State', 'invoicing'), |
|
87 | + '_wpinv_zip' => __('Zip Code', 'invoicing'), |
|
88 | 88 | ); |
89 | 89 | |
90 | - $subscription = wpinv_get_subscription( $invoice ); |
|
90 | + $subscription = wpinv_get_subscription($invoice); |
|
91 | 91 | $period = $initial_amt = $bill_times = $billed = $renewal_date = ''; |
92 | 92 | |
93 | - if ( $invoice->is_recurring() && !empty( $subscription ) ) { |
|
94 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(),$subscription->get_frequency() ); |
|
95 | - $period = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() ) . ' / ' . $frequency; |
|
96 | - $initial_amt = wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
97 | - $bill_times = $subscription->get_times_billed() . ' / ' . ( ( $subscription->get_bill_times() == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $subscription->get_bill_times() ); |
|
98 | - $renewal_date = ! empty( $subscription->expiration ) ? getpaid_format_date( $subscription->expiration ) : __( 'N/A', 'invoicing' ); |
|
99 | - |
|
100 | - $props_to_export['period'] = __( 'Billing Cycle', 'invoicing' ); |
|
101 | - $props_to_export['initial_amount'] = __( 'Initial Amount', 'invoicing' ); |
|
102 | - $props_to_export['bill_times'] = __( 'Times Billed', 'invoicing' ); |
|
103 | - $props_to_export['renewal_date'] = __( 'Renewal Date', 'invoicing' ); |
|
93 | + if ($invoice->is_recurring() && !empty($subscription)) { |
|
94 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency()); |
|
95 | + $period = wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $subscription->get_parent_payment()->get_currency()) . ' / ' . $frequency; |
|
96 | + $initial_amt = wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $subscription->get_parent_payment()->get_currency()); |
|
97 | + $bill_times = $subscription->get_times_billed() . ' / ' . (($subscription->get_bill_times() == 0) ? __('Until Cancelled', 'invoicing') : $subscription->get_bill_times()); |
|
98 | + $renewal_date = !empty($subscription->expiration) ? getpaid_format_date($subscription->expiration) : __('N/A', 'invoicing'); |
|
99 | + |
|
100 | + $props_to_export['period'] = __('Billing Cycle', 'invoicing'); |
|
101 | + $props_to_export['initial_amount'] = __('Initial Amount', 'invoicing'); |
|
102 | + $props_to_export['bill_times'] = __('Times Billed', 'invoicing'); |
|
103 | + $props_to_export['renewal_date'] = __('Renewal Date', 'invoicing'); |
|
104 | 104 | } |
105 | 105 | |
106 | - $props_to_export['ip'] = __( 'IP Address', 'invoicing' ); |
|
107 | - $props_to_export['view_url'] = __( 'Invoice Link', 'invoicing' ); |
|
106 | + $props_to_export['ip'] = __('IP Address', 'invoicing'); |
|
107 | + $props_to_export['view_url'] = __('Invoice Link', 'invoicing'); |
|
108 | 108 | |
109 | - $props_to_export = apply_filters( 'wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
109 | + $props_to_export = apply_filters('wpinv_privacy_export_invoice_personal_data_props', $props_to_export, $invoice, $subscription); |
|
110 | 110 | |
111 | - foreach ( $props_to_export as $prop => $name ) { |
|
111 | + foreach ($props_to_export as $prop => $name) { |
|
112 | 112 | $value = ''; |
113 | 113 | |
114 | - switch ( $prop ) { |
|
114 | + switch ($prop) { |
|
115 | 115 | case 'items': |
116 | 116 | $item_names = array(); |
117 | - foreach ( $invoice->get_cart_details() as $key => $cart_item ) { |
|
118 | - $item_quantity = $cart_item['quantity'] > 0 ? absint( $cart_item['quantity'] ) : 1; |
|
117 | + foreach ($invoice->get_cart_details() as $key => $cart_item) { |
|
118 | + $item_quantity = $cart_item['quantity'] > 0 ? absint($cart_item['quantity']) : 1; |
|
119 | 119 | $item_names[] = $cart_item['name'] . ' x ' . $item_quantity; |
120 | 120 | } |
121 | - $value = implode( ', ', $item_names ); |
|
121 | + $value = implode(', ', $item_names); |
|
122 | 122 | break; |
123 | 123 | case 'status': |
124 | 124 | $value = $invoice->get_status(true); |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | $value = $renewal_date; |
140 | 140 | break; |
141 | 141 | default: |
142 | - if ( is_callable( array( $invoice, 'get_' . $prop ) ) ) { |
|
142 | + if (is_callable(array($invoice, 'get_' . $prop))) { |
|
143 | 143 | $value = $invoice->{"get_$prop"}(); |
144 | 144 | } else { |
145 | 145 | $value = $invoice->get_meta($prop); |
@@ -147,9 +147,9 @@ discard block |
||
147 | 147 | break; |
148 | 148 | } |
149 | 149 | |
150 | - $value = apply_filters( 'wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice ); |
|
150 | + $value = apply_filters('wpi_privacy_export_invoice_personal_data_prop', $value, $prop, $invoice); |
|
151 | 151 | |
152 | - if ( $value ) { |
|
152 | + if ($value) { |
|
153 | 153 | $personal_data[] = array( |
154 | 154 | 'name' => $name, |
155 | 155 | 'value' => $value, |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | } |
160 | 160 | |
161 | - $personal_data = apply_filters( 'wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice ); |
|
161 | + $personal_data = apply_filters('wpinv_privacy_export_invoice_personal_data', $personal_data, $invoice); |
|
162 | 162 | |
163 | 163 | return $personal_data; |
164 | 164 |
@@ -43,64 +43,64 @@ discard block |
||
43 | 43 | <td class="w-75"> |
44 | 44 | <?php |
45 | 45 | |
46 | - switch ( $key ) { |
|
46 | + switch ( $key ) { |
|
47 | 47 | |
48 | - case 'status': |
|
49 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
50 | - break; |
|
48 | + case 'status': |
|
49 | + echo sanitize_text_field( $subscription->get_status_label() ); |
|
50 | + break; |
|
51 | 51 | |
52 | - case 'start_date': |
|
53 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
54 | - break; |
|
52 | + case 'start_date': |
|
53 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
54 | + break; |
|
55 | 55 | |
56 | - case 'expiry_date': |
|
57 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
58 | - break; |
|
56 | + case 'expiry_date': |
|
57 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
58 | + break; |
|
59 | 59 | |
60 | - case 'initial_amount': |
|
61 | - echo wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
60 | + case 'initial_amount': |
|
61 | + echo wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
62 | 62 | |
63 | - if ( $subscription->has_trial_period() ) { |
|
63 | + if ( $subscription->has_trial_period() ) { |
|
64 | 64 | |
65 | - echo "<small class='text-muted'> "; |
|
66 | - printf( |
|
67 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
69 | - ); |
|
70 | - echo '</small>'; |
|
65 | + echo "<small class='text-muted'> "; |
|
66 | + printf( |
|
67 | + _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | + sanitize_text_field( $subscription->get_trial_period() ) |
|
69 | + ); |
|
70 | + echo '</small>'; |
|
71 | 71 | |
72 | - } |
|
72 | + } |
|
73 | 73 | |
74 | - break; |
|
74 | + break; |
|
75 | 75 | |
76 | - case 'recurring_amount': |
|
77 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | - $amount = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
79 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" ); |
|
80 | - break; |
|
76 | + case 'recurring_amount': |
|
77 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | + $amount = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
79 | + echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" ); |
|
80 | + break; |
|
81 | 81 | |
82 | - case 'item': |
|
83 | - $item = get_post( $subscription->get_product_id() ); |
|
82 | + case 'item': |
|
83 | + $item = get_post( $subscription->get_product_id() ); |
|
84 | 84 | |
85 | - if ( ! empty( $item ) ) { |
|
86 | - echo esc_html( get_the_title( $item ) ); |
|
87 | - } else { |
|
88 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
89 | - } |
|
85 | + if ( ! empty( $item ) ) { |
|
86 | + echo esc_html( get_the_title( $item ) ); |
|
87 | + } else { |
|
88 | + echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
89 | + } |
|
90 | 90 | |
91 | - break; |
|
91 | + break; |
|
92 | 92 | |
93 | - case 'payments': |
|
93 | + case 'payments': |
|
94 | 94 | |
95 | - $max_activations = (int) $subscription->get_bill_times(); |
|
96 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
95 | + $max_activations = (int) $subscription->get_bill_times(); |
|
96 | + echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
97 | 97 | |
98 | - break; |
|
98 | + break; |
|
99 | 99 | |
100 | - } |
|
101 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
100 | + } |
|
101 | + do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
102 | 102 | |
103 | - ?> |
|
103 | + ?> |
|
104 | 104 | </td> |
105 | 105 | |
106 | 106 | </tr> |
@@ -117,15 +117,15 @@ discard block |
||
117 | 117 | <span class="form-text"> |
118 | 118 | |
119 | 119 | <?php |
120 | - if ( $subscription->can_cancel() ) { |
|
121 | - printf( |
|
122 | - '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
123 | - esc_url( $subscription->get_cancel_url() ), |
|
124 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | - __( 'Cancel Subscription', 'invoicing' ) |
|
126 | - ); |
|
127 | - } |
|
128 | - ?> |
|
120 | + if ( $subscription->can_cancel() ) { |
|
121 | + printf( |
|
122 | + '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
123 | + esc_url( $subscription->get_cancel_url() ), |
|
124 | + esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | + __( 'Cancel Subscription', 'invoicing' ) |
|
126 | + ); |
|
127 | + } |
|
128 | + ?> |
|
129 | 129 | |
130 | 130 | <a href="<?php echo esc_url( get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
131 | 131 | </span> |
132 | 132 | \ No newline at end of file |
@@ -9,14 +9,14 @@ discard block |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_single_subscription_before_notices', $subscription ); |
|
14 | +do_action('getpaid_single_subscription_before_notices', $subscription); |
|
15 | 15 | |
16 | 16 | // Display errors and notices. |
17 | 17 | wpinv_print_errors(); |
18 | 18 | |
19 | -do_action( 'getpaid_before_single_subscription', $subscription ); |
|
19 | +do_action('getpaid_before_single_subscription', $subscription); |
|
20 | 20 | |
21 | 21 | ?> |
22 | 22 | |
@@ -28,44 +28,44 @@ discard block |
||
28 | 28 | |
29 | 29 | </style> |
30 | 30 | |
31 | -<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
31 | +<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
32 | 32 | <table class="table table-bordered"> |
33 | 33 | <tbody> |
34 | 34 | |
35 | - <?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?> |
|
35 | + <?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?> |
|
36 | 36 | |
37 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
37 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
38 | 38 | |
39 | 39 | <th class="w-25" style="font-weight: 500;"> |
40 | - <?php echo sanitize_text_field( $label ); ?> |
|
40 | + <?php echo sanitize_text_field($label); ?> |
|
41 | 41 | </th> |
42 | 42 | |
43 | 43 | <td class="w-75"> |
44 | 44 | <?php |
45 | 45 | |
46 | - switch ( $key ) { |
|
46 | + switch ($key) { |
|
47 | 47 | |
48 | 48 | case 'status': |
49 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
49 | + echo sanitize_text_field($subscription->get_status_label()); |
|
50 | 50 | break; |
51 | 51 | |
52 | 52 | case 'start_date': |
53 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
53 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created())); |
|
54 | 54 | break; |
55 | 55 | |
56 | 56 | case 'expiry_date': |
57 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
57 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date())); |
|
58 | 58 | break; |
59 | 59 | |
60 | 60 | case 'initial_amount': |
61 | - echo wpinv_price( wpinv_format_amount( $subscription->get_initial_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
61 | + echo wpinv_price(wpinv_format_amount($subscription->get_initial_amount()), $subscription->get_parent_payment()->get_currency()); |
|
62 | 62 | |
63 | - if ( $subscription->has_trial_period() ) { |
|
63 | + if ($subscription->has_trial_period()) { |
|
64 | 64 | |
65 | 65 | echo "<small class='text-muted'> "; |
66 | 66 | printf( |
67 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
68 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
67 | + _x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'), |
|
68 | + sanitize_text_field($subscription->get_trial_period()) |
|
69 | 69 | ); |
70 | 70 | echo '</small>'; |
71 | 71 | |
@@ -74,18 +74,18 @@ discard block |
||
74 | 74 | break; |
75 | 75 | |
76 | 76 | case 'recurring_amount': |
77 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
78 | - $amount = wpinv_price( wpinv_format_amount( $subscription->get_recurring_amount() ), $subscription->get_parent_payment()->get_currency() ); |
|
79 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / $frequency" ); |
|
77 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
78 | + $amount = wpinv_price(wpinv_format_amount($subscription->get_recurring_amount()), $subscription->get_parent_payment()->get_currency()); |
|
79 | + echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / $frequency"); |
|
80 | 80 | break; |
81 | 81 | |
82 | 82 | case 'item': |
83 | - $item = get_post( $subscription->get_product_id() ); |
|
83 | + $item = get_post($subscription->get_product_id()); |
|
84 | 84 | |
85 | - if ( ! empty( $item ) ) { |
|
86 | - echo esc_html( get_the_title( $item ) ); |
|
85 | + if (!empty($item)) { |
|
86 | + echo esc_html(get_the_title($item)); |
|
87 | 87 | } else { |
88 | - echo sprintf( __( 'Item #%s', 'invoicing' ), $subscription->get_product_id() ); |
|
88 | + echo sprintf(__('Item #%s', 'invoicing'), $subscription->get_product_id()); |
|
89 | 89 | } |
90 | 90 | |
91 | 91 | break; |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | case 'payments': |
94 | 94 | |
95 | 95 | $max_activations = (int) $subscription->get_bill_times(); |
96 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
96 | + echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "∞" : $max_activations); |
|
97 | 97 | |
98 | 98 | break; |
99 | 99 | |
100 | 100 | } |
101 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
101 | + do_action("getpaid_render_single_subscription_column_$key", $subscription); |
|
102 | 102 | |
103 | 103 | ?> |
104 | 104 | </td> |
@@ -110,22 +110,22 @@ discard block |
||
110 | 110 | </tbody> |
111 | 111 | </table> |
112 | 112 | |
113 | -<h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Invoices', 'invoicing' ); ?></h2> |
|
113 | +<h2 class='mt-5 mb-1 h4'><?php _e('Subscription Invoices', 'invoicing'); ?></h2> |
|
114 | 114 | |
115 | -<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?> |
|
115 | +<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?> |
|
116 | 116 | |
117 | 117 | <span class="form-text"> |
118 | 118 | |
119 | 119 | <?php |
120 | - if ( $subscription->can_cancel() ) { |
|
120 | + if ($subscription->can_cancel()) { |
|
121 | 121 | printf( |
122 | 122 | '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
123 | - esc_url( $subscription->get_cancel_url() ), |
|
124 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
125 | - __( 'Cancel Subscription', 'invoicing' ) |
|
123 | + esc_url($subscription->get_cancel_url()), |
|
124 | + esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'), |
|
125 | + __('Cancel Subscription', 'invoicing') |
|
126 | 126 | ); |
127 | 127 | } |
128 | 128 | ?> |
129 | 129 | |
130 | - <a href="<?php echo esc_url( get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
|
130 | + <a href="<?php echo esc_url(get_permalink((int) wpinv_get_option('invoice_subscription_page'))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a> |
|
131 | 131 | </span> |
132 | 132 | \ No newline at end of file |