@@ -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 | * |
@@ -17,28 +17,28 @@ discard block |
||
| 17 | 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( 'wpinv_invoice_metabox_saved', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
| 33 | - add_action( 'getpaid_checkout_invoice_updated', array( $this, 'maybe_update_invoice_subscription' ), 5 ); |
|
| 32 | + add_action('wpinv_invoice_metabox_saved', array($this, 'maybe_update_invoice_subscription'), 5); |
|
| 33 | + add_action('getpaid_checkout_invoice_updated', array($this, 'maybe_update_invoice_subscription'), 5); |
|
| 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->exists() ? $subscription : wpinv_get_invoice_subscription( $invoice ); |
|
| 62 | + return $subscription->exists() ? $subscription : wpinv_get_invoice_subscription($invoice); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | /** |
@@ -67,21 +67,21 @@ 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 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 72 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 73 | 73 | |
| 74 | - if ( empty( $subscriptions ) ) { |
|
| 74 | + if (empty($subscriptions)) { |
|
| 75 | 75 | return; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - if ( ! is_array( $subscriptions ) ) { |
|
| 79 | - $subscriptions = array( $subscriptions ); |
|
| 78 | + if (!is_array($subscriptions)) { |
|
| 79 | + $subscriptions = array($subscriptions); |
|
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - foreach ( $subscriptions as $subscription ) { |
|
| 83 | - if ( $subscription->is_active() ) { |
|
| 84 | - $subscription->set_status( 'pending' ); |
|
| 82 | + foreach ($subscriptions as $subscription) { |
|
| 83 | + if ($subscription->is_active()) { |
|
| 84 | + $subscription->set_status('pending'); |
|
| 85 | 85 | $subscription->save(); |
| 86 | 86 | } |
| 87 | 87 | } |
@@ -95,15 +95,15 @@ discard block |
||
| 95 | 95 | * @param string $from |
| 96 | 96 | * @param string $to |
| 97 | 97 | */ |
| 98 | - public function process_subscription_status_change( $subscription, $from, $to ) { |
|
| 98 | + public function process_subscription_status_change($subscription, $from, $to) { |
|
| 99 | 99 | |
| 100 | 100 | $gateway = $subscription->get_gateway(); |
| 101 | 101 | |
| 102 | - if ( ! empty( $gateway ) ) { |
|
| 103 | - $gateway = sanitize_key( $gateway ); |
|
| 104 | - $from = sanitize_key( $from ); |
|
| 105 | - $to = sanitize_key( $to ); |
|
| 106 | - do_action( "getpaid_{$gateway}_subscription_$to", $subscription, $from ); |
|
| 102 | + if (!empty($gateway)) { |
|
| 103 | + $gateway = sanitize_key($gateway); |
|
| 104 | + $from = sanitize_key($from); |
|
| 105 | + $to = sanitize_key($to); |
|
| 106 | + do_action("getpaid_{$gateway}_subscription_$to", $subscription, $from); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | 109 | } |
@@ -116,8 +116,8 @@ discard block |
||
| 116 | 116 | * @deprecated |
| 117 | 117 | * @return mixed|string|void |
| 118 | 118 | */ |
| 119 | - public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1 ) { |
|
| 120 | - return getpaid_get_subscription_period_label( $period, $frequency_count ); |
|
| 119 | + public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) { |
|
| 120 | + return getpaid_get_subscription_period_label($period, $frequency_count); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | 123 | /** |
@@ -127,21 +127,21 @@ discard block |
||
| 127 | 127 | * @since 1.0.0 |
| 128 | 128 | * @return void |
| 129 | 129 | */ |
| 130 | - public function user_cancel_single_subscription( $data ) { |
|
| 130 | + public function user_cancel_single_subscription($data) { |
|
| 131 | 131 | |
| 132 | 132 | // Ensure there is a subscription to cancel. |
| 133 | - if ( empty( $data['subscription'] ) ) { |
|
| 133 | + if (empty($data['subscription'])) { |
|
| 134 | 134 | return; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | - $subscription = new WPInv_Subscription( (int) $data['subscription'] ); |
|
| 137 | + $subscription = new WPInv_Subscription((int) $data['subscription']); |
|
| 138 | 138 | |
| 139 | 139 | // Ensure that it exists and that it belongs to the current user. |
| 140 | - if ( ! $subscription->exists() || $subscription->get_customer_id() != get_current_user_id() ) { |
|
| 140 | + if (!$subscription->exists() || $subscription->get_customer_id() != get_current_user_id()) { |
|
| 141 | 141 | $notice = 'perm_cancel_subscription'; |
| 142 | 142 | |
| 143 | 143 | // Can it be cancelled. |
| 144 | - } elseif ( ! $subscription->can_cancel() ) { |
|
| 144 | + } elseif (!$subscription->can_cancel()) { |
|
| 145 | 145 | $notice = 'cannot_cancel_subscription'; |
| 146 | 146 | |
| 147 | 147 | // Cancel it. |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | 'wpinv-notice' => $notice, |
| 158 | 158 | ); |
| 159 | 159 | |
| 160 | - wp_safe_redirect( add_query_arg( $redirect ) ); |
|
| 160 | + wp_safe_redirect(add_query_arg($redirect)); |
|
| 161 | 161 | exit; |
| 162 | 162 | |
| 163 | 163 | } |
@@ -169,41 +169,41 @@ discard block |
||
| 169 | 169 | * @param WPInv_Invoice $invoice |
| 170 | 170 | * @since 1.0.0 |
| 171 | 171 | */ |
| 172 | - public function maybe_create_invoice_subscription( $invoice ) { |
|
| 172 | + public function maybe_create_invoice_subscription($invoice) { |
|
| 173 | 173 | global $getpaid_subscriptions_skip_invoice_update; |
| 174 | 174 | |
| 175 | 175 | // Abort if it is not recurring. |
| 176 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) { |
|
| 176 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) { |
|
| 177 | 177 | return; |
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | // Either group the subscriptions or only process a single suscription. |
| 181 | - if ( getpaid_should_group_subscriptions( $invoice ) ) { |
|
| 181 | + if (getpaid_should_group_subscriptions($invoice)) { |
|
| 182 | 182 | |
| 183 | 183 | $subscription_groups = array(); |
| 184 | 184 | $is_first = true; |
| 185 | 185 | |
| 186 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
| 187 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, 0, $is_first ); |
|
| 186 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
| 187 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, 0, $is_first); |
|
| 188 | 188 | |
| 189 | - if ( $is_first ) { |
|
| 189 | + if ($is_first) { |
|
| 190 | 190 | $getpaid_subscriptions_skip_invoice_update = true; |
| 191 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
| 191 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
| 192 | 192 | $invoice->save(); |
| 193 | 193 | $getpaid_subscriptions_skip_invoice_update = false; |
| 194 | 194 | } |
| 195 | 195 | |
| 196 | - $is_first = false; |
|
| 196 | + $is_first = false; |
|
| 197 | 197 | } |
| 198 | 198 | |
| 199 | 199 | // Cache subscription groups. |
| 200 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
| 200 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
| 201 | 201 | return true; |
| 202 | 202 | |
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | $subscription = new WPInv_Subscription(); |
| 206 | - return $this->update_invoice_subscription( $subscription, $invoice ); |
|
| 206 | + return $this->update_invoice_subscription($subscription, $invoice); |
|
| 207 | 207 | |
| 208 | 208 | } |
| 209 | 209 | |
@@ -218,46 +218,46 @@ discard block |
||
| 218 | 218 | * |
| 219 | 219 | * @since 2.3.0 |
| 220 | 220 | */ |
| 221 | - public function create_invoice_subscription_group( $totals, $invoice, $subscription_id = 0, $is_first = false ) { |
|
| 221 | + public function create_invoice_subscription_group($totals, $invoice, $subscription_id = 0, $is_first = false) { |
|
| 222 | 222 | |
| 223 | - $subscription = new WPInv_Subscription( (int) $subscription_id ); |
|
| 223 | + $subscription = new WPInv_Subscription((int) $subscription_id); |
|
| 224 | 224 | $initial_amt = $totals['initial_total']; |
| 225 | 225 | $recurring_amt = $totals['recurring_total']; |
| 226 | 226 | $fees = array(); |
| 227 | 227 | |
| 228 | 228 | // Maybe add recurring fees. |
| 229 | - if ( $is_first ) { |
|
| 229 | + if ($is_first) { |
|
| 230 | 230 | |
| 231 | - foreach ( $invoice->get_fees() as $i => $fee ) { |
|
| 232 | - if ( ! empty( $fee['recurring_fee'] ) ) { |
|
| 233 | - $initial_amt += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
| 234 | - $recurring_amt += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
| 235 | - $fees[ $i ] = $fee; |
|
| 231 | + foreach ($invoice->get_fees() as $i => $fee) { |
|
| 232 | + if (!empty($fee['recurring_fee'])) { |
|
| 233 | + $initial_amt += wpinv_sanitize_amount($fee['initial_fee']); |
|
| 234 | + $recurring_amt += wpinv_sanitize_amount($fee['recurring_fee']); |
|
| 235 | + $fees[$i] = $fee; |
|
| 236 | 236 | } |
| 237 | 237 | } |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
| 241 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
| 242 | - $subscription->set_initial_amount( $initial_amt ); |
|
| 243 | - $subscription->set_recurring_amount( $recurring_amt ); |
|
| 244 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 245 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
| 246 | - $subscription->set_product_id( $totals['item_id'] ); |
|
| 247 | - $subscription->set_period( $totals['period'] ); |
|
| 248 | - $subscription->set_frequency( $totals['interval'] ); |
|
| 249 | - $subscription->set_bill_times( $totals['recurring_limit'] ); |
|
| 250 | - $subscription->set_next_renewal_date( $totals['renews_on'] ); |
|
| 240 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
| 241 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
| 242 | + $subscription->set_initial_amount($initial_amt); |
|
| 243 | + $subscription->set_recurring_amount($recurring_amt); |
|
| 244 | + $subscription->set_date_created(current_time('mysql')); |
|
| 245 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
| 246 | + $subscription->set_product_id($totals['item_id']); |
|
| 247 | + $subscription->set_period($totals['period']); |
|
| 248 | + $subscription->set_frequency($totals['interval']); |
|
| 249 | + $subscription->set_bill_times($totals['recurring_limit']); |
|
| 250 | + $subscription->set_next_renewal_date($totals['renews_on']); |
|
| 251 | 251 | |
| 252 | 252 | // Trial periods. |
| 253 | - if ( ! empty( $totals['trialling'] ) ) { |
|
| 254 | - $subscription->set_trial_period( $totals['trialling'] ); |
|
| 255 | - $subscription->set_status( 'trialling' ); |
|
| 253 | + if (!empty($totals['trialling'])) { |
|
| 254 | + $subscription->set_trial_period($totals['trialling']); |
|
| 255 | + $subscription->set_status('trialling'); |
|
| 256 | 256 | |
| 257 | 257 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
| 258 | - } elseif ( empty( $initial_amt ) ) { |
|
| 259 | - $subscription->set_trial_period( $totals['interval'] . ' ' . $totals['period'] ); |
|
| 260 | - $subscription->set_status( 'trialling' ); |
|
| 258 | + } elseif (empty($initial_amt)) { |
|
| 259 | + $subscription->set_trial_period($totals['interval'] . ' ' . $totals['period']); |
|
| 260 | + $subscription->set_status('trialling'); |
|
| 261 | 261 | } |
| 262 | 262 | |
| 263 | 263 | $subscription->save(); |
@@ -275,86 +275,86 @@ discard block |
||
| 275 | 275 | * @param WPInv_Invoice $invoice |
| 276 | 276 | * @since 1.0.19 |
| 277 | 277 | */ |
| 278 | - public function maybe_update_invoice_subscription( $invoice ) { |
|
| 278 | + public function maybe_update_invoice_subscription($invoice) { |
|
| 279 | 279 | global $getpaid_subscriptions_skip_invoice_update; |
| 280 | 280 | |
| 281 | 281 | // Avoid infinite loops. |
| 282 | - if ( ! empty( $getpaid_subscriptions_skip_invoice_update ) ) { |
|
| 282 | + if (!empty($getpaid_subscriptions_skip_invoice_update)) { |
|
| 283 | 283 | return; |
| 284 | 284 | } |
| 285 | 285 | |
| 286 | 286 | // Do not process renewals. |
| 287 | - if ( $invoice->is_renewal() ) { |
|
| 287 | + if ($invoice->is_renewal()) { |
|
| 288 | 288 | return; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Delete existing subscriptions if available and the invoice is not recurring. |
| 292 | - if ( ! $invoice->is_recurring() ) { |
|
| 293 | - $this->delete_invoice_subscriptions( $invoice ); |
|
| 292 | + if (!$invoice->is_recurring()) { |
|
| 293 | + $this->delete_invoice_subscriptions($invoice); |
|
| 294 | 294 | return; |
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | // Fetch existing subscriptions. |
| 298 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 298 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 299 | 299 | |
| 300 | 300 | // Create new ones if no existing subscriptions. |
| 301 | - if ( empty( $subscriptions ) ) { |
|
| 302 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
| 301 | + if (empty($subscriptions)) { |
|
| 302 | + return $this->maybe_create_invoice_subscription($invoice); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | // Abort if an invoice is paid and already has a subscription. |
| 306 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
| 306 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $is_grouped = is_array( $subscriptions ); |
|
| 311 | - $should_group = getpaid_should_group_subscriptions( $invoice ); |
|
| 310 | + $is_grouped = is_array($subscriptions); |
|
| 311 | + $should_group = getpaid_should_group_subscriptions($invoice); |
|
| 312 | 312 | |
| 313 | 313 | // Ensure that the subscriptions are only grouped if there are more than 1 recurring items. |
| 314 | - if ( $is_grouped != $should_group ) { |
|
| 315 | - $this->delete_invoice_subscriptions( $invoice ); |
|
| 316 | - delete_post_meta( $invoice->get_id(), 'getpaid_subscription_groups' ); |
|
| 317 | - return $this->maybe_create_invoice_subscription( $invoice ); |
|
| 314 | + if ($is_grouped != $should_group) { |
|
| 315 | + $this->delete_invoice_subscriptions($invoice); |
|
| 316 | + delete_post_meta($invoice->get_id(), 'getpaid_subscription_groups'); |
|
| 317 | + return $this->maybe_create_invoice_subscription($invoice); |
|
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // If there is only one recurring item... |
| 321 | - if ( ! $is_grouped ) { |
|
| 322 | - return $this->update_invoice_subscription( $subscriptions, $invoice ); |
|
| 321 | + if (!$is_grouped) { |
|
| 322 | + return $this->update_invoice_subscription($subscriptions, $invoice); |
|
| 323 | 323 | } |
| 324 | 324 | |
| 325 | 325 | // Process subscription groups. |
| 326 | - $current_groups = getpaid_get_invoice_subscription_groups( $invoice->get_id() ); |
|
| 326 | + $current_groups = getpaid_get_invoice_subscription_groups($invoice->get_id()); |
|
| 327 | 327 | $subscription_groups = array(); |
| 328 | 328 | $is_first = true; |
| 329 | 329 | |
| 330 | 330 | // Create new subscription groups. |
| 331 | - foreach ( getpaid_calculate_subscription_totals( $invoice ) as $group_key => $totals ) { |
|
| 332 | - $subscription_id = isset( $current_groups[ $group_key ] ) ? $current_groups[ $group_key ]['subscription_id'] : 0; |
|
| 333 | - $subscription_groups[ $group_key ] = $this->create_invoice_subscription_group( $totals, $invoice, $subscription_id, $is_first ); |
|
| 331 | + foreach (getpaid_calculate_subscription_totals($invoice) as $group_key => $totals) { |
|
| 332 | + $subscription_id = isset($current_groups[$group_key]) ? $current_groups[$group_key]['subscription_id'] : 0; |
|
| 333 | + $subscription_groups[$group_key] = $this->create_invoice_subscription_group($totals, $invoice, $subscription_id, $is_first); |
|
| 334 | 334 | |
| 335 | - if ( $is_first && $invoice->get_subscription_id() !== $subscription_groups[ $group_key ]['subscription_id'] ) { |
|
| 335 | + if ($is_first && $invoice->get_subscription_id() !== $subscription_groups[$group_key]['subscription_id']) { |
|
| 336 | 336 | $getpaid_subscriptions_skip_invoice_update = true; |
| 337 | - $invoice->set_subscription_id( $subscription_groups[ $group_key ]['subscription_id'] ); |
|
| 337 | + $invoice->set_subscription_id($subscription_groups[$group_key]['subscription_id']); |
|
| 338 | 338 | $invoice->save(); |
| 339 | 339 | $getpaid_subscriptions_skip_invoice_update = false; |
| 340 | 340 | } |
| 341 | 341 | |
| 342 | - $is_first = false; |
|
| 342 | + $is_first = false; |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | // Delete non-existent subscription groups. |
| 346 | - foreach ( $current_groups as $group_key => $data ) { |
|
| 347 | - if ( ! isset( $subscription_groups[ $group_key ] ) ) { |
|
| 348 | - $subscription = new WPInv_Subscription( (int) $data['subscription_id'] ); |
|
| 346 | + foreach ($current_groups as $group_key => $data) { |
|
| 347 | + if (!isset($subscription_groups[$group_key])) { |
|
| 348 | + $subscription = new WPInv_Subscription((int) $data['subscription_id']); |
|
| 349 | 349 | |
| 350 | - if ( $subscription->exists() ) { |
|
| 351 | - $subscription->delete( true ); |
|
| 350 | + if ($subscription->exists()) { |
|
| 351 | + $subscription->delete(true); |
|
| 352 | 352 | } |
| 353 | 353 | } |
| 354 | 354 | } |
| 355 | 355 | |
| 356 | 356 | // Cache subscription groups. |
| 357 | - update_post_meta( $invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups ); |
|
| 357 | + update_post_meta($invoice->get_id(), 'getpaid_subscription_groups', $subscription_groups); |
|
| 358 | 358 | return true; |
| 359 | 359 | |
| 360 | 360 | } |
@@ -364,20 +364,20 @@ discard block |
||
| 364 | 364 | * |
| 365 | 365 | * @param WPInv_Invoice $invoice |
| 366 | 366 | */ |
| 367 | - public function delete_invoice_subscriptions( $invoice ) { |
|
| 367 | + public function delete_invoice_subscriptions($invoice) { |
|
| 368 | 368 | |
| 369 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 369 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 370 | 370 | |
| 371 | - if ( empty( $subscriptions ) ) { |
|
| 371 | + if (empty($subscriptions)) { |
|
| 372 | 372 | return; |
| 373 | 373 | } |
| 374 | 374 | |
| 375 | - if ( ! is_array( $subscriptions ) ) { |
|
| 376 | - $subscriptions = array( $subscriptions ); |
|
| 375 | + if (!is_array($subscriptions)) { |
|
| 376 | + $subscriptions = array($subscriptions); |
|
| 377 | 377 | } |
| 378 | 378 | |
| 379 | - foreach ( $subscriptions as $subscription ) { |
|
| 380 | - $subscription->delete( true ); |
|
| 379 | + foreach ($subscriptions as $subscription) { |
|
| 380 | + $subscription->delete(true); |
|
| 381 | 381 | } |
| 382 | 382 | |
| 383 | 383 | } |
@@ -390,57 +390,57 @@ discard block |
||
| 390 | 390 | * @param WPInv_Invoice $invoice |
| 391 | 391 | * @since 1.0.19 |
| 392 | 392 | */ |
| 393 | - public function update_invoice_subscription( $subscription, $invoice ) { |
|
| 393 | + public function update_invoice_subscription($subscription, $invoice) { |
|
| 394 | 394 | |
| 395 | 395 | // Delete the subscription if an invoice is free or nolonger recurring. |
| 396 | - if ( ! $invoice->is_type( 'invoice' ) || $invoice->is_free() || ! $invoice->is_recurring() ) { |
|
| 396 | + if (!$invoice->is_type('invoice') || $invoice->is_free() || !$invoice->is_recurring()) { |
|
| 397 | 397 | return $subscription->delete(); |
| 398 | 398 | } |
| 399 | 399 | |
| 400 | - $subscription->set_customer_id( $invoice->get_customer_id() ); |
|
| 401 | - $subscription->set_parent_invoice_id( $invoice->get_id() ); |
|
| 402 | - $subscription->set_initial_amount( $invoice->get_initial_total() ); |
|
| 403 | - $subscription->set_recurring_amount( $invoice->get_recurring_total() ); |
|
| 404 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
| 405 | - $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' ); |
|
| 400 | + $subscription->set_customer_id($invoice->get_customer_id()); |
|
| 401 | + $subscription->set_parent_invoice_id($invoice->get_id()); |
|
| 402 | + $subscription->set_initial_amount($invoice->get_initial_total()); |
|
| 403 | + $subscription->set_recurring_amount($invoice->get_recurring_total()); |
|
| 404 | + $subscription->set_date_created(current_time('mysql')); |
|
| 405 | + $subscription->set_status($invoice->is_paid() ? 'active' : 'pending'); |
|
| 406 | 406 | |
| 407 | 407 | // Get the recurring item and abort if it does not exist. |
| 408 | - $subscription_item = $invoice->get_recurring( true ); |
|
| 409 | - if ( ! $subscription_item->get_id() ) { |
|
| 410 | - $invoice->set_subscription_id( 0 ); |
|
| 408 | + $subscription_item = $invoice->get_recurring(true); |
|
| 409 | + if (!$subscription_item->get_id()) { |
|
| 410 | + $invoice->set_subscription_id(0); |
|
| 411 | 411 | $invoice->save(); |
| 412 | 412 | return $subscription->delete(); |
| 413 | 413 | } |
| 414 | 414 | |
| 415 | - $subscription->set_product_id( $subscription_item->get_id() ); |
|
| 416 | - $subscription->set_period( $subscription_item->get_recurring_period( true ) ); |
|
| 417 | - $subscription->set_frequency( $subscription_item->get_recurring_interval() ); |
|
| 418 | - $subscription->set_bill_times( $subscription_item->get_recurring_limit() ); |
|
| 415 | + $subscription->set_product_id($subscription_item->get_id()); |
|
| 416 | + $subscription->set_period($subscription_item->get_recurring_period(true)); |
|
| 417 | + $subscription->set_frequency($subscription_item->get_recurring_interval()); |
|
| 418 | + $subscription->set_bill_times($subscription_item->get_recurring_limit()); |
|
| 419 | 419 | |
| 420 | 420 | // Calculate the next renewal date. |
| 421 | - $period = $subscription_item->get_recurring_period( true ); |
|
| 421 | + $period = $subscription_item->get_recurring_period(true); |
|
| 422 | 422 | $interval = $subscription_item->get_recurring_interval(); |
| 423 | 423 | |
| 424 | 424 | // If the subscription item has a trial period... |
| 425 | - if ( $subscription_item->has_free_trial() ) { |
|
| 426 | - $period = $subscription_item->get_trial_period( true ); |
|
| 425 | + if ($subscription_item->has_free_trial()) { |
|
| 426 | + $period = $subscription_item->get_trial_period(true); |
|
| 427 | 427 | $interval = $subscription_item->get_trial_interval(); |
| 428 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
| 429 | - $subscription->set_status( 'trialling' ); |
|
| 428 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
| 429 | + $subscription->set_status('trialling'); |
|
| 430 | 430 | } |
| 431 | 431 | |
| 432 | 432 | // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial. |
| 433 | - if ( $invoice->has_free_trial() ) { |
|
| 434 | - $subscription->set_trial_period( $interval . ' ' . $period ); |
|
| 435 | - $subscription->set_status( 'trialling' ); |
|
| 433 | + if ($invoice->has_free_trial()) { |
|
| 434 | + $subscription->set_trial_period($interval . ' ' . $period); |
|
| 435 | + $subscription->set_status('trialling'); |
|
| 436 | 436 | } |
| 437 | 437 | |
| 438 | 438 | // Calculate the next renewal date. |
| 439 | - $expiration = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", strtotime( $subscription->get_date_created() ) ) ); |
|
| 439 | + $expiration = date('Y-m-d H:i:s', strtotime("+$interval $period", strtotime($subscription->get_date_created()))); |
|
| 440 | 440 | |
| 441 | - $subscription->set_next_renewal_date( $expiration ); |
|
| 441 | + $subscription->set_next_renewal_date($expiration); |
|
| 442 | 442 | $subscription->save(); |
| 443 | - $invoice->set_subscription_id( $subscription->get_id() ); |
|
| 443 | + $invoice->set_subscription_id($subscription->get_id()); |
|
| 444 | 444 | return $subscription->get_id(); |
| 445 | 445 | |
| 446 | 446 | } |
@@ -451,31 +451,31 @@ discard block |
||
| 451 | 451 | * @param array $data |
| 452 | 452 | * @since 1.0.19 |
| 453 | 453 | */ |
| 454 | - public function admin_update_single_subscription( $args ) { |
|
| 454 | + public function admin_update_single_subscription($args) { |
|
| 455 | 455 | |
| 456 | 456 | // Ensure the subscription exists and that a status has been given. |
| 457 | - if ( empty( $args['subscription_id'] ) ) { |
|
| 457 | + if (empty($args['subscription_id'])) { |
|
| 458 | 458 | return; |
| 459 | 459 | } |
| 460 | 460 | |
| 461 | 461 | // Retrieve the subscriptions. |
| 462 | - $subscription = new WPInv_Subscription( $args['subscription_id'] ); |
|
| 462 | + $subscription = new WPInv_Subscription($args['subscription_id']); |
|
| 463 | 463 | |
| 464 | - if ( $subscription->get_id() ) { |
|
| 464 | + if ($subscription->get_id()) { |
|
| 465 | 465 | |
| 466 | 466 | $subscription->set_props( |
| 467 | 467 | array( |
| 468 | - 'status' => isset( $args['subscription_status'] ) ? $args['subscription_status'] : null, |
|
| 469 | - 'profile_id' => isset( $args['wpinv_subscription_profile_id'] ) ? $args['wpinv_subscription_profile_id'] : null, |
|
| 470 | - 'date_created' => ! empty( $args['wpinv_subscription_date_created'] ) ? $args['wpinv_subscription_date_created'] : null, |
|
| 471 | - 'expiration' => ! empty( $args['wpinv_subscription_expiration'] ) ? $args['wpinv_subscription_expiration'] : null, |
|
| 468 | + 'status' => isset($args['subscription_status']) ? $args['subscription_status'] : null, |
|
| 469 | + 'profile_id' => isset($args['wpinv_subscription_profile_id']) ? $args['wpinv_subscription_profile_id'] : null, |
|
| 470 | + 'date_created' => !empty($args['wpinv_subscription_date_created']) ? $args['wpinv_subscription_date_created'] : null, |
|
| 471 | + 'expiration' => !empty($args['wpinv_subscription_expiration']) ? $args['wpinv_subscription_expiration'] : null, |
|
| 472 | 472 | ) |
| 473 | 473 | ); |
| 474 | 474 | |
| 475 | 475 | $subscription->save(); |
| 476 | - getpaid_admin()->show_info( __( 'Subscription updated', 'invoicing' ) ); |
|
| 476 | + getpaid_admin()->show_info(__('Subscription updated', 'invoicing')); |
|
| 477 | 477 | |
| 478 | - do_action( 'getpaid_admin_updated_subscription', $subscription, $args ); |
|
| 478 | + do_action('getpaid_admin_updated_subscription', $subscription, $args); |
|
| 479 | 479 | } |
| 480 | 480 | |
| 481 | 481 | } |
@@ -486,27 +486,27 @@ discard block |
||
| 486 | 486 | * @param array $data |
| 487 | 487 | * @since 1.0.19 |
| 488 | 488 | */ |
| 489 | - public function admin_renew_single_subscription( $args ) { |
|
| 489 | + public function admin_renew_single_subscription($args) { |
|
| 490 | 490 | |
| 491 | 491 | // Ensure the subscription exists and that a status has been given. |
| 492 | - if ( empty( $args['id'] ) ) { |
|
| 492 | + if (empty($args['id'])) { |
|
| 493 | 493 | return; |
| 494 | 494 | } |
| 495 | 495 | |
| 496 | 496 | // Retrieve the subscriptions. |
| 497 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
| 497 | + $subscription = new WPInv_Subscription($args['id']); |
|
| 498 | 498 | |
| 499 | - if ( $subscription->get_id() ) { |
|
| 499 | + if ($subscription->get_id()) { |
|
| 500 | 500 | |
| 501 | - do_action( 'getpaid_admin_renew_subscription', $subscription ); |
|
| 501 | + do_action('getpaid_admin_renew_subscription', $subscription); |
|
| 502 | 502 | |
| 503 | - $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) ); |
|
| 503 | + $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_')); |
|
| 504 | 504 | |
| 505 | - if ( ! $subscription->add_payment( $args ) ) { |
|
| 506 | - getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) ); |
|
| 505 | + if (!$subscription->add_payment($args)) { |
|
| 506 | + getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing')); |
|
| 507 | 507 | } else { |
| 508 | 508 | $subscription->renew(); |
| 509 | - getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) ); |
|
| 509 | + getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing')); |
|
| 510 | 510 | } |
| 511 | 511 | |
| 512 | 512 | wp_safe_redirect( |
@@ -529,20 +529,20 @@ discard block |
||
| 529 | 529 | * @param array $data |
| 530 | 530 | * @since 1.0.19 |
| 531 | 531 | */ |
| 532 | - public function admin_delete_single_subscription( $args ) { |
|
| 532 | + public function admin_delete_single_subscription($args) { |
|
| 533 | 533 | |
| 534 | 534 | // Ensure the subscription exists and that a status has been given. |
| 535 | - if ( empty( $args['id'] ) ) { |
|
| 535 | + if (empty($args['id'])) { |
|
| 536 | 536 | return; |
| 537 | 537 | } |
| 538 | 538 | |
| 539 | 539 | // Retrieve the subscriptions. |
| 540 | - $subscription = new WPInv_Subscription( $args['id'] ); |
|
| 540 | + $subscription = new WPInv_Subscription($args['id']); |
|
| 541 | 541 | |
| 542 | - if ( $subscription->delete() ) { |
|
| 543 | - getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) ); |
|
| 542 | + if ($subscription->delete()) { |
|
| 543 | + getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing')); |
|
| 544 | 544 | } else { |
| 545 | - getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) ); |
|
| 545 | + getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing')); |
|
| 546 | 546 | } |
| 547 | 547 | |
| 548 | 548 | $redirected = wp_safe_redirect( |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | ) |
| 556 | 556 | ); |
| 557 | 557 | |
| 558 | - if ( $redirected ) { |
|
| 558 | + if ($redirected) { |
|
| 559 | 559 | exit; |
| 560 | 560 | } |
| 561 | 561 | |
@@ -568,16 +568,16 @@ discard block |
||
| 568 | 568 | * @param WPInv_Item $item |
| 569 | 569 | * @param WPInv_Invoice $invoice |
| 570 | 570 | */ |
| 571 | - public function filter_invoice_line_item_actions( $actions, $item, $invoice ) { |
|
| 571 | + public function filter_invoice_line_item_actions($actions, $item, $invoice) { |
|
| 572 | 572 | |
| 573 | 573 | // Abort if this invoice uses subscription groups. |
| 574 | - $subscriptions = getpaid_get_invoice_subscriptions( $invoice ); |
|
| 575 | - if ( ! $invoice->is_recurring() || ! is_object( $subscriptions ) ) { |
|
| 574 | + $subscriptions = getpaid_get_invoice_subscriptions($invoice); |
|
| 575 | + if (!$invoice->is_recurring() || !is_object($subscriptions)) { |
|
| 576 | 576 | return $actions; |
| 577 | 577 | } |
| 578 | 578 | |
| 579 | 579 | // Fetch item subscription. |
| 580 | - $args = array( |
|
| 580 | + $args = array( |
|
| 581 | 581 | 'invoice_in' => $invoice->is_parent() ? $invoice->get_id() : $invoice->get_parent_id(), |
| 582 | 582 | 'product_in' => $item->get_id(), |
| 583 | 583 | 'number' => 1, |
@@ -585,13 +585,13 @@ discard block |
||
| 585 | 585 | 'fields' => 'id', |
| 586 | 586 | ); |
| 587 | 587 | |
| 588 | - $subscription = new GetPaid_Subscriptions_Query( $args ); |
|
| 588 | + $subscription = new GetPaid_Subscriptions_Query($args); |
|
| 589 | 589 | $subscription = $subscription->get_results(); |
| 590 | 590 | |
| 591 | 591 | // In case we found a match... |
| 592 | - if ( ! empty( $subscription ) ) { |
|
| 593 | - $url = esc_url( add_query_arg( 'subscription', (int) $subscription[0], get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); |
|
| 594 | - $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 592 | + if (!empty($subscription)) { |
|
| 593 | + $url = esc_url(add_query_arg('subscription', (int) $subscription[0], get_permalink((int) wpinv_get_option('invoice_subscription_page')))); |
|
| 594 | + $actions['subscription'] = "<a href='$url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
| 595 | 595 | } |
| 596 | 596 | |
| 597 | 597 | return $actions; |
@@ -3,7 +3,7 @@ discard block |
||
| 3 | 3 | * Contains functions that display the subscriptions admin page. |
| 4 | 4 | */ |
| 5 | 5 | |
| 6 | -defined( 'ABSPATH' ) || exit; |
|
| 6 | +defined('ABSPATH') || exit; |
|
| 7 | 7 | |
| 8 | 8 | /** |
| 9 | 9 | * Render the Subscriptions page |
@@ -17,23 +17,23 @@ discard block |
||
| 17 | 17 | ?> |
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | - <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
|
| 20 | + <h1><?php echo esc_html(get_admin_page_title()); ?></h1> |
|
| 21 | 21 | <div class="bsui"> |
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | 25 | // Verify user permissions. |
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 26 | + if (!wpinv_current_user_can_manage_invoicing()) { |
|
| 27 | 27 | |
| 28 | 28 | aui()->alert( |
| 29 | 29 | array( |
| 30 | 30 | 'type' => 'danger', |
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 31 | + 'content' => __('You are not permitted to view this page.', 'invoicing'), |
|
| 32 | 32 | ), |
| 33 | 33 | true |
| 34 | 34 | ); |
| 35 | 35 | |
| 36 | - } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | + } elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
| 37 | 37 | |
| 38 | 38 | // Display a single subscription. |
| 39 | 39 | wpinv_recurring_subscription_details(); |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | <?php $subscribers_table->views(); ?> |
| 68 | 68 | <form id="subscribers-filter" class="bsui" method="get"> |
| 69 | 69 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 70 | - <?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?> |
|
| 70 | + <?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?> |
|
| 71 | 71 | <?php $subscribers_table->display(); ?> |
| 72 | 72 | </form> |
| 73 | 73 | <?php |
@@ -83,13 +83,13 @@ discard block |
||
| 83 | 83 | function wpinv_recurring_subscription_details() { |
| 84 | 84 | |
| 85 | 85 | // Fetch the subscription. |
| 86 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 87 | - if ( ! $sub->exists() ) { |
|
| 86 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 87 | + if (!$sub->exists()) { |
|
| 88 | 88 | |
| 89 | 89 | aui()->alert( |
| 90 | 90 | array( |
| 91 | 91 | 'type' => 'danger', |
| 92 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 92 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 93 | 93 | ), |
| 94 | 94 | true |
| 95 | 95 | ); |
@@ -98,32 +98,32 @@ discard block |
||
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | // Use metaboxes to display the subscription details. |
| 101 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 102 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 101 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
| 102 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
| 103 | 103 | |
| 104 | 104 | $subscription_id = $sub->get_id(); |
| 105 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 106 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 105 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
| 106 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
| 107 | 107 | |
| 108 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 109 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 108 | + if (1 < count($subscription_groups)) { |
|
| 109 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if ( ! empty( $subscription_group ) ) { |
|
| 113 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 112 | + if (!empty($subscription_group)) { |
|
| 113 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 116 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
| 117 | 117 | |
| 118 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 118 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
| 119 | 119 | |
| 120 | 120 | ?> |
| 121 | 121 | |
| 122 | - <form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>"> |
|
| 122 | + <form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>"> |
|
| 123 | 123 | |
| 124 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 125 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 126 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 124 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 125 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 126 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 127 | 127 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 128 | 128 | <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
| 129 | 129 | |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 132 | 132 | |
| 133 | 133 | <div id="postbox-container-1" class="postbox-container"> |
| 134 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 134 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 135 | 135 | </div> |
| 136 | 136 | |
| 137 | 137 | <div id="postbox-container-2" class="postbox-container"> |
| 138 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 139 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 138 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 139 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 140 | 140 | </div> |
| 141 | 141 | |
| 142 | 142 | </div> |
@@ -155,43 +155,43 @@ discard block |
||
| 155 | 155 | * |
| 156 | 156 | * @param WPInv_Subscription $sub |
| 157 | 157 | */ |
| 158 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 158 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 159 | 159 | |
| 160 | 160 | // Subscription items. |
| 161 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 162 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 161 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
| 162 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 163 | 163 | |
| 164 | 164 | // Prepare subscription detail columns. |
| 165 | 165 | $fields = apply_filters( |
| 166 | 166 | 'getpaid_subscription_admin_page_fields', |
| 167 | 167 | array( |
| 168 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 169 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 170 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 171 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 172 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 173 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 174 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 175 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 176 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 177 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 168 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 169 | + 'customer' => __('Customer', 'invoicing'), |
|
| 170 | + 'amount' => __('Amount', 'invoicing'), |
|
| 171 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 172 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
| 173 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 174 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
| 175 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
| 176 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
| 177 | + 'status' => __('Status', 'invoicing'), |
|
| 178 | 178 | ) |
| 179 | 179 | ); |
| 180 | 180 | |
| 181 | - if ( ! $sub->is_active() ) { |
|
| 181 | + if (!$sub->is_active()) { |
|
| 182 | 182 | |
| 183 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 184 | - unset( $fields['renews_on'] ); |
|
| 183 | + if (isset($fields['renews_on'])) { |
|
| 184 | + unset($fields['renews_on']); |
|
| 185 | 185 | } |
| 186 | 186 | |
| 187 | - if ( isset( $fields['gateway'] ) ) { |
|
| 188 | - unset( $fields['gateway'] ); |
|
| 187 | + if (isset($fields['gateway'])) { |
|
| 188 | + unset($fields['gateway']); |
|
| 189 | 189 | } |
| 190 | 190 | } |
| 191 | 191 | |
| 192 | 192 | $profile_id = $sub->get_profile_id(); |
| 193 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 194 | - unset( $fields['profile_id'] ); |
|
| 193 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 194 | + unset($fields['profile_id']); |
|
| 195 | 195 | } |
| 196 | 196 | |
| 197 | 197 | ?> |
@@ -199,16 +199,16 @@ discard block |
||
| 199 | 199 | <table class="table table-borderless" style="font-size: 14px;"> |
| 200 | 200 | <tbody> |
| 201 | 201 | |
| 202 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 202 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 203 | 203 | |
| 204 | - <tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>"> |
|
| 204 | + <tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>"> |
|
| 205 | 205 | |
| 206 | 206 | <th class="w-25" style="font-weight: 500;"> |
| 207 | - <?php echo esc_html( $label ); ?> |
|
| 207 | + <?php echo esc_html($label); ?> |
|
| 208 | 208 | </th> |
| 209 | 209 | |
| 210 | 210 | <td class="w-75 text-muted"> |
| 211 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?> |
|
| 211 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?> |
|
| 212 | 212 | </td> |
| 213 | 213 | |
| 214 | 214 | </tr> |
@@ -226,172 +226,172 @@ discard block |
||
| 226 | 226 | * |
| 227 | 227 | * @param WPInv_Subscription $subscription |
| 228 | 228 | */ |
| 229 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 229 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 230 | 230 | |
| 231 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 231 | + $username = __('(Missing User)', 'invoicing'); |
|
| 232 | 232 | |
| 233 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 234 | - if ( $user ) { |
|
| 233 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 234 | + if ($user) { |
|
| 235 | 235 | |
| 236 | 236 | $username = sprintf( |
| 237 | 237 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 238 | - absint( $user->ID ), |
|
| 239 | - ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 238 | + absint($user->ID), |
|
| 239 | + !empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email) |
|
| 240 | 240 | ); |
| 241 | 241 | |
| 242 | 242 | } |
| 243 | 243 | |
| 244 | - echo wp_kses_post( $username ); |
|
| 244 | + echo wp_kses_post($username); |
|
| 245 | 245 | } |
| 246 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 246 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 247 | 247 | |
| 248 | 248 | /** |
| 249 | 249 | * Displays the subscription amount. |
| 250 | 250 | * |
| 251 | 251 | * @param WPInv_Subscription $subscription |
| 252 | 252 | */ |
| 253 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 254 | - $amount = getpaid_get_formatted_subscription_amount( $subscription ); |
|
| 255 | - echo wp_kses_post( "<span>$amount</span>" ); |
|
| 253 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 254 | + $amount = getpaid_get_formatted_subscription_amount($subscription); |
|
| 255 | + echo wp_kses_post("<span>$amount</span>"); |
|
| 256 | 256 | } |
| 257 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 257 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 258 | 258 | |
| 259 | 259 | /** |
| 260 | 260 | * Displays the subscription id. |
| 261 | 261 | * |
| 262 | 262 | * @param WPInv_Subscription $subscription |
| 263 | 263 | */ |
| 264 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 264 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 265 | 265 | |
| 266 | 266 | printf( |
| 267 | 267 | '<a href="%s">#%s</a>', |
| 268 | - esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ), |
|
| 269 | - absint( $subscription->get_id() ) |
|
| 268 | + esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))), |
|
| 269 | + absint($subscription->get_id()) |
|
| 270 | 270 | ); |
| 271 | 271 | |
| 272 | 272 | } |
| 273 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 273 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 274 | 274 | |
| 275 | 275 | /** |
| 276 | 276 | * Displays the subscription renewal date. |
| 277 | 277 | * |
| 278 | 278 | * @param WPInv_Subscription $subscription |
| 279 | 279 | */ |
| 280 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 280 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 281 | 281 | |
| 282 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 282 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
| 283 | 283 | aui()->input( |
| 284 | 284 | array( |
| 285 | 285 | 'type' => 'text', |
| 286 | 286 | 'id' => 'wpinv_subscription_date_created', |
| 287 | 287 | 'name' => 'wpinv_subscription_date_created', |
| 288 | - 'label' => __( 'Start Date', 'invoicing' ), |
|
| 288 | + 'label' => __('Start Date', 'invoicing'), |
|
| 289 | 289 | 'label_type' => 'hidden', |
| 290 | 290 | 'placeholder' => 'YYYY-MM-DD', |
| 291 | - 'value' => esc_attr( $subscription->get_date_created( 'edit' ) ), |
|
| 291 | + 'value' => esc_attr($subscription->get_date_created('edit')), |
|
| 292 | 292 | 'no_wrap' => true, |
| 293 | 293 | 'size' => 'sm', |
| 294 | 294 | ), |
| 295 | 295 | true |
| 296 | 296 | ); |
| 297 | 297 | } else { |
| 298 | - echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 298 | + echo esc_html(getpaid_format_date_value($subscription->get_date_created())); |
|
| 299 | 299 | } |
| 300 | 300 | |
| 301 | 301 | } |
| 302 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 302 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 303 | 303 | |
| 304 | 304 | /** |
| 305 | 305 | * Displays the subscription renewal date. |
| 306 | 306 | * |
| 307 | 307 | * @param WPInv_Subscription $subscription |
| 308 | 308 | */ |
| 309 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 309 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 310 | 310 | |
| 311 | - if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) { |
|
| 311 | + if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) { |
|
| 312 | 312 | aui()->input( |
| 313 | 313 | array( |
| 314 | 314 | 'type' => 'text', |
| 315 | 315 | 'id' => 'wpinv_subscription_expiration', |
| 316 | 316 | 'name' => 'wpinv_subscription_expiration', |
| 317 | - 'label' => __( 'Renews On', 'invoicing' ), |
|
| 317 | + 'label' => __('Renews On', 'invoicing'), |
|
| 318 | 318 | 'label_type' => 'hidden', |
| 319 | 319 | 'placeholder' => 'YYYY-MM-DD', |
| 320 | - 'value' => esc_attr( $subscription->get_expiration( 'edit' ) ), |
|
| 320 | + 'value' => esc_attr($subscription->get_expiration('edit')), |
|
| 321 | 321 | 'no_wrap' => true, |
| 322 | 322 | 'size' => 'sm', |
| 323 | 323 | ), |
| 324 | 324 | true |
| 325 | 325 | ); |
| 326 | 326 | } else { |
| 327 | - echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) ); |
|
| 327 | + echo esc_html(getpaid_format_date_value($subscription->get_expiration())); |
|
| 328 | 328 | } |
| 329 | 329 | } |
| 330 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 330 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 331 | 331 | |
| 332 | 332 | /** |
| 333 | 333 | * Displays the subscription renewal count. |
| 334 | 334 | * |
| 335 | 335 | * @param WPInv_Subscription $subscription |
| 336 | 336 | */ |
| 337 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 337 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 338 | 338 | $max_bills = $subscription->get_bill_times(); |
| 339 | - echo ( (int) $subscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 339 | + echo ((int) $subscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
| 340 | 340 | } |
| 341 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 341 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 342 | 342 | /** |
| 343 | 343 | * Displays the subscription item. |
| 344 | 344 | * |
| 345 | 345 | * @param WPInv_Subscription $subscription |
| 346 | 346 | * @param false|array $subscription_group |
| 347 | 347 | */ |
| 348 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
| 348 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
| 349 | 349 | |
| 350 | - if ( empty( $subscription_group ) ) { |
|
| 351 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) ); |
|
| 350 | + if (empty($subscription_group)) { |
|
| 351 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id())); |
|
| 352 | 352 | return; |
| 353 | 353 | } |
| 354 | 354 | |
| 355 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 356 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 355 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 356 | + echo wp_kses_post(implode(' | ', $markup)); |
|
| 357 | 357 | |
| 358 | 358 | } |
| 359 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
| 359 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
| 360 | 360 | |
| 361 | 361 | /** |
| 362 | 362 | * Displays the subscription gateway. |
| 363 | 363 | * |
| 364 | 364 | * @param WPInv_Subscription $subscription |
| 365 | 365 | */ |
| 366 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 366 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 367 | 367 | |
| 368 | 368 | $gateway = $subscription->get_gateway(); |
| 369 | 369 | |
| 370 | - if ( ! empty( $gateway ) ) { |
|
| 371 | - echo esc_html( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 370 | + if (!empty($gateway)) { |
|
| 371 | + echo esc_html(wpinv_get_gateway_admin_label($gateway)); |
|
| 372 | 372 | } else { |
| 373 | 373 | echo '—'; |
| 374 | 374 | } |
| 375 | 375 | |
| 376 | 376 | } |
| 377 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 377 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 378 | 378 | |
| 379 | 379 | /** |
| 380 | 380 | * Displays the subscription status. |
| 381 | 381 | * |
| 382 | 382 | * @param WPInv_Subscription $subscription |
| 383 | 383 | */ |
| 384 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 385 | - echo wp_kses_post( $subscription->get_status_label_html() ); |
|
| 384 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 385 | + echo wp_kses_post($subscription->get_status_label_html()); |
|
| 386 | 386 | } |
| 387 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 387 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 388 | 388 | |
| 389 | 389 | /** |
| 390 | 390 | * Displays the subscription profile id. |
| 391 | 391 | * |
| 392 | 392 | * @param WPInv_Subscription $subscription |
| 393 | 393 | */ |
| 394 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 394 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 395 | 395 | |
| 396 | 396 | $profile_id = $subscription->get_profile_id(); |
| 397 | 397 | |
@@ -400,10 +400,10 @@ discard block |
||
| 400 | 400 | 'type' => 'text', |
| 401 | 401 | 'id' => 'wpinv_subscription_profile_id', |
| 402 | 402 | 'name' => 'wpinv_subscription_profile_id', |
| 403 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 403 | + 'label' => __('Profile Id', 'invoicing'), |
|
| 404 | 404 | 'label_type' => 'hidden', |
| 405 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 406 | - 'value' => esc_attr( $profile_id ), |
|
| 405 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
| 406 | + 'value' => esc_attr($profile_id), |
|
| 407 | 407 | 'input_group_right' => '', |
| 408 | 408 | 'no_wrap' => true, |
| 409 | 409 | 'size' => 'sm', |
@@ -411,20 +411,20 @@ discard block |
||
| 411 | 411 | true |
| 412 | 412 | ); |
| 413 | 413 | |
| 414 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 415 | - if ( ! empty( $url ) ) { |
|
| 416 | - echo ' <a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 414 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
| 415 | + if (!empty($url)) { |
|
| 416 | + echo ' <a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 417 | 417 | } |
| 418 | 418 | |
| 419 | 419 | } |
| 420 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 420 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 421 | 421 | |
| 422 | 422 | /** |
| 423 | 423 | * Displays the subscriptions update metabox. |
| 424 | 424 | * |
| 425 | 425 | * @param WPInv_Subscription $subscription |
| 426 | 426 | */ |
| 427 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 427 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 428 | 428 | |
| 429 | 429 | ?> |
| 430 | 430 | <div class="mt-3"> |
@@ -437,10 +437,10 @@ discard block |
||
| 437 | 437 | 'id' => 'subscription_status_update_select', |
| 438 | 438 | 'required' => true, |
| 439 | 439 | 'no_wrap' => false, |
| 440 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 441 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 440 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 441 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 442 | 442 | 'select2' => true, |
| 443 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 443 | + 'value' => $subscription->get_status('edit'), |
|
| 444 | 444 | ), |
| 445 | 445 | true |
| 446 | 446 | ); |
@@ -449,14 +449,14 @@ discard block |
||
| 449 | 449 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 450 | 450 | |
| 451 | 451 | <?php |
| 452 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 452 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 453 | 453 | |
| 454 | - $url = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ); |
|
| 455 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 456 | - $title = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' ); |
|
| 454 | + $url = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'); |
|
| 455 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 456 | + $title = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing'); |
|
| 457 | 457 | |
| 458 | - if ( $subscription->is_active() ) { |
|
| 459 | - echo "<a href='" . esc_url( $url ) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr( $title ) . "\")'>" . esc_html( $anchor ) . "</a>"; |
|
| 458 | + if ($subscription->is_active()) { |
|
| 459 | + echo "<a href='" . esc_url($url) . "' class='float-right text-muted' onclick='return confirm(\"" . esc_attr($title) . "\")'>" . esc_html($anchor) . "</a>"; |
|
| 460 | 460 | } |
| 461 | 461 | |
| 462 | 462 | echo '</div></div>'; |
@@ -468,44 +468,44 @@ discard block |
||
| 468 | 468 | * @param WPInv_Subscription $subscription |
| 469 | 469 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
| 470 | 470 | */ |
| 471 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
| 471 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
| 472 | 472 | |
| 473 | 473 | $columns = apply_filters( |
| 474 | 474 | 'getpaid_subscription_related_invoices_columns', |
| 475 | 475 | array( |
| 476 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 477 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 478 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 479 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 480 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 476 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 477 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 478 | + 'date' => __('Date', 'invoicing'), |
|
| 479 | + 'status' => __('Status', 'invoicing'), |
|
| 480 | + 'total' => __('Total', 'invoicing'), |
|
| 481 | 481 | ), |
| 482 | 482 | $subscription |
| 483 | 483 | ); |
| 484 | 484 | |
| 485 | 485 | // Prepare the invoices. |
| 486 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 486 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
| 487 | 487 | $parent = $subscription->get_parent_invoice(); |
| 488 | 488 | |
| 489 | - if ( $parent->exists() ) { |
|
| 490 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 489 | + if ($parent->exists()) { |
|
| 490 | + $payments = array_merge(array($parent), $payments); |
|
| 491 | 491 | } |
| 492 | 492 | |
| 493 | 493 | $table_class = 'w-100 bg-white'; |
| 494 | 494 | |
| 495 | - if ( ! is_admin() ) { |
|
| 495 | + if (!is_admin()) { |
|
| 496 | 496 | $table_class = 'table table-bordered'; |
| 497 | 497 | } |
| 498 | 498 | |
| 499 | 499 | ?> |
| 500 | 500 | <div class="m-0" style="overflow: auto;"> |
| 501 | 501 | |
| 502 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 502 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 503 | 503 | |
| 504 | 504 | <thead> |
| 505 | 505 | <tr> |
| 506 | 506 | <?php |
| 507 | - foreach ( $columns as $key => $label ) { |
|
| 508 | - echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 507 | + foreach ($columns as $key => $label) { |
|
| 508 | + echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 509 | 509 | } |
| 510 | 510 | ?> |
| 511 | 511 | </tr> |
@@ -513,71 +513,71 @@ discard block |
||
| 513 | 513 | |
| 514 | 514 | <tbody> |
| 515 | 515 | |
| 516 | - <?php if ( empty( $payments ) ) : ?> |
|
| 516 | + <?php if (empty($payments)) : ?> |
|
| 517 | 517 | <tr> |
| 518 | - <td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted"> |
|
| 519 | - <?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 518 | + <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
|
| 519 | + <?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 520 | 520 | </td> |
| 521 | 521 | </tr> |
| 522 | 522 | <?php endif; ?> |
| 523 | 523 | |
| 524 | 524 | <?php |
| 525 | 525 | |
| 526 | - foreach ( $payments as $payment ) : |
|
| 526 | + foreach ($payments as $payment) : |
|
| 527 | 527 | |
| 528 | 528 | // Ensure that we have an invoice. |
| 529 | - $payment = new WPInv_Invoice( $payment ); |
|
| 529 | + $payment = new WPInv_Invoice($payment); |
|
| 530 | 530 | |
| 531 | 531 | // Abort if the invoice is invalid... |
| 532 | - if ( ! $payment->exists() ) { |
|
| 532 | + if (!$payment->exists()) { |
|
| 533 | 533 | continue; |
| 534 | 534 | } |
| 535 | 535 | |
| 536 | 536 | // ... or belongs to a different subscription. |
| 537 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 537 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
| 538 | 538 | continue; |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | 541 | echo '<tr>'; |
| 542 | 542 | |
| 543 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 543 | + foreach (array_keys($columns) as $key) { |
|
| 544 | 544 | |
| 545 | 545 | echo "<td class='p-2 text-left'>"; |
| 546 | 546 | |
| 547 | - switch ( $key ) { |
|
| 547 | + switch ($key) { |
|
| 548 | 548 | |
| 549 | 549 | case 'total': |
| 550 | 550 | echo '<strong>'; |
| 551 | - wpinv_the_price( $payment->get_total(), $payment->get_currency() ); |
|
| 551 | + wpinv_the_price($payment->get_total(), $payment->get_currency()); |
|
| 552 | 552 | echo '</strong>'; |
| 553 | 553 | break; |
| 554 | 554 | |
| 555 | 555 | case 'relationship': |
| 556 | - echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' ); |
|
| 556 | + echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing'); |
|
| 557 | 557 | break; |
| 558 | 558 | |
| 559 | 559 | case 'date': |
| 560 | - echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) ); |
|
| 560 | + echo esc_html(getpaid_format_date_value($payment->get_date_created())); |
|
| 561 | 561 | break; |
| 562 | 562 | |
| 563 | 563 | case 'status': |
| 564 | 564 | $status = $payment->get_status_nicename(); |
| 565 | - if ( is_admin() ) { |
|
| 565 | + if (is_admin()) { |
|
| 566 | 566 | $status = $payment->get_status_label_html(); |
| 567 | 567 | } |
| 568 | 568 | |
| 569 | - echo wp_kses_post( $status ); |
|
| 569 | + echo wp_kses_post($status); |
|
| 570 | 570 | break; |
| 571 | 571 | |
| 572 | 572 | case 'invoice': |
| 573 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 573 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 574 | 574 | |
| 575 | - if ( ! is_admin() ) { |
|
| 576 | - $link = esc_url( $payment->get_view_url() ); |
|
| 575 | + if (!is_admin()) { |
|
| 576 | + $link = esc_url($payment->get_view_url()); |
|
| 577 | 577 | } |
| 578 | 578 | |
| 579 | - $invoice = esc_html( $payment->get_number() ); |
|
| 580 | - echo wp_kses_post( "<a href='$link'>$invoice</a>" ); |
|
| 579 | + $invoice = esc_html($payment->get_number()); |
|
| 580 | + echo wp_kses_post("<a href='$link'>$invoice</a>"); |
|
| 581 | 581 | break; |
| 582 | 582 | } |
| 583 | 583 | |
@@ -604,12 +604,12 @@ discard block |
||
| 604 | 604 | * |
| 605 | 605 | * @param WPInv_Subscription $subscription |
| 606 | 606 | */ |
| 607 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
| 607 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
| 608 | 608 | |
| 609 | 609 | // Fetch the subscription group. |
| 610 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 610 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
| 611 | 611 | |
| 612 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 612 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
| 613 | 613 | return; |
| 614 | 614 | } |
| 615 | 615 | |
@@ -617,12 +617,12 @@ discard block |
||
| 617 | 617 | $columns = apply_filters( |
| 618 | 618 | 'getpaid_subscription_item_details_columns', |
| 619 | 619 | array( |
| 620 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 621 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 622 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 623 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 620 | + 'item_name' => __('Item', 'invoicing'), |
|
| 621 | + 'price' => __('Price', 'invoicing'), |
|
| 622 | + 'tax' => __('Tax', 'invoicing'), |
|
| 623 | + 'discount' => __('Discount', 'invoicing'), |
|
| 624 | 624 | //'initial' => __( 'Initial Amount', 'invoicing' ), |
| 625 | - 'recurring' => __( 'Subtotal', 'invoicing' ), |
|
| 625 | + 'recurring' => __('Subtotal', 'invoicing'), |
|
| 626 | 626 | ), |
| 627 | 627 | $subscription |
| 628 | 628 | ); |
@@ -631,27 +631,27 @@ discard block |
||
| 631 | 631 | |
| 632 | 632 | $invoice = $subscription->get_parent_invoice(); |
| 633 | 633 | |
| 634 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 635 | - unset( $columns['tax'] ); |
|
| 634 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
| 635 | + unset($columns['tax']); |
|
| 636 | 636 | } |
| 637 | 637 | |
| 638 | 638 | $table_class = 'w-100 bg-white'; |
| 639 | 639 | |
| 640 | - if ( ! is_admin() ) { |
|
| 640 | + if (!is_admin()) { |
|
| 641 | 641 | $table_class = 'table table-bordered'; |
| 642 | 642 | } |
| 643 | 643 | |
| 644 | 644 | ?> |
| 645 | 645 | <div class="m-0" style="overflow: auto;"> |
| 646 | 646 | |
| 647 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 647 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 648 | 648 | |
| 649 | 649 | <thead> |
| 650 | 650 | <tr> |
| 651 | 651 | <?php |
| 652 | 652 | |
| 653 | - foreach ( $columns as $key => $label ) { |
|
| 654 | - echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 653 | + foreach ($columns as $key => $label) { |
|
| 654 | + echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 655 | 655 | } |
| 656 | 656 | ?> |
| 657 | 657 | </tr> |
@@ -661,48 +661,48 @@ discard block |
||
| 661 | 661 | |
| 662 | 662 | <?php |
| 663 | 663 | |
| 664 | - foreach ( $subscription_group['items'] as $subscription_group_item ) : |
|
| 664 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
| 665 | 665 | |
| 666 | 666 | echo '<tr>'; |
| 667 | 667 | |
| 668 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 668 | + foreach (array_keys($columns) as $key) { |
|
| 669 | 669 | |
| 670 | 670 | $class = 'text-left'; |
| 671 | 671 | |
| 672 | 672 | echo "<td class='p-2 text-left'>"; |
| 673 | 673 | |
| 674 | - switch ( $key ) { |
|
| 674 | + switch ($key) { |
|
| 675 | 675 | |
| 676 | 676 | case 'item_name': |
| 677 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 678 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 677 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
| 678 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
| 679 | 679 | |
| 680 | - if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) { |
|
| 681 | - echo esc_html( $item_name ); |
|
| 680 | + if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) { |
|
| 681 | + echo esc_html($item_name); |
|
| 682 | 682 | } else { |
| 683 | - printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] ); |
|
| 683 | + printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']); |
|
| 684 | 684 | } |
| 685 | 685 | |
| 686 | 686 | break; |
| 687 | 687 | |
| 688 | 688 | case 'price': |
| 689 | - wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() ); |
|
| 689 | + wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency()); |
|
| 690 | 690 | break; |
| 691 | 691 | |
| 692 | 692 | case 'tax': |
| 693 | - wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 693 | + wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
| 694 | 694 | break; |
| 695 | 695 | |
| 696 | 696 | case 'discount': |
| 697 | - wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 697 | + wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
| 698 | 698 | break; |
| 699 | 699 | |
| 700 | 700 | case 'initial': |
| 701 | - wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ); |
|
| 701 | + wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()); |
|
| 702 | 702 | break; |
| 703 | 703 | |
| 704 | 704 | case 'recurring': |
| 705 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' ); |
|
| 705 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'); |
|
| 706 | 706 | break; |
| 707 | 707 | |
| 708 | 708 | } |
@@ -715,24 +715,24 @@ discard block |
||
| 715 | 715 | |
| 716 | 716 | endforeach; |
| 717 | 717 | |
| 718 | - foreach ( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 718 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
| 719 | 719 | |
| 720 | 720 | echo '<tr>'; |
| 721 | 721 | |
| 722 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 722 | + foreach (array_keys($columns) as $key) { |
|
| 723 | 723 | |
| 724 | 724 | $class = 'text-left'; |
| 725 | 725 | |
| 726 | 726 | echo "<td class='p-2 text-left'>"; |
| 727 | 727 | |
| 728 | - switch ( $key ) { |
|
| 728 | + switch ($key) { |
|
| 729 | 729 | |
| 730 | 730 | case 'item_name': |
| 731 | - echo esc_html( $subscription_group_fee['name'] ); |
|
| 731 | + echo esc_html($subscription_group_fee['name']); |
|
| 732 | 732 | break; |
| 733 | 733 | |
| 734 | 734 | case 'price': |
| 735 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 735 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 736 | 736 | break; |
| 737 | 737 | |
| 738 | 738 | case 'tax': |
@@ -744,11 +744,11 @@ discard block |
||
| 744 | 744 | break; |
| 745 | 745 | |
| 746 | 746 | case 'initial': |
| 747 | - wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 747 | + wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 748 | 748 | break; |
| 749 | 749 | |
| 750 | 750 | case 'recurring': |
| 751 | - echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' ); |
|
| 751 | + echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'); |
|
| 752 | 752 | break; |
| 753 | 753 | |
| 754 | 754 | } |
@@ -777,12 +777,12 @@ discard block |
||
| 777 | 777 | * @param WPInv_Subscription $subscription |
| 778 | 778 | * @param bool $skip_current |
| 779 | 779 | */ |
| 780 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
| 780 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
| 781 | 781 | |
| 782 | 782 | // Fetch the subscription groups. |
| 783 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 783 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
| 784 | 784 | |
| 785 | - if ( empty( $subscription_groups ) ) { |
|
| 785 | + if (empty($subscription_groups)) { |
|
| 786 | 786 | return; |
| 787 | 787 | } |
| 788 | 788 | |
@@ -790,37 +790,37 @@ discard block |
||
| 790 | 790 | $columns = apply_filters( |
| 791 | 791 | 'getpaid_subscription_related_subscriptions_columns', |
| 792 | 792 | array( |
| 793 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 794 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 795 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 796 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 797 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 798 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 793 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 794 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 795 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
| 796 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 797 | + 'item' => __('Items', 'invoicing'), |
|
| 798 | + 'status' => __('Status', 'invoicing'), |
|
| 799 | 799 | ), |
| 800 | 800 | $subscription |
| 801 | 801 | ); |
| 802 | 802 | |
| 803 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 804 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 803 | + if ($subscription->get_status() == 'pending') { |
|
| 804 | + unset($columns['start_date'], $columns['renewal_date']); |
|
| 805 | 805 | } |
| 806 | 806 | |
| 807 | 807 | $table_class = 'w-100 bg-white'; |
| 808 | 808 | |
| 809 | - if ( ! is_admin() ) { |
|
| 809 | + if (!is_admin()) { |
|
| 810 | 810 | $table_class = 'table table-bordered'; |
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | ?> |
| 814 | 814 | <div class="m-0" style="overflow: auto;"> |
| 815 | 815 | |
| 816 | - <table class="<?php echo esc_attr( $table_class ); ?>"> |
|
| 816 | + <table class="<?php echo esc_attr($table_class); ?>"> |
|
| 817 | 817 | |
| 818 | 818 | <thead> |
| 819 | 819 | <tr> |
| 820 | 820 | <?php |
| 821 | 821 | |
| 822 | - foreach ( $columns as $key => $label ) { |
|
| 823 | - echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>"; |
|
| 822 | + foreach ($columns as $key => $label) { |
|
| 823 | + echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>"; |
|
| 824 | 824 | } |
| 825 | 825 | ?> |
| 826 | 826 | </tr> |
@@ -830,62 +830,62 @@ discard block |
||
| 830 | 830 | |
| 831 | 831 | <?php |
| 832 | 832 | |
| 833 | - foreach ( $subscription_groups as $subscription_group ) : |
|
| 833 | + foreach ($subscription_groups as $subscription_group) : |
|
| 834 | 834 | |
| 835 | 835 | // Do not list current subscription. |
| 836 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 836 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
| 837 | 837 | continue; |
| 838 | 838 | } |
| 839 | 839 | |
| 840 | 840 | // Ensure the subscription exists. |
| 841 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 841 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
| 842 | 842 | |
| 843 | - if ( ! $_suscription->exists() ) { |
|
| 843 | + if (!$_suscription->exists()) { |
|
| 844 | 844 | continue; |
| 845 | 845 | } |
| 846 | 846 | |
| 847 | 847 | echo '<tr>'; |
| 848 | 848 | |
| 849 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 849 | + foreach (array_keys($columns) as $key) { |
|
| 850 | 850 | |
| 851 | 851 | $class = 'text-left'; |
| 852 | 852 | |
| 853 | 853 | echo "<td class='p-2 text-left'>"; |
| 854 | 854 | |
| 855 | - switch ( $key ) { |
|
| 855 | + switch ($key) { |
|
| 856 | 856 | |
| 857 | 857 | case 'status': |
| 858 | - echo wp_kses_post( $_suscription->get_status_label_html() ); |
|
| 858 | + echo wp_kses_post($_suscription->get_status_label_html()); |
|
| 859 | 859 | break; |
| 860 | 860 | |
| 861 | 861 | case 'item': |
| 862 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 863 | - echo wp_kses_post( implode( ' | ', $markup ) ); |
|
| 862 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 863 | + echo wp_kses_post(implode(' | ', $markup)); |
|
| 864 | 864 | break; |
| 865 | 865 | |
| 866 | 866 | case 'renewals': |
| 867 | 867 | $max_bills = $_suscription->get_bill_times(); |
| 868 | - echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '∞' : (int) $max_bills ); |
|
| 868 | + echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '∞' : (int) $max_bills); |
|
| 869 | 869 | break; |
| 870 | 870 | |
| 871 | 871 | case 'renewal_date': |
| 872 | - echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '—'; |
|
| 872 | + echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '—'; |
|
| 873 | 873 | break; |
| 874 | 874 | |
| 875 | 875 | case 'start_date': |
| 876 | - echo 'pending' == $_suscription->get_status() ? '—' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) ); |
|
| 876 | + echo 'pending' == $_suscription->get_status() ? '—' : esc_html(getpaid_format_date_value($_suscription->get_date_created())); |
|
| 877 | 877 | break; |
| 878 | 878 | |
| 879 | 879 | case 'subscription': |
| 880 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 880 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
| 881 | 881 | printf( |
| 882 | 882 | '%1$s#%2$s%3$s', |
| 883 | - '<a href="' . esc_url( $url ) . '">', |
|
| 884 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 883 | + '<a href="' . esc_url($url) . '">', |
|
| 884 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
| 885 | 885 | '</a>' |
| 886 | 886 | ); |
| 887 | 887 | |
| 888 | - echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) ); |
|
| 888 | + echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription)); |
|
| 889 | 889 | break; |
| 890 | 890 | |
| 891 | 891 | } |
@@ -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 ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) { |
|
| 80 | - $this->set_id( $subscription_id ); |
|
| 81 | - } elseif ( ! empty( $subscription->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 ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) { |
|
| 80 | + $this->set_id($subscription_id); |
|
| 81 | + } elseif (!empty($subscription->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 | } |
@@ -162,9 +162,9 @@ discard block |
||
| 162 | 162 | 'getpaid_subscriptions' => $this->get_id(), |
| 163 | 163 | ); |
| 164 | 164 | |
| 165 | - foreach ( $caches as $cache => $value ) { |
|
| 166 | - if ( '' !== $value && false !== $value ) { |
|
| 167 | - wp_cache_delete( $value, $cache ); |
|
| 165 | + foreach ($caches as $cache => $value) { |
|
| 166 | + if ('' !== $value && false !== $value) { |
|
| 167 | + wp_cache_delete($value, $cache); |
|
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } |
@@ -172,8 +172,8 @@ discard block |
||
| 172 | 172 | /** |
| 173 | 173 | * Checks if a subscription key is set. |
| 174 | 174 | */ |
| 175 | - public function _isset( $key ) { |
|
| 176 | - return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" ); |
|
| 175 | + public function _isset($key) { |
|
| 176 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
| 177 | 177 | } |
| 178 | 178 | |
| 179 | 179 | /* |
@@ -198,8 +198,8 @@ discard block |
||
| 198 | 198 | * @param string $context View or edit context. |
| 199 | 199 | * @return int |
| 200 | 200 | */ |
| 201 | - public function get_customer_id( $context = 'view' ) { |
|
| 202 | - return (int) $this->get_prop( 'customer_id', $context ); |
|
| 201 | + public function get_customer_id($context = 'view') { |
|
| 202 | + return (int) $this->get_prop('customer_id', $context); |
|
| 203 | 203 | } |
| 204 | 204 | |
| 205 | 205 | /** |
@@ -209,8 +209,8 @@ discard block |
||
| 209 | 209 | * @param string $context View or edit context. |
| 210 | 210 | * @return WP_User|false WP_User object on success, false on failure. |
| 211 | 211 | */ |
| 212 | - public function get_customer( $context = 'view' ) { |
|
| 213 | - return get_userdata( $this->get_customer_id( $context ) ); |
|
| 212 | + public function get_customer($context = 'view') { |
|
| 213 | + return get_userdata($this->get_customer_id($context)); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -220,8 +220,8 @@ discard block |
||
| 220 | 220 | * @param string $context View or edit context. |
| 221 | 221 | * @return int |
| 222 | 222 | */ |
| 223 | - public function get_parent_invoice_id( $context = 'view' ) { |
|
| 224 | - return (int) $this->get_prop( 'parent_payment_id', $context ); |
|
| 223 | + public function get_parent_invoice_id($context = 'view') { |
|
| 224 | + return (int) $this->get_prop('parent_payment_id', $context); |
|
| 225 | 225 | } |
| 226 | 226 | |
| 227 | 227 | /** |
@@ -231,8 +231,8 @@ discard block |
||
| 231 | 231 | * @param string $context View or edit context. |
| 232 | 232 | * @return int |
| 233 | 233 | */ |
| 234 | - public function get_parent_payment_id( $context = 'view' ) { |
|
| 235 | - return $this->get_parent_invoice_id( $context ); |
|
| 234 | + public function get_parent_payment_id($context = 'view') { |
|
| 235 | + return $this->get_parent_invoice_id($context); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | /** |
@@ -241,8 +241,8 @@ discard block |
||
| 241 | 241 | * @since 1.0.0 |
| 242 | 242 | * @return int |
| 243 | 243 | */ |
| 244 | - public function get_original_payment_id( $context = 'view' ) { |
|
| 245 | - return $this->get_parent_invoice_id( $context ); |
|
| 244 | + public function get_original_payment_id($context = 'view') { |
|
| 245 | + return $this->get_parent_invoice_id($context); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | /** |
@@ -252,8 +252,8 @@ discard block |
||
| 252 | 252 | * @param string $context View or edit context. |
| 253 | 253 | * @return WPInv_Invoice |
| 254 | 254 | */ |
| 255 | - public function get_parent_invoice( $context = 'view' ) { |
|
| 256 | - return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) ); |
|
| 255 | + public function get_parent_invoice($context = 'view') { |
|
| 256 | + return new WPInv_Invoice($this->get_parent_invoice_id($context)); |
|
| 257 | 257 | } |
| 258 | 258 | |
| 259 | 259 | /** |
@@ -263,8 +263,8 @@ discard block |
||
| 263 | 263 | * @param string $context View or edit context. |
| 264 | 264 | * @return WPInv_Invoice |
| 265 | 265 | */ |
| 266 | - public function get_parent_payment( $context = 'view' ) { |
|
| 267 | - return $this->get_parent_invoice( $context ); |
|
| 266 | + public function get_parent_payment($context = 'view') { |
|
| 267 | + return $this->get_parent_invoice($context); |
|
| 268 | 268 | } |
| 269 | 269 | |
| 270 | 270 | /** |
@@ -274,8 +274,8 @@ discard block |
||
| 274 | 274 | * @param string $context View or edit context. |
| 275 | 275 | * @return int |
| 276 | 276 | */ |
| 277 | - public function get_product_id( $context = 'view' ) { |
|
| 278 | - return (int) $this->get_prop( 'product_id', $context ); |
|
| 277 | + public function get_product_id($context = 'view') { |
|
| 278 | + return (int) $this->get_prop('product_id', $context); |
|
| 279 | 279 | } |
| 280 | 280 | |
| 281 | 281 | /** |
@@ -285,8 +285,8 @@ discard block |
||
| 285 | 285 | * @param string $context View or edit context. |
| 286 | 286 | * @return WPInv_Item |
| 287 | 287 | */ |
| 288 | - public function get_product( $context = 'view' ) { |
|
| 289 | - return new WPInv_Item( $this->get_product_id( $context ) ); |
|
| 288 | + public function get_product($context = 'view') { |
|
| 289 | + return new WPInv_Item($this->get_product_id($context)); |
|
| 290 | 290 | } |
| 291 | 291 | |
| 292 | 292 | /** |
@@ -298,8 +298,8 @@ discard block |
||
| 298 | 298 | * @param string $context View or edit context. |
| 299 | 299 | * @return string |
| 300 | 300 | */ |
| 301 | - public function get_gateway( $context = 'view' ) { |
|
| 302 | - return $this->get_parent_invoice( $context )->get_gateway(); |
|
| 301 | + public function get_gateway($context = 'view') { |
|
| 302 | + return $this->get_parent_invoice($context)->get_gateway(); |
|
| 303 | 303 | } |
| 304 | 304 | |
| 305 | 305 | /** |
@@ -309,8 +309,8 @@ discard block |
||
| 309 | 309 | * @param string $context View or edit context. |
| 310 | 310 | * @return string |
| 311 | 311 | */ |
| 312 | - public function get_period( $context = 'view' ) { |
|
| 313 | - return $this->get_prop( 'period', $context ); |
|
| 312 | + public function get_period($context = 'view') { |
|
| 313 | + return $this->get_prop('period', $context); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | /** |
@@ -320,8 +320,8 @@ discard block |
||
| 320 | 320 | * @param string $context View or edit context. |
| 321 | 321 | * @return int |
| 322 | 322 | */ |
| 323 | - public function get_frequency( $context = 'view' ) { |
|
| 324 | - return (int) $this->get_prop( 'frequency', $context ); |
|
| 323 | + public function get_frequency($context = 'view') { |
|
| 324 | + return (int) $this->get_prop('frequency', $context); |
|
| 325 | 325 | } |
| 326 | 326 | |
| 327 | 327 | /** |
@@ -331,8 +331,8 @@ discard block |
||
| 331 | 331 | * @param string $context View or edit context. |
| 332 | 332 | * @return float |
| 333 | 333 | */ |
| 334 | - public function get_initial_amount( $context = 'view' ) { |
|
| 335 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) ); |
|
| 334 | + public function get_initial_amount($context = 'view') { |
|
| 335 | + return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context)); |
|
| 336 | 336 | } |
| 337 | 337 | |
| 338 | 338 | /** |
@@ -342,8 +342,8 @@ discard block |
||
| 342 | 342 | * @param string $context View or edit context. |
| 343 | 343 | * @return float |
| 344 | 344 | */ |
| 345 | - public function get_recurring_amount( $context = 'view' ) { |
|
| 346 | - return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) ); |
|
| 345 | + public function get_recurring_amount($context = 'view') { |
|
| 346 | + return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context)); |
|
| 347 | 347 | } |
| 348 | 348 | |
| 349 | 349 | /** |
@@ -353,8 +353,8 @@ discard block |
||
| 353 | 353 | * @param string $context View or edit context. |
| 354 | 354 | * @return int |
| 355 | 355 | */ |
| 356 | - public function get_bill_times( $context = 'view' ) { |
|
| 357 | - return (int) $this->get_prop( 'bill_times', $context ); |
|
| 356 | + public function get_bill_times($context = 'view') { |
|
| 357 | + return (int) $this->get_prop('bill_times', $context); |
|
| 358 | 358 | } |
| 359 | 359 | |
| 360 | 360 | /** |
@@ -364,8 +364,8 @@ discard block |
||
| 364 | 364 | * @param string $context View or edit context. |
| 365 | 365 | * @return string |
| 366 | 366 | */ |
| 367 | - public function get_transaction_id( $context = 'view' ) { |
|
| 368 | - return $this->get_prop( 'transaction_id', $context ); |
|
| 367 | + public function get_transaction_id($context = 'view') { |
|
| 368 | + return $this->get_prop('transaction_id', $context); |
|
| 369 | 369 | } |
| 370 | 370 | |
| 371 | 371 | /** |
@@ -375,8 +375,8 @@ discard block |
||
| 375 | 375 | * @param string $context View or edit context. |
| 376 | 376 | * @return string |
| 377 | 377 | */ |
| 378 | - public function get_created( $context = 'view' ) { |
|
| 379 | - return $this->get_prop( 'created', $context ); |
|
| 378 | + public function get_created($context = 'view') { |
|
| 379 | + return $this->get_prop('created', $context); |
|
| 380 | 380 | } |
| 381 | 381 | |
| 382 | 382 | /** |
@@ -386,8 +386,8 @@ discard block |
||
| 386 | 386 | * @param string $context View or edit context. |
| 387 | 387 | * @return string |
| 388 | 388 | */ |
| 389 | - public function get_date_created( $context = 'view' ) { |
|
| 390 | - return $this->get_created( $context ); |
|
| 389 | + public function get_date_created($context = 'view') { |
|
| 390 | + return $this->get_created($context); |
|
| 391 | 391 | } |
| 392 | 392 | |
| 393 | 393 | /** |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | */ |
| 399 | 399 | public function get_time_created() { |
| 400 | 400 | $created = $this->get_date_created(); |
| 401 | - return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) ); |
|
| 401 | + return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp')); |
|
| 402 | 402 | } |
| 403 | 403 | |
| 404 | 404 | /** |
@@ -408,11 +408,11 @@ discard block |
||
| 408 | 408 | * @param string $context View or edit context. |
| 409 | 409 | * @return string |
| 410 | 410 | */ |
| 411 | - public function get_date_created_gmt( $context = 'view' ) { |
|
| 412 | - $date = $this->get_date_created( $context ); |
|
| 411 | + public function get_date_created_gmt($context = 'view') { |
|
| 412 | + $date = $this->get_date_created($context); |
|
| 413 | 413 | |
| 414 | - if ( $date ) { |
|
| 415 | - $date = get_gmt_from_date( $date ); |
|
| 414 | + if ($date) { |
|
| 415 | + $date = get_gmt_from_date($date); |
|
| 416 | 416 | } |
| 417 | 417 | return $date; |
| 418 | 418 | } |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | * @param string $context View or edit context. |
| 425 | 425 | * @return string |
| 426 | 426 | */ |
| 427 | - public function get_next_renewal_date( $context = 'view' ) { |
|
| 428 | - return $this->get_prop( 'expiration', $context ); |
|
| 427 | + public function get_next_renewal_date($context = 'view') { |
|
| 428 | + return $this->get_prop('expiration', $context); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -435,8 +435,8 @@ discard block |
||
| 435 | 435 | * @param string $context View or edit context. |
| 436 | 436 | * @return string |
| 437 | 437 | */ |
| 438 | - public function get_expiration( $context = 'view' ) { |
|
| 439 | - return $this->get_next_renewal_date( $context ); |
|
| 438 | + public function get_expiration($context = 'view') { |
|
| 439 | + return $this->get_next_renewal_date($context); |
|
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | /** |
@@ -448,12 +448,12 @@ discard block |
||
| 448 | 448 | public function get_expiration_time() { |
| 449 | 449 | $expiration = $this->get_expiration(); |
| 450 | 450 | |
| 451 | - if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) { |
|
| 452 | - return current_time( 'timestamp' ); |
|
| 451 | + if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) { |
|
| 452 | + return current_time('timestamp'); |
|
| 453 | 453 | } |
| 454 | 454 | |
| 455 | - $expiration = strtotime( $expiration, current_time( 'timestamp' ) ); |
|
| 456 | - return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration; |
|
| 455 | + $expiration = strtotime($expiration, current_time('timestamp')); |
|
| 456 | + return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration; |
|
| 457 | 457 | } |
| 458 | 458 | |
| 459 | 459 | /** |
@@ -463,11 +463,11 @@ discard block |
||
| 463 | 463 | * @param string $context View or edit context. |
| 464 | 464 | * @return string |
| 465 | 465 | */ |
| 466 | - public function get_next_renewal_date_gmt( $context = 'view' ) { |
|
| 467 | - $date = $this->get_next_renewal_date( $context ); |
|
| 466 | + public function get_next_renewal_date_gmt($context = 'view') { |
|
| 467 | + $date = $this->get_next_renewal_date($context); |
|
| 468 | 468 | |
| 469 | - if ( $date ) { |
|
| 470 | - $date = get_gmt_from_date( $date ); |
|
| 469 | + if ($date) { |
|
| 470 | + $date = get_gmt_from_date($date); |
|
| 471 | 471 | } |
| 472 | 472 | return $date; |
| 473 | 473 | } |
@@ -479,8 +479,8 @@ discard block |
||
| 479 | 479 | * @param string $context View or edit context. |
| 480 | 480 | * @return string |
| 481 | 481 | */ |
| 482 | - public function get_trial_period( $context = 'view' ) { |
|
| 483 | - return $this->get_prop( 'trial_period', $context ); |
|
| 482 | + public function get_trial_period($context = 'view') { |
|
| 483 | + return $this->get_prop('trial_period', $context); |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | /** |
@@ -490,8 +490,8 @@ discard block |
||
| 490 | 490 | * @param string $context View or edit context. |
| 491 | 491 | * @return string |
| 492 | 492 | */ |
| 493 | - public function get_status( $context = 'view' ) { |
|
| 494 | - return $this->get_prop( 'status', $context ); |
|
| 493 | + public function get_status($context = 'view') { |
|
| 494 | + return $this->get_prop('status', $context); |
|
| 495 | 495 | } |
| 496 | 496 | |
| 497 | 497 | /** |
@@ -501,8 +501,8 @@ discard block |
||
| 501 | 501 | * @param string $context View or edit context. |
| 502 | 502 | * @return string |
| 503 | 503 | */ |
| 504 | - public function get_profile_id( $context = 'view' ) { |
|
| 505 | - return $this->get_prop( 'profile_id', $context ); |
|
| 504 | + public function get_profile_id($context = 'view') { |
|
| 505 | + return $this->get_prop('profile_id', $context); |
|
| 506 | 506 | } |
| 507 | 507 | |
| 508 | 508 | /* |
@@ -517,8 +517,8 @@ discard block |
||
| 517 | 517 | * @since 1.0.19 |
| 518 | 518 | * @param int $value The customer's id. |
| 519 | 519 | */ |
| 520 | - public function set_customer_id( $value ) { |
|
| 521 | - $this->set_prop( 'customer_id', (int) $value ); |
|
| 520 | + public function set_customer_id($value) { |
|
| 521 | + $this->set_prop('customer_id', (int) $value); |
|
| 522 | 522 | } |
| 523 | 523 | |
| 524 | 524 | /** |
@@ -527,8 +527,8 @@ discard block |
||
| 527 | 527 | * @since 1.0.19 |
| 528 | 528 | * @param int $value The parent invoice id. |
| 529 | 529 | */ |
| 530 | - public function set_parent_invoice_id( $value ) { |
|
| 531 | - $this->set_prop( 'parent_payment_id', (int) $value ); |
|
| 530 | + public function set_parent_invoice_id($value) { |
|
| 531 | + $this->set_prop('parent_payment_id', (int) $value); |
|
| 532 | 532 | } |
| 533 | 533 | |
| 534 | 534 | /** |
@@ -537,8 +537,8 @@ discard block |
||
| 537 | 537 | * @since 1.0.19 |
| 538 | 538 | * @param int $value The parent invoice id. |
| 539 | 539 | */ |
| 540 | - public function set_parent_payment_id( $value ) { |
|
| 541 | - $this->set_parent_invoice_id( $value ); |
|
| 540 | + public function set_parent_payment_id($value) { |
|
| 541 | + $this->set_parent_invoice_id($value); |
|
| 542 | 542 | } |
| 543 | 543 | |
| 544 | 544 | /** |
@@ -547,8 +547,8 @@ discard block |
||
| 547 | 547 | * @since 1.0.19 |
| 548 | 548 | * @param int $value The parent invoice id. |
| 549 | 549 | */ |
| 550 | - public function set_original_payment_id( $value ) { |
|
| 551 | - $this->set_parent_invoice_id( $value ); |
|
| 550 | + public function set_original_payment_id($value) { |
|
| 551 | + $this->set_parent_invoice_id($value); |
|
| 552 | 552 | } |
| 553 | 553 | |
| 554 | 554 | /** |
@@ -557,8 +557,8 @@ discard block |
||
| 557 | 557 | * @since 1.0.19 |
| 558 | 558 | * @param int $value The subscription product id. |
| 559 | 559 | */ |
| 560 | - public function set_product_id( $value ) { |
|
| 561 | - $this->set_prop( 'product_id', (int) $value ); |
|
| 560 | + public function set_product_id($value) { |
|
| 561 | + $this->set_prop('product_id', (int) $value); |
|
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | /** |
@@ -567,8 +567,8 @@ discard block |
||
| 567 | 567 | * @since 1.0.19 |
| 568 | 568 | * @param string $value The renewal period. |
| 569 | 569 | */ |
| 570 | - public function set_period( $value ) { |
|
| 571 | - $this->set_prop( 'period', $value ); |
|
| 570 | + public function set_period($value) { |
|
| 571 | + $this->set_prop('period', $value); |
|
| 572 | 572 | } |
| 573 | 573 | |
| 574 | 574 | /** |
@@ -577,9 +577,9 @@ discard block |
||
| 577 | 577 | * @since 1.0.19 |
| 578 | 578 | * @param int $value The subscription frequency. |
| 579 | 579 | */ |
| 580 | - public function set_frequency( $value ) { |
|
| 581 | - $value = empty( $value ) ? 1 : (int) $value; |
|
| 582 | - $this->set_prop( 'frequency', absint( $value ) ); |
|
| 580 | + public function set_frequency($value) { |
|
| 581 | + $value = empty($value) ? 1 : (int) $value; |
|
| 582 | + $this->set_prop('frequency', absint($value)); |
|
| 583 | 583 | } |
| 584 | 584 | |
| 585 | 585 | /** |
@@ -588,8 +588,8 @@ discard block |
||
| 588 | 588 | * @since 1.0.19 |
| 589 | 589 | * @param float $value The initial subcription amount. |
| 590 | 590 | */ |
| 591 | - public function set_initial_amount( $value ) { |
|
| 592 | - $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) ); |
|
| 591 | + public function set_initial_amount($value) { |
|
| 592 | + $this->set_prop('initial_amount', wpinv_sanitize_amount($value)); |
|
| 593 | 593 | } |
| 594 | 594 | |
| 595 | 595 | /** |
@@ -598,8 +598,8 @@ discard block |
||
| 598 | 598 | * @since 1.0.19 |
| 599 | 599 | * @param float $value The recurring subcription amount. |
| 600 | 600 | */ |
| 601 | - public function set_recurring_amount( $value ) { |
|
| 602 | - $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) ); |
|
| 601 | + public function set_recurring_amount($value) { |
|
| 602 | + $this->set_prop('recurring_amount', wpinv_sanitize_amount($value)); |
|
| 603 | 603 | } |
| 604 | 604 | |
| 605 | 605 | /** |
@@ -608,8 +608,8 @@ discard block |
||
| 608 | 608 | * @since 1.0.19 |
| 609 | 609 | * @param int $value Bill times. |
| 610 | 610 | */ |
| 611 | - public function set_bill_times( $value ) { |
|
| 612 | - $this->set_prop( 'bill_times', (int) $value ); |
|
| 611 | + public function set_bill_times($value) { |
|
| 612 | + $this->set_prop('bill_times', (int) $value); |
|
| 613 | 613 | } |
| 614 | 614 | |
| 615 | 615 | /** |
@@ -618,8 +618,8 @@ discard block |
||
| 618 | 618 | * @since 1.0.19 |
| 619 | 619 | * @param string $value Bill times. |
| 620 | 620 | */ |
| 621 | - public function set_transaction_id( $value ) { |
|
| 622 | - $this->set_prop( 'transaction_id', sanitize_text_field( $value ) ); |
|
| 621 | + public function set_transaction_id($value) { |
|
| 622 | + $this->set_prop('transaction_id', sanitize_text_field($value)); |
|
| 623 | 623 | } |
| 624 | 624 | |
| 625 | 625 | /** |
@@ -628,15 +628,15 @@ discard block |
||
| 628 | 628 | * @since 1.0.19 |
| 629 | 629 | * @param string $value strtotime compliant date. |
| 630 | 630 | */ |
| 631 | - public function set_created( $value ) { |
|
| 632 | - $date = strtotime( $value ); |
|
| 631 | + public function set_created($value) { |
|
| 632 | + $date = strtotime($value); |
|
| 633 | 633 | |
| 634 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 635 | - $this->set_prop( 'created', gmdate( 'Y-m-d H:i:s', $date ) ); |
|
| 634 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 635 | + $this->set_prop('created', gmdate('Y-m-d H:i:s', $date)); |
|
| 636 | 636 | return; |
| 637 | 637 | } |
| 638 | 638 | |
| 639 | - $this->set_prop( 'created', '' ); |
|
| 639 | + $this->set_prop('created', ''); |
|
| 640 | 640 | |
| 641 | 641 | } |
| 642 | 642 | |
@@ -646,8 +646,8 @@ discard block |
||
| 646 | 646 | * @since 1.0.19 |
| 647 | 647 | * @param string $value strtotime compliant date. |
| 648 | 648 | */ |
| 649 | - public function set_date_created( $value ) { |
|
| 650 | - $this->set_created( $value ); |
|
| 649 | + public function set_date_created($value) { |
|
| 650 | + $this->set_created($value); |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | /** |
@@ -656,15 +656,15 @@ discard block |
||
| 656 | 656 | * @since 1.0.19 |
| 657 | 657 | * @param string $value strtotime compliant date. |
| 658 | 658 | */ |
| 659 | - public function set_next_renewal_date( $value ) { |
|
| 660 | - $date = strtotime( $value ); |
|
| 659 | + public function set_next_renewal_date($value) { |
|
| 660 | + $date = strtotime($value); |
|
| 661 | 661 | |
| 662 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
| 663 | - $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) ); |
|
| 662 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
| 663 | + $this->set_prop('expiration', gmdate('Y-m-d H:i:s', $date)); |
|
| 664 | 664 | return; |
| 665 | 665 | } |
| 666 | 666 | |
| 667 | - $this->set_prop( 'expiration', '' ); |
|
| 667 | + $this->set_prop('expiration', ''); |
|
| 668 | 668 | |
| 669 | 669 | } |
| 670 | 670 | |
@@ -674,8 +674,8 @@ discard block |
||
| 674 | 674 | * @since 1.0.19 |
| 675 | 675 | * @param string $value strtotime compliant date. |
| 676 | 676 | */ |
| 677 | - public function set_expiration( $value ) { |
|
| 678 | - $this->set_next_renewal_date( $value ); |
|
| 677 | + public function set_expiration($value) { |
|
| 678 | + $this->set_next_renewal_date($value); |
|
| 679 | 679 | } |
| 680 | 680 | |
| 681 | 681 | /** |
@@ -684,8 +684,8 @@ discard block |
||
| 684 | 684 | * @since 1.0.19 |
| 685 | 685 | * @param string $value trial period e.g 1 year. |
| 686 | 686 | */ |
| 687 | - public function set_trial_period( $value ) { |
|
| 688 | - $this->set_prop( 'trial_period', $value ); |
|
| 687 | + public function set_trial_period($value) { |
|
| 688 | + $this->set_prop('trial_period', $value); |
|
| 689 | 689 | } |
| 690 | 690 | |
| 691 | 691 | /** |
@@ -694,22 +694,22 @@ discard block |
||
| 694 | 694 | * @since 1.0.19 |
| 695 | 695 | * @param string $new_status New subscription status. |
| 696 | 696 | */ |
| 697 | - public function set_status( $new_status ) { |
|
| 697 | + public function set_status($new_status) { |
|
| 698 | 698 | |
| 699 | 699 | // Abort if this is not a valid status; |
| 700 | - if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) { |
|
| 700 | + if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) { |
|
| 701 | 701 | return; |
| 702 | 702 | } |
| 703 | 703 | |
| 704 | - $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status(); |
|
| 705 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
| 704 | + $old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status(); |
|
| 705 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
| 706 | 706 | $this->status_transition = array( |
| 707 | 707 | 'from' => $old_status, |
| 708 | 708 | 'to' => $new_status, |
| 709 | 709 | ); |
| 710 | 710 | } |
| 711 | 711 | |
| 712 | - $this->set_prop( 'status', $new_status ); |
|
| 712 | + $this->set_prop('status', $new_status); |
|
| 713 | 713 | } |
| 714 | 714 | |
| 715 | 715 | /** |
@@ -718,8 +718,8 @@ discard block |
||
| 718 | 718 | * @since 1.0.19 |
| 719 | 719 | * @param string $value the remote profile id. |
| 720 | 720 | */ |
| 721 | - public function set_profile_id( $value ) { |
|
| 722 | - $this->set_prop( 'profile_id', sanitize_text_field( $value ) ); |
|
| 721 | + public function set_profile_id($value) { |
|
| 722 | + $this->set_prop('profile_id', sanitize_text_field($value)); |
|
| 723 | 723 | } |
| 724 | 724 | |
| 725 | 725 | /* |
@@ -737,8 +737,8 @@ discard block |
||
| 737 | 737 | * @param string|array String or array of strings to check for. |
| 738 | 738 | * @return bool |
| 739 | 739 | */ |
| 740 | - public function has_status( $status ) { |
|
| 741 | - return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) ); |
|
| 740 | + public function has_status($status) { |
|
| 741 | + return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status))); |
|
| 742 | 742 | } |
| 743 | 743 | |
| 744 | 744 | /** |
@@ -748,7 +748,7 @@ discard block |
||
| 748 | 748 | */ |
| 749 | 749 | public function has_trial_period() { |
| 750 | 750 | $period = $this->get_trial_period(); |
| 751 | - return ! empty( $period ); |
|
| 751 | + return !empty($period); |
|
| 752 | 752 | } |
| 753 | 753 | |
| 754 | 754 | /** |
@@ -757,7 +757,7 @@ discard block |
||
| 757 | 757 | * @return bool |
| 758 | 758 | */ |
| 759 | 759 | public function is_active() { |
| 760 | - return $this->has_status( 'active trialling' ) && ! $this->is_expired(); |
|
| 760 | + return $this->has_status('active trialling') && !$this->is_expired(); |
|
| 761 | 761 | } |
| 762 | 762 | |
| 763 | 763 | /** |
@@ -766,7 +766,7 @@ discard block |
||
| 766 | 766 | * @return bool |
| 767 | 767 | */ |
| 768 | 768 | public function is_expired() { |
| 769 | - return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) ); |
|
| 769 | + return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('timestamp')); |
|
| 770 | 770 | } |
| 771 | 771 | |
| 772 | 772 | /** |
@@ -776,7 +776,7 @@ discard block |
||
| 776 | 776 | */ |
| 777 | 777 | public function is_last_renewal() { |
| 778 | 778 | $max_bills = $this->get_bill_times(); |
| 779 | - return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed(); |
|
| 779 | + return !empty($max_bills) && $max_bills <= $this->get_times_billed(); |
|
| 780 | 780 | } |
| 781 | 781 | |
| 782 | 782 | /* |
@@ -791,11 +791,11 @@ discard block |
||
| 791 | 791 | /** |
| 792 | 792 | * Backwards compatibilty. |
| 793 | 793 | */ |
| 794 | - public function create( $data = array() ) { |
|
| 794 | + public function create($data = array()) { |
|
| 795 | 795 | |
| 796 | 796 | // Set the properties. |
| 797 | - if ( is_array( $data ) ) { |
|
| 798 | - $this->set_props( $data ); |
|
| 797 | + if (is_array($data)) { |
|
| 798 | + $this->set_props($data); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | // Save the item. |
@@ -806,8 +806,8 @@ discard block |
||
| 806 | 806 | /** |
| 807 | 807 | * Backwards compatibilty. |
| 808 | 808 | */ |
| 809 | - public function update( $args = array() ) { |
|
| 810 | - return $this->create( $args ); |
|
| 809 | + public function update($args = array()) { |
|
| 810 | + return $this->create($args); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -816,12 +816,12 @@ discard block |
||
| 816 | 816 | * @since 1.0.0 |
| 817 | 817 | * @return WP_Post[] |
| 818 | 818 | */ |
| 819 | - public function get_child_payments( $hide_pending = true ) { |
|
| 819 | + public function get_child_payments($hide_pending = true) { |
|
| 820 | 820 | |
| 821 | - $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' ); |
|
| 821 | + $statuses = array('publish', 'wpi-processing', 'wpi-renewal'); |
|
| 822 | 822 | |
| 823 | - if ( ! $hide_pending ) { |
|
| 824 | - $statuses = array_keys( wpinv_get_invoice_statuses() ); |
|
| 823 | + if (!$hide_pending) { |
|
| 824 | + $statuses = array_keys(wpinv_get_invoice_statuses()); |
|
| 825 | 825 | } |
| 826 | 826 | |
| 827 | 827 | return get_posts( |
@@ -843,7 +843,7 @@ discard block |
||
| 843 | 843 | * @return int |
| 844 | 844 | */ |
| 845 | 845 | public function get_total_payments() { |
| 846 | - return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() ); |
|
| 846 | + return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id()); |
|
| 847 | 847 | } |
| 848 | 848 | |
| 849 | 849 | /** |
@@ -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 ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) { |
|
| 858 | + if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) { |
|
| 859 | 859 | $times_billed--; |
| 860 | 860 | } |
| 861 | 861 | |
@@ -870,47 +870,47 @@ 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 ) ) { |
|
| 882 | - $invoice = $this->create_payment( false ); |
|
| 881 | + if (empty($invoice)) { |
|
| 882 | + $invoice = $this->create_payment(false); |
|
| 883 | 883 | |
| 884 | - if ( empty( $invoice ) ) { |
|
| 884 | + if (empty($invoice)) { |
|
| 885 | 885 | return false; |
| 886 | 886 | } |
| 887 | 887 | } |
| 888 | 888 | |
| 889 | 889 | // Maybe set a transaction id. |
| 890 | - if ( ! empty( $args['transaction_id'] ) ) { |
|
| 891 | - $invoice->set_transaction_id( $args['transaction_id'] ); |
|
| 890 | + if (!empty($args['transaction_id'])) { |
|
| 891 | + $invoice->set_transaction_id($args['transaction_id']); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | // Set the completed date. |
| 895 | - $invoice->set_completed_date( current_time( 'mysql' ) ); |
|
| 895 | + $invoice->set_completed_date(current_time('mysql')); |
|
| 896 | 896 | |
| 897 | 897 | // And the gateway. |
| 898 | - if ( ! empty( $args['gateway'] ) ) { |
|
| 899 | - $invoice->set_gateway( $args['gateway'] ); |
|
| 898 | + if (!empty($args['gateway'])) { |
|
| 899 | + $invoice->set_gateway($args['gateway']); |
|
| 900 | 900 | } |
| 901 | 901 | |
| 902 | - $invoice->set_status( 'wpi-renewal' ); |
|
| 902 | + $invoice->set_status('wpi-renewal'); |
|
| 903 | 903 | $invoice->save(); |
| 904 | 904 | |
| 905 | - if ( ! $invoice->exists() ) { |
|
| 905 | + if (!$invoice->exists()) { |
|
| 906 | 906 | return false; |
| 907 | 907 | } |
| 908 | 908 | |
| 909 | - do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this ); |
|
| 910 | - do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this ); |
|
| 911 | - do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() ); |
|
| 909 | + do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this); |
|
| 910 | + do_action('wpinv_recurring_add_subscription_payment', $invoice, $this); |
|
| 911 | + do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id()); |
|
| 912 | 912 | |
| 913 | - update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id ); |
|
| 913 | + update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id); |
|
| 914 | 914 | |
| 915 | 915 | return $invoice->get_id(); |
| 916 | 916 | } |
@@ -922,47 +922,47 @@ discard block |
||
| 922 | 922 | * @param bool $save Whether we should save the invoice. |
| 923 | 923 | * @return WPInv_Invoice|bool |
| 924 | 924 | */ |
| 925 | - public function create_payment( $save = true ) { |
|
| 925 | + public function create_payment($save = true) { |
|
| 926 | 926 | |
| 927 | 927 | $parent_invoice = $this->get_parent_payment(); |
| 928 | 928 | |
| 929 | - if ( ! $parent_invoice->exists() ) { |
|
| 929 | + if (!$parent_invoice->exists()) { |
|
| 930 | 930 | return false; |
| 931 | 931 | } |
| 932 | 932 | |
| 933 | 933 | // Duplicate the parent invoice. |
| 934 | - $invoice = getpaid_duplicate_invoice( $parent_invoice ); |
|
| 935 | - $invoice->set_parent_id( $parent_invoice->get_id() ); |
|
| 936 | - $invoice->set_subscription_id( $this->get_id() ); |
|
| 937 | - $invoice->set_remote_subscription_id( $this->get_profile_id() ); |
|
| 934 | + $invoice = getpaid_duplicate_invoice($parent_invoice); |
|
| 935 | + $invoice->set_parent_id($parent_invoice->get_id()); |
|
| 936 | + $invoice->set_subscription_id($this->get_id()); |
|
| 937 | + $invoice->set_remote_subscription_id($this->get_profile_id()); |
|
| 938 | 938 | |
| 939 | 939 | // Set invoice items. |
| 940 | - $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() ); |
|
| 941 | - $allowed_items = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] ); |
|
| 940 | + $subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id()); |
|
| 941 | + $allowed_items = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']); |
|
| 942 | 942 | $invoice_items = array(); |
| 943 | 943 | |
| 944 | - foreach ( $invoice->get_items() as $item ) { |
|
| 945 | - if ( in_array( $item->get_id(), $allowed_items ) ) { |
|
| 944 | + foreach ($invoice->get_items() as $item) { |
|
| 945 | + if (in_array($item->get_id(), $allowed_items)) { |
|
| 946 | 946 | $invoice_items[] = $item; |
| 947 | 947 | } |
| 948 | 948 | } |
| 949 | 949 | |
| 950 | - $invoice->set_items( $invoice_items ); |
|
| 950 | + $invoice->set_items($invoice_items); |
|
| 951 | 951 | |
| 952 | - if ( ! empty( $subscription_group['fees'] ) ) { |
|
| 953 | - $invoice->set_fees( $subscription_group['fees'] ); |
|
| 952 | + if (!empty($subscription_group['fees'])) { |
|
| 953 | + $invoice->set_fees($subscription_group['fees']); |
|
| 954 | 954 | } |
| 955 | 955 | |
| 956 | 956 | // Maybe recalculate discount (Pre-GetPaid Fix). |
| 957 | - $discount = new WPInv_Discount( $invoice->get_discount_code() ); |
|
| 958 | - if ( $discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount() ) { |
|
| 959 | - $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) ); |
|
| 957 | + $discount = new WPInv_Discount($invoice->get_discount_code()); |
|
| 958 | + if ($discount->exists() && $discount->is_recurring() && 0 == $invoice->get_total_discount()) { |
|
| 959 | + $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount)); |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | $invoice->recalculate_total(); |
| 963 | - $invoice->set_status( 'wpi-pending' ); |
|
| 963 | + $invoice->set_status('wpi-pending'); |
|
| 964 | 964 | |
| 965 | - if ( ! $save ) { |
|
| 965 | + if (!$save) { |
|
| 966 | 966 | return $invoice; |
| 967 | 967 | } |
| 968 | 968 | |
@@ -977,24 +977,24 @@ discard block |
||
| 977 | 977 | * @since 1.0.0 |
| 978 | 978 | * @return int The subscription's id |
| 979 | 979 | */ |
| 980 | - public function renew( $calculate_from = null ) { |
|
| 980 | + public function renew($calculate_from = null) { |
|
| 981 | 981 | |
| 982 | 982 | // Complete subscription if applicable |
| 983 | - if ( $this->is_last_renewal() ) { |
|
| 983 | + if ($this->is_last_renewal()) { |
|
| 984 | 984 | return $this->complete(); |
| 985 | 985 | } |
| 986 | 986 | |
| 987 | 987 | // Calculate new expiration |
| 988 | 988 | $frequency = $this->get_frequency(); |
| 989 | 989 | $period = $this->get_period(); |
| 990 | - $calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from; |
|
| 991 | - $new_expiration = strtotime( "+ $frequency $period", $calculate_from ); |
|
| 990 | + $calculate_from = empty($calculate_from) ? $this->get_expiration_time() : $calculate_from; |
|
| 991 | + $new_expiration = strtotime("+ $frequency $period", $calculate_from); |
|
| 992 | 992 | |
| 993 | - $this->set_expiration( date( 'Y-m-d H:i:s', $new_expiration ) ); |
|
| 994 | - $this->set_status( 'active' ); |
|
| 993 | + $this->set_expiration(date('Y-m-d H:i:s', $new_expiration)); |
|
| 994 | + $this->set_status('active'); |
|
| 995 | 995 | $this->save(); |
| 996 | 996 | |
| 997 | - do_action( 'getpaid_subscription_renewed', $this ); |
|
| 997 | + do_action('getpaid_subscription_renewed', $this); |
|
| 998 | 998 | |
| 999 | 999 | return $this->get_id(); |
| 1000 | 1000 | } |
@@ -1010,11 +1010,11 @@ discard block |
||
| 1010 | 1010 | public function complete() { |
| 1011 | 1011 | |
| 1012 | 1012 | // Only mark a subscription as complete if it's not already cancelled. |
| 1013 | - if ( $this->has_status( 'cancelled' ) ) { |
|
| 1013 | + if ($this->has_status('cancelled')) { |
|
| 1014 | 1014 | return false; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - $this->set_status( 'completed' ); |
|
| 1017 | + $this->set_status('completed'); |
|
| 1018 | 1018 | return $this->save(); |
| 1019 | 1019 | |
| 1020 | 1020 | } |
@@ -1026,14 +1026,14 @@ discard block |
||
| 1026 | 1026 | * @param bool $check_expiration |
| 1027 | 1027 | * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future. |
| 1028 | 1028 | */ |
| 1029 | - public function expire( $check_expiration = false ) { |
|
| 1029 | + public function expire($check_expiration = false) { |
|
| 1030 | 1030 | |
| 1031 | - if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) { |
|
| 1031 | + if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) { |
|
| 1032 | 1032 | // Do not mark as expired since real expiration date is in the future |
| 1033 | 1033 | return false; |
| 1034 | 1034 | } |
| 1035 | 1035 | |
| 1036 | - $this->set_status( 'expired' ); |
|
| 1036 | + $this->set_status('expired'); |
|
| 1037 | 1037 | return $this->save(); |
| 1038 | 1038 | |
| 1039 | 1039 | } |
@@ -1045,7 +1045,7 @@ discard block |
||
| 1045 | 1045 | * @return int Subscription id. |
| 1046 | 1046 | */ |
| 1047 | 1047 | public function failing() { |
| 1048 | - $this->set_status( 'failing' ); |
|
| 1048 | + $this->set_status('failing'); |
|
| 1049 | 1049 | return $this->save(); |
| 1050 | 1050 | } |
| 1051 | 1051 | |
@@ -1056,7 +1056,7 @@ discard block |
||
| 1056 | 1056 | * @return int Subscription id. |
| 1057 | 1057 | */ |
| 1058 | 1058 | public function cancel() { |
| 1059 | - $this->set_status( 'cancelled' ); |
|
| 1059 | + $this->set_status('cancelled'); |
|
| 1060 | 1060 | return $this->save(); |
| 1061 | 1061 | } |
| 1062 | 1062 | |
@@ -1067,7 +1067,7 @@ discard block |
||
| 1067 | 1067 | * @return bool |
| 1068 | 1068 | */ |
| 1069 | 1069 | public function can_cancel() { |
| 1070 | - return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this ); |
|
| 1070 | + return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this); |
|
| 1071 | 1071 | } |
| 1072 | 1072 | |
| 1073 | 1073 | /** |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | * @return array |
| 1079 | 1079 | */ |
| 1080 | 1080 | public function get_cancellable_statuses() { |
| 1081 | - return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) ); |
|
| 1081 | + return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing')); |
|
| 1082 | 1082 | } |
| 1083 | 1083 | |
| 1084 | 1084 | /** |
@@ -1088,8 +1088,8 @@ discard block |
||
| 1088 | 1088 | * @return string |
| 1089 | 1089 | */ |
| 1090 | 1090 | public function get_cancel_url() { |
| 1091 | - $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() ); |
|
| 1092 | - return apply_filters( 'wpinv_subscription_cancel_url', $url, $this ); |
|
| 1091 | + $url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url()); |
|
| 1092 | + return apply_filters('wpinv_subscription_cancel_url', $url, $this); |
|
| 1093 | 1093 | } |
| 1094 | 1094 | |
| 1095 | 1095 | /** |
@@ -1100,10 +1100,10 @@ discard block |
||
| 1100 | 1100 | */ |
| 1101 | 1101 | public function get_view_url() { |
| 1102 | 1102 | |
| 1103 | - $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 1104 | - $url = add_query_arg( 'subscription', $this->get_id(), $url ); |
|
| 1103 | + $url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
| 1104 | + $url = add_query_arg('subscription', $this->get_id(), $url); |
|
| 1105 | 1105 | |
| 1106 | - return apply_filters( 'getpaid_get_subscription_view_url', $url, $this ); |
|
| 1106 | + return apply_filters('getpaid_get_subscription_view_url', $url, $this); |
|
| 1107 | 1107 | } |
| 1108 | 1108 | |
| 1109 | 1109 | /** |
@@ -1116,7 +1116,7 @@ discard block |
||
| 1116 | 1116 | * @return bool |
| 1117 | 1117 | */ |
| 1118 | 1118 | public function can_renew() { |
| 1119 | - return apply_filters( 'wpinv_subscription_can_renew', true, $this ); |
|
| 1119 | + return apply_filters('wpinv_subscription_can_renew', true, $this); |
|
| 1120 | 1120 | } |
| 1121 | 1121 | |
| 1122 | 1122 | /** |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | ), |
| 1136 | 1136 | 'getpaid-nonce' |
| 1137 | 1137 | ); |
| 1138 | - return apply_filters( 'wpinv_subscription_renew_url', $url, $this ); |
|
| 1138 | + return apply_filters('wpinv_subscription_renew_url', $url, $this); |
|
| 1139 | 1139 | } |
| 1140 | 1140 | |
| 1141 | 1141 | /** |
@@ -1145,7 +1145,7 @@ discard block |
||
| 1145 | 1145 | * @return bool |
| 1146 | 1146 | */ |
| 1147 | 1147 | public function can_update() { |
| 1148 | - return apply_filters( 'wpinv_subscription_can_update', false, $this ); |
|
| 1148 | + return apply_filters('wpinv_subscription_can_update', false, $this); |
|
| 1149 | 1149 | } |
| 1150 | 1150 | |
| 1151 | 1151 | /** |
@@ -1161,7 +1161,7 @@ discard block |
||
| 1161 | 1161 | 'subscription_id' => $this->get_id(), |
| 1162 | 1162 | ) |
| 1163 | 1163 | ); |
| 1164 | - return apply_filters( 'wpinv_subscription_update_url', $url, $this ); |
|
| 1164 | + return apply_filters('wpinv_subscription_update_url', $url, $this); |
|
| 1165 | 1165 | } |
| 1166 | 1166 | |
| 1167 | 1167 | /** |
@@ -1171,7 +1171,7 @@ discard block |
||
| 1171 | 1171 | * @return string |
| 1172 | 1172 | */ |
| 1173 | 1173 | public function get_status_label() { |
| 1174 | - return getpaid_get_subscription_status_label( $this->get_status() ); |
|
| 1174 | + return getpaid_get_subscription_status_label($this->get_status()); |
|
| 1175 | 1175 | } |
| 1176 | 1176 | |
| 1177 | 1177 | /** |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | */ |
| 1183 | 1183 | public function get_status_class() { |
| 1184 | 1184 | $statuses = getpaid_get_subscription_status_classes(); |
| 1185 | - return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark'; |
|
| 1185 | + return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark'; |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | /** |
@@ -1193,9 +1193,9 @@ discard block |
||
| 1193 | 1193 | */ |
| 1194 | 1194 | public function get_status_label_html() { |
| 1195 | 1195 | |
| 1196 | - $status_label = sanitize_text_field( $this->get_status_label() ); |
|
| 1197 | - $class = esc_attr( $this->get_status_class() ); |
|
| 1198 | - $status = sanitize_html_class( $this->get_status() ); |
|
| 1196 | + $status_label = sanitize_text_field($this->get_status_label()); |
|
| 1197 | + $class = esc_attr($this->get_status_class()); |
|
| 1198 | + $status = sanitize_html_class($this->get_status()); |
|
| 1199 | 1199 | |
| 1200 | 1200 | return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>"; |
| 1201 | 1201 | } |
@@ -1207,9 +1207,9 @@ discard block |
||
| 1207 | 1207 | * @param string $txn_id The transaction ID from the merchant processor |
| 1208 | 1208 | * @return bool |
| 1209 | 1209 | */ |
| 1210 | - public function payment_exists( $txn_id = '' ) { |
|
| 1211 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' ); |
|
| 1212 | - return ! empty( $invoice_id ); |
|
| 1210 | + public function payment_exists($txn_id = '') { |
|
| 1211 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id'); |
|
| 1212 | + return !empty($invoice_id); |
|
| 1213 | 1213 | } |
| 1214 | 1214 | |
| 1215 | 1215 | /** |
@@ -1221,35 +1221,35 @@ discard block |
||
| 1221 | 1221 | // Reset status transition variable. |
| 1222 | 1222 | $this->status_transition = false; |
| 1223 | 1223 | |
| 1224 | - if ( $status_transition ) { |
|
| 1224 | + if ($status_transition) { |
|
| 1225 | 1225 | try { |
| 1226 | 1226 | |
| 1227 | 1227 | // Fire a hook for the status change. |
| 1228 | - do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
| 1229 | - do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition ); |
|
| 1228 | + do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition); |
|
| 1229 | + do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition); |
|
| 1230 | 1230 | |
| 1231 | - if ( ! empty( $status_transition['from'] ) ) { |
|
| 1231 | + if (!empty($status_transition['from'])) { |
|
| 1232 | 1232 | |
| 1233 | 1233 | /* translators: 1: old subscription status 2: new subscription status */ |
| 1234 | - $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'] ) ); |
|
| 1234 | + $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'])); |
|
| 1235 | 1235 | |
| 1236 | 1236 | // Note the transition occurred. |
| 1237 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
| 1237 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
| 1238 | 1238 | |
| 1239 | 1239 | // Fire another hook. |
| 1240 | - do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
| 1241 | - do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
| 1240 | + do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this); |
|
| 1241 | + do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
| 1242 | 1242 | |
| 1243 | 1243 | } else { |
| 1244 | 1244 | /* translators: %s: new invoice status */ |
| 1245 | - $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) ); |
|
| 1245 | + $transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to'])); |
|
| 1246 | 1246 | |
| 1247 | 1247 | // Note the transition occurred. |
| 1248 | - $this->get_parent_payment()->add_note( $transition_note, false, false, true ); |
|
| 1248 | + $this->get_parent_payment()->add_note($transition_note, false, false, true); |
|
| 1249 | 1249 | |
| 1250 | 1250 | } |
| 1251 | - } catch ( Exception $e ) { |
|
| 1252 | - $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
| 1251 | + } catch (Exception $e) { |
|
| 1252 | + $this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
| 1253 | 1253 | } |
| 1254 | 1254 | } |
| 1255 | 1255 | |
@@ -1275,7 +1275,7 @@ discard block |
||
| 1275 | 1275 | */ |
| 1276 | 1276 | public function activate() { |
| 1277 | 1277 | $status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active'; |
| 1278 | - $this->set_status( $status ); |
|
| 1278 | + $this->set_status($status); |
|
| 1279 | 1279 | return $this->save(); |
| 1280 | 1280 | } |
| 1281 | 1281 | |