@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | /** |
9 | 9 | * Main Subscriptions class. |
10 | 10 | * |
@@ -14,31 +14,31 @@ discard block |
||
14 | 14 | /** |
15 | 15 | * Class constructor. |
16 | 16 | */ |
17 | - public function __construct(){ |
|
17 | + public function __construct() { |
|
18 | 18 | |
19 | 19 | // Fire gateway specific hooks when a subscription changes. |
20 | - add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 ); |
|
20 | + add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3); |
|
21 | 21 | |
22 | 22 | // De-activate a subscription whenever the invoice changes payment statuses. |
23 | - add_action( 'getpaid_invoice_status_wpi-refunded', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
24 | - add_action( 'getpaid_invoice_status_wpi-failed', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
25 | - add_action( 'getpaid_invoice_status_wpi-cancelled', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
26 | - add_action( 'getpaid_invoice_status_wpi-pending', array( $this, 'maybe_deactivate_invoice_subscription' ), 20 ); |
|
23 | + add_action('getpaid_invoice_status_wpi-refunded', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
24 | + add_action('getpaid_invoice_status_wpi-failed', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
25 | + add_action('getpaid_invoice_status_wpi-cancelled', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
26 | + add_action('getpaid_invoice_status_wpi-pending', array($this, 'maybe_deactivate_invoice_subscription'), 20); |
|
27 | 27 | |
28 | 28 | // Handles subscription cancelations. |
29 | - add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) ); |
|
29 | + add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription')); |
|
30 | 30 | |
31 | 31 | // Create a subscription whenever an invoice is created, (and update it when it is updated). |
32 | - add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ) ); |
|
33 | - add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ) ); |
|
32 | + add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription')); |
|
33 | + add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription')); |
|
34 | 34 | |
35 | 35 | // Handles admin subscription update actions. |
36 | - add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) ); |
|
37 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) ); |
|
38 | - add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) ); |
|
36 | + add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription')); |
|
37 | + add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription')); |
|
38 | + add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription')); |
|
39 | 39 | |
40 | 40 | // Filter invoice item row actions. |
41 | - add_action( 'getpaid-invoice-page-line-item-actions', array( $this, 'filter_invoice_line_item_actions' ), 10, 3 ); |
|
41 | + add_action('getpaid-invoice-page-line-item-actions', array($this, 'filter_invoice_line_item_actions'), 10, 3); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -47,19 +47,19 @@ discard block |
||
47 | 47 | * @param WPInv_Invoice $invoice |
48 | 48 | * @return WPInv_Subscription|bool |
49 | 49 | */ |
50 | - public function get_invoice_subscription( $invoice ) { |
|
50 | + public function get_invoice_subscription($invoice) { |
|
51 | 51 | $subscription_id = $invoice->get_subscription_id(); |
52 | 52 | |
53 | 53 | // Fallback to the parent invoice if the child invoice has no subscription id. |
54 | - if ( empty( $subscription_id && $invoice->is_renewal() ) ) { |
|
54 | + if (empty($subscription_id && $invoice->is_renewal())) { |
|
55 | 55 | $subscription_id = $invoice->get_parent_payment()->get_subscription_id(); |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Fetch the subscription. |
59 | - $subscription = new WPInv_Subscription( $subscription_id ); |
|
59 | + $subscription = new WPInv_Subscription($subscription_id); |
|
60 | 60 | |
61 | 61 | // Return subscription or use a fallback for backwards compatibility. |
62 | - return $subscription->get_id() ? $subscription : wpinv_get_subscription( $invoice ); |
|
62 | + return $subscription->get_id() ? $subscription : wpinv_get_subscription($invoice); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -67,16 +67,16 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @param WPInv_Invoice $invoice |
69 | 69 | */ |
70 | - public function maybe_deactivate_invoice_subscription( $invoice ) { |
|
70 | + public function maybe_deactivate_invoice_subscription($invoice) { |
|
71 | 71 | |
72 | - $subscription = $this->get_invoice_subscription( $invoice ); |
|
72 | + $subscription = $this->get_invoice_subscription($invoice); |
|
73 | 73 | |
74 | 74 | // Abort if the subscription is missing or not active. |
75 | - if ( empty( $subscription ) || ! $subscription->is_active() ) { |
|
75 | + if (empty($subscription) || !$subscription->is_active()) { |
|
76 | 76 | return; |
77 | 77 | } |
78 | 78 | |
79 | - $subscription->set_status( 'pending' ); |
|
79 | + $subscription->set_status('pending'); |
|
80 | 80 | $subscription->save(); |
81 | 81 | |
82 | 82 | } |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | * @param string $from |
89 | 89 | * @param string $to |
90 | 90 | */ |
91 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
91 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
92 | 92 | |
93 | 93 | $gateway = $subscription->get_gateway(); |
94 | 94 | |
95 | - if ( ! empty( $gateway ) ) { |
|
96 | - $gateway = sanitize_key( $gateway ); |
|
97 | - $from = sanitize_key( $from ); |
|
98 | - $to = sanitize_key( $to ); |
|
99 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
95 | + if (!empty($gateway)) { |
|
96 | + $gateway = sanitize_key($gateway); |
|
97 | + $from = sanitize_key($from); |
|
98 | + $to = sanitize_key($to); |
|
99 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | } |
@@ -109,8 +109,8 @@ discard block |
||
109 | 109 | * @deprecated |
110 | 110 | * @return mixed|string|void |
111 | 111 | */ |
112 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
113 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
112 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
113 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -120,29 +120,29 @@ discard block |
||
120 | 120 | * @since 1.0.0 |
121 | 121 | * @return void |
122 | 122 | */ |
123 | - public function user_cancel_single_subscription( $data ) { |
|
123 | + public function user_cancel_single_subscription($data) { |
|
124 | 124 | |
125 | 125 | // Ensure there is a subscription to cancel. |
126 | - if ( empty( $data['subscription'] ) ) { |
|
126 | + if (empty($data['subscription'])) { |
|
127 | 127 | return; |
128 | 128 | } |
129 | 129 | |
130 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
130 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
131 | 131 | |
132 | 132 | // Ensure that it exists and that it belongs to the current user. |
133 | - if ( ! $subscription->get_id() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
134 | - wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) ); |
|
133 | + if (!$subscription->get_id() || $subscription->get_customer_id() != get_current_user_id()) { |
|
134 | + wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing')); |
|
135 | 135 | |
136 | 136 | // Can it be cancelled. |
137 | - } else if ( ! $subscription->can_cancel() ) { |
|
138 | - wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) ); |
|
137 | + } else if (!$subscription->can_cancel()) { |
|
138 | + wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing')); |
|
139 | 139 | |
140 | 140 | |
141 | 141 | // Cancel it. |
142 | 142 | } else { |
143 | 143 | |
144 | 144 | $subscription->cancel(); |
145 | - wpinv_set_error( 'cancelled', __( 'This subscription has been cancelled.', 'invoicing' ), 'info' ); |
|
145 | + wpinv_set_error('cancelled', __('This subscription has been cancelled.', 'invoicing'), 'info'); |
|
146 | 146 | } |
147 | 147 | |
148 | 148 | $redirect = add_query_arg( |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | ) |
153 | 153 | ); |
154 | 154 | |
155 | - wp_safe_redirect( esc_url( $redirect ) ); |
|
155 | + wp_safe_redirect(esc_url($redirect)); |
|
156 | 156 | exit; |
157 | 157 | |
158 | 158 | } |
@@ -164,15 +164,15 @@ discard block |
||
164 | 164 | * @param WPInv_Invoice $invoice |
165 | 165 | * @since 1.0.0 |
166 | 166 | */ |
167 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
167 | + public function maybe_create_invoice_subscription($invoice) { |
|
168 | 168 | |
169 | 169 | // Abort if it is not recurring. |
170 | - if ( $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
170 | + if ($invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
171 | 171 | return; |
172 | 172 | } |
173 | 173 | |
174 | 174 | $subscription = new WPInv_Subscription(); |
175 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
175 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
176 | 176 | |
177 | 177 | } |
178 | 178 | |
@@ -183,32 +183,32 @@ discard block |
||
183 | 183 | * @param WPInv_Invoice $invoice |
184 | 184 | * @since 1.0.19 |
185 | 185 | */ |
186 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
186 | + public function maybe_update_invoice_subscription($invoice) { |
|
187 | 187 | |
188 | 188 | // Do not process renewals. |
189 | - if ( $invoice->is_renewal() ) { |
|
189 | + if ($invoice->is_renewal()) { |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Delete existing subscription if available and the invoice is not recurring. |
194 | - if ( ! $invoice->is_recurring() ) { |
|
195 | - $subscription = new WPInv_Subscription( $invoice->get_subscription_id() ); |
|
196 | - $subscription->delete( true ); |
|
194 | + if (!$invoice->is_recurring()) { |
|
195 | + $subscription = new WPInv_Subscription($invoice->get_subscription_id()); |
|
196 | + $subscription->delete(true); |
|
197 | 197 | return; |
198 | 198 | } |
199 | 199 | |
200 | 200 | // (Maybe) create a new subscription. |
201 | - $subscription = $this->get_invoice_subscription( $invoice ); |
|
202 | - if ( empty( $subscription ) ) { |
|
203 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
201 | + $subscription = $this->get_invoice_subscription($invoice); |
|
202 | + if (empty($subscription)) { |
|
203 | + return $this->maybe_create_invoice_subscription($invoice); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | // Abort if an invoice is paid and already has a subscription. |
207 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
207 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
208 | 208 | return; |
209 | 209 | } |
210 | 210 | |
211 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
211 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
212 | 212 | |
213 | 213 | } |
214 | 214 | |
@@ -220,57 +220,57 @@ discard block |
||
220 | 220 | * @param WPInv_Invoice $invoice |
221 | 221 | * @since 1.0.19 |
222 | 222 | */ |
223 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
223 | + public function update_invoice_subscription($subscription, $invoice) { |
|
224 | 224 | |
225 | 225 | // Delete the subscription if an invoice is free or nolonger recurring. |
226 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
226 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
227 | 227 | return $subscription->delete(); |
228 | 228 | } |
229 | 229 | |
230 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
231 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
232 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
233 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
234 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
235 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
230 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
231 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
232 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
233 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
234 | + $subscription->set_date_created(current_time('mysql')); |
|
235 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
236 | 236 | |
237 | 237 | // Get the recurring item and abort if it does not exist. |
238 | - $subscription_item = $invoice->get_recurring( true ); |
|
239 | - if ( ! $subscription_item->get_id() ) { |
|
238 | + $subscription_item = $invoice->get_recurring(true); |
|
239 | + if (!$subscription_item->get_id()) { |
|
240 | 240 | $invoice->set_subscription_id(0); |
241 | 241 | $invoice->save(); |
242 | 242 | return $subscription->delete(); |
243 | 243 | } |
244 | 244 | |
245 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
246 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
247 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
248 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
245 | + $subscription->set_product_id($subscription_item->get_id()); |
|
246 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
247 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
248 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
249 | 249 | |
250 | 250 | // Calculate the next renewal date. |
251 | - $period = $subscription_item->get_recurring_period( true ); |
|
251 | + $period = $subscription_item->get_recurring_period(true); |
|
252 | 252 | $interval = $subscription_item->get_recurring_interval(); |
253 | 253 | |
254 | 254 | // If the subscription item has a trial period... |
255 | - if ( $subscription_item->has_free_trial() ) { |
|
256 | - $period = $subscription_item->get_trial_period( true ); |
|
255 | + if ($subscription_item->has_free_trial()) { |
|
256 | + $period = $subscription_item->get_trial_period(true); |
|
257 | 257 | $interval = $subscription_item->get_trial_interval(); |
258 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
259 | - $subscription->set_status( 'trialling' ); |
|
258 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
259 | + $subscription->set_status('trialling'); |
|
260 | 260 | } |
261 | 261 | |
262 | 262 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
263 | - if ( $invoice->has_free_trial() ) { |
|
264 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
265 | - $subscription->set_status( 'trialling' ); |
|
263 | + if ($invoice->has_free_trial()) { |
|
264 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
265 | + $subscription->set_status('trialling'); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | // Calculate the next renewal date. |
269 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
269 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
270 | 270 | |
271 | - $subscription->set_next_renewal_date( $expiration ); |
|
271 | + $subscription->set_next_renewal_date($expiration); |
|
272 | 272 | $subscription->save(); |
273 | - $invoice->set_subscription_id( $subscription->get_id() ); |
|
273 | + $invoice->set_subscription_id($subscription->get_id()); |
|
274 | 274 | return $subscription->get_id(); |
275 | 275 | |
276 | 276 | } |
@@ -281,21 +281,21 @@ discard block |
||
281 | 281 | * @param array $data |
282 | 282 | * @since 1.0.19 |
283 | 283 | */ |
284 | - public function admin_update_single_subscription( $args ) { |
|
284 | + public function admin_update_single_subscription($args) { |
|
285 | 285 | |
286 | 286 | // Ensure the subscription exists and that a status has been given. |
287 | - if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) { |
|
287 | + if (empty($args['subscription_id']) || empty($args['subscription_status'])) { |
|
288 | 288 | return; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Retrieve the subscriptions. |
292 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
292 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
293 | 293 | |
294 | - if ( $subscription->get_id() ) { |
|
294 | + if ($subscription->get_id()) { |
|
295 | 295 | |
296 | - $subscription->set_status( $args['subscription_status'] ); |
|
296 | + $subscription->set_status($args['subscription_status']); |
|
297 | 297 | $subscription->save(); |
298 | - getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) ); |
|
298 | + getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing')); |
|
299 | 299 | |
300 | 300 | } |
301 | 301 | |
@@ -307,27 +307,27 @@ discard block |
||
307 | 307 | * @param array $data |
308 | 308 | * @since 1.0.19 |
309 | 309 | */ |
310 | - public function admin_renew_single_subscription( $args ) { |
|
310 | + public function admin_renew_single_subscription($args) { |
|
311 | 311 | |
312 | 312 | // Ensure the subscription exists and that a status has been given. |
313 | - if ( empty( $args['id'] ) ) { |
|
313 | + if (empty($args['id'])) { |
|
314 | 314 | return; |
315 | 315 | } |
316 | 316 | |
317 | 317 | // Retrieve the subscriptions. |
318 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
318 | + $subscription = new WPInv_Subscription($args['id']); |
|
319 | 319 | |
320 | - if ( $subscription->get_id() ) { |
|
320 | + if ($subscription->get_id()) { |
|
321 | 321 | |
322 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
322 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
323 | 323 | |
324 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
324 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
325 | 325 | |
326 | - if ( ! $subscription->add_payment( $args ) ) { |
|
327 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
326 | + if (!$subscription->add_payment($args)) { |
|
327 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
328 | 328 | } else { |
329 | 329 | $subscription->renew(); |
330 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
330 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
331 | 331 | } |
332 | 332 | |
333 | 333 | wp_safe_redirect( |
@@ -350,20 +350,20 @@ discard block |
||
350 | 350 | * @param array $data |
351 | 351 | * @since 1.0.19 |
352 | 352 | */ |
353 | - public function admin_delete_single_subscription( $args ) { |
|
353 | + public function admin_delete_single_subscription($args) { |
|
354 | 354 | |
355 | 355 | // Ensure the subscription exists and that a status has been given. |
356 | - if ( empty( $args['id'] ) ) { |
|
356 | + if (empty($args['id'])) { |
|
357 | 357 | return; |
358 | 358 | } |
359 | 359 | |
360 | 360 | // Retrieve the subscriptions. |
361 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
361 | + $subscription = new WPInv_Subscription($args['id']); |
|
362 | 362 | |
363 | - if ( $subscription->delete() ) { |
|
364 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
363 | + if ($subscription->delete()) { |
|
364 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
365 | 365 | } else { |
366 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
366 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | $redirected = wp_safe_redirect( |
@@ -376,7 +376,7 @@ discard block |
||
376 | 376 | ) |
377 | 377 | ); |
378 | 378 | |
379 | - if ( $redirected ) { |
|
379 | + if ($redirected) { |
|
380 | 380 | exit; |
381 | 381 | } |
382 | 382 | |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | * @param WPInv_Item $item |
390 | 390 | * @param WPInv_Invoice $invoice |
391 | 391 | */ |
392 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
392 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
393 | 393 | |
394 | 394 | // Fetch item subscription. |
395 | - $args = array( |
|
395 | + $args = array( |
|
396 | 396 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
397 | 397 | 'product_in' => $item->get_id(), |
398 | 398 | 'number' => 1, |
@@ -400,13 +400,13 @@ discard block |
||
400 | 400 | 'fields' => 'id', |
401 | 401 | ); |
402 | 402 | |
403 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
403 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
404 | 404 | $subscription = $subscription->get_results(); |
405 | 405 | |
406 | 406 | // In case we found a match... |
407 | - if ( ! empty( $subscription ) ) { |
|
408 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
409 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
407 | + if (!empty($subscription)) { |
|
408 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
409 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
410 | 410 | } |
411 | 411 | |
412 | 412 | return $actions; |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * GetPaid_Subscription_Data_Store class file. |
5 | 5 | * |
6 | 6 | */ |
7 | -if ( ! defined( 'ABSPATH' ) ) { |
|
7 | +if (!defined('ABSPATH')) { |
|
8 | 8 | exit; |
9 | 9 | } |
10 | 10 | |
@@ -50,29 +50,29 @@ discard block |
||
50 | 50 | * |
51 | 51 | * @param WPInv_Subscription $subscription Subscription object. |
52 | 52 | */ |
53 | - public function create( &$subscription ) { |
|
53 | + public function create(&$subscription) { |
|
54 | 54 | global $wpdb; |
55 | 55 | |
56 | 56 | $values = array(); |
57 | 57 | $formats = array(); |
58 | 58 | |
59 | 59 | $fields = $this->database_fields_to_data_type; |
60 | - unset( $fields['id'] ); |
|
60 | + unset($fields['id']); |
|
61 | 61 | |
62 | - foreach ( $fields as $key => $format ) { |
|
62 | + foreach ($fields as $key => $format) { |
|
63 | 63 | $method = "get_$key"; |
64 | - $values[$key] = $subscription->$method( 'edit' ); |
|
64 | + $values[$key] = $subscription->$method('edit'); |
|
65 | 65 | $formats[] = $format; |
66 | 66 | } |
67 | 67 | |
68 | - $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats ); |
|
68 | + $result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $values, $formats); |
|
69 | 69 | |
70 | - if ( $result ) { |
|
71 | - $subscription->set_id( $wpdb->insert_id ); |
|
70 | + if ($result) { |
|
71 | + $subscription->set_id($wpdb->insert_id); |
|
72 | 72 | $subscription->apply_changes(); |
73 | 73 | $subscription->clear_cache(); |
74 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
75 | - do_action( 'getpaid_new_subscription', $subscription ); |
|
74 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id()); |
|
75 | + do_action('getpaid_new_subscription', $subscription); |
|
76 | 76 | return true; |
77 | 77 | } |
78 | 78 | |
@@ -85,22 +85,22 @@ discard block |
||
85 | 85 | * @param WPInv_Subscription $subscription Subscription object. |
86 | 86 | * |
87 | 87 | */ |
88 | - public function read( &$subscription ) { |
|
88 | + public function read(&$subscription) { |
|
89 | 89 | global $wpdb; |
90 | 90 | |
91 | 91 | $subscription->set_defaults(); |
92 | 92 | |
93 | - if ( ! $subscription->get_id() ) { |
|
94 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
95 | - $subscription->set_id( 0 ); |
|
93 | + if (!$subscription->get_id()) { |
|
94 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
95 | + $subscription->set_id(0); |
|
96 | 96 | return false; |
97 | 97 | } |
98 | 98 | |
99 | 99 | // Maybe retrieve from the cache. |
100 | - $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' ); |
|
100 | + $raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions'); |
|
101 | 101 | |
102 | 102 | // If not found, retrieve from the db. |
103 | - if ( false === $raw_subscription ) { |
|
103 | + if (false === $raw_subscription) { |
|
104 | 104 | |
105 | 105 | $raw_subscription = $wpdb->get_row( |
106 | 106 | $wpdb->prepare( |
@@ -110,22 +110,22 @@ discard block |
||
110 | 110 | ); |
111 | 111 | |
112 | 112 | // Update the cache with our data |
113 | - wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' ); |
|
113 | + wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions'); |
|
114 | 114 | |
115 | 115 | } |
116 | 116 | |
117 | - if ( ! $raw_subscription ) { |
|
118 | - $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' ); |
|
117 | + if (!$raw_subscription) { |
|
118 | + $subscription->last_error = __('Invalid subscription ID.', 'invoicing'); |
|
119 | 119 | return false; |
120 | 120 | } |
121 | 121 | |
122 | - foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) { |
|
123 | - $method = "set_$key"; |
|
124 | - $subscription->$method( $raw_subscription->$key ); |
|
122 | + foreach (array_keys($this->database_fields_to_data_type) as $key) { |
|
123 | + $method = "set_$key"; |
|
124 | + $subscription->$method($raw_subscription->$key); |
|
125 | 125 | } |
126 | 126 | |
127 | - $subscription->set_object_read( true ); |
|
128 | - do_action( 'getpaid_read_subscription', $subscription ); |
|
127 | + $subscription->set_object_read(true); |
|
128 | + do_action('getpaid_read_subscription', $subscription); |
|
129 | 129 | |
130 | 130 | } |
131 | 131 | |
@@ -134,22 +134,22 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param WPInv_Subscription $subscription Subscription object. |
136 | 136 | */ |
137 | - public function update( &$subscription ) { |
|
137 | + public function update(&$subscription) { |
|
138 | 138 | global $wpdb; |
139 | 139 | |
140 | 140 | $changes = $subscription->get_changes(); |
141 | 141 | $values = array(); |
142 | 142 | $formats = array(); |
143 | 143 | |
144 | - foreach ( $this->database_fields_to_data_type as $key => $format ) { |
|
145 | - if ( array_key_exists( $key, $changes ) ) { |
|
144 | + foreach ($this->database_fields_to_data_type as $key => $format) { |
|
145 | + if (array_key_exists($key, $changes)) { |
|
146 | 146 | $method = "get_$key"; |
147 | - $values[$key] = $subscription->$method( 'edit' ); |
|
147 | + $values[$key] = $subscription->$method('edit'); |
|
148 | 148 | $formats[] = $format; |
149 | 149 | } |
150 | 150 | } |
151 | 151 | |
152 | - if ( empty( $values ) ) { |
|
152 | + if (empty($values)) { |
|
153 | 153 | return; |
154 | 154 | } |
155 | 155 | |
@@ -169,11 +169,11 @@ discard block |
||
169 | 169 | // Delete cache. |
170 | 170 | $subscription->clear_cache(); |
171 | 171 | |
172 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() ); |
|
173 | - update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() ); |
|
172 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id()); |
|
173 | + update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id()); |
|
174 | 174 | |
175 | 175 | // Fire a hook. |
176 | - do_action( 'getpaid_update_subscription', $subscription ); |
|
176 | + do_action('getpaid_update_subscription', $subscription); |
|
177 | 177 | |
178 | 178 | } |
179 | 179 | |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | * |
183 | 183 | * @param WPInv_Subscription $subscription |
184 | 184 | */ |
185 | - public function delete( &$subscription ) { |
|
185 | + public function delete(&$subscription) { |
|
186 | 186 | global $wpdb; |
187 | 187 | |
188 | 188 | $wpdb->query( |
@@ -193,16 +193,16 @@ discard block |
||
193 | 193 | ) |
194 | 194 | ); |
195 | 195 | |
196 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' ); |
|
197 | - delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' ); |
|
196 | + delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id'); |
|
197 | + delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id'); |
|
198 | 198 | |
199 | 199 | // Delete cache. |
200 | 200 | $subscription->clear_cache(); |
201 | 201 | |
202 | 202 | // Fire a hook. |
203 | - do_action( 'getpaid_delete_subscription', $subscription ); |
|
203 | + do_action('getpaid_delete_subscription', $subscription); |
|
204 | 204 | |
205 | - $subscription->set_id( 0 ); |
|
205 | + $subscription->set_id(0); |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | /* |
@@ -8,7 +8,7 @@ discard block |
||
8 | 8 | * |
9 | 9 | */ |
10 | 10 | |
11 | -if ( ! defined( 'ABSPATH' ) ) { |
|
11 | +if (!defined('ABSPATH')) { |
|
12 | 12 | exit; |
13 | 13 | } |
14 | 14 | |
@@ -117,8 +117,8 @@ discard block |
||
117 | 117 | * |
118 | 118 | * @param int|object|array|string $read ID to load from the DB (optional) or already queried data. |
119 | 119 | */ |
120 | - public function __construct( $read = 0 ) { |
|
121 | - $this->data = array_merge( $this->data, $this->extra_data ); |
|
120 | + public function __construct($read = 0) { |
|
121 | + $this->data = array_merge($this->data, $this->extra_data); |
|
122 | 122 | $this->default_data = $this->data; |
123 | 123 | } |
124 | 124 | |
@@ -128,7 +128,7 @@ discard block |
||
128 | 128 | * @return array |
129 | 129 | */ |
130 | 130 | public function __sleep() { |
131 | - return array( 'id' ); |
|
131 | + return array('id'); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * If the object no longer exists, remove the ID. |
138 | 138 | */ |
139 | 139 | public function __wakeup() { |
140 | - $this->__construct( absint( $this->id ) ); |
|
140 | + $this->__construct(absint($this->id)); |
|
141 | 141 | |
142 | - if ( ! empty( $this->last_error ) ) { |
|
143 | - $this->set_id( 0 ); |
|
142 | + if (!empty($this->last_error)) { |
|
143 | + $this->set_id(0); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -152,11 +152,11 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function __clone() { |
154 | 154 | $this->maybe_read_meta_data(); |
155 | - if ( ! empty( $this->meta_data ) ) { |
|
156 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
157 | - $this->meta_data[ $array_key ] = clone $meta; |
|
158 | - if ( ! empty( $meta->id ) ) { |
|
159 | - $this->meta_data[ $array_key ]->id = null; |
|
155 | + if (!empty($this->meta_data)) { |
|
156 | + foreach ($this->meta_data as $array_key => $meta) { |
|
157 | + $this->meta_data[$array_key] = clone $meta; |
|
158 | + if (!empty($meta->id)) { |
|
159 | + $this->meta_data[$array_key]->id = null; |
|
160 | 160 | } |
161 | 161 | } |
162 | 162 | } |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param string $context View or edit context. |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function get_status( $context = 'view' ) { |
|
203 | - return $this->get_prop( 'status', $context ); |
|
202 | + public function get_status($context = 'view') { |
|
203 | + return $this->get_prop('status', $context); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -210,10 +210,10 @@ discard block |
||
210 | 210 | * @param bool $force_delete Should the data be deleted permanently. |
211 | 211 | * @return bool result |
212 | 212 | */ |
213 | - public function delete( $force_delete = false ) { |
|
214 | - if ( $this->data_store && $this->exists() ) { |
|
215 | - $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) ); |
|
216 | - $this->set_id( 0 ); |
|
213 | + public function delete($force_delete = false) { |
|
214 | + if ($this->data_store && $this->exists()) { |
|
215 | + $this->data_store->delete($this, array('force_delete' => $force_delete)); |
|
216 | + $this->set_id(0); |
|
217 | 217 | return true; |
218 | 218 | } |
219 | 219 | return false; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | * @return int |
227 | 227 | */ |
228 | 228 | public function save() { |
229 | - if ( ! $this->data_store ) { |
|
229 | + if (!$this->data_store) { |
|
230 | 230 | return $this->get_id(); |
231 | 231 | } |
232 | 232 | |
@@ -236,12 +236,12 @@ discard block |
||
236 | 236 | * @param GetPaid_Data $this The object being saved. |
237 | 237 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
238 | 238 | */ |
239 | - do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
239 | + do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
240 | 240 | |
241 | - if ( $this->get_id() ) { |
|
242 | - $this->data_store->update( $this ); |
|
241 | + if ($this->get_id()) { |
|
242 | + $this->data_store->update($this); |
|
243 | 243 | } else { |
244 | - $this->data_store->create( $this ); |
|
244 | + $this->data_store->create($this); |
|
245 | 245 | } |
246 | 246 | |
247 | 247 | /** |
@@ -250,7 +250,7 @@ discard block |
||
250 | 250 | * @param GetPaid_Data $this The object being saved. |
251 | 251 | * @param GetPaid_Data_Store_WP $data_store The data store persisting the data. |
252 | 252 | */ |
253 | - do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store ); |
|
253 | + do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store); |
|
254 | 254 | |
255 | 255 | return $this->get_id(); |
256 | 256 | } |
@@ -262,7 +262,7 @@ discard block |
||
262 | 262 | * @return string Data in JSON format. |
263 | 263 | */ |
264 | 264 | public function __toString() { |
265 | - return wp_json_encode( $this->get_data() ); |
|
265 | + return wp_json_encode($this->get_data()); |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | /** |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | * @return array |
273 | 273 | */ |
274 | 274 | public function get_data() { |
275 | - return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) ); |
|
275 | + return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data())); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | * @return array |
283 | 283 | */ |
284 | 284 | public function get_data_keys() { |
285 | - return array_keys( $this->data ); |
|
285 | + return array_keys($this->data); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -292,7 +292,7 @@ discard block |
||
292 | 292 | * @return array |
293 | 293 | */ |
294 | 294 | public function get_extra_data_keys() { |
295 | - return array_keys( $this->extra_data ); |
|
295 | + return array_keys($this->extra_data); |
|
296 | 296 | } |
297 | 297 | |
298 | 298 | /** |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param mixed $meta Meta value to check. |
303 | 303 | * @return bool |
304 | 304 | */ |
305 | - protected function filter_null_meta( $meta ) { |
|
306 | - return ! is_null( $meta->value ); |
|
305 | + protected function filter_null_meta($meta) { |
|
306 | + return !is_null($meta->value); |
|
307 | 307 | } |
308 | 308 | |
309 | 309 | /** |
@@ -314,7 +314,7 @@ discard block |
||
314 | 314 | */ |
315 | 315 | public function get_meta_data() { |
316 | 316 | $this->maybe_read_meta_data(); |
317 | - return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) ); |
|
317 | + return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta'))); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -324,21 +324,21 @@ discard block |
||
324 | 324 | * @param string $key Key to check. |
325 | 325 | * @return bool true if it's an internal key, false otherwise |
326 | 326 | */ |
327 | - protected function is_internal_meta_key( $key ) { |
|
328 | - $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true ); |
|
327 | + protected function is_internal_meta_key($key) { |
|
328 | + $internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true); |
|
329 | 329 | |
330 | - if ( ! $internal_meta_key ) { |
|
330 | + if (!$internal_meta_key) { |
|
331 | 331 | return false; |
332 | 332 | } |
333 | 333 | |
334 | - $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) ); |
|
334 | + $has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key)); |
|
335 | 335 | |
336 | - if ( ! $has_setter_or_getter ) { |
|
336 | + if (!$has_setter_or_getter) { |
|
337 | 337 | return false; |
338 | 338 | } |
339 | 339 | |
340 | 340 | /* translators: %s: $key Key to check */ |
341 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
341 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
342 | 342 | |
343 | 343 | return true; |
344 | 344 | } |
@@ -352,20 +352,20 @@ discard block |
||
352 | 352 | * @access public |
353 | 353 | * |
354 | 354 | */ |
355 | - public function __set( $key, $value ) { |
|
355 | + public function __set($key, $value) { |
|
356 | 356 | |
357 | - if ( 'id' == strtolower( $key ) ) { |
|
358 | - return $this->set_id( $value ); |
|
357 | + if ('id' == strtolower($key)) { |
|
358 | + return $this->set_id($value); |
|
359 | 359 | } |
360 | 360 | |
361 | - if ( method_exists( $this, "set_$key") ) { |
|
361 | + if (method_exists($this, "set_$key")) { |
|
362 | 362 | |
363 | 363 | /* translators: %s: $key Key to set */ |
364 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
364 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
365 | 365 | |
366 | - call_user_func( array( $this, "set_$key" ), $value ); |
|
366 | + call_user_func(array($this, "set_$key"), $value); |
|
367 | 367 | } else { |
368 | - $this->set_prop( $key, $value ); |
|
368 | + $this->set_prop($key, $value); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | } |
@@ -373,25 +373,25 @@ discard block |
||
373 | 373 | /** |
374 | 374 | * Margic method for retrieving a property. |
375 | 375 | */ |
376 | - public function __get( $key ) { |
|
376 | + public function __get($key) { |
|
377 | 377 | |
378 | 378 | // Check if we have a helper method for that. |
379 | - if ( method_exists( $this, 'get_' . $key ) ) { |
|
379 | + if (method_exists($this, 'get_' . $key)) { |
|
380 | 380 | |
381 | - if ( 'post_type' != $key ) { |
|
381 | + if ('post_type' != $key) { |
|
382 | 382 | /* translators: %s: $key Key to set */ |
383 | - getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing' ), $key ), '1.0.19' ); |
|
383 | + getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'invoicing'), $key), '1.0.19'); |
|
384 | 384 | } |
385 | 385 | |
386 | - return call_user_func( array( $this, 'get_' . $key ) ); |
|
386 | + return call_user_func(array($this, 'get_' . $key)); |
|
387 | 387 | } |
388 | 388 | |
389 | 389 | // Check if the key is in the associated $post object. |
390 | - if ( ! empty( $this->post ) && isset( $this->post->$key ) ) { |
|
390 | + if (!empty($this->post) && isset($this->post->$key)) { |
|
391 | 391 | return $this->post->$key; |
392 | 392 | } |
393 | 393 | |
394 | - return $this->get_prop( $key ); |
|
394 | + return $this->get_prop($key); |
|
395 | 395 | |
396 | 396 | } |
397 | 397 | |
@@ -404,15 +404,15 @@ discard block |
||
404 | 404 | * @param string $context What the value is for. Valid values are view and edit. |
405 | 405 | * @return mixed |
406 | 406 | */ |
407 | - public function get_meta( $key = '', $single = true, $context = 'view' ) { |
|
407 | + public function get_meta($key = '', $single = true, $context = 'view') { |
|
408 | 408 | |
409 | 409 | // Check if this is an internal meta key. |
410 | - $_key = str_replace( '_wpinv', '', $key ); |
|
411 | - $_key = str_replace( 'wpinv', '', $_key ); |
|
412 | - if ( $this->is_internal_meta_key( $_key ) ) { |
|
410 | + $_key = str_replace('_wpinv', '', $key); |
|
411 | + $_key = str_replace('wpinv', '', $_key); |
|
412 | + if ($this->is_internal_meta_key($_key)) { |
|
413 | 413 | $function = 'get_' . $_key; |
414 | 414 | |
415 | - if ( is_callable( array( $this, $function ) ) ) { |
|
415 | + if (is_callable(array($this, $function))) { |
|
416 | 416 | return $this->{$function}(); |
417 | 417 | } |
418 | 418 | } |
@@ -420,20 +420,20 @@ discard block |
||
420 | 420 | // Read the meta data if not yet read. |
421 | 421 | $this->maybe_read_meta_data(); |
422 | 422 | $meta_data = $this->get_meta_data(); |
423 | - $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true ); |
|
423 | + $array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true); |
|
424 | 424 | $value = $single ? '' : array(); |
425 | 425 | |
426 | - if ( ! empty( $array_keys ) ) { |
|
426 | + if (!empty($array_keys)) { |
|
427 | 427 | // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()). |
428 | - if ( $single ) { |
|
429 | - $value = $meta_data[ current( $array_keys ) ]->value; |
|
428 | + if ($single) { |
|
429 | + $value = $meta_data[current($array_keys)]->value; |
|
430 | 430 | } else { |
431 | - $value = array_intersect_key( $meta_data, array_flip( $array_keys ) ); |
|
431 | + $value = array_intersect_key($meta_data, array_flip($array_keys)); |
|
432 | 432 | } |
433 | 433 | } |
434 | 434 | |
435 | - if ( 'view' === $context ) { |
|
436 | - $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this ); |
|
435 | + if ('view' === $context) { |
|
436 | + $value = apply_filters($this->get_hook_prefix() . $key, $value, $this); |
|
437 | 437 | } |
438 | 438 | |
439 | 439 | return $value; |
@@ -446,10 +446,10 @@ discard block |
||
446 | 446 | * @param string $key Meta Key. |
447 | 447 | * @return boolean |
448 | 448 | */ |
449 | - public function meta_exists( $key = '' ) { |
|
449 | + public function meta_exists($key = '') { |
|
450 | 450 | $this->maybe_read_meta_data(); |
451 | - $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' ); |
|
452 | - return in_array( $key, $array_keys, true ); |
|
451 | + $array_keys = wp_list_pluck($this->get_meta_data(), 'key'); |
|
452 | + return in_array($key, $array_keys, true); |
|
453 | 453 | } |
454 | 454 | |
455 | 455 | /** |
@@ -458,12 +458,12 @@ discard block |
||
458 | 458 | * @since 1.0.19 |
459 | 459 | * @param array $data Key/Value pairs. |
460 | 460 | */ |
461 | - public function set_meta_data( $data ) { |
|
462 | - if ( ! empty( $data ) && is_array( $data ) ) { |
|
461 | + public function set_meta_data($data) { |
|
462 | + if (!empty($data) && is_array($data)) { |
|
463 | 463 | $this->maybe_read_meta_data(); |
464 | - foreach ( $data as $meta ) { |
|
464 | + foreach ($data as $meta) { |
|
465 | 465 | $meta = (array) $meta; |
466 | - if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) { |
|
466 | + if (isset($meta['key'], $meta['value'], $meta['id'])) { |
|
467 | 467 | $this->meta_data[] = new GetPaid_Meta_Data( |
468 | 468 | array( |
469 | 469 | 'id' => $meta['id'], |
@@ -485,18 +485,18 @@ discard block |
||
485 | 485 | * @param string|array $value Meta value. |
486 | 486 | * @param bool $unique Should this be a unique key?. |
487 | 487 | */ |
488 | - public function add_meta_data( $key, $value, $unique = false ) { |
|
489 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
488 | + public function add_meta_data($key, $value, $unique = false) { |
|
489 | + if ($this->is_internal_meta_key($key)) { |
|
490 | 490 | $function = 'set_' . $key; |
491 | 491 | |
492 | - if ( is_callable( array( $this, $function ) ) ) { |
|
493 | - return $this->{$function}( $value ); |
|
492 | + if (is_callable(array($this, $function))) { |
|
493 | + return $this->{$function}($value); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
497 | 497 | $this->maybe_read_meta_data(); |
498 | - if ( $unique ) { |
|
499 | - $this->delete_meta_data( $key ); |
|
498 | + if ($unique) { |
|
499 | + $this->delete_meta_data($key); |
|
500 | 500 | } |
501 | 501 | $this->meta_data[] = new GetPaid_Meta_Data( |
502 | 502 | array( |
@@ -515,12 +515,12 @@ discard block |
||
515 | 515 | * @param string|array $value Meta value. |
516 | 516 | * @param int $meta_id Meta ID. |
517 | 517 | */ |
518 | - public function update_meta_data( $key, $value, $meta_id = 0 ) { |
|
519 | - if ( $this->is_internal_meta_key( $key ) ) { |
|
518 | + public function update_meta_data($key, $value, $meta_id = 0) { |
|
519 | + if ($this->is_internal_meta_key($key)) { |
|
520 | 520 | $function = 'set_' . $key; |
521 | 521 | |
522 | - if ( is_callable( array( $this, $function ) ) ) { |
|
523 | - return $this->{$function}( $value ); |
|
522 | + if (is_callable(array($this, $function))) { |
|
523 | + return $this->{$function}($value); |
|
524 | 524 | } |
525 | 525 | } |
526 | 526 | |
@@ -528,33 +528,33 @@ discard block |
||
528 | 528 | |
529 | 529 | $array_key = false; |
530 | 530 | |
531 | - if ( $meta_id ) { |
|
532 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true ); |
|
533 | - $array_key = $array_keys ? current( $array_keys ) : false; |
|
531 | + if ($meta_id) { |
|
532 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true); |
|
533 | + $array_key = $array_keys ? current($array_keys) : false; |
|
534 | 534 | } else { |
535 | 535 | // Find matches by key. |
536 | 536 | $matches = array(); |
537 | - foreach ( $this->meta_data as $meta_data_array_key => $meta ) { |
|
538 | - if ( $meta->key === $key ) { |
|
537 | + foreach ($this->meta_data as $meta_data_array_key => $meta) { |
|
538 | + if ($meta->key === $key) { |
|
539 | 539 | $matches[] = $meta_data_array_key; |
540 | 540 | } |
541 | 541 | } |
542 | 542 | |
543 | - if ( ! empty( $matches ) ) { |
|
543 | + if (!empty($matches)) { |
|
544 | 544 | // Set matches to null so only one key gets the new value. |
545 | - foreach ( $matches as $meta_data_array_key ) { |
|
546 | - $this->meta_data[ $meta_data_array_key ]->value = null; |
|
545 | + foreach ($matches as $meta_data_array_key) { |
|
546 | + $this->meta_data[$meta_data_array_key]->value = null; |
|
547 | 547 | } |
548 | - $array_key = current( $matches ); |
|
548 | + $array_key = current($matches); |
|
549 | 549 | } |
550 | 550 | } |
551 | 551 | |
552 | - if ( false !== $array_key ) { |
|
553 | - $meta = $this->meta_data[ $array_key ]; |
|
552 | + if (false !== $array_key) { |
|
553 | + $meta = $this->meta_data[$array_key]; |
|
554 | 554 | $meta->key = $key; |
555 | 555 | $meta->value = $value; |
556 | 556 | } else { |
557 | - $this->add_meta_data( $key, $value, true ); |
|
557 | + $this->add_meta_data($key, $value, true); |
|
558 | 558 | } |
559 | 559 | } |
560 | 560 | |
@@ -564,13 +564,13 @@ discard block |
||
564 | 564 | * @since 1.0.19 |
565 | 565 | * @param string $key Meta key. |
566 | 566 | */ |
567 | - public function delete_meta_data( $key ) { |
|
567 | + public function delete_meta_data($key) { |
|
568 | 568 | $this->maybe_read_meta_data(); |
569 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true ); |
|
569 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true); |
|
570 | 570 | |
571 | - if ( $array_keys ) { |
|
572 | - foreach ( $array_keys as $array_key ) { |
|
573 | - $this->meta_data[ $array_key ]->value = null; |
|
571 | + if ($array_keys) { |
|
572 | + foreach ($array_keys as $array_key) { |
|
573 | + $this->meta_data[$array_key]->value = null; |
|
574 | 574 | } |
575 | 575 | } |
576 | 576 | } |
@@ -581,13 +581,13 @@ discard block |
||
581 | 581 | * @since 1.0.19 |
582 | 582 | * @param int $mid Meta ID. |
583 | 583 | */ |
584 | - public function delete_meta_data_by_mid( $mid ) { |
|
584 | + public function delete_meta_data_by_mid($mid) { |
|
585 | 585 | $this->maybe_read_meta_data(); |
586 | - $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true ); |
|
586 | + $array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true); |
|
587 | 587 | |
588 | - if ( $array_keys ) { |
|
589 | - foreach ( $array_keys as $array_key ) { |
|
590 | - $this->meta_data[ $array_key ]->value = null; |
|
588 | + if ($array_keys) { |
|
589 | + foreach ($array_keys as $array_key) { |
|
590 | + $this->meta_data[$array_key]->value = null; |
|
591 | 591 | } |
592 | 592 | } |
593 | 593 | } |
@@ -598,7 +598,7 @@ discard block |
||
598 | 598 | * @since 1.0.19 |
599 | 599 | */ |
600 | 600 | protected function maybe_read_meta_data() { |
601 | - if ( is_null( $this->meta_data ) ) { |
|
601 | + if (is_null($this->meta_data)) { |
|
602 | 602 | $this->read_meta_data(); |
603 | 603 | } |
604 | 604 | } |
@@ -610,42 +610,42 @@ discard block |
||
610 | 610 | * @since 1.0.19 |
611 | 611 | * @param bool $force_read True to force a new DB read (and update cache). |
612 | 612 | */ |
613 | - public function read_meta_data( $force_read = false ) { |
|
613 | + public function read_meta_data($force_read = false) { |
|
614 | 614 | |
615 | 615 | // Reset meta data. |
616 | 616 | $this->meta_data = array(); |
617 | 617 | |
618 | 618 | // Maybe abort early. |
619 | - if ( ! $this->get_id() || ! $this->data_store ) { |
|
619 | + if (!$this->get_id() || !$this->data_store) { |
|
620 | 620 | return; |
621 | 621 | } |
622 | 622 | |
623 | 623 | // Only read from cache if the cache key is set. |
624 | 624 | $cache_key = null; |
625 | - if ( ! $force_read && ! empty( $this->cache_group ) ) { |
|
626 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
627 | - $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group ); |
|
625 | + if (!$force_read && !empty($this->cache_group)) { |
|
626 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
627 | + $raw_meta_data = wp_cache_get($cache_key, $this->cache_group); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | // Should we force read? |
631 | - if ( empty( $raw_meta_data ) ) { |
|
632 | - $raw_meta_data = $this->data_store->read_meta( $this ); |
|
631 | + if (empty($raw_meta_data)) { |
|
632 | + $raw_meta_data = $this->data_store->read_meta($this); |
|
633 | 633 | |
634 | - if ( ! empty( $cache_key ) ) { |
|
635 | - wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group ); |
|
634 | + if (!empty($cache_key)) { |
|
635 | + wp_cache_set($cache_key, $raw_meta_data, $this->cache_group); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | } |
639 | 639 | |
640 | 640 | // Set meta data. |
641 | - if ( is_array( $raw_meta_data ) ) { |
|
641 | + if (is_array($raw_meta_data)) { |
|
642 | 642 | |
643 | - foreach ( $raw_meta_data as $meta ) { |
|
643 | + foreach ($raw_meta_data as $meta) { |
|
644 | 644 | $this->meta_data[] = new GetPaid_Meta_Data( |
645 | 645 | array( |
646 | 646 | 'id' => (int) $meta->meta_id, |
647 | 647 | 'key' => $meta->meta_key, |
648 | - 'value' => maybe_unserialize( $meta->meta_value ), |
|
648 | + 'value' => maybe_unserialize($meta->meta_value), |
|
649 | 649 | ) |
650 | 650 | ); |
651 | 651 | } |
@@ -660,28 +660,28 @@ discard block |
||
660 | 660 | * @since 1.0.19 |
661 | 661 | */ |
662 | 662 | public function save_meta_data() { |
663 | - if ( ! $this->data_store || is_null( $this->meta_data ) ) { |
|
663 | + if (!$this->data_store || is_null($this->meta_data)) { |
|
664 | 664 | return; |
665 | 665 | } |
666 | - foreach ( $this->meta_data as $array_key => $meta ) { |
|
667 | - if ( is_null( $meta->value ) ) { |
|
668 | - if ( ! empty( $meta->id ) ) { |
|
669 | - $this->data_store->delete_meta( $this, $meta ); |
|
670 | - unset( $this->meta_data[ $array_key ] ); |
|
666 | + foreach ($this->meta_data as $array_key => $meta) { |
|
667 | + if (is_null($meta->value)) { |
|
668 | + if (!empty($meta->id)) { |
|
669 | + $this->data_store->delete_meta($this, $meta); |
|
670 | + unset($this->meta_data[$array_key]); |
|
671 | 671 | } |
672 | - } elseif ( empty( $meta->id ) ) { |
|
673 | - $meta->id = $this->data_store->add_meta( $this, $meta ); |
|
672 | + } elseif (empty($meta->id)) { |
|
673 | + $meta->id = $this->data_store->add_meta($this, $meta); |
|
674 | 674 | $meta->apply_changes(); |
675 | 675 | } else { |
676 | - if ( $meta->get_changes() ) { |
|
677 | - $this->data_store->update_meta( $this, $meta ); |
|
676 | + if ($meta->get_changes()) { |
|
677 | + $this->data_store->update_meta($this, $meta); |
|
678 | 678 | $meta->apply_changes(); |
679 | 679 | } |
680 | 680 | } |
681 | 681 | } |
682 | - if ( ! empty( $this->cache_group ) ) { |
|
683 | - $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id(); |
|
684 | - wp_cache_delete( $cache_key, $this->cache_group ); |
|
682 | + if (!empty($this->cache_group)) { |
|
683 | + $cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id(); |
|
684 | + wp_cache_delete($cache_key, $this->cache_group); |
|
685 | 685 | } |
686 | 686 | } |
687 | 687 | |
@@ -691,8 +691,8 @@ discard block |
||
691 | 691 | * @since 1.0.19 |
692 | 692 | * @param int $id ID. |
693 | 693 | */ |
694 | - public function set_id( $id ) { |
|
695 | - $this->id = absint( $id ); |
|
694 | + public function set_id($id) { |
|
695 | + $this->id = absint($id); |
|
696 | 696 | } |
697 | 697 | |
698 | 698 | /** |
@@ -702,10 +702,10 @@ discard block |
||
702 | 702 | * @param string $status New status. |
703 | 703 | * @return array details of change. |
704 | 704 | */ |
705 | - public function set_status( $status ) { |
|
705 | + public function set_status($status) { |
|
706 | 706 | $old_status = $this->get_status(); |
707 | 707 | |
708 | - $this->set_prop( 'status', $status ); |
|
708 | + $this->set_prop('status', $status); |
|
709 | 709 | |
710 | 710 | return array( |
711 | 711 | 'from' => $old_status, |
@@ -721,7 +721,7 @@ discard block |
||
721 | 721 | public function set_defaults() { |
722 | 722 | $this->data = $this->default_data; |
723 | 723 | $this->changes = array(); |
724 | - $this->set_object_read( false ); |
|
724 | + $this->set_object_read(false); |
|
725 | 725 | } |
726 | 726 | |
727 | 727 | /** |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | * @since 1.0.19 |
731 | 731 | * @param boolean $read Should read?. |
732 | 732 | */ |
733 | - public function set_object_read( $read = true ) { |
|
733 | + public function set_object_read($read = true) { |
|
734 | 734 | $this->object_read = (bool) $read; |
735 | 735 | } |
736 | 736 | |
@@ -755,32 +755,32 @@ discard block |
||
755 | 755 | * |
756 | 756 | * @return bool|WP_Error |
757 | 757 | */ |
758 | - public function set_props( $props, $context = 'set' ) { |
|
758 | + public function set_props($props, $context = 'set') { |
|
759 | 759 | $errors = false; |
760 | 760 | |
761 | - foreach ( $props as $prop => $value ) { |
|
761 | + foreach ($props as $prop => $value) { |
|
762 | 762 | try { |
763 | 763 | /** |
764 | 764 | * Checks if the prop being set is allowed, and the value is not null. |
765 | 765 | */ |
766 | - if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) { |
|
766 | + if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) { |
|
767 | 767 | continue; |
768 | 768 | } |
769 | 769 | $setter = "set_$prop"; |
770 | 770 | |
771 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
772 | - $this->{$setter}( $value ); |
|
771 | + if (is_callable(array($this, $setter))) { |
|
772 | + $this->{$setter}($value); |
|
773 | 773 | } |
774 | - } catch ( Exception $e ) { |
|
775 | - if ( ! $errors ) { |
|
774 | + } catch (Exception $e) { |
|
775 | + if (!$errors) { |
|
776 | 776 | $errors = new WP_Error(); |
777 | 777 | } |
778 | - $errors->add( $e->getCode(), $e->getMessage() ); |
|
778 | + $errors->add($e->getCode(), $e->getMessage()); |
|
779 | 779 | $this->last_error = $e->getMessage(); |
780 | 780 | } |
781 | 781 | } |
782 | 782 | |
783 | - return $errors && count( $errors->get_error_codes() ) ? $errors : true; |
|
783 | + return $errors && count($errors->get_error_codes()) ? $errors : true; |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | /** |
@@ -793,14 +793,14 @@ discard block |
||
793 | 793 | * @param string $prop Name of prop to set. |
794 | 794 | * @param mixed $value Value of the prop. |
795 | 795 | */ |
796 | - protected function set_prop( $prop, $value ) { |
|
797 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
798 | - if ( true === $this->object_read ) { |
|
799 | - if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) { |
|
800 | - $this->changes[ $prop ] = $value; |
|
796 | + protected function set_prop($prop, $value) { |
|
797 | + if (array_key_exists($prop, $this->data)) { |
|
798 | + if (true === $this->object_read) { |
|
799 | + if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) { |
|
800 | + $this->changes[$prop] = $value; |
|
801 | 801 | } |
802 | 802 | } else { |
803 | - $this->data[ $prop ] = $value; |
|
803 | + $this->data[$prop] = $value; |
|
804 | 804 | } |
805 | 805 | } |
806 | 806 | } |
@@ -821,7 +821,7 @@ discard block |
||
821 | 821 | * @since 1.0.19 |
822 | 822 | */ |
823 | 823 | public function apply_changes() { |
824 | - $this->data = array_replace_recursive( $this->data, $this->changes ); |
|
824 | + $this->data = array_replace_recursive($this->data, $this->changes); |
|
825 | 825 | $this->changes = array(); |
826 | 826 | } |
827 | 827 | |
@@ -846,14 +846,14 @@ discard block |
||
846 | 846 | * @param string $context What the value is for. Valid values are view and edit. |
847 | 847 | * @return mixed |
848 | 848 | */ |
849 | - protected function get_prop( $prop, $context = 'view' ) { |
|
849 | + protected function get_prop($prop, $context = 'view') { |
|
850 | 850 | $value = null; |
851 | 851 | |
852 | - if ( array_key_exists( $prop, $this->data ) ) { |
|
853 | - $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ]; |
|
852 | + if (array_key_exists($prop, $this->data)) { |
|
853 | + $value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop]; |
|
854 | 854 | |
855 | - if ( 'view' === $context ) { |
|
856 | - $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); |
|
855 | + if ('view' === $context) { |
|
856 | + $value = apply_filters($this->get_hook_prefix() . $prop, $value, $this); |
|
857 | 857 | } |
858 | 858 | } |
859 | 859 | |
@@ -867,13 +867,13 @@ discard block |
||
867 | 867 | * @param string $prop Name of prop to set. |
868 | 868 | * @param string|integer $value Value of the prop. |
869 | 869 | */ |
870 | - protected function set_date_prop( $prop, $value ) { |
|
870 | + protected function set_date_prop($prop, $value) { |
|
871 | 871 | |
872 | - if ( empty( $value ) ) { |
|
873 | - $this->set_prop( $prop, null ); |
|
872 | + if (empty($value)) { |
|
873 | + $this->set_prop($prop, null); |
|
874 | 874 | return; |
875 | 875 | } |
876 | - $this->set_prop( $prop, $value ); |
|
876 | + $this->set_prop($prop, $value); |
|
877 | 877 | |
878 | 878 | } |
879 | 879 | |
@@ -884,7 +884,7 @@ discard block |
||
884 | 884 | * @param string $code Error code. |
885 | 885 | * @param string $message Error message. |
886 | 886 | */ |
887 | - protected function error( $code, $message ) { |
|
887 | + protected function error($code, $message) { |
|
888 | 888 | $this->last_error = $message; |
889 | 889 | } |
890 | 890 | |
@@ -896,7 +896,7 @@ discard block |
||
896 | 896 | */ |
897 | 897 | public function exists() { |
898 | 898 | $id = $this->get_id(); |
899 | - return ! empty( $id ); |
|
899 | + return !empty($id); |
|
900 | 900 | } |
901 | 901 | |
902 | 902 | } |