@@ -46,64 +46,64 @@ discard block |
||
| 46 | 46 | <td style="width: 65%"> |
| 47 | 47 | <?php |
| 48 | 48 | |
| 49 | - switch ( $key ) { |
|
| 49 | + switch ( $key ) { |
|
| 50 | 50 | |
| 51 | - case 'status': |
|
| 52 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
| 53 | - break; |
|
| 51 | + case 'status': |
|
| 52 | + echo sanitize_text_field( $subscription->get_status_label() ); |
|
| 53 | + break; |
|
| 54 | 54 | |
| 55 | - case 'start_date': |
|
| 56 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 57 | - break; |
|
| 55 | + case 'start_date': |
|
| 56 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 57 | + break; |
|
| 58 | 58 | |
| 59 | - case 'expiry_date': |
|
| 60 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
| 61 | - break; |
|
| 59 | + case 'expiry_date': |
|
| 60 | + echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
| 61 | + break; |
|
| 62 | 62 | |
| 63 | - case 'initial_amount': |
|
| 64 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 63 | + case 'initial_amount': |
|
| 64 | + echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 65 | 65 | |
| 66 | - if ( $subscription->has_trial_period() ) { |
|
| 66 | + if ( $subscription->has_trial_period() ) { |
|
| 67 | 67 | |
| 68 | - echo "<small class='text-muted'> "; |
|
| 69 | - printf( |
|
| 70 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
| 71 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
| 72 | - ); |
|
| 73 | - echo '</small>'; |
|
| 68 | + echo "<small class='text-muted'> "; |
|
| 69 | + printf( |
|
| 70 | + _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
| 71 | + sanitize_text_field( $subscription->get_trial_period() ) |
|
| 72 | + ); |
|
| 73 | + echo '</small>'; |
|
| 74 | 74 | |
| 75 | - } |
|
| 75 | + } |
|
| 76 | 76 | |
| 77 | - break; |
|
| 77 | + break; |
|
| 78 | 78 | |
| 79 | - case 'recurring_amount': |
|
| 80 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
| 81 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 82 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
| 83 | - break; |
|
| 79 | + case 'recurring_amount': |
|
| 80 | + $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
| 81 | + $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 82 | + echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
| 83 | + break; |
|
| 84 | 84 | |
| 85 | - case 'item': |
|
| 85 | + case 'item': |
|
| 86 | 86 | |
| 87 | - if ( empty( $subscription_group ) ) { |
|
| 88 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $item->get_product_id() ); |
|
| 89 | - } else { |
|
| 90 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 91 | - echo implode( ' | ', $markup ); |
|
| 92 | - } |
|
| 87 | + if ( empty( $subscription_group ) ) { |
|
| 88 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $item->get_product_id() ); |
|
| 89 | + } else { |
|
| 90 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 91 | + echo implode( ' | ', $markup ); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - break; |
|
| 94 | + break; |
|
| 95 | 95 | |
| 96 | - case 'payments': |
|
| 96 | + case 'payments': |
|
| 97 | 97 | |
| 98 | - $max_activations = (int) $subscription->get_bill_times(); |
|
| 99 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
| 98 | + $max_activations = (int) $subscription->get_bill_times(); |
|
| 99 | + echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
| 100 | 100 | |
| 101 | - break; |
|
| 101 | + break; |
|
| 102 | 102 | |
| 103 | - } |
|
| 104 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
| 103 | + } |
|
| 104 | + do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
| 105 | 105 | |
| 106 | - ?> |
|
| 106 | + ?> |
|
| 107 | 107 | </td> |
| 108 | 108 | |
| 109 | 109 | </tr> |
@@ -130,17 +130,17 @@ discard block |
||
| 130 | 130 | <span class="form-text"> |
| 131 | 131 | |
| 132 | 132 | <?php |
| 133 | - if ( $subscription->can_cancel() ) { |
|
| 134 | - printf( |
|
| 135 | - '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
| 136 | - esc_url( $subscription->get_cancel_url() ), |
|
| 137 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
| 138 | - __( 'Cancel Subscription', 'invoicing' ) |
|
| 139 | - ); |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
| 143 | - ?> |
|
| 133 | + if ( $subscription->can_cancel() ) { |
|
| 134 | + printf( |
|
| 135 | + '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
|
| 136 | + esc_url( $subscription->get_cancel_url() ), |
|
| 137 | + esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
| 138 | + __( 'Cancel Subscription', 'invoicing' ) |
|
| 139 | + ); |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
| 143 | + ?> |
|
| 144 | 144 | |
| 145 | 145 | <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
| 146 | 146 | </span> |
@@ -9,17 +9,17 @@ discard block |
||
| 9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
| 10 | 10 | */ |
| 11 | 11 | |
| 12 | -defined( 'ABSPATH' ) || exit; |
|
| 12 | +defined('ABSPATH') || exit; |
|
| 13 | 13 | |
| 14 | -do_action( 'getpaid_single_subscription_before_notices', $subscription ); |
|
| 14 | +do_action('getpaid_single_subscription_before_notices', $subscription); |
|
| 15 | 15 | |
| 16 | 16 | // Display errors and notices. |
| 17 | 17 | wpinv_print_errors(); |
| 18 | 18 | |
| 19 | -$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() ); |
|
| 20 | -$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 19 | +$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_invoice_id()); |
|
| 20 | +$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
| 21 | 21 | |
| 22 | -do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups ); |
|
| 22 | +do_action('getpaid_before_single_subscription', $subscription, $subscription_groups); |
|
| 23 | 23 | |
| 24 | 24 | ?> |
| 25 | 25 | |
@@ -31,44 +31,44 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | </style> |
| 33 | 33 | |
| 34 | -<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
| 34 | +<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
| 35 | 35 | <table class="table table-bordered"> |
| 36 | 36 | <tbody> |
| 37 | 37 | |
| 38 | - <?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?> |
|
| 38 | + <?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?> |
|
| 39 | 39 | |
| 40 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 40 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 41 | 41 | |
| 42 | 42 | <th class="font-weight-bold" style="width: 35%"> |
| 43 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 43 | + <?php echo sanitize_text_field($label); ?> |
|
| 44 | 44 | </th> |
| 45 | 45 | |
| 46 | 46 | <td style="width: 65%"> |
| 47 | 47 | <?php |
| 48 | 48 | |
| 49 | - switch ( $key ) { |
|
| 49 | + switch ($key) { |
|
| 50 | 50 | |
| 51 | 51 | case 'status': |
| 52 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
| 52 | + echo sanitize_text_field($subscription->get_status_label()); |
|
| 53 | 53 | break; |
| 54 | 54 | |
| 55 | 55 | case 'start_date': |
| 56 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
| 56 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created())); |
|
| 57 | 57 | break; |
| 58 | 58 | |
| 59 | 59 | case 'expiry_date': |
| 60 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
| 60 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date())); |
|
| 61 | 61 | break; |
| 62 | 62 | |
| 63 | 63 | case 'initial_amount': |
| 64 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 64 | + echo wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
| 65 | 65 | |
| 66 | - if ( $subscription->has_trial_period() ) { |
|
| 66 | + if ($subscription->has_trial_period()) { |
|
| 67 | 67 | |
| 68 | 68 | echo "<small class='text-muted'> "; |
| 69 | 69 | printf( |
| 70 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
| 71 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
| 70 | + _x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'), |
|
| 71 | + sanitize_text_field($subscription->get_trial_period()) |
|
| 72 | 72 | ); |
| 73 | 73 | echo '</small>'; |
| 74 | 74 | |
@@ -77,18 +77,18 @@ discard block |
||
| 77 | 77 | break; |
| 78 | 78 | |
| 79 | 79 | case 'recurring_amount': |
| 80 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
| 81 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
| 82 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
| 80 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
| 81 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
| 82 | + echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>"); |
|
| 83 | 83 | break; |
| 84 | 84 | |
| 85 | 85 | case 'item': |
| 86 | 86 | |
| 87 | - if ( empty( $subscription_group ) ) { |
|
| 88 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $item->get_product_id() ); |
|
| 87 | + if (empty($subscription_group)) { |
|
| 88 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($item->get_product_id()); |
|
| 89 | 89 | } else { |
| 90 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 91 | - echo implode( ' | ', $markup ); |
|
| 90 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 91 | + echo implode(' | ', $markup); |
|
| 92 | 92 | } |
| 93 | 93 | |
| 94 | 94 | break; |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | case 'payments': |
| 97 | 97 | |
| 98 | 98 | $max_activations = (int) $subscription->get_bill_times(); |
| 99 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
| 99 | + echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "∞" : $max_activations); |
|
| 100 | 100 | |
| 101 | 101 | break; |
| 102 | 102 | |
| 103 | 103 | } |
| 104 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
| 104 | + do_action("getpaid_render_single_subscription_column_$key", $subscription); |
|
| 105 | 105 | |
| 106 | 106 | ?> |
| 107 | 107 | </td> |
@@ -113,34 +113,34 @@ discard block |
||
| 113 | 113 | </tbody> |
| 114 | 114 | </table> |
| 115 | 115 | |
| 116 | -<?php if ( ! empty( $subscription_group ) ) : ?> |
|
| 117 | - <h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Items', 'invoicing' ); ?></h2> |
|
| 118 | - <?php getpaid_admin_subscription_item_details_metabox( $subscription ); ?> |
|
| 116 | +<?php if (!empty($subscription_group)) : ?> |
|
| 117 | + <h2 class='mt-5 mb-1 h4'><?php _e('Subscription Items', 'invoicing'); ?></h2> |
|
| 118 | + <?php getpaid_admin_subscription_item_details_metabox($subscription); ?> |
|
| 119 | 119 | <?php endif; ?> |
| 120 | 120 | |
| 121 | -<h2 class='mt-5 mb-1 h4'><?php _e( 'Related Invoices', 'invoicing' ); ?></h2> |
|
| 121 | +<h2 class='mt-5 mb-1 h4'><?php _e('Related Invoices', 'invoicing'); ?></h2> |
|
| 122 | 122 | |
| 123 | -<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?> |
|
| 123 | +<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?> |
|
| 124 | 124 | |
| 125 | -<?php if ( 1 < count( $subscription_groups ) ) : ?> |
|
| 126 | - <h2 class='mt-5 mb-1 h4'><?php _e( 'Related Subscriptions', 'invoicing' ); ?></h2> |
|
| 127 | - <?php getpaid_admin_subscription_related_subscriptions_metabox( $subscription ); ?> |
|
| 125 | +<?php if (1 < count($subscription_groups)) : ?> |
|
| 126 | + <h2 class='mt-5 mb-1 h4'><?php _e('Related Subscriptions', 'invoicing'); ?></h2> |
|
| 127 | + <?php getpaid_admin_subscription_related_subscriptions_metabox($subscription); ?> |
|
| 128 | 128 | <?php endif; ?> |
| 129 | 129 | |
| 130 | 130 | <span class="form-text"> |
| 131 | 131 | |
| 132 | 132 | <?php |
| 133 | - if ( $subscription->can_cancel() ) { |
|
| 133 | + if ($subscription->can_cancel()) { |
|
| 134 | 134 | printf( |
| 135 | 135 | '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
| 136 | - esc_url( $subscription->get_cancel_url() ), |
|
| 137 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
| 138 | - __( 'Cancel Subscription', 'invoicing' ) |
|
| 136 | + esc_url($subscription->get_cancel_url()), |
|
| 137 | + esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'), |
|
| 138 | + __('Cancel Subscription', 'invoicing') |
|
| 139 | 139 | ); |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
| 142 | + do_action('getpaid-single-subscription-page-actions', $subscription); |
|
| 143 | 143 | ?> |
| 144 | 144 | |
| 145 | - <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
|
| 145 | + <a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a> |
|
| 146 | 146 | </span> |
@@ -14,144 +14,144 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | class WPInv_Subscriptions_Widget extends WP_Super_Duper { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Register the widget with WordPress. |
|
| 19 | - * |
|
| 20 | - */ |
|
| 21 | - public function __construct() { |
|
| 22 | - |
|
| 23 | - $options = array( |
|
| 24 | - 'textdomain' => 'invoicing', |
|
| 25 | - 'block-icon' => 'controls-repeat', |
|
| 26 | - 'block-category'=> 'widgets', |
|
| 27 | - 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
|
| 28 | - 'class_name' => __CLASS__, |
|
| 29 | - 'base_id' => 'wpinv_subscriptions', |
|
| 30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 31 | - 'widget_ops' => array( |
|
| 32 | - 'classname' => 'getpaid-subscriptions bsui', |
|
| 33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 34 | - ), |
|
| 35 | - 'arguments' => array( |
|
| 36 | - 'title' => array( |
|
| 37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 39 | - 'type' => 'text', |
|
| 40 | - 'desc_tip' => true, |
|
| 41 | - 'default' => '', |
|
| 42 | - 'advanced' => false |
|
| 43 | - ), |
|
| 44 | - ) |
|
| 45 | - |
|
| 46 | - ); |
|
| 47 | - |
|
| 48 | - |
|
| 49 | - parent::__construct( $options ); |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Retrieves current user's subscriptions. |
|
| 54 | - * |
|
| 55 | - * @return GetPaid_Subscriptions_Query |
|
| 56 | - */ |
|
| 57 | - public function get_subscriptions() { |
|
| 58 | - |
|
| 59 | - // Prepare license args. |
|
| 60 | - $args = array( |
|
| 61 | - 'customer_in' => get_current_user_id(), |
|
| 62 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 63 | - ); |
|
| 64 | - |
|
| 65 | - return new GetPaid_Subscriptions_Query( $args ); |
|
| 66 | - |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * The Super block output function. |
|
| 71 | - * |
|
| 72 | - * @param array $args |
|
| 73 | - * @param array $widget_args |
|
| 74 | - * @param string $content |
|
| 75 | - * |
|
| 76 | - * @return mixed|string|bool |
|
| 77 | - */ |
|
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 79 | - |
|
| 80 | - // Ensure that the user is logged in. |
|
| 81 | - if ( ! is_user_logged_in() ) { |
|
| 82 | - |
|
| 83 | - return aui()->alert( |
|
| 84 | - array( |
|
| 85 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 86 | - 'type' => 'error', |
|
| 87 | - ) |
|
| 88 | - ); |
|
| 89 | - |
|
| 90 | - } |
|
| 91 | - |
|
| 92 | - // Are we displaying a single subscription? |
|
| 93 | - if ( isset( $_GET['subscription'] ) ) { |
|
| 94 | - return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - // Retrieve the user's subscriptions. |
|
| 98 | - $subscriptions = $this->get_subscriptions(); |
|
| 99 | - |
|
| 100 | - // Start the output buffer. |
|
| 101 | - ob_start(); |
|
| 102 | - |
|
| 103 | - // Backwards compatibility. |
|
| 104 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
| 105 | - |
|
| 106 | - // Display errors and notices. |
|
| 107 | - wpinv_print_errors(); |
|
| 108 | - |
|
| 109 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 110 | - |
|
| 111 | - // Print the table header. |
|
| 112 | - $this->print_table_header(); |
|
| 113 | - |
|
| 114 | - // Print table body. |
|
| 115 | - $this->print_table_body( $subscriptions->get_results() ); |
|
| 116 | - |
|
| 117 | - // Print table footer. |
|
| 118 | - $this->print_table_footer(); |
|
| 119 | - |
|
| 120 | - // Print the navigation. |
|
| 121 | - $this->print_navigation( $subscriptions->get_total() ); |
|
| 122 | - |
|
| 123 | - // Backwards compatibility. |
|
| 124 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
| 125 | - |
|
| 126 | - // Return the output. |
|
| 127 | - return ob_get_clean(); |
|
| 128 | - |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * Retrieves the subscription columns. |
|
| 133 | - * |
|
| 134 | - * @return array |
|
| 135 | - */ |
|
| 136 | - public function get_subscriptions_table_columns() { |
|
| 17 | + /** |
|
| 18 | + * Register the widget with WordPress. |
|
| 19 | + * |
|
| 20 | + */ |
|
| 21 | + public function __construct() { |
|
| 22 | + |
|
| 23 | + $options = array( |
|
| 24 | + 'textdomain' => 'invoicing', |
|
| 25 | + 'block-icon' => 'controls-repeat', |
|
| 26 | + 'block-category'=> 'widgets', |
|
| 27 | + 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
|
| 28 | + 'class_name' => __CLASS__, |
|
| 29 | + 'base_id' => 'wpinv_subscriptions', |
|
| 30 | + 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 31 | + 'widget_ops' => array( |
|
| 32 | + 'classname' => 'getpaid-subscriptions bsui', |
|
| 33 | + 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 34 | + ), |
|
| 35 | + 'arguments' => array( |
|
| 36 | + 'title' => array( |
|
| 37 | + 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | + 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 39 | + 'type' => 'text', |
|
| 40 | + 'desc_tip' => true, |
|
| 41 | + 'default' => '', |
|
| 42 | + 'advanced' => false |
|
| 43 | + ), |
|
| 44 | + ) |
|
| 45 | + |
|
| 46 | + ); |
|
| 47 | + |
|
| 48 | + |
|
| 49 | + parent::__construct( $options ); |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Retrieves current user's subscriptions. |
|
| 54 | + * |
|
| 55 | + * @return GetPaid_Subscriptions_Query |
|
| 56 | + */ |
|
| 57 | + public function get_subscriptions() { |
|
| 58 | + |
|
| 59 | + // Prepare license args. |
|
| 60 | + $args = array( |
|
| 61 | + 'customer_in' => get_current_user_id(), |
|
| 62 | + 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 63 | + ); |
|
| 64 | + |
|
| 65 | + return new GetPaid_Subscriptions_Query( $args ); |
|
| 66 | + |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * The Super block output function. |
|
| 71 | + * |
|
| 72 | + * @param array $args |
|
| 73 | + * @param array $widget_args |
|
| 74 | + * @param string $content |
|
| 75 | + * |
|
| 76 | + * @return mixed|string|bool |
|
| 77 | + */ |
|
| 78 | + public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 79 | + |
|
| 80 | + // Ensure that the user is logged in. |
|
| 81 | + if ( ! is_user_logged_in() ) { |
|
| 82 | + |
|
| 83 | + return aui()->alert( |
|
| 84 | + array( |
|
| 85 | + 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 86 | + 'type' => 'error', |
|
| 87 | + ) |
|
| 88 | + ); |
|
| 89 | + |
|
| 90 | + } |
|
| 91 | + |
|
| 92 | + // Are we displaying a single subscription? |
|
| 93 | + if ( isset( $_GET['subscription'] ) ) { |
|
| 94 | + return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + // Retrieve the user's subscriptions. |
|
| 98 | + $subscriptions = $this->get_subscriptions(); |
|
| 99 | + |
|
| 100 | + // Start the output buffer. |
|
| 101 | + ob_start(); |
|
| 102 | + |
|
| 103 | + // Backwards compatibility. |
|
| 104 | + do_action( 'wpinv_before_user_subscriptions' ); |
|
| 105 | + |
|
| 106 | + // Display errors and notices. |
|
| 107 | + wpinv_print_errors(); |
|
| 108 | + |
|
| 109 | + do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 110 | + |
|
| 111 | + // Print the table header. |
|
| 112 | + $this->print_table_header(); |
|
| 113 | + |
|
| 114 | + // Print table body. |
|
| 115 | + $this->print_table_body( $subscriptions->get_results() ); |
|
| 116 | + |
|
| 117 | + // Print table footer. |
|
| 118 | + $this->print_table_footer(); |
|
| 119 | + |
|
| 120 | + // Print the navigation. |
|
| 121 | + $this->print_navigation( $subscriptions->get_total() ); |
|
| 122 | + |
|
| 123 | + // Backwards compatibility. |
|
| 124 | + do_action( 'wpinv_after_user_subscriptions' ); |
|
| 125 | + |
|
| 126 | + // Return the output. |
|
| 127 | + return ob_get_clean(); |
|
| 128 | + |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * Retrieves the subscription columns. |
|
| 133 | + * |
|
| 134 | + * @return array |
|
| 135 | + */ |
|
| 136 | + public function get_subscriptions_table_columns() { |
|
| 137 | 137 | |
| 138 | - $columns = array( |
|
| 139 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 140 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 141 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 142 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 143 | - ); |
|
| 138 | + $columns = array( |
|
| 139 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 140 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 141 | + 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 142 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 143 | + ); |
|
| 144 | 144 | |
| 145 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 146 | - } |
|
| 145 | + return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 146 | + } |
|
| 147 | 147 | |
| 148 | - /** |
|
| 149 | - * Displays the table header. |
|
| 150 | - * |
|
| 151 | - */ |
|
| 152 | - public function print_table_header() { |
|
| 148 | + /** |
|
| 149 | + * Displays the table header. |
|
| 150 | + * |
|
| 151 | + */ |
|
| 152 | + public function print_table_header() { |
|
| 153 | 153 | |
| 154 | - ?> |
|
| 154 | + ?> |
|
| 155 | 155 | |
| 156 | 156 | <table class="table table-bordered table-striped"> |
| 157 | 157 | |
@@ -167,121 +167,121 @@ discard block |
||
| 167 | 167 | |
| 168 | 168 | <?php |
| 169 | 169 | |
| 170 | - } |
|
| 170 | + } |
|
| 171 | 171 | |
| 172 | - /** |
|
| 173 | - * Displays the table body. |
|
| 174 | - * |
|
| 175 | - * @param WPInv_Subscription[] $subscriptions |
|
| 176 | - */ |
|
| 177 | - public function print_table_body( $subscriptions ) { |
|
| 172 | + /** |
|
| 173 | + * Displays the table body. |
|
| 174 | + * |
|
| 175 | + * @param WPInv_Subscription[] $subscriptions |
|
| 176 | + */ |
|
| 177 | + public function print_table_body( $subscriptions ) { |
|
| 178 | 178 | |
| 179 | - if ( empty( $subscriptions ) ) { |
|
| 180 | - $this->print_table_body_no_subscriptions(); |
|
| 181 | - } else { |
|
| 182 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
| 183 | - } |
|
| 179 | + if ( empty( $subscriptions ) ) { |
|
| 180 | + $this->print_table_body_no_subscriptions(); |
|
| 181 | + } else { |
|
| 182 | + $this->print_table_body_subscriptions( $subscriptions ); |
|
| 183 | + } |
|
| 184 | 184 | |
| 185 | - } |
|
| 185 | + } |
|
| 186 | 186 | |
| 187 | - /** |
|
| 188 | - * Displays the table body if no subscriptions were found. |
|
| 189 | - * |
|
| 190 | - */ |
|
| 191 | - public function print_table_body_no_subscriptions() { |
|
| 187 | + /** |
|
| 188 | + * Displays the table body if no subscriptions were found. |
|
| 189 | + * |
|
| 190 | + */ |
|
| 191 | + public function print_table_body_no_subscriptions() { |
|
| 192 | 192 | |
| 193 | - ?> |
|
| 193 | + ?> |
|
| 194 | 194 | <tbody> |
| 195 | 195 | |
| 196 | 196 | <tr> |
| 197 | 197 | <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
| 198 | 198 | |
| 199 | 199 | <?php |
| 200 | - echo aui()->alert( |
|
| 201 | - array( |
|
| 202 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 203 | - 'type' => 'warning', |
|
| 204 | - ) |
|
| 205 | - ); |
|
| 206 | - ?> |
|
| 200 | + echo aui()->alert( |
|
| 201 | + array( |
|
| 202 | + 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 203 | + 'type' => 'warning', |
|
| 204 | + ) |
|
| 205 | + ); |
|
| 206 | + ?> |
|
| 207 | 207 | |
| 208 | 208 | </td> |
| 209 | 209 | </tr> |
| 210 | 210 | |
| 211 | 211 | </tbody> |
| 212 | 212 | <?php |
| 213 | - } |
|
| 213 | + } |
|
| 214 | 214 | |
| 215 | - /** |
|
| 216 | - * Displays the table body if subscriptions were found. |
|
| 217 | - * |
|
| 218 | - * @param WPInv_Subscription[] $subscriptions |
|
| 219 | - */ |
|
| 220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
| 215 | + /** |
|
| 216 | + * Displays the table body if subscriptions were found. |
|
| 217 | + * |
|
| 218 | + * @param WPInv_Subscription[] $subscriptions |
|
| 219 | + */ |
|
| 220 | + public function print_table_body_subscriptions( $subscriptions ) { |
|
| 221 | 221 | |
| 222 | - ?> |
|
| 222 | + ?> |
|
| 223 | 223 | <tbody> |
| 224 | 224 | |
| 225 | 225 | <?php foreach ( $subscriptions as $subscription ) : ?> |
| 226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
| 227 | 227 | <?php |
| 228 | - wpinv_get_template( |
|
| 229 | - 'subscriptions/subscriptions-table-row.php', |
|
| 230 | - array( |
|
| 231 | - 'subscription' => $subscription, |
|
| 232 | - 'widget' => $this |
|
| 233 | - ) |
|
| 234 | - ); |
|
| 235 | - ?> |
|
| 228 | + wpinv_get_template( |
|
| 229 | + 'subscriptions/subscriptions-table-row.php', |
|
| 230 | + array( |
|
| 231 | + 'subscription' => $subscription, |
|
| 232 | + 'widget' => $this |
|
| 233 | + ) |
|
| 234 | + ); |
|
| 235 | + ?> |
|
| 236 | 236 | </tr> |
| 237 | 237 | <?php endforeach; ?> |
| 238 | 238 | |
| 239 | 239 | </tbody> |
| 240 | 240 | <?php |
| 241 | - } |
|
| 242 | - |
|
| 243 | - /** |
|
| 244 | - * Adds row actions to a column |
|
| 245 | - * |
|
| 246 | - * @param string $content column content |
|
| 247 | - * @param WPInv_Subscription $subscription |
|
| 248 | - * @since 1.0.0 |
|
| 249 | - * @return string |
|
| 250 | - */ |
|
| 251 | - public function add_row_actions( $content, $subscription ) { |
|
| 252 | - |
|
| 253 | - // Prepare row actions. |
|
| 254 | - $actions = array(); |
|
| 255 | - |
|
| 256 | - // View subscription action. |
|
| 257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 260 | - |
|
| 261 | - // Filter the actions. |
|
| 262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 263 | - |
|
| 264 | - $sanitized = array(); |
|
| 265 | - foreach ( $actions as $key => $action ) { |
|
| 266 | - $key = sanitize_html_class( $key ); |
|
| 267 | - $action = wp_kses_post( $action ); |
|
| 268 | - $sanitized[] = "<span class='$key'>$action</span>"; |
|
| 269 | - } |
|
| 270 | - |
|
| 271 | - $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
| 272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
| 273 | - $row_actions .= '</small>'; |
|
| 274 | - |
|
| 275 | - return $content . $row_actions; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * Displays the table footer. |
|
| 280 | - * |
|
| 281 | - */ |
|
| 282 | - public function print_table_footer() { |
|
| 283 | - |
|
| 284 | - ?> |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + /** |
|
| 244 | + * Adds row actions to a column |
|
| 245 | + * |
|
| 246 | + * @param string $content column content |
|
| 247 | + * @param WPInv_Subscription $subscription |
|
| 248 | + * @since 1.0.0 |
|
| 249 | + * @return string |
|
| 250 | + */ |
|
| 251 | + public function add_row_actions( $content, $subscription ) { |
|
| 252 | + |
|
| 253 | + // Prepare row actions. |
|
| 254 | + $actions = array(); |
|
| 255 | + |
|
| 256 | + // View subscription action. |
|
| 257 | + $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | + $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 260 | + |
|
| 261 | + // Filter the actions. |
|
| 262 | + $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 263 | + |
|
| 264 | + $sanitized = array(); |
|
| 265 | + foreach ( $actions as $key => $action ) { |
|
| 266 | + $key = sanitize_html_class( $key ); |
|
| 267 | + $action = wp_kses_post( $action ); |
|
| 268 | + $sanitized[] = "<span class='$key'>$action</span>"; |
|
| 269 | + } |
|
| 270 | + |
|
| 271 | + $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
|
| 272 | + $row_actions .= implode( ' | ', $sanitized ); |
|
| 273 | + $row_actions .= '</small>'; |
|
| 274 | + |
|
| 275 | + return $content . $row_actions; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * Displays the table footer. |
|
| 280 | + * |
|
| 281 | + */ |
|
| 282 | + public function print_table_footer() { |
|
| 283 | + |
|
| 284 | + ?> |
|
| 285 | 285 | |
| 286 | 286 | <tfoot> |
| 287 | 287 | <tr> |
@@ -296,143 +296,143 @@ discard block |
||
| 296 | 296 | </table> |
| 297 | 297 | <?php |
| 298 | 298 | |
| 299 | - } |
|
| 299 | + } |
|
| 300 | 300 | |
| 301 | - /** |
|
| 302 | - * Displays the navigation. |
|
| 303 | - * |
|
| 304 | - * @param int $total |
|
| 305 | - */ |
|
| 306 | - public function print_navigation( $total ) { |
|
| 301 | + /** |
|
| 302 | + * Displays the navigation. |
|
| 303 | + * |
|
| 304 | + * @param int $total |
|
| 305 | + */ |
|
| 306 | + public function print_navigation( $total ) { |
|
| 307 | 307 | |
| 308 | - if ( $total < 1 ) { |
|
| 308 | + if ( $total < 1 ) { |
|
| 309 | 309 | |
| 310 | - // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 311 | - $args = array( |
|
| 312 | - 'customer_in' => get_current_user_id(), |
|
| 313 | - 'fields' => 'id', |
|
| 314 | - ); |
|
| 310 | + // Out-of-bounds, run the query again without LIMIT for total count. |
|
| 311 | + $args = array( |
|
| 312 | + 'customer_in' => get_current_user_id(), |
|
| 313 | + 'fields' => 'id', |
|
| 314 | + ); |
|
| 315 | 315 | |
| 316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 317 | - $total = $count_query->get_total(); |
|
| 318 | - } |
|
| 316 | + $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 317 | + $total = $count_query->get_total(); |
|
| 318 | + } |
|
| 319 | 319 | |
| 320 | - // Abort if we do not have pages. |
|
| 321 | - if ( 2 > $total ) { |
|
| 322 | - return; |
|
| 323 | - } |
|
| 320 | + // Abort if we do not have pages. |
|
| 321 | + if ( 2 > $total ) { |
|
| 322 | + return; |
|
| 323 | + } |
|
| 324 | 324 | |
| 325 | - ?> |
|
| 325 | + ?> |
|
| 326 | 326 | |
| 327 | 327 | <div class="getpaid-subscriptions-pagination"> |
| 328 | 328 | <?php |
| 329 | - $big = 999999; |
|
| 330 | - |
|
| 331 | - echo getpaid_paginate_links( |
|
| 332 | - array( |
|
| 333 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 334 | - 'format' => '?paged=%#%', |
|
| 335 | - 'total' => (int) ceil( $total / 10 ), |
|
| 336 | - ) |
|
| 337 | - ); |
|
| 338 | - ?> |
|
| 329 | + $big = 999999; |
|
| 330 | + |
|
| 331 | + echo getpaid_paginate_links( |
|
| 332 | + array( |
|
| 333 | + 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 334 | + 'format' => '?paged=%#%', |
|
| 335 | + 'total' => (int) ceil( $total / 10 ), |
|
| 336 | + ) |
|
| 337 | + ); |
|
| 338 | + ?> |
|
| 339 | 339 | </div> |
| 340 | 340 | |
| 341 | 341 | <?php |
| 342 | - } |
|
| 343 | - |
|
| 344 | - /** |
|
| 345 | - * Returns a single subscription's columns. |
|
| 346 | - * |
|
| 347 | - * @param WPInv_Subscription $subscription |
|
| 348 | - * |
|
| 349 | - * @return array |
|
| 350 | - */ |
|
| 351 | - public function get_single_subscription_columns( $subscription ) { |
|
| 352 | - |
|
| 353 | - // Prepare subscription detail columns. |
|
| 354 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 355 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 356 | - $fields = apply_filters( |
|
| 357 | - 'getpaid_single_subscription_details_fields', |
|
| 358 | - array( |
|
| 359 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 360 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 361 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 362 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 363 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 364 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
| 365 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 366 | - ), |
|
| 367 | - $subscription |
|
| 368 | - ); |
|
| 369 | - |
|
| 370 | - if ( isset( $fields['expiry_date'] ) ) { |
|
| 371 | - |
|
| 372 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 373 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - if ( 'pending' == $subscription->get_status() ) { |
|
| 377 | - unset( $fields['expiry_date'] ); |
|
| 378 | - } |
|
| 379 | - |
|
| 380 | - } |
|
| 381 | - |
|
| 382 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
| 383 | - unset( $fields['start_date'] ); |
|
| 384 | - } |
|
| 385 | - |
|
| 386 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
| 387 | - unset( $fields['initial_amount'] ); |
|
| 388 | - } |
|
| 389 | - |
|
| 390 | - return $fields; |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - /** |
|
| 394 | - * Displays a single subscription. |
|
| 395 | - * |
|
| 396 | - * @param string $subscription |
|
| 397 | - * |
|
| 398 | - * @return string |
|
| 399 | - */ |
|
| 400 | - public function display_single_subscription( $subscription ) { |
|
| 401 | - |
|
| 402 | - // Fetch the subscription. |
|
| 403 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 404 | - |
|
| 405 | - if ( ! $subscription->exists() ) { |
|
| 406 | - |
|
| 407 | - return aui()->alert( |
|
| 408 | - array( |
|
| 409 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 410 | - 'type' => 'error', |
|
| 411 | - ) |
|
| 412 | - ); |
|
| 413 | - |
|
| 414 | - } |
|
| 415 | - |
|
| 416 | - // Ensure that the user owns this subscription key. |
|
| 417 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 418 | - |
|
| 419 | - return aui()->alert( |
|
| 420 | - array( |
|
| 421 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 422 | - 'type' => 'error', |
|
| 423 | - ) |
|
| 424 | - ); |
|
| 425 | - |
|
| 426 | - } |
|
| 427 | - |
|
| 428 | - return wpinv_get_template_html( |
|
| 429 | - 'subscriptions/subscription-details.php', |
|
| 430 | - array( |
|
| 431 | - 'subscription' => $subscription, |
|
| 432 | - 'widget' => $this |
|
| 433 | - ) |
|
| 434 | - ); |
|
| 435 | - |
|
| 436 | - } |
|
| 342 | + } |
|
| 343 | + |
|
| 344 | + /** |
|
| 345 | + * Returns a single subscription's columns. |
|
| 346 | + * |
|
| 347 | + * @param WPInv_Subscription $subscription |
|
| 348 | + * |
|
| 349 | + * @return array |
|
| 350 | + */ |
|
| 351 | + public function get_single_subscription_columns( $subscription ) { |
|
| 352 | + |
|
| 353 | + // Prepare subscription detail columns. |
|
| 354 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 355 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 356 | + $fields = apply_filters( |
|
| 357 | + 'getpaid_single_subscription_details_fields', |
|
| 358 | + array( |
|
| 359 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 360 | + 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 361 | + 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 362 | + 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 363 | + 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 364 | + 'payments' => __( 'Payments', 'invoicing' ), |
|
| 365 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 366 | + ), |
|
| 367 | + $subscription |
|
| 368 | + ); |
|
| 369 | + |
|
| 370 | + if ( isset( $fields['expiry_date'] ) ) { |
|
| 371 | + |
|
| 372 | + if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 373 | + $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + if ( 'pending' == $subscription->get_status() ) { |
|
| 377 | + unset( $fields['expiry_date'] ); |
|
| 378 | + } |
|
| 379 | + |
|
| 380 | + } |
|
| 381 | + |
|
| 382 | + if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
| 383 | + unset( $fields['start_date'] ); |
|
| 384 | + } |
|
| 385 | + |
|
| 386 | + if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
| 387 | + unset( $fields['initial_amount'] ); |
|
| 388 | + } |
|
| 389 | + |
|
| 390 | + return $fields; |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + /** |
|
| 394 | + * Displays a single subscription. |
|
| 395 | + * |
|
| 396 | + * @param string $subscription |
|
| 397 | + * |
|
| 398 | + * @return string |
|
| 399 | + */ |
|
| 400 | + public function display_single_subscription( $subscription ) { |
|
| 401 | + |
|
| 402 | + // Fetch the subscription. |
|
| 403 | + $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 404 | + |
|
| 405 | + if ( ! $subscription->exists() ) { |
|
| 406 | + |
|
| 407 | + return aui()->alert( |
|
| 408 | + array( |
|
| 409 | + 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 410 | + 'type' => 'error', |
|
| 411 | + ) |
|
| 412 | + ); |
|
| 413 | + |
|
| 414 | + } |
|
| 415 | + |
|
| 416 | + // Ensure that the user owns this subscription key. |
|
| 417 | + if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 418 | + |
|
| 419 | + return aui()->alert( |
|
| 420 | + array( |
|
| 421 | + 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 422 | + 'type' => 'error', |
|
| 423 | + ) |
|
| 424 | + ); |
|
| 425 | + |
|
| 426 | + } |
|
| 427 | + |
|
| 428 | + return wpinv_get_template_html( |
|
| 429 | + 'subscriptions/subscription-details.php', |
|
| 430 | + array( |
|
| 431 | + 'subscription' => $subscription, |
|
| 432 | + 'widget' => $this |
|
| 433 | + ) |
|
| 434 | + ); |
|
| 435 | + |
|
| 436 | + } |
|
| 437 | 437 | |
| 438 | 438 | } |
@@ -5,7 +5,7 @@ discard block |
||
| 5 | 5 | * @version 1.0.0 |
| 6 | 6 | */ |
| 7 | 7 | |
| 8 | -defined( 'ABSPATH' ) || exit; |
|
| 8 | +defined('ABSPATH') || exit; |
|
| 9 | 9 | |
| 10 | 10 | /** |
| 11 | 11 | * Contains the subscriptions widget. |
@@ -27,15 +27,15 @@ discard block |
||
| 27 | 27 | 'block-keywords'=> "['invoicing','subscriptions', 'getpaid']", |
| 28 | 28 | 'class_name' => __CLASS__, |
| 29 | 29 | 'base_id' => 'wpinv_subscriptions', |
| 30 | - 'name' => __( 'GetPaid > Subscriptions', 'invoicing' ), |
|
| 30 | + 'name' => __('GetPaid > Subscriptions', 'invoicing'), |
|
| 31 | 31 | 'widget_ops' => array( |
| 32 | 32 | 'classname' => 'getpaid-subscriptions bsui', |
| 33 | - 'description' => esc_html__( "Displays the current user's subscriptions.", 'invoicing' ), |
|
| 33 | + 'description' => esc_html__("Displays the current user's subscriptions.", 'invoicing'), |
|
| 34 | 34 | ), |
| 35 | 35 | 'arguments' => array( |
| 36 | 36 | 'title' => array( |
| 37 | - 'title' => __( 'Widget title', 'invoicing' ), |
|
| 38 | - 'desc' => __( 'Enter widget title.', 'invoicing' ), |
|
| 37 | + 'title' => __('Widget title', 'invoicing'), |
|
| 38 | + 'desc' => __('Enter widget title.', 'invoicing'), |
|
| 39 | 39 | 'type' => 'text', |
| 40 | 40 | 'desc_tip' => true, |
| 41 | 41 | 'default' => '', |
@@ -46,7 +46,7 @@ discard block |
||
| 46 | 46 | ); |
| 47 | 47 | |
| 48 | 48 | |
| 49 | - parent::__construct( $options ); |
|
| 49 | + parent::__construct($options); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -57,12 +57,12 @@ discard block |
||
| 57 | 57 | public function get_subscriptions() { |
| 58 | 58 | |
| 59 | 59 | // Prepare license args. |
| 60 | - $args = array( |
|
| 60 | + $args = array( |
|
| 61 | 61 | 'customer_in' => get_current_user_id(), |
| 62 | - 'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
| 62 | + 'paged' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
| 63 | 63 | ); |
| 64 | 64 | |
| 65 | - return new GetPaid_Subscriptions_Query( $args ); |
|
| 65 | + return new GetPaid_Subscriptions_Query($args); |
|
| 66 | 66 | |
| 67 | 67 | } |
| 68 | 68 | |
@@ -75,14 +75,14 @@ discard block |
||
| 75 | 75 | * |
| 76 | 76 | * @return mixed|string|bool |
| 77 | 77 | */ |
| 78 | - public function output( $args = array(), $widget_args = array(), $content = '' ) { |
|
| 78 | + public function output($args = array(), $widget_args = array(), $content = '') { |
|
| 79 | 79 | |
| 80 | 80 | // Ensure that the user is logged in. |
| 81 | - if ( ! is_user_logged_in() ) { |
|
| 81 | + if (!is_user_logged_in()) { |
|
| 82 | 82 | |
| 83 | 83 | return aui()->alert( |
| 84 | 84 | array( |
| 85 | - 'content' => wp_kses_post( __( 'You need to log-in or create an account to view this section.', 'invoicing' ) ), |
|
| 85 | + 'content' => wp_kses_post(__('You need to log-in or create an account to view this section.', 'invoicing')), |
|
| 86 | 86 | 'type' => 'error', |
| 87 | 87 | ) |
| 88 | 88 | ); |
@@ -90,8 +90,8 @@ discard block |
||
| 90 | 90 | } |
| 91 | 91 | |
| 92 | 92 | // Are we displaying a single subscription? |
| 93 | - if ( isset( $_GET['subscription'] ) ) { |
|
| 94 | - return $this->display_single_subscription( trim( $_GET['subscription'] ) ); |
|
| 93 | + if (isset($_GET['subscription'])) { |
|
| 94 | + return $this->display_single_subscription(trim($_GET['subscription'])); |
|
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Retrieve the user's subscriptions. |
@@ -101,27 +101,27 @@ discard block |
||
| 101 | 101 | ob_start(); |
| 102 | 102 | |
| 103 | 103 | // Backwards compatibility. |
| 104 | - do_action( 'wpinv_before_user_subscriptions' ); |
|
| 104 | + do_action('wpinv_before_user_subscriptions'); |
|
| 105 | 105 | |
| 106 | 106 | // Display errors and notices. |
| 107 | 107 | wpinv_print_errors(); |
| 108 | 108 | |
| 109 | - do_action( 'getpaid_license_manager_before_subscriptions', $subscriptions ); |
|
| 109 | + do_action('getpaid_license_manager_before_subscriptions', $subscriptions); |
|
| 110 | 110 | |
| 111 | 111 | // Print the table header. |
| 112 | 112 | $this->print_table_header(); |
| 113 | 113 | |
| 114 | 114 | // Print table body. |
| 115 | - $this->print_table_body( $subscriptions->get_results() ); |
|
| 115 | + $this->print_table_body($subscriptions->get_results()); |
|
| 116 | 116 | |
| 117 | 117 | // Print table footer. |
| 118 | 118 | $this->print_table_footer(); |
| 119 | 119 | |
| 120 | 120 | // Print the navigation. |
| 121 | - $this->print_navigation( $subscriptions->get_total() ); |
|
| 121 | + $this->print_navigation($subscriptions->get_total()); |
|
| 122 | 122 | |
| 123 | 123 | // Backwards compatibility. |
| 124 | - do_action( 'wpinv_after_user_subscriptions' ); |
|
| 124 | + do_action('wpinv_after_user_subscriptions'); |
|
| 125 | 125 | |
| 126 | 126 | // Return the output. |
| 127 | 127 | return ob_get_clean(); |
@@ -136,13 +136,13 @@ discard block |
||
| 136 | 136 | public function get_subscriptions_table_columns() { |
| 137 | 137 | |
| 138 | 138 | $columns = array( |
| 139 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 140 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 141 | - 'renewal-date' => __( 'Next payment', 'invoicing' ), |
|
| 142 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 139 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 140 | + 'amount' => __('Amount', 'invoicing'), |
|
| 141 | + 'renewal-date' => __('Next payment', 'invoicing'), |
|
| 142 | + 'status' => __('Status', 'invoicing'), |
|
| 143 | 143 | ); |
| 144 | 144 | |
| 145 | - return apply_filters( 'getpaid_frontend_subscriptions_table_columns', $columns ); |
|
| 145 | + return apply_filters('getpaid_frontend_subscriptions_table_columns', $columns); |
|
| 146 | 146 | } |
| 147 | 147 | |
| 148 | 148 | /** |
@@ -157,9 +157,9 @@ discard block |
||
| 157 | 157 | |
| 158 | 158 | <thead> |
| 159 | 159 | <tr> |
| 160 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
| 161 | - <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 162 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 160 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
| 161 | + <th scope="col" class="font-weight-bold getpaid-subscriptions-table-<?php echo sanitize_html_class($key); ?>"> |
|
| 162 | + <?php echo sanitize_text_field($label); ?> |
|
| 163 | 163 | </th> |
| 164 | 164 | <?php endforeach; ?> |
| 165 | 165 | </tr> |
@@ -174,12 +174,12 @@ discard block |
||
| 174 | 174 | * |
| 175 | 175 | * @param WPInv_Subscription[] $subscriptions |
| 176 | 176 | */ |
| 177 | - public function print_table_body( $subscriptions ) { |
|
| 177 | + public function print_table_body($subscriptions) { |
|
| 178 | 178 | |
| 179 | - if ( empty( $subscriptions ) ) { |
|
| 179 | + if (empty($subscriptions)) { |
|
| 180 | 180 | $this->print_table_body_no_subscriptions(); |
| 181 | 181 | } else { |
| 182 | - $this->print_table_body_subscriptions( $subscriptions ); |
|
| 182 | + $this->print_table_body_subscriptions($subscriptions); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | } |
@@ -194,12 +194,12 @@ discard block |
||
| 194 | 194 | <tbody> |
| 195 | 195 | |
| 196 | 196 | <tr> |
| 197 | - <td colspan="<?php echo count( $this->get_subscriptions_table_columns() ); ?>"> |
|
| 197 | + <td colspan="<?php echo count($this->get_subscriptions_table_columns()); ?>"> |
|
| 198 | 198 | |
| 199 | 199 | <?php |
| 200 | 200 | echo aui()->alert( |
| 201 | 201 | array( |
| 202 | - 'content' => wp_kses_post( __( 'No subscriptions found.', 'invoicing' ) ), |
|
| 202 | + 'content' => wp_kses_post(__('No subscriptions found.', 'invoicing')), |
|
| 203 | 203 | 'type' => 'warning', |
| 204 | 204 | ) |
| 205 | 205 | ); |
@@ -217,12 +217,12 @@ discard block |
||
| 217 | 217 | * |
| 218 | 218 | * @param WPInv_Subscription[] $subscriptions |
| 219 | 219 | */ |
| 220 | - public function print_table_body_subscriptions( $subscriptions ) { |
|
| 220 | + public function print_table_body_subscriptions($subscriptions) { |
|
| 221 | 221 | |
| 222 | 222 | ?> |
| 223 | 223 | <tbody> |
| 224 | 224 | |
| 225 | - <?php foreach ( $subscriptions as $subscription ) : ?> |
|
| 225 | + <?php foreach ($subscriptions as $subscription) : ?> |
|
| 226 | 226 | <tr class="getpaid-subscriptions-table-row subscription-<?php echo (int) $subscription->get_id(); ?>"> |
| 227 | 227 | <?php |
| 228 | 228 | wpinv_get_template( |
@@ -248,28 +248,28 @@ discard block |
||
| 248 | 248 | * @since 1.0.0 |
| 249 | 249 | * @return string |
| 250 | 250 | */ |
| 251 | - public function add_row_actions( $content, $subscription ) { |
|
| 251 | + public function add_row_actions($content, $subscription) { |
|
| 252 | 252 | |
| 253 | 253 | // Prepare row actions. |
| 254 | 254 | $actions = array(); |
| 255 | 255 | |
| 256 | 256 | // View subscription action. |
| 257 | - $view_url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ); |
|
| 258 | - $view_url = esc_url( add_query_arg( 'subscription', (int) $subscription->get_id(), $view_url ) ); |
|
| 259 | - $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __( 'Manage Subscription', 'invoicing' ) . '</a>'; |
|
| 257 | + $view_url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page'))); |
|
| 258 | + $view_url = esc_url(add_query_arg('subscription', (int) $subscription->get_id(), $view_url)); |
|
| 259 | + $actions['view'] = "<a href='$view_url' class='text-decoration-none'>" . __('Manage Subscription', 'invoicing') . '</a>'; |
|
| 260 | 260 | |
| 261 | 261 | // Filter the actions. |
| 262 | - $actions = apply_filters( 'getpaid_subscriptions_table_subscription_actions', $actions, $subscription ); |
|
| 262 | + $actions = apply_filters('getpaid_subscriptions_table_subscription_actions', $actions, $subscription); |
|
| 263 | 263 | |
| 264 | - $sanitized = array(); |
|
| 265 | - foreach ( $actions as $key => $action ) { |
|
| 266 | - $key = sanitize_html_class( $key ); |
|
| 267 | - $action = wp_kses_post( $action ); |
|
| 264 | + $sanitized = array(); |
|
| 265 | + foreach ($actions as $key => $action) { |
|
| 266 | + $key = sanitize_html_class($key); |
|
| 267 | + $action = wp_kses_post($action); |
|
| 268 | 268 | $sanitized[] = "<span class='$key'>$action</span>"; |
| 269 | 269 | } |
| 270 | 270 | |
| 271 | 271 | $row_actions = "<small class='form-text getpaid-subscription-item-actions'>"; |
| 272 | - $row_actions .= implode( ' | ', $sanitized ); |
|
| 272 | + $row_actions .= implode(' | ', $sanitized); |
|
| 273 | 273 | $row_actions .= '</small>'; |
| 274 | 274 | |
| 275 | 275 | return $content . $row_actions; |
@@ -285,9 +285,9 @@ discard block |
||
| 285 | 285 | |
| 286 | 286 | <tfoot> |
| 287 | 287 | <tr> |
| 288 | - <?php foreach ( $this->get_subscriptions_table_columns() as $key => $label ) : ?> |
|
| 289 | - <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 290 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 288 | + <?php foreach ($this->get_subscriptions_table_columns() as $key => $label) : ?> |
|
| 289 | + <th class="font-weight-bold getpaid-subscriptions-<?php echo sanitize_html_class($key); ?>"> |
|
| 290 | + <?php echo sanitize_text_field($label); ?> |
|
| 291 | 291 | </th> |
| 292 | 292 | <?php endforeach; ?> |
| 293 | 293 | </tr> |
@@ -303,22 +303,22 @@ discard block |
||
| 303 | 303 | * |
| 304 | 304 | * @param int $total |
| 305 | 305 | */ |
| 306 | - public function print_navigation( $total ) { |
|
| 306 | + public function print_navigation($total) { |
|
| 307 | 307 | |
| 308 | - if ( $total < 1 ) { |
|
| 308 | + if ($total < 1) { |
|
| 309 | 309 | |
| 310 | 310 | // Out-of-bounds, run the query again without LIMIT for total count. |
| 311 | - $args = array( |
|
| 311 | + $args = array( |
|
| 312 | 312 | 'customer_in' => get_current_user_id(), |
| 313 | 313 | 'fields' => 'id', |
| 314 | 314 | ); |
| 315 | 315 | |
| 316 | - $count_query = new GetPaid_Subscriptions_Query( $args ); |
|
| 316 | + $count_query = new GetPaid_Subscriptions_Query($args); |
|
| 317 | 317 | $total = $count_query->get_total(); |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | 320 | // Abort if we do not have pages. |
| 321 | - if ( 2 > $total ) { |
|
| 321 | + if (2 > $total) { |
|
| 322 | 322 | return; |
| 323 | 323 | } |
| 324 | 324 | |
@@ -330,9 +330,9 @@ discard block |
||
| 330 | 330 | |
| 331 | 331 | echo getpaid_paginate_links( |
| 332 | 332 | array( |
| 333 | - 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), |
|
| 333 | + 'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))), |
|
| 334 | 334 | 'format' => '?paged=%#%', |
| 335 | - 'total' => (int) ceil( $total / 10 ), |
|
| 335 | + 'total' => (int) ceil($total / 10), |
|
| 336 | 336 | ) |
| 337 | 337 | ); |
| 338 | 338 | ?> |
@@ -348,43 +348,43 @@ discard block |
||
| 348 | 348 | * |
| 349 | 349 | * @return array |
| 350 | 350 | */ |
| 351 | - public function get_single_subscription_columns( $subscription ) { |
|
| 351 | + public function get_single_subscription_columns($subscription) { |
|
| 352 | 352 | |
| 353 | 353 | // Prepare subscription detail columns. |
| 354 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
| 355 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 354 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
| 355 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 356 | 356 | $fields = apply_filters( |
| 357 | 357 | 'getpaid_single_subscription_details_fields', |
| 358 | 358 | array( |
| 359 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 360 | - 'initial_amount' => __( 'Initial amount', 'invoicing' ), |
|
| 361 | - 'recurring_amount' => __( 'Recurring amount', 'invoicing' ), |
|
| 362 | - 'start_date' => __( 'Start date', 'invoicing' ), |
|
| 363 | - 'expiry_date' => __( 'Next payment', 'invoicing' ), |
|
| 364 | - 'payments' => __( 'Payments', 'invoicing' ), |
|
| 365 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 359 | + 'status' => __('Status', 'invoicing'), |
|
| 360 | + 'initial_amount' => __('Initial amount', 'invoicing'), |
|
| 361 | + 'recurring_amount' => __('Recurring amount', 'invoicing'), |
|
| 362 | + 'start_date' => __('Start date', 'invoicing'), |
|
| 363 | + 'expiry_date' => __('Next payment', 'invoicing'), |
|
| 364 | + 'payments' => __('Payments', 'invoicing'), |
|
| 365 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
| 366 | 366 | ), |
| 367 | 367 | $subscription |
| 368 | 368 | ); |
| 369 | 369 | |
| 370 | - if ( isset( $fields['expiry_date'] ) ) { |
|
| 370 | + if (isset($fields['expiry_date'])) { |
|
| 371 | 371 | |
| 372 | - if ( ! $subscription->is_active() || $subscription->is_last_renewal() ) { |
|
| 373 | - $fields['expiry_date'] = __( 'End date', 'invoicing' ); |
|
| 372 | + if (!$subscription->is_active() || $subscription->is_last_renewal()) { |
|
| 373 | + $fields['expiry_date'] = __('End date', 'invoicing'); |
|
| 374 | 374 | } |
| 375 | 375 | |
| 376 | - if ( 'pending' == $subscription->get_status() ) { |
|
| 377 | - unset( $fields['expiry_date'] ); |
|
| 376 | + if ('pending' == $subscription->get_status()) { |
|
| 377 | + unset($fields['expiry_date']); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | } |
| 381 | 381 | |
| 382 | - if ( isset( $fields['start_date'] ) && 'pending' == $subscription->get_status() ) { |
|
| 383 | - unset( $fields['start_date'] ); |
|
| 382 | + if (isset($fields['start_date']) && 'pending' == $subscription->get_status()) { |
|
| 383 | + unset($fields['start_date']); |
|
| 384 | 384 | } |
| 385 | 385 | |
| 386 | - if ( $subscription->get_initial_amount() == $subscription->get_recurring_amount() ) { |
|
| 387 | - unset( $fields['initial_amount'] ); |
|
| 386 | + if ($subscription->get_initial_amount() == $subscription->get_recurring_amount()) { |
|
| 387 | + unset($fields['initial_amount']); |
|
| 388 | 388 | } |
| 389 | 389 | |
| 390 | 390 | return $fields; |
@@ -397,16 +397,16 @@ discard block |
||
| 397 | 397 | * |
| 398 | 398 | * @return string |
| 399 | 399 | */ |
| 400 | - public function display_single_subscription( $subscription ) { |
|
| 400 | + public function display_single_subscription($subscription) { |
|
| 401 | 401 | |
| 402 | 402 | // Fetch the subscription. |
| 403 | - $subscription = new WPInv_Subscription( (int) $subscription ); |
|
| 403 | + $subscription = new WPInv_Subscription((int) $subscription); |
|
| 404 | 404 | |
| 405 | - if ( ! $subscription->exists() ) { |
|
| 405 | + if (!$subscription->exists()) { |
|
| 406 | 406 | |
| 407 | 407 | return aui()->alert( |
| 408 | 408 | array( |
| 409 | - 'content' => wp_kses_post( __( 'Subscription not found.', 'invoicing' ) ), |
|
| 409 | + 'content' => wp_kses_post(__('Subscription not found.', 'invoicing')), |
|
| 410 | 410 | 'type' => 'error', |
| 411 | 411 | ) |
| 412 | 412 | ); |
@@ -414,11 +414,11 @@ discard block |
||
| 414 | 414 | } |
| 415 | 415 | |
| 416 | 416 | // Ensure that the user owns this subscription key. |
| 417 | - if ( get_current_user_id() != $subscription->get_customer_id() && ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 417 | + if (get_current_user_id() != $subscription->get_customer_id() && !wpinv_current_user_can_manage_invoicing()) { |
|
| 418 | 418 | |
| 419 | 419 | return aui()->alert( |
| 420 | 420 | array( |
| 421 | - 'content' => wp_kses_post( __( 'You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing' ) ), |
|
| 421 | + 'content' => wp_kses_post(__('You do not have permission to view this subscription. Ensure that you are logged in to the account that owns the subscription.', 'invoicing')), |
|
| 422 | 422 | 'type' => 'error', |
| 423 | 423 | ) |
| 424 | 424 | ); |
@@ -14,7 +14,7 @@ discard block |
||
| 14 | 14 | */ |
| 15 | 15 | function wpinv_subscriptions_page() { |
| 16 | 16 | |
| 17 | - ?> |
|
| 17 | + ?> |
|
| 18 | 18 | |
| 19 | 19 | <div class="wrap"> |
| 20 | 20 | <h1><?php echo esc_html( get_admin_page_title() ); ?></h1> |
@@ -22,27 +22,27 @@ discard block |
||
| 22 | 22 | |
| 23 | 23 | <?php |
| 24 | 24 | |
| 25 | - // Verify user permissions. |
|
| 26 | - if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 25 | + // Verify user permissions. |
|
| 26 | + if ( ! wpinv_current_user_can_manage_invoicing() ) { |
|
| 27 | 27 | |
| 28 | - echo aui()->alert( |
|
| 29 | - array( |
|
| 30 | - 'type' => 'danger', |
|
| 31 | - 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | - ) |
|
| 33 | - ); |
|
| 28 | + echo aui()->alert( |
|
| 29 | + array( |
|
| 30 | + 'type' => 'danger', |
|
| 31 | + 'content' => __( 'You are not permitted to view this page.', 'invoicing' ), |
|
| 32 | + ) |
|
| 33 | + ); |
|
| 34 | 34 | |
| 35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 35 | + } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 36 | 36 | |
| 37 | - // Display a single subscription. |
|
| 38 | - wpinv_recurring_subscription_details(); |
|
| 39 | - } else { |
|
| 37 | + // Display a single subscription. |
|
| 38 | + wpinv_recurring_subscription_details(); |
|
| 39 | + } else { |
|
| 40 | 40 | |
| 41 | - // Display a list of available subscriptions. |
|
| 42 | - getpaid_print_subscriptions_list(); |
|
| 43 | - } |
|
| 41 | + // Display a list of available subscriptions. |
|
| 42 | + getpaid_print_subscriptions_list(); |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - ?> |
|
| 45 | + ?> |
|
| 46 | 46 | |
| 47 | 47 | </div> |
| 48 | 48 | </div> |
@@ -59,10 +59,10 @@ discard block |
||
| 59 | 59 | */ |
| 60 | 60 | function getpaid_print_subscriptions_list() { |
| 61 | 61 | |
| 62 | - $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 63 | - $subscribers_table->prepare_items(); |
|
| 62 | + $subscribers_table = new WPInv_Subscriptions_List_Table(); |
|
| 63 | + $subscribers_table->prepare_items(); |
|
| 64 | 64 | |
| 65 | - ?> |
|
| 65 | + ?> |
|
| 66 | 66 | <form id="subscribers-filter" class="bsui" method="get"> |
| 67 | 67 | <input type="hidden" name="page" value="wpinv-subscriptions" /> |
| 68 | 68 | <?php $subscribers_table->views(); ?> |
@@ -80,41 +80,41 @@ discard block |
||
| 80 | 80 | */ |
| 81 | 81 | function wpinv_recurring_subscription_details() { |
| 82 | 82 | |
| 83 | - // Fetch the subscription. |
|
| 84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | - if ( ! $sub->exists() ) { |
|
| 83 | + // Fetch the subscription. |
|
| 84 | + $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | + if ( ! $sub->exists() ) { |
|
| 86 | 86 | |
| 87 | - echo aui()->alert( |
|
| 88 | - array( |
|
| 89 | - 'type' => 'danger', |
|
| 90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | - ) |
|
| 92 | - ); |
|
| 87 | + echo aui()->alert( |
|
| 88 | + array( |
|
| 89 | + 'type' => 'danger', |
|
| 90 | + 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 91 | + ) |
|
| 92 | + ); |
|
| 93 | 93 | |
| 94 | - return; |
|
| 95 | - } |
|
| 94 | + return; |
|
| 95 | + } |
|
| 96 | 96 | |
| 97 | - // Use metaboxes to display the subscription details. |
|
| 98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 97 | + // Use metaboxes to display the subscription details. |
|
| 98 | + add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 99 | + add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 100 | 100 | |
| 101 | - $subscription_id = $sub->get_id(); |
|
| 102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 101 | + $subscription_id = $sub->get_id(); |
|
| 102 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 103 | + $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 104 | 104 | |
| 105 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 107 | - } |
|
| 105 | + if ( 1 < count( $subscription_groups ) ) { |
|
| 106 | + add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 107 | + } |
|
| 108 | 108 | |
| 109 | - if ( ! empty( $subscription_group ) ) { |
|
| 110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 111 | - } |
|
| 109 | + if ( ! empty( $subscription_group ) ) { |
|
| 110 | + add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 111 | + } |
|
| 112 | 112 | |
| 113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 113 | + add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 114 | 114 | |
| 115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 115 | + do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 116 | 116 | |
| 117 | - ?> |
|
| 117 | + ?> |
|
| 118 | 118 | |
| 119 | 119 | <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
| 120 | 120 | |
@@ -154,45 +154,45 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | function getpaid_admin_subscription_details_metabox( $sub ) { |
| 156 | 156 | |
| 157 | - // Subscription items. |
|
| 158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 160 | - |
|
| 161 | - // Prepare subscription detail columns. |
|
| 162 | - $fields = apply_filters( |
|
| 163 | - 'getpaid_subscription_admin_page_fields', |
|
| 164 | - array( |
|
| 165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 174 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 175 | - ) |
|
| 176 | - ); |
|
| 177 | - |
|
| 178 | - if ( ! $sub->is_active() ) { |
|
| 179 | - |
|
| 180 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 181 | - unset( $fields['renews_on'] ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - if ( isset( $fields['gateway'] ) ) { |
|
| 185 | - unset( $fields['gateway'] ); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - $profile_id = $sub->get_profile_id(); |
|
| 191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 192 | - unset( $fields['profile_id'] ); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - ?> |
|
| 157 | + // Subscription items. |
|
| 158 | + $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 159 | + $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 160 | + |
|
| 161 | + // Prepare subscription detail columns. |
|
| 162 | + $fields = apply_filters( |
|
| 163 | + 'getpaid_subscription_admin_page_fields', |
|
| 164 | + array( |
|
| 165 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 166 | + 'customer' => __( 'Customer', 'invoicing' ), |
|
| 167 | + 'amount' => __( 'Amount', 'invoicing' ), |
|
| 168 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 169 | + 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 170 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 171 | + 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 172 | + 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 173 | + 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 174 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 175 | + ) |
|
| 176 | + ); |
|
| 177 | + |
|
| 178 | + if ( ! $sub->is_active() ) { |
|
| 179 | + |
|
| 180 | + if ( isset( $fields['renews_on'] ) ) { |
|
| 181 | + unset( $fields['renews_on'] ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + if ( isset( $fields['gateway'] ) ) { |
|
| 185 | + unset( $fields['gateway'] ); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + $profile_id = $sub->get_profile_id(); |
|
| 191 | + if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 192 | + unset( $fields['profile_id'] ); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + ?> |
|
| 196 | 196 | |
| 197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
| 198 | 198 | <tbody> |
@@ -226,20 +226,20 @@ discard block |
||
| 226 | 226 | */ |
| 227 | 227 | function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
| 228 | 228 | |
| 229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 229 | + $username = __( '(Missing User)', 'invoicing' ); |
|
| 230 | 230 | |
| 231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 232 | - if ( $user ) { |
|
| 231 | + $user = get_userdata( $subscription->get_customer_id() ); |
|
| 232 | + if ( $user ) { |
|
| 233 | 233 | |
| 234 | - $username = sprintf( |
|
| 235 | - '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 236 | - absint( $user->ID ), |
|
| 237 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 238 | - ); |
|
| 234 | + $username = sprintf( |
|
| 235 | + '<a href="user-edit.php?user_id=%s">%s</a>', |
|
| 236 | + absint( $user->ID ), |
|
| 237 | + ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 238 | + ); |
|
| 239 | 239 | |
| 240 | - } |
|
| 240 | + } |
|
| 241 | 241 | |
| 242 | - echo $username; |
|
| 242 | + echo $username; |
|
| 243 | 243 | } |
| 244 | 244 | add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
| 245 | 245 | |
@@ -249,8 +249,8 @@ discard block |
||
| 249 | 249 | * @param WPInv_Subscription $subscription |
| 250 | 250 | */ |
| 251 | 251 | function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
| 252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 253 | - echo "<span>$amount</span>"; |
|
| 252 | + $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 253 | + echo "<span>$amount</span>"; |
|
| 254 | 254 | } |
| 255 | 255 | add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
| 256 | 256 | |
@@ -260,7 +260,7 @@ discard block |
||
| 260 | 260 | * @param WPInv_Subscription $subscription |
| 261 | 261 | */ |
| 262 | 262 | function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
| 263 | - echo '#' . absint( $subscription->get_id() ); |
|
| 263 | + echo '#' . absint( $subscription->get_id() ); |
|
| 264 | 264 | } |
| 265 | 265 | add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
| 266 | 266 | |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | * @param WPInv_Subscription $subscription |
| 271 | 271 | */ |
| 272 | 272 | function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
| 273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 273 | + echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 274 | 274 | } |
| 275 | 275 | add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
| 276 | 276 | |
@@ -280,7 +280,7 @@ discard block |
||
| 280 | 280 | * @param WPInv_Subscription $subscription |
| 281 | 281 | */ |
| 282 | 282 | function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
| 283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 283 | + echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 284 | 284 | } |
| 285 | 285 | add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
| 286 | 286 | |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | * @param WPInv_Subscription $subscription |
| 291 | 291 | */ |
| 292 | 292 | function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
| 293 | - $max_bills = $subscription->get_bill_times(); |
|
| 294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 293 | + $max_bills = $subscription->get_bill_times(); |
|
| 294 | + echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 295 | 295 | } |
| 296 | 296 | add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
| 297 | 297 | /** |
@@ -302,13 +302,13 @@ discard block |
||
| 302 | 302 | */ |
| 303 | 303 | function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
| 304 | 304 | |
| 305 | - if ( empty( $subscription_group ) ) { |
|
| 306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 307 | - return; |
|
| 308 | - } |
|
| 305 | + if ( empty( $subscription_group ) ) { |
|
| 306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 307 | + return; |
|
| 308 | + } |
|
| 309 | 309 | |
| 310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 311 | - echo implode( ' | ', $markup ); |
|
| 310 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 311 | + echo implode( ' | ', $markup ); |
|
| 312 | 312 | |
| 313 | 313 | } |
| 314 | 314 | add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
@@ -320,13 +320,13 @@ discard block |
||
| 320 | 320 | */ |
| 321 | 321 | function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
| 322 | 322 | |
| 323 | - $gateway = $subscription->get_gateway(); |
|
| 323 | + $gateway = $subscription->get_gateway(); |
|
| 324 | 324 | |
| 325 | - if ( ! empty( $gateway ) ) { |
|
| 326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 327 | - } else { |
|
| 328 | - echo "—"; |
|
| 329 | - } |
|
| 325 | + if ( ! empty( $gateway ) ) { |
|
| 326 | + echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 327 | + } else { |
|
| 328 | + echo "—"; |
|
| 329 | + } |
|
| 330 | 330 | |
| 331 | 331 | } |
| 332 | 332 | add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
@@ -337,7 +337,7 @@ discard block |
||
| 337 | 337 | * @param WPInv_Subscription $subscription |
| 338 | 338 | */ |
| 339 | 339 | function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
| 340 | - echo $subscription->get_status_label_html(); |
|
| 340 | + echo $subscription->get_status_label_html(); |
|
| 341 | 341 | } |
| 342 | 342 | add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
| 343 | 343 | |
@@ -348,29 +348,29 @@ discard block |
||
| 348 | 348 | */ |
| 349 | 349 | function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
| 350 | 350 | |
| 351 | - $profile_id = $subscription->get_profile_id(); |
|
| 352 | - |
|
| 353 | - $input = aui()->input( |
|
| 354 | - array( |
|
| 355 | - 'type' => 'text', |
|
| 356 | - 'id' => 'wpinv_subscription_profile_id', |
|
| 357 | - 'name' => 'wpinv_subscription_profile_id', |
|
| 358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 359 | - 'label_type' => 'hidden', |
|
| 360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 361 | - 'value' => sanitize_text_field( $profile_id ), |
|
| 362 | - 'input_group_right' => '', |
|
| 363 | - 'no_wrap' => true, |
|
| 364 | - ) |
|
| 365 | - ); |
|
| 366 | - |
|
| 367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 368 | - |
|
| 369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 370 | - if ( ! empty( $url ) ) { |
|
| 371 | - $url = esc_url_raw( $url ); |
|
| 372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 373 | - } |
|
| 351 | + $profile_id = $subscription->get_profile_id(); |
|
| 352 | + |
|
| 353 | + $input = aui()->input( |
|
| 354 | + array( |
|
| 355 | + 'type' => 'text', |
|
| 356 | + 'id' => 'wpinv_subscription_profile_id', |
|
| 357 | + 'name' => 'wpinv_subscription_profile_id', |
|
| 358 | + 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 359 | + 'label_type' => 'hidden', |
|
| 360 | + 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 361 | + 'value' => sanitize_text_field( $profile_id ), |
|
| 362 | + 'input_group_right' => '', |
|
| 363 | + 'no_wrap' => true, |
|
| 364 | + ) |
|
| 365 | + ); |
|
| 366 | + |
|
| 367 | + echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 368 | + |
|
| 369 | + $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 370 | + if ( ! empty( $url ) ) { |
|
| 371 | + $url = esc_url_raw( $url ); |
|
| 372 | + echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 373 | + } |
|
| 374 | 374 | |
| 375 | 375 | } |
| 376 | 376 | add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
@@ -382,39 +382,39 @@ discard block |
||
| 382 | 382 | */ |
| 383 | 383 | function getpaid_admin_subscription_update_metabox( $subscription ) { |
| 384 | 384 | |
| 385 | - ?> |
|
| 385 | + ?> |
|
| 386 | 386 | <div class="mt-3"> |
| 387 | 387 | |
| 388 | 388 | <?php |
| 389 | - echo aui()->select( |
|
| 390 | - array( |
|
| 391 | - 'options' => getpaid_get_subscription_statuses(), |
|
| 392 | - 'name' => 'subscription_status', |
|
| 393 | - 'id' => 'subscription_status_update_select', |
|
| 394 | - 'required' => true, |
|
| 395 | - 'no_wrap' => false, |
|
| 396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 398 | - 'select2' => true, |
|
| 399 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 400 | - ) |
|
| 401 | - ); |
|
| 402 | - ?> |
|
| 389 | + echo aui()->select( |
|
| 390 | + array( |
|
| 391 | + 'options' => getpaid_get_subscription_statuses(), |
|
| 392 | + 'name' => 'subscription_status', |
|
| 393 | + 'id' => 'subscription_status_update_select', |
|
| 394 | + 'required' => true, |
|
| 395 | + 'no_wrap' => false, |
|
| 396 | + 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 397 | + 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 398 | + 'select2' => true, |
|
| 399 | + 'value' => $subscription->get_status( 'edit' ), |
|
| 400 | + ) |
|
| 401 | + ); |
|
| 402 | + ?> |
|
| 403 | 403 | |
| 404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 405 | 405 | |
| 406 | 406 | <?php |
| 407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 407 | + submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 408 | 408 | |
| 409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 411 | - $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' ); |
|
| 409 | + $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 410 | + $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 411 | + $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' ); |
|
| 412 | 412 | |
| 413 | - if ( $subscription->is_active() ) { |
|
| 414 | - echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
| 415 | - } |
|
| 413 | + if ( $subscription->is_active() ) { |
|
| 414 | + echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
|
| 415 | + } |
|
| 416 | 416 | |
| 417 | - echo '</div></div>'; |
|
| 417 | + echo '</div></div>'; |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -425,33 +425,33 @@ discard block |
||
| 425 | 425 | */ |
| 426 | 426 | function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
| 427 | 427 | |
| 428 | - $columns = apply_filters( |
|
| 429 | - 'getpaid_subscription_related_invoices_columns', |
|
| 430 | - array( |
|
| 431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 433 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 434 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 435 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 436 | - ), |
|
| 437 | - $subscription |
|
| 438 | - ); |
|
| 439 | - |
|
| 440 | - // Prepare the invoices. |
|
| 441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 442 | - $parent = $subscription->get_parent_invoice(); |
|
| 443 | - |
|
| 444 | - if ( $parent->exists() ) { |
|
| 445 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 446 | - } |
|
| 447 | - |
|
| 448 | - $table_class = 'w-100 bg-white'; |
|
| 449 | - |
|
| 450 | - if ( ! is_admin() ) { |
|
| 451 | - $table_class = 'table table-bordered'; |
|
| 452 | - } |
|
| 453 | - |
|
| 454 | - ?> |
|
| 428 | + $columns = apply_filters( |
|
| 429 | + 'getpaid_subscription_related_invoices_columns', |
|
| 430 | + array( |
|
| 431 | + 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 432 | + 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 433 | + 'date' => __( 'Date', 'invoicing' ), |
|
| 434 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 435 | + 'total' => __( 'Total', 'invoicing' ), |
|
| 436 | + ), |
|
| 437 | + $subscription |
|
| 438 | + ); |
|
| 439 | + |
|
| 440 | + // Prepare the invoices. |
|
| 441 | + $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 442 | + $parent = $subscription->get_parent_invoice(); |
|
| 443 | + |
|
| 444 | + if ( $parent->exists() ) { |
|
| 445 | + $payments = array_merge( array( $parent ), $payments ); |
|
| 446 | + } |
|
| 447 | + |
|
| 448 | + $table_class = 'w-100 bg-white'; |
|
| 449 | + |
|
| 450 | + if ( ! is_admin() ) { |
|
| 451 | + $table_class = 'table table-bordered'; |
|
| 452 | + } |
|
| 453 | + |
|
| 454 | + ?> |
|
| 455 | 455 | <div class="m-0" style="overflow: auto;"> |
| 456 | 456 | |
| 457 | 457 | <table class="<?php echo $table_class; ?>"> |
@@ -459,14 +459,14 @@ discard block |
||
| 459 | 459 | <thead> |
| 460 | 460 | <tr> |
| 461 | 461 | <?php |
| 462 | - foreach ( $columns as $key => $label ) { |
|
| 463 | - $key = esc_attr( $key ); |
|
| 464 | - $label = sanitize_text_field( $label ); |
|
| 465 | - $class = 'text-left'; |
|
| 466 | - |
|
| 467 | - echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 468 | - } |
|
| 469 | - ?> |
|
| 462 | + foreach ( $columns as $key => $label ) { |
|
| 463 | + $key = esc_attr( $key ); |
|
| 464 | + $label = sanitize_text_field( $label ); |
|
| 465 | + $class = 'text-left'; |
|
| 466 | + |
|
| 467 | + echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 468 | + } |
|
| 469 | + ?> |
|
| 470 | 470 | </tr> |
| 471 | 471 | </thead> |
| 472 | 472 | |
@@ -482,73 +482,73 @@ discard block |
||
| 482 | 482 | |
| 483 | 483 | <?php |
| 484 | 484 | |
| 485 | - foreach( $payments as $payment ) : |
|
| 485 | + foreach( $payments as $payment ) : |
|
| 486 | 486 | |
| 487 | - // Ensure that we have an invoice. |
|
| 488 | - $payment = new WPInv_Invoice( $payment ); |
|
| 487 | + // Ensure that we have an invoice. |
|
| 488 | + $payment = new WPInv_Invoice( $payment ); |
|
| 489 | 489 | |
| 490 | - // Abort if the invoice is invalid... |
|
| 491 | - if ( ! $payment->exists() ) { |
|
| 492 | - continue; |
|
| 493 | - } |
|
| 490 | + // Abort if the invoice is invalid... |
|
| 491 | + if ( ! $payment->exists() ) { |
|
| 492 | + continue; |
|
| 493 | + } |
|
| 494 | 494 | |
| 495 | - // ... or belongs to a different subscription. |
|
| 496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 497 | - continue; |
|
| 498 | - } |
|
| 495 | + // ... or belongs to a different subscription. |
|
| 496 | + if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 497 | + continue; |
|
| 498 | + } |
|
| 499 | 499 | |
| 500 | - echo '<tr>'; |
|
| 500 | + echo '<tr>'; |
|
| 501 | 501 | |
| 502 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 502 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 503 | 503 | |
| 504 | - $class = 'text-left'; |
|
| 504 | + $class = 'text-left'; |
|
| 505 | 505 | |
| 506 | - echo "<td class='p-2 $class'>"; |
|
| 506 | + echo "<td class='p-2 $class'>"; |
|
| 507 | 507 | |
| 508 | - switch( $key ) { |
|
| 508 | + switch( $key ) { |
|
| 509 | 509 | |
| 510 | - case 'total': |
|
| 511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 512 | - break; |
|
| 510 | + case 'total': |
|
| 511 | + echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 512 | + break; |
|
| 513 | 513 | |
| 514 | - case 'relationship': |
|
| 515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 516 | - break; |
|
| 514 | + case 'relationship': |
|
| 515 | + echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 516 | + break; |
|
| 517 | 517 | |
| 518 | - case 'date': |
|
| 519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 520 | - break; |
|
| 518 | + case 'date': |
|
| 519 | + echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 520 | + break; |
|
| 521 | 521 | |
| 522 | - case 'status': |
|
| 522 | + case 'status': |
|
| 523 | 523 | |
| 524 | - $status = $payment->get_status_nicename(); |
|
| 525 | - if ( is_admin() ) { |
|
| 526 | - $status = $payment->get_status_label_html(); |
|
| 527 | - } |
|
| 524 | + $status = $payment->get_status_nicename(); |
|
| 525 | + if ( is_admin() ) { |
|
| 526 | + $status = $payment->get_status_label_html(); |
|
| 527 | + } |
|
| 528 | 528 | |
| 529 | - echo $status; |
|
| 530 | - break; |
|
| 529 | + echo $status; |
|
| 530 | + break; |
|
| 531 | 531 | |
| 532 | - case 'invoice': |
|
| 533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 532 | + case 'invoice': |
|
| 533 | + $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 534 | 534 | |
| 535 | - if ( ! is_admin() ) { |
|
| 536 | - $link = esc_url( $payment->get_view_url() ); |
|
| 537 | - } |
|
| 535 | + if ( ! is_admin() ) { |
|
| 536 | + $link = esc_url( $payment->get_view_url() ); |
|
| 537 | + } |
|
| 538 | 538 | |
| 539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 540 | - echo "<a href='$link'>$invoice</a>"; |
|
| 541 | - break; |
|
| 542 | - } |
|
| 539 | + $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 540 | + echo "<a href='$link'>$invoice</a>"; |
|
| 541 | + break; |
|
| 542 | + } |
|
| 543 | 543 | |
| 544 | - echo '</td>'; |
|
| 544 | + echo '</td>'; |
|
| 545 | 545 | |
| 546 | - } |
|
| 546 | + } |
|
| 547 | 547 | |
| 548 | - echo '</tr>'; |
|
| 548 | + echo '</tr>'; |
|
| 549 | 549 | |
| 550 | - endforeach; |
|
| 551 | - ?> |
|
| 550 | + endforeach; |
|
| 551 | + ?> |
|
| 552 | 552 | |
| 553 | 553 | </tbody> |
| 554 | 554 | |
@@ -566,42 +566,42 @@ discard block |
||
| 566 | 566 | */ |
| 567 | 567 | function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
| 568 | 568 | |
| 569 | - // Fetch the subscription group. |
|
| 570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 569 | + // Fetch the subscription group. |
|
| 570 | + $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 571 | 571 | |
| 572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 573 | - return; |
|
| 574 | - } |
|
| 572 | + if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 573 | + return; |
|
| 574 | + } |
|
| 575 | 575 | |
| 576 | - // Prepare table columns. |
|
| 577 | - $columns = apply_filters( |
|
| 578 | - 'getpaid_subscription_item_details_columns', |
|
| 579 | - array( |
|
| 580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 581 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 584 | - 'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 585 | - 'recurring' => __( 'Recurring Amount', 'invoicing' ), |
|
| 586 | - ), |
|
| 587 | - $subscription |
|
| 588 | - ); |
|
| 576 | + // Prepare table columns. |
|
| 577 | + $columns = apply_filters( |
|
| 578 | + 'getpaid_subscription_item_details_columns', |
|
| 579 | + array( |
|
| 580 | + 'item_name' => __( 'Item', 'invoicing' ), |
|
| 581 | + 'price' => __( 'Price', 'invoicing' ), |
|
| 582 | + 'tax' => __( 'Tax', 'invoicing' ), |
|
| 583 | + 'discount' => __( 'Discount', 'invoicing' ), |
|
| 584 | + 'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 585 | + 'recurring' => __( 'Recurring Amount', 'invoicing' ), |
|
| 586 | + ), |
|
| 587 | + $subscription |
|
| 588 | + ); |
|
| 589 | 589 | |
| 590 | - // Prepare the invoices. |
|
| 590 | + // Prepare the invoices. |
|
| 591 | 591 | |
| 592 | - $invoice = $subscription->get_parent_invoice(); |
|
| 592 | + $invoice = $subscription->get_parent_invoice(); |
|
| 593 | 593 | |
| 594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 595 | - unset( $columns['tax'] ); |
|
| 596 | - } |
|
| 594 | + if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 595 | + unset( $columns['tax'] ); |
|
| 596 | + } |
|
| 597 | 597 | |
| 598 | - $table_class = 'w-100 bg-white'; |
|
| 598 | + $table_class = 'w-100 bg-white'; |
|
| 599 | 599 | |
| 600 | - if ( ! is_admin() ) { |
|
| 601 | - $table_class = 'table table-bordered'; |
|
| 602 | - } |
|
| 600 | + if ( ! is_admin() ) { |
|
| 601 | + $table_class = 'table table-bordered'; |
|
| 602 | + } |
|
| 603 | 603 | |
| 604 | - ?> |
|
| 604 | + ?> |
|
| 605 | 605 | <div class="m-0" style="overflow: auto;"> |
| 606 | 606 | |
| 607 | 607 | <table class="<?php echo $table_class; ?>"> |
@@ -610,14 +610,14 @@ discard block |
||
| 610 | 610 | <tr> |
| 611 | 611 | <?php |
| 612 | 612 | |
| 613 | - foreach ( $columns as $key => $label ) { |
|
| 614 | - $key = esc_attr( $key ); |
|
| 615 | - $label = sanitize_text_field( $label ); |
|
| 616 | - $class = 'text-left'; |
|
| 613 | + foreach ( $columns as $key => $label ) { |
|
| 614 | + $key = esc_attr( $key ); |
|
| 615 | + $label = sanitize_text_field( $label ); |
|
| 616 | + $class = 'text-left'; |
|
| 617 | 617 | |
| 618 | - echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 619 | - } |
|
| 620 | - ?> |
|
| 618 | + echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 619 | + } |
|
| 620 | + ?> |
|
| 621 | 621 | </tr> |
| 622 | 622 | </thead> |
| 623 | 623 | |
@@ -625,106 +625,106 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | <?php |
| 627 | 627 | |
| 628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 628 | + foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 629 | 629 | |
| 630 | - echo '<tr>'; |
|
| 630 | + echo '<tr>'; |
|
| 631 | 631 | |
| 632 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 632 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 633 | 633 | |
| 634 | - $class = 'text-left'; |
|
| 634 | + $class = 'text-left'; |
|
| 635 | 635 | |
| 636 | - echo "<td class='p-2 $class'>"; |
|
| 636 | + echo "<td class='p-2 $class'>"; |
|
| 637 | 637 | |
| 638 | - switch( $key ) { |
|
| 638 | + switch( $key ) { |
|
| 639 | 639 | |
| 640 | - case 'item_name': |
|
| 641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 640 | + case 'item_name': |
|
| 641 | + $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 642 | + $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 643 | 643 | |
| 644 | - if ( $invoice->get_template() == 'amount' || 1 === (int) $subscription_group_item['quantity'] ) { |
|
| 645 | - echo sanitize_text_field( $item_name ); |
|
| 646 | - } else { |
|
| 647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (int) $subscription_group_item['quantity'] ); |
|
| 648 | - } |
|
| 644 | + if ( $invoice->get_template() == 'amount' || 1 === (int) $subscription_group_item['quantity'] ) { |
|
| 645 | + echo sanitize_text_field( $item_name ); |
|
| 646 | + } else { |
|
| 647 | + printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (int) $subscription_group_item['quantity'] ); |
|
| 648 | + } |
|
| 649 | 649 | |
| 650 | - break; |
|
| 650 | + break; |
|
| 651 | 651 | |
| 652 | - case 'price': |
|
| 653 | - echo wpinv_price( $subscription_group_item['price'], $invoice->get_currency() ); |
|
| 654 | - break; |
|
| 652 | + case 'price': |
|
| 653 | + echo wpinv_price( $subscription_group_item['price'], $invoice->get_currency() ); |
|
| 654 | + break; |
|
| 655 | 655 | |
| 656 | - case 'tax': |
|
| 657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 658 | - break; |
|
| 656 | + case 'tax': |
|
| 657 | + echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 658 | + break; |
|
| 659 | 659 | |
| 660 | - case 'discount': |
|
| 661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 662 | - break; |
|
| 660 | + case 'discount': |
|
| 661 | + echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 662 | + break; |
|
| 663 | 663 | |
| 664 | - case 'initial': |
|
| 665 | - echo wpinv_price( $subscription_group_item['subtotal'], $invoice->get_currency() ); |
|
| 666 | - break; |
|
| 664 | + case 'initial': |
|
| 665 | + echo wpinv_price( $subscription_group_item['subtotal'], $invoice->get_currency() ); |
|
| 666 | + break; |
|
| 667 | 667 | |
| 668 | - case 'recurring': |
|
| 669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 670 | - break; |
|
| 668 | + case 'recurring': |
|
| 669 | + echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 670 | + break; |
|
| 671 | 671 | |
| 672 | - } |
|
| 672 | + } |
|
| 673 | 673 | |
| 674 | - echo '</td>'; |
|
| 674 | + echo '</td>'; |
|
| 675 | 675 | |
| 676 | - } |
|
| 676 | + } |
|
| 677 | 677 | |
| 678 | - echo '</tr>'; |
|
| 678 | + echo '</tr>'; |
|
| 679 | 679 | |
| 680 | - endforeach; |
|
| 680 | + endforeach; |
|
| 681 | 681 | |
| 682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 682 | + foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 683 | 683 | |
| 684 | - echo '<tr>'; |
|
| 684 | + echo '<tr>'; |
|
| 685 | 685 | |
| 686 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 686 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 687 | 687 | |
| 688 | - $class = 'text-left'; |
|
| 688 | + $class = 'text-left'; |
|
| 689 | 689 | |
| 690 | - echo "<td class='p-2 $class'>"; |
|
| 690 | + echo "<td class='p-2 $class'>"; |
|
| 691 | 691 | |
| 692 | - switch( $key ) { |
|
| 692 | + switch( $key ) { |
|
| 693 | 693 | |
| 694 | - case 'item_name': |
|
| 695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
| 696 | - break; |
|
| 694 | + case 'item_name': |
|
| 695 | + echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
| 696 | + break; |
|
| 697 | 697 | |
| 698 | - case 'price': |
|
| 699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 700 | - break; |
|
| 698 | + case 'price': |
|
| 699 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 700 | + break; |
|
| 701 | 701 | |
| 702 | - case 'tax': |
|
| 703 | - echo "—"; |
|
| 704 | - break; |
|
| 702 | + case 'tax': |
|
| 703 | + echo "—"; |
|
| 704 | + break; |
|
| 705 | 705 | |
| 706 | - case 'discount': |
|
| 707 | - echo "—"; |
|
| 708 | - break; |
|
| 706 | + case 'discount': |
|
| 707 | + echo "—"; |
|
| 708 | + break; |
|
| 709 | 709 | |
| 710 | - case 'initial': |
|
| 711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 712 | - break; |
|
| 710 | + case 'initial': |
|
| 711 | + echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 712 | + break; |
|
| 713 | 713 | |
| 714 | - case 'recurring': |
|
| 715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 716 | - break; |
|
| 714 | + case 'recurring': |
|
| 715 | + echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 716 | + break; |
|
| 717 | 717 | |
| 718 | - } |
|
| 718 | + } |
|
| 719 | 719 | |
| 720 | - echo '</td>'; |
|
| 720 | + echo '</td>'; |
|
| 721 | 721 | |
| 722 | - } |
|
| 722 | + } |
|
| 723 | 723 | |
| 724 | - echo '</tr>'; |
|
| 724 | + echo '</tr>'; |
|
| 725 | 725 | |
| 726 | - endforeach; |
|
| 727 | - ?> |
|
| 726 | + endforeach; |
|
| 727 | + ?> |
|
| 728 | 728 | |
| 729 | 729 | </tbody> |
| 730 | 730 | |
@@ -743,38 +743,38 @@ discard block |
||
| 743 | 743 | */ |
| 744 | 744 | function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
| 745 | 745 | |
| 746 | - // Fetch the subscription groups. |
|
| 747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 748 | - |
|
| 749 | - if ( empty( $subscription_groups ) ) { |
|
| 750 | - return; |
|
| 751 | - } |
|
| 752 | - |
|
| 753 | - // Prepare table columns. |
|
| 754 | - $columns = apply_filters( |
|
| 755 | - 'getpaid_subscription_related_subscriptions_columns', |
|
| 756 | - array( |
|
| 757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 761 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 762 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 763 | - ), |
|
| 764 | - $subscription |
|
| 765 | - ); |
|
| 766 | - |
|
| 767 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 769 | - } |
|
| 770 | - |
|
| 771 | - $table_class = 'w-100 bg-white'; |
|
| 772 | - |
|
| 773 | - if ( ! is_admin() ) { |
|
| 774 | - $table_class = 'table table-bordered'; |
|
| 775 | - } |
|
| 776 | - |
|
| 777 | - ?> |
|
| 746 | + // Fetch the subscription groups. |
|
| 747 | + $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 748 | + |
|
| 749 | + if ( empty( $subscription_groups ) ) { |
|
| 750 | + return; |
|
| 751 | + } |
|
| 752 | + |
|
| 753 | + // Prepare table columns. |
|
| 754 | + $columns = apply_filters( |
|
| 755 | + 'getpaid_subscription_related_subscriptions_columns', |
|
| 756 | + array( |
|
| 757 | + 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 758 | + 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 759 | + 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 760 | + 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 761 | + 'item' => __( 'Items', 'invoicing' ), |
|
| 762 | + 'status' => __( 'Status', 'invoicing' ), |
|
| 763 | + ), |
|
| 764 | + $subscription |
|
| 765 | + ); |
|
| 766 | + |
|
| 767 | + if ( $subscription->get_status() == 'pending' ) { |
|
| 768 | + unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 769 | + } |
|
| 770 | + |
|
| 771 | + $table_class = 'w-100 bg-white'; |
|
| 772 | + |
|
| 773 | + if ( ! is_admin() ) { |
|
| 774 | + $table_class = 'table table-bordered'; |
|
| 775 | + } |
|
| 776 | + |
|
| 777 | + ?> |
|
| 778 | 778 | <div class="m-0" style="overflow: auto;"> |
| 779 | 779 | |
| 780 | 780 | <table class="<?php echo $table_class; ?>"> |
@@ -783,14 +783,14 @@ discard block |
||
| 783 | 783 | <tr> |
| 784 | 784 | <?php |
| 785 | 785 | |
| 786 | - foreach ( $columns as $key => $label ) { |
|
| 787 | - $key = esc_attr( $key ); |
|
| 788 | - $label = sanitize_text_field( $label ); |
|
| 789 | - $class = 'text-left'; |
|
| 786 | + foreach ( $columns as $key => $label ) { |
|
| 787 | + $key = esc_attr( $key ); |
|
| 788 | + $label = sanitize_text_field( $label ); |
|
| 789 | + $class = 'text-left'; |
|
| 790 | 790 | |
| 791 | - echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 792 | - } |
|
| 793 | - ?> |
|
| 791 | + echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
|
| 792 | + } |
|
| 793 | + ?> |
|
| 794 | 794 | </tr> |
| 795 | 795 | </thead> |
| 796 | 796 | |
@@ -798,74 +798,74 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | <?php |
| 800 | 800 | |
| 801 | - foreach( $subscription_groups as $subscription_group ) : |
|
| 801 | + foreach( $subscription_groups as $subscription_group ) : |
|
| 802 | 802 | |
| 803 | - // Do not list current subscription. |
|
| 804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 805 | - continue; |
|
| 806 | - } |
|
| 803 | + // Do not list current subscription. |
|
| 804 | + if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 805 | + continue; |
|
| 806 | + } |
|
| 807 | 807 | |
| 808 | - // Ensure the subscription exists. |
|
| 809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 808 | + // Ensure the subscription exists. |
|
| 809 | + $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 810 | 810 | |
| 811 | - if ( ! $_suscription->exists() ) { |
|
| 812 | - continue; |
|
| 813 | - } |
|
| 811 | + if ( ! $_suscription->exists() ) { |
|
| 812 | + continue; |
|
| 813 | + } |
|
| 814 | 814 | |
| 815 | - echo '<tr>'; |
|
| 815 | + echo '<tr>'; |
|
| 816 | 816 | |
| 817 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 817 | + foreach ( array_keys( $columns ) as $key ) { |
|
| 818 | 818 | |
| 819 | - $class = 'text-left'; |
|
| 819 | + $class = 'text-left'; |
|
| 820 | 820 | |
| 821 | - echo "<td class='p-2 $class'>"; |
|
| 821 | + echo "<td class='p-2 $class'>"; |
|
| 822 | 822 | |
| 823 | - switch( $key ) { |
|
| 823 | + switch( $key ) { |
|
| 824 | 824 | |
| 825 | - case 'status': |
|
| 826 | - echo $_suscription->get_status_label_html(); |
|
| 827 | - break; |
|
| 825 | + case 'status': |
|
| 826 | + echo $_suscription->get_status_label_html(); |
|
| 827 | + break; |
|
| 828 | 828 | |
| 829 | - case 'item': |
|
| 830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 831 | - echo implode( ' | ', $markup ); |
|
| 832 | - break; |
|
| 829 | + case 'item': |
|
| 830 | + $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 831 | + echo implode( ' | ', $markup ); |
|
| 832 | + break; |
|
| 833 | 833 | |
| 834 | - case 'renewals': |
|
| 835 | - $max_bills = $_suscription->get_bill_times(); |
|
| 836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 837 | - break; |
|
| 834 | + case 'renewals': |
|
| 835 | + $max_bills = $_suscription->get_bill_times(); |
|
| 836 | + echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 837 | + break; |
|
| 838 | 838 | |
| 839 | - case 'renewal_date': |
|
| 840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 841 | - break; |
|
| 839 | + case 'renewal_date': |
|
| 840 | + echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 841 | + break; |
|
| 842 | 842 | |
| 843 | - case 'start_date': |
|
| 844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 845 | - break; |
|
| 843 | + case 'start_date': |
|
| 844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 845 | + break; |
|
| 846 | 846 | |
| 847 | - case 'subscription': |
|
| 848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 849 | - printf( |
|
| 850 | - '%1$s#%2$s%3$s', |
|
| 851 | - '<a href="' . esc_url( $url ) . '">', |
|
| 852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 853 | - '</a>' |
|
| 854 | - ); |
|
| 847 | + case 'subscription': |
|
| 848 | + $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 849 | + printf( |
|
| 850 | + '%1$s#%2$s%3$s', |
|
| 851 | + '<a href="' . esc_url( $url ) . '">', |
|
| 852 | + '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 853 | + '</a>' |
|
| 854 | + ); |
|
| 855 | 855 | |
| 856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 857 | - break; |
|
| 856 | + echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 857 | + break; |
|
| 858 | 858 | |
| 859 | - } |
|
| 859 | + } |
|
| 860 | 860 | |
| 861 | - echo '</td>'; |
|
| 861 | + echo '</td>'; |
|
| 862 | 862 | |
| 863 | - } |
|
| 863 | + } |
|
| 864 | 864 | |
| 865 | - echo '</tr>'; |
|
| 865 | + echo '</tr>'; |
|
| 866 | 866 | |
| 867 | - endforeach; |
|
| 868 | - ?> |
|
| 867 | + endforeach; |
|
| 868 | + ?> |
|
| 869 | 869 | |
| 870 | 870 | </tbody> |
| 871 | 871 | |
@@ -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,22 +17,22 @@ 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 | echo 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 | ); |
| 34 | 34 | |
| 35 | - } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) { |
|
| 35 | + } else if (!empty($_GET['id']) && is_numeric($_GET['id'])) { |
|
| 36 | 36 | |
| 37 | 37 | // Display a single subscription. |
| 38 | 38 | wpinv_recurring_subscription_details(); |
@@ -81,13 +81,13 @@ discard block |
||
| 81 | 81 | function wpinv_recurring_subscription_details() { |
| 82 | 82 | |
| 83 | 83 | // Fetch the subscription. |
| 84 | - $sub = new WPInv_Subscription( (int) $_GET['id'] ); |
|
| 85 | - if ( ! $sub->exists() ) { |
|
| 84 | + $sub = new WPInv_Subscription((int) $_GET['id']); |
|
| 85 | + if (!$sub->exists()) { |
|
| 86 | 86 | |
| 87 | 87 | echo aui()->alert( |
| 88 | 88 | array( |
| 89 | 89 | 'type' => 'danger', |
| 90 | - 'content' => __( 'Subscription not found.', 'invoicing' ), |
|
| 90 | + 'content' => __('Subscription not found.', 'invoicing'), |
|
| 91 | 91 | ) |
| 92 | 92 | ); |
| 93 | 93 | |
@@ -95,45 +95,45 @@ discard block |
||
| 95 | 95 | } |
| 96 | 96 | |
| 97 | 97 | // Use metaboxes to display the subscription details. |
| 98 | - add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' ); |
|
| 99 | - add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' ); |
|
| 98 | + add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high'); |
|
| 99 | + add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side'); |
|
| 100 | 100 | |
| 101 | 101 | $subscription_id = $sub->get_id(); |
| 102 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() ); |
|
| 103 | - $subscription_group = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) ); |
|
| 102 | + $subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id()); |
|
| 103 | + $subscription_group = wp_list_filter($subscription_groups, compact('subscription_id')); |
|
| 104 | 104 | |
| 105 | - if ( 1 < count( $subscription_groups ) ) { |
|
| 106 | - add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' ); |
|
| 105 | + if (1 < count($subscription_groups)) { |
|
| 106 | + add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced'); |
|
| 107 | 107 | } |
| 108 | 108 | |
| 109 | - if ( ! empty( $subscription_group ) ) { |
|
| 110 | - add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' ); |
|
| 109 | + if (!empty($subscription_group)) { |
|
| 110 | + add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low'); |
|
| 111 | 111 | } |
| 112 | 112 | |
| 113 | - add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' ); |
|
| 113 | + add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced'); |
|
| 114 | 114 | |
| 115 | - do_action( 'getpaid_admin_single_subscription_register_metabox', $sub ); |
|
| 115 | + do_action('getpaid_admin_single_subscription_register_metabox', $sub); |
|
| 116 | 116 | |
| 117 | 117 | ?> |
| 118 | 118 | |
| 119 | - <form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>"> |
|
| 119 | + <form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>"> |
|
| 120 | 120 | |
| 121 | - <?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?> |
|
| 122 | - <?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?> |
|
| 123 | - <?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?> |
|
| 121 | + <?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?> |
|
| 122 | + <?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?> |
|
| 123 | + <?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?> |
|
| 124 | 124 | <input type="hidden" name="getpaid-admin-action" value="update_single_subscription" /> |
| 125 | - <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" /> |
|
| 125 | + <input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" /> |
|
| 126 | 126 | |
| 127 | 127 | <div id="poststuff"> |
| 128 | 128 | <div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>"> |
| 129 | 129 | |
| 130 | 130 | <div id="postbox-container-1" class="postbox-container"> |
| 131 | - <?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?> |
|
| 131 | + <?php do_meta_boxes(get_current_screen(), 'side', $sub); ?> |
|
| 132 | 132 | </div> |
| 133 | 133 | |
| 134 | 134 | <div id="postbox-container-2" class="postbox-container"> |
| 135 | - <?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?> |
|
| 136 | - <?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?> |
|
| 135 | + <?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?> |
|
| 136 | + <?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?> |
|
| 137 | 137 | </div> |
| 138 | 138 | |
| 139 | 139 | </div> |
@@ -152,44 +152,44 @@ discard block |
||
| 152 | 152 | * |
| 153 | 153 | * @param WPInv_Subscription $sub |
| 154 | 154 | */ |
| 155 | -function getpaid_admin_subscription_details_metabox( $sub ) { |
|
| 155 | +function getpaid_admin_subscription_details_metabox($sub) { |
|
| 156 | 156 | |
| 157 | 157 | // Subscription items. |
| 158 | - $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() ); |
|
| 159 | - $items_count = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] ); |
|
| 158 | + $subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id()); |
|
| 159 | + $items_count = empty($subscription_group) ? 1 : count($subscription_group['items']); |
|
| 160 | 160 | |
| 161 | 161 | // Prepare subscription detail columns. |
| 162 | 162 | $fields = apply_filters( |
| 163 | 163 | 'getpaid_subscription_admin_page_fields', |
| 164 | 164 | array( |
| 165 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 166 | - 'customer' => __( 'Customer', 'invoicing' ), |
|
| 167 | - 'amount' => __( 'Amount', 'invoicing' ), |
|
| 168 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 169 | - 'renews_on' => __( 'Next Payment', 'invoicing' ), |
|
| 170 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 171 | - 'item' => _n( 'Item', 'Items', $items_count, 'invoicing' ), |
|
| 172 | - 'gateway' => __( 'Payment Method', 'invoicing' ), |
|
| 173 | - 'profile_id' => __( 'Profile ID', 'invoicing' ), |
|
| 174 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 165 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 166 | + 'customer' => __('Customer', 'invoicing'), |
|
| 167 | + 'amount' => __('Amount', 'invoicing'), |
|
| 168 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 169 | + 'renews_on' => __('Next Payment', 'invoicing'), |
|
| 170 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 171 | + 'item' => _n('Item', 'Items', $items_count, 'invoicing'), |
|
| 172 | + 'gateway' => __('Payment Method', 'invoicing'), |
|
| 173 | + 'profile_id' => __('Profile ID', 'invoicing'), |
|
| 174 | + 'status' => __('Status', 'invoicing'), |
|
| 175 | 175 | ) |
| 176 | 176 | ); |
| 177 | 177 | |
| 178 | - if ( ! $sub->is_active() ) { |
|
| 178 | + if (!$sub->is_active()) { |
|
| 179 | 179 | |
| 180 | - if ( isset( $fields['renews_on'] ) ) { |
|
| 181 | - unset( $fields['renews_on'] ); |
|
| 180 | + if (isset($fields['renews_on'])) { |
|
| 181 | + unset($fields['renews_on']); |
|
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - if ( isset( $fields['gateway'] ) ) { |
|
| 185 | - unset( $fields['gateway'] ); |
|
| 184 | + if (isset($fields['gateway'])) { |
|
| 185 | + unset($fields['gateway']); |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | } |
| 189 | 189 | |
| 190 | 190 | $profile_id = $sub->get_profile_id(); |
| 191 | - if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) { |
|
| 192 | - unset( $fields['profile_id'] ); |
|
| 191 | + if (empty($profile_id) && isset($fields['profile_id'])) { |
|
| 192 | + unset($fields['profile_id']); |
|
| 193 | 193 | } |
| 194 | 194 | |
| 195 | 195 | ?> |
@@ -197,16 +197,16 @@ discard block |
||
| 197 | 197 | <table class="table table-borderless" style="font-size: 14px;"> |
| 198 | 198 | <tbody> |
| 199 | 199 | |
| 200 | - <?php foreach ( $fields as $key => $label ) : ?> |
|
| 200 | + <?php foreach ($fields as $key => $label) : ?> |
|
| 201 | 201 | |
| 202 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
| 202 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
| 203 | 203 | |
| 204 | 204 | <th class="w-25" style="font-weight: 500;"> |
| 205 | - <?php echo sanitize_text_field( $label ); ?> |
|
| 205 | + <?php echo sanitize_text_field($label); ?> |
|
| 206 | 206 | </th> |
| 207 | 207 | |
| 208 | 208 | <td class="w-75 text-muted"> |
| 209 | - <?php do_action( 'getpaid_subscription_admin_display_' . sanitize_text_field( $key ), $sub, $subscription_group ); ?> |
|
| 209 | + <?php do_action('getpaid_subscription_admin_display_' . sanitize_text_field($key), $sub, $subscription_group); ?> |
|
| 210 | 210 | </td> |
| 211 | 211 | |
| 212 | 212 | </tr> |
@@ -224,129 +224,129 @@ discard block |
||
| 224 | 224 | * |
| 225 | 225 | * @param WPInv_Subscription $subscription |
| 226 | 226 | */ |
| 227 | -function getpaid_admin_subscription_metabox_display_customer( $subscription ) { |
|
| 227 | +function getpaid_admin_subscription_metabox_display_customer($subscription) { |
|
| 228 | 228 | |
| 229 | - $username = __( '(Missing User)', 'invoicing' ); |
|
| 229 | + $username = __('(Missing User)', 'invoicing'); |
|
| 230 | 230 | |
| 231 | - $user = get_userdata( $subscription->get_customer_id() ); |
|
| 232 | - if ( $user ) { |
|
| 231 | + $user = get_userdata($subscription->get_customer_id()); |
|
| 232 | + if ($user) { |
|
| 233 | 233 | |
| 234 | 234 | $username = sprintf( |
| 235 | 235 | '<a href="user-edit.php?user_id=%s">%s</a>', |
| 236 | - absint( $user->ID ), |
|
| 237 | - ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email ) |
|
| 236 | + absint($user->ID), |
|
| 237 | + !empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email) |
|
| 238 | 238 | ); |
| 239 | 239 | |
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | echo $username; |
| 243 | 243 | } |
| 244 | -add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' ); |
|
| 244 | +add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer'); |
|
| 245 | 245 | |
| 246 | 246 | /** |
| 247 | 247 | * Displays the subscription amount. |
| 248 | 248 | * |
| 249 | 249 | * @param WPInv_Subscription $subscription |
| 250 | 250 | */ |
| 251 | -function getpaid_admin_subscription_metabox_display_amount( $subscription ) { |
|
| 252 | - $amount = sanitize_text_field( getpaid_get_formatted_subscription_amount( $subscription ) ); |
|
| 251 | +function getpaid_admin_subscription_metabox_display_amount($subscription) { |
|
| 252 | + $amount = sanitize_text_field(getpaid_get_formatted_subscription_amount($subscription)); |
|
| 253 | 253 | echo "<span>$amount</span>"; |
| 254 | 254 | } |
| 255 | -add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' ); |
|
| 255 | +add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount'); |
|
| 256 | 256 | |
| 257 | 257 | /** |
| 258 | 258 | * Displays the subscription id. |
| 259 | 259 | * |
| 260 | 260 | * @param WPInv_Subscription $subscription |
| 261 | 261 | */ |
| 262 | -function getpaid_admin_subscription_metabox_display_id( $subscription ) { |
|
| 263 | - echo '#' . absint( $subscription->get_id() ); |
|
| 262 | +function getpaid_admin_subscription_metabox_display_id($subscription) { |
|
| 263 | + echo '#' . absint($subscription->get_id()); |
|
| 264 | 264 | } |
| 265 | -add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' ); |
|
| 265 | +add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id'); |
|
| 266 | 266 | |
| 267 | 267 | /** |
| 268 | 268 | * Displays the subscription renewal date. |
| 269 | 269 | * |
| 270 | 270 | * @param WPInv_Subscription $subscription |
| 271 | 271 | */ |
| 272 | -function getpaid_admin_subscription_metabox_display_start_date( $subscription ) { |
|
| 273 | - echo getpaid_format_date_value( $subscription->get_date_created() ); |
|
| 272 | +function getpaid_admin_subscription_metabox_display_start_date($subscription) { |
|
| 273 | + echo getpaid_format_date_value($subscription->get_date_created()); |
|
| 274 | 274 | } |
| 275 | -add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' ); |
|
| 275 | +add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date'); |
|
| 276 | 276 | |
| 277 | 277 | /** |
| 278 | 278 | * Displays the subscription renewal date. |
| 279 | 279 | * |
| 280 | 280 | * @param WPInv_Subscription $subscription |
| 281 | 281 | */ |
| 282 | -function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) { |
|
| 283 | - echo getpaid_format_date_value( $subscription->get_expiration() ); |
|
| 282 | +function getpaid_admin_subscription_metabox_display_renews_on($subscription) { |
|
| 283 | + echo getpaid_format_date_value($subscription->get_expiration()); |
|
| 284 | 284 | } |
| 285 | -add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' ); |
|
| 285 | +add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on'); |
|
| 286 | 286 | |
| 287 | 287 | /** |
| 288 | 288 | * Displays the subscription renewal count. |
| 289 | 289 | * |
| 290 | 290 | * @param WPInv_Subscription $subscription |
| 291 | 291 | */ |
| 292 | -function getpaid_admin_subscription_metabox_display_renewals( $subscription ) { |
|
| 292 | +function getpaid_admin_subscription_metabox_display_renewals($subscription) { |
|
| 293 | 293 | $max_bills = $subscription->get_bill_times(); |
| 294 | - echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 294 | + echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 295 | 295 | } |
| 296 | -add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' ); |
|
| 296 | +add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals'); |
|
| 297 | 297 | /** |
| 298 | 298 | * Displays the subscription item. |
| 299 | 299 | * |
| 300 | 300 | * @param WPInv_Subscription $subscription |
| 301 | 301 | * @param false|array $subscription_group |
| 302 | 302 | */ |
| 303 | -function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) { |
|
| 303 | +function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) { |
|
| 304 | 304 | |
| 305 | - if ( empty( $subscription_group ) ) { |
|
| 306 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
| 305 | + if (empty($subscription_group)) { |
|
| 306 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
| 307 | 307 | return; |
| 308 | 308 | } |
| 309 | 309 | |
| 310 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 311 | - echo implode( ' | ', $markup ); |
|
| 310 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 311 | + echo implode(' | ', $markup); |
|
| 312 | 312 | |
| 313 | 313 | } |
| 314 | -add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 ); |
|
| 314 | +add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2); |
|
| 315 | 315 | |
| 316 | 316 | /** |
| 317 | 317 | * Displays the subscription gateway. |
| 318 | 318 | * |
| 319 | 319 | * @param WPInv_Subscription $subscription |
| 320 | 320 | */ |
| 321 | -function getpaid_admin_subscription_metabox_display_gateway( $subscription ) { |
|
| 321 | +function getpaid_admin_subscription_metabox_display_gateway($subscription) { |
|
| 322 | 322 | |
| 323 | 323 | $gateway = $subscription->get_gateway(); |
| 324 | 324 | |
| 325 | - if ( ! empty( $gateway ) ) { |
|
| 326 | - echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) ); |
|
| 325 | + if (!empty($gateway)) { |
|
| 326 | + echo sanitize_text_field(wpinv_get_gateway_admin_label($gateway)); |
|
| 327 | 327 | } else { |
| 328 | 328 | echo "—"; |
| 329 | 329 | } |
| 330 | 330 | |
| 331 | 331 | } |
| 332 | -add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' ); |
|
| 332 | +add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway'); |
|
| 333 | 333 | |
| 334 | 334 | /** |
| 335 | 335 | * Displays the subscription status. |
| 336 | 336 | * |
| 337 | 337 | * @param WPInv_Subscription $subscription |
| 338 | 338 | */ |
| 339 | -function getpaid_admin_subscription_metabox_display_status( $subscription ) { |
|
| 339 | +function getpaid_admin_subscription_metabox_display_status($subscription) { |
|
| 340 | 340 | echo $subscription->get_status_label_html(); |
| 341 | 341 | } |
| 342 | -add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' ); |
|
| 342 | +add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status'); |
|
| 343 | 343 | |
| 344 | 344 | /** |
| 345 | 345 | * Displays the subscription profile id. |
| 346 | 346 | * |
| 347 | 347 | * @param WPInv_Subscription $subscription |
| 348 | 348 | */ |
| 349 | -function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) { |
|
| 349 | +function getpaid_admin_subscription_metabox_display_profile_id($subscription) { |
|
| 350 | 350 | |
| 351 | 351 | $profile_id = $subscription->get_profile_id(); |
| 352 | 352 | |
@@ -355,32 +355,32 @@ discard block |
||
| 355 | 355 | 'type' => 'text', |
| 356 | 356 | 'id' => 'wpinv_subscription_profile_id', |
| 357 | 357 | 'name' => 'wpinv_subscription_profile_id', |
| 358 | - 'label' => __( 'Profile Id', 'invoicing' ), |
|
| 358 | + 'label' => __('Profile Id', 'invoicing'), |
|
| 359 | 359 | 'label_type' => 'hidden', |
| 360 | - 'placeholder' => __( 'Profile Id', 'invoicing' ), |
|
| 361 | - 'value' => sanitize_text_field( $profile_id ), |
|
| 360 | + 'placeholder' => __('Profile Id', 'invoicing'), |
|
| 361 | + 'value' => sanitize_text_field($profile_id), |
|
| 362 | 362 | 'input_group_right' => '', |
| 363 | 363 | 'no_wrap' => true, |
| 364 | 364 | ) |
| 365 | 365 | ); |
| 366 | 366 | |
| 367 | - echo str_ireplace( 'form-control', 'regular-text', $input ); |
|
| 367 | + echo str_ireplace('form-control', 'regular-text', $input); |
|
| 368 | 368 | |
| 369 | - $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription ); |
|
| 370 | - if ( ! empty( $url ) ) { |
|
| 371 | - $url = esc_url_raw( $url ); |
|
| 372 | - echo ' <a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 369 | + $url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription); |
|
| 370 | + if (!empty($url)) { |
|
| 371 | + $url = esc_url_raw($url); |
|
| 372 | + echo ' <a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>'; |
|
| 373 | 373 | } |
| 374 | 374 | |
| 375 | 375 | } |
| 376 | -add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' ); |
|
| 376 | +add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id'); |
|
| 377 | 377 | |
| 378 | 378 | /** |
| 379 | 379 | * Displays the subscriptions update metabox. |
| 380 | 380 | * |
| 381 | 381 | * @param WPInv_Subscription $subscription |
| 382 | 382 | */ |
| 383 | -function getpaid_admin_subscription_update_metabox( $subscription ) { |
|
| 383 | +function getpaid_admin_subscription_update_metabox($subscription) { |
|
| 384 | 384 | |
| 385 | 385 | ?> |
| 386 | 386 | <div class="mt-3"> |
@@ -393,10 +393,10 @@ discard block |
||
| 393 | 393 | 'id' => 'subscription_status_update_select', |
| 394 | 394 | 'required' => true, |
| 395 | 395 | 'no_wrap' => false, |
| 396 | - 'label' => __( 'Subscription Status', 'invoicing' ), |
|
| 397 | - 'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ), |
|
| 396 | + 'label' => __('Subscription Status', 'invoicing'), |
|
| 397 | + 'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'), |
|
| 398 | 398 | 'select2' => true, |
| 399 | - 'value' => $subscription->get_status( 'edit' ), |
|
| 399 | + 'value' => $subscription->get_status('edit'), |
|
| 400 | 400 | ) |
| 401 | 401 | ); |
| 402 | 402 | ?> |
@@ -404,13 +404,13 @@ discard block |
||
| 404 | 404 | <div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;"> |
| 405 | 405 | |
| 406 | 406 | <?php |
| 407 | - submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false ); |
|
| 407 | + submit_button(__('Update', 'invoicing'), 'primary', 'submit', false); |
|
| 408 | 408 | |
| 409 | - $url = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) ); |
|
| 410 | - $anchor = __( 'Renew Subscription', 'invoicing' ); |
|
| 411 | - $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' ); |
|
| 409 | + $url = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce')); |
|
| 410 | + $anchor = __('Renew Subscription', 'invoicing'); |
|
| 411 | + $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'); |
|
| 412 | 412 | |
| 413 | - if ( $subscription->is_active() ) { |
|
| 413 | + if ($subscription->is_active()) { |
|
| 414 | 414 | echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>"; |
| 415 | 415 | } |
| 416 | 416 | |
@@ -423,31 +423,31 @@ discard block |
||
| 423 | 423 | * @param WPInv_Subscription $subscription |
| 424 | 424 | * @param bool $strict Whether or not to skip invoices of sibling subscriptions |
| 425 | 425 | */ |
| 426 | -function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) { |
|
| 426 | +function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) { |
|
| 427 | 427 | |
| 428 | 428 | $columns = apply_filters( |
| 429 | 429 | 'getpaid_subscription_related_invoices_columns', |
| 430 | 430 | array( |
| 431 | - 'invoice' => __( 'Invoice', 'invoicing' ), |
|
| 432 | - 'relationship' => __( 'Relationship', 'invoicing' ), |
|
| 433 | - 'date' => __( 'Date', 'invoicing' ), |
|
| 434 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 435 | - 'total' => __( 'Total', 'invoicing' ), |
|
| 431 | + 'invoice' => __('Invoice', 'invoicing'), |
|
| 432 | + 'relationship' => __('Relationship', 'invoicing'), |
|
| 433 | + 'date' => __('Date', 'invoicing'), |
|
| 434 | + 'status' => __('Status', 'invoicing'), |
|
| 435 | + 'total' => __('Total', 'invoicing'), |
|
| 436 | 436 | ), |
| 437 | 437 | $subscription |
| 438 | 438 | ); |
| 439 | 439 | |
| 440 | 440 | // Prepare the invoices. |
| 441 | - $payments = $subscription->get_child_payments( ! is_admin() ); |
|
| 441 | + $payments = $subscription->get_child_payments(!is_admin()); |
|
| 442 | 442 | $parent = $subscription->get_parent_invoice(); |
| 443 | 443 | |
| 444 | - if ( $parent->exists() ) { |
|
| 445 | - $payments = array_merge( array( $parent ), $payments ); |
|
| 444 | + if ($parent->exists()) { |
|
| 445 | + $payments = array_merge(array($parent), $payments); |
|
| 446 | 446 | } |
| 447 | 447 | |
| 448 | 448 | $table_class = 'w-100 bg-white'; |
| 449 | 449 | |
| 450 | - if ( ! is_admin() ) { |
|
| 450 | + if (!is_admin()) { |
|
| 451 | 451 | $table_class = 'table table-bordered'; |
| 452 | 452 | } |
| 453 | 453 | |
@@ -459,9 +459,9 @@ discard block |
||
| 459 | 459 | <thead> |
| 460 | 460 | <tr> |
| 461 | 461 | <?php |
| 462 | - foreach ( $columns as $key => $label ) { |
|
| 463 | - $key = esc_attr( $key ); |
|
| 464 | - $label = sanitize_text_field( $label ); |
|
| 462 | + foreach ($columns as $key => $label) { |
|
| 463 | + $key = esc_attr($key); |
|
| 464 | + $label = sanitize_text_field($label); |
|
| 465 | 465 | $class = 'text-left'; |
| 466 | 466 | |
| 467 | 467 | echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -472,57 +472,57 @@ discard block |
||
| 472 | 472 | |
| 473 | 473 | <tbody> |
| 474 | 474 | |
| 475 | - <?php if ( empty( $payments ) ) : ?> |
|
| 475 | + <?php if (empty($payments)) : ?> |
|
| 476 | 476 | <tr> |
| 477 | 477 | <td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted"> |
| 478 | - <?php _e( 'This subscription has no invoices.', 'invoicing' ); ?> |
|
| 478 | + <?php _e('This subscription has no invoices.', 'invoicing'); ?> |
|
| 479 | 479 | </td> |
| 480 | 480 | </tr> |
| 481 | 481 | <?php endif; ?> |
| 482 | 482 | |
| 483 | 483 | <?php |
| 484 | 484 | |
| 485 | - foreach( $payments as $payment ) : |
|
| 485 | + foreach ($payments as $payment) : |
|
| 486 | 486 | |
| 487 | 487 | // Ensure that we have an invoice. |
| 488 | - $payment = new WPInv_Invoice( $payment ); |
|
| 488 | + $payment = new WPInv_Invoice($payment); |
|
| 489 | 489 | |
| 490 | 490 | // Abort if the invoice is invalid... |
| 491 | - if ( ! $payment->exists() ) { |
|
| 491 | + if (!$payment->exists()) { |
|
| 492 | 492 | continue; |
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | // ... or belongs to a different subscription. |
| 496 | - if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) { |
|
| 496 | + if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) { |
|
| 497 | 497 | continue; |
| 498 | 498 | } |
| 499 | 499 | |
| 500 | 500 | echo '<tr>'; |
| 501 | 501 | |
| 502 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 502 | + foreach (array_keys($columns) as $key) { |
|
| 503 | 503 | |
| 504 | 504 | $class = 'text-left'; |
| 505 | 505 | |
| 506 | 506 | echo "<td class='p-2 $class'>"; |
| 507 | 507 | |
| 508 | - switch( $key ) { |
|
| 508 | + switch ($key) { |
|
| 509 | 509 | |
| 510 | 510 | case 'total': |
| 511 | - echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>'; |
|
| 511 | + echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>'; |
|
| 512 | 512 | break; |
| 513 | 513 | |
| 514 | 514 | case 'relationship': |
| 515 | - echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' ); |
|
| 515 | + echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing'); |
|
| 516 | 516 | break; |
| 517 | 517 | |
| 518 | 518 | case 'date': |
| 519 | - echo getpaid_format_date_value( $payment->get_date_created() ); |
|
| 519 | + echo getpaid_format_date_value($payment->get_date_created()); |
|
| 520 | 520 | break; |
| 521 | 521 | |
| 522 | 522 | case 'status': |
| 523 | 523 | |
| 524 | 524 | $status = $payment->get_status_nicename(); |
| 525 | - if ( is_admin() ) { |
|
| 525 | + if (is_admin()) { |
|
| 526 | 526 | $status = $payment->get_status_label_html(); |
| 527 | 527 | } |
| 528 | 528 | |
@@ -530,13 +530,13 @@ discard block |
||
| 530 | 530 | break; |
| 531 | 531 | |
| 532 | 532 | case 'invoice': |
| 533 | - $link = esc_url( get_edit_post_link( $payment->get_id() ) ); |
|
| 533 | + $link = esc_url(get_edit_post_link($payment->get_id())); |
|
| 534 | 534 | |
| 535 | - if ( ! is_admin() ) { |
|
| 536 | - $link = esc_url( $payment->get_view_url() ); |
|
| 535 | + if (!is_admin()) { |
|
| 536 | + $link = esc_url($payment->get_view_url()); |
|
| 537 | 537 | } |
| 538 | 538 | |
| 539 | - $invoice = sanitize_text_field( $payment->get_number() ); |
|
| 539 | + $invoice = sanitize_text_field($payment->get_number()); |
|
| 540 | 540 | echo "<a href='$link'>$invoice</a>"; |
| 541 | 541 | break; |
| 542 | 542 | } |
@@ -564,12 +564,12 @@ discard block |
||
| 564 | 564 | * |
| 565 | 565 | * @param WPInv_Subscription $subscription |
| 566 | 566 | */ |
| 567 | -function getpaid_admin_subscription_item_details_metabox( $subscription ) { |
|
| 567 | +function getpaid_admin_subscription_item_details_metabox($subscription) { |
|
| 568 | 568 | |
| 569 | 569 | // Fetch the subscription group. |
| 570 | - $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() ); |
|
| 570 | + $subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id()); |
|
| 571 | 571 | |
| 572 | - if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) { |
|
| 572 | + if (empty($subscription_group) || empty($subscription_group['items'])) { |
|
| 573 | 573 | return; |
| 574 | 574 | } |
| 575 | 575 | |
@@ -577,12 +577,12 @@ discard block |
||
| 577 | 577 | $columns = apply_filters( |
| 578 | 578 | 'getpaid_subscription_item_details_columns', |
| 579 | 579 | array( |
| 580 | - 'item_name' => __( 'Item', 'invoicing' ), |
|
| 581 | - 'price' => __( 'Price', 'invoicing' ), |
|
| 582 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
| 583 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
| 584 | - 'initial' => __( 'Initial Amount', 'invoicing' ), |
|
| 585 | - 'recurring' => __( 'Recurring Amount', 'invoicing' ), |
|
| 580 | + 'item_name' => __('Item', 'invoicing'), |
|
| 581 | + 'price' => __('Price', 'invoicing'), |
|
| 582 | + 'tax' => __('Tax', 'invoicing'), |
|
| 583 | + 'discount' => __('Discount', 'invoicing'), |
|
| 584 | + 'initial' => __('Initial Amount', 'invoicing'), |
|
| 585 | + 'recurring' => __('Recurring Amount', 'invoicing'), |
|
| 586 | 586 | ), |
| 587 | 587 | $subscription |
| 588 | 588 | ); |
@@ -591,13 +591,13 @@ discard block |
||
| 591 | 591 | |
| 592 | 592 | $invoice = $subscription->get_parent_invoice(); |
| 593 | 593 | |
| 594 | - if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) { |
|
| 595 | - unset( $columns['tax'] ); |
|
| 594 | + if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) { |
|
| 595 | + unset($columns['tax']); |
|
| 596 | 596 | } |
| 597 | 597 | |
| 598 | 598 | $table_class = 'w-100 bg-white'; |
| 599 | 599 | |
| 600 | - if ( ! is_admin() ) { |
|
| 600 | + if (!is_admin()) { |
|
| 601 | 601 | $table_class = 'table table-bordered'; |
| 602 | 602 | } |
| 603 | 603 | |
@@ -610,9 +610,9 @@ discard block |
||
| 610 | 610 | <tr> |
| 611 | 611 | <?php |
| 612 | 612 | |
| 613 | - foreach ( $columns as $key => $label ) { |
|
| 614 | - $key = esc_attr( $key ); |
|
| 615 | - $label = sanitize_text_field( $label ); |
|
| 613 | + foreach ($columns as $key => $label) { |
|
| 614 | + $key = esc_attr($key); |
|
| 615 | + $label = sanitize_text_field($label); |
|
| 616 | 616 | $class = 'text-left'; |
| 617 | 617 | |
| 618 | 618 | echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -625,48 +625,48 @@ discard block |
||
| 625 | 625 | |
| 626 | 626 | <?php |
| 627 | 627 | |
| 628 | - foreach( $subscription_group['items'] as $subscription_group_item ) : |
|
| 628 | + foreach ($subscription_group['items'] as $subscription_group_item) : |
|
| 629 | 629 | |
| 630 | 630 | echo '<tr>'; |
| 631 | 631 | |
| 632 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 632 | + foreach (array_keys($columns) as $key) { |
|
| 633 | 633 | |
| 634 | 634 | $class = 'text-left'; |
| 635 | 635 | |
| 636 | 636 | echo "<td class='p-2 $class'>"; |
| 637 | 637 | |
| 638 | - switch( $key ) { |
|
| 638 | + switch ($key) { |
|
| 639 | 639 | |
| 640 | 640 | case 'item_name': |
| 641 | - $item_name = get_the_title( $subscription_group_item['item_id'] ); |
|
| 642 | - $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name; |
|
| 641 | + $item_name = get_the_title($subscription_group_item['item_id']); |
|
| 642 | + $item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name; |
|
| 643 | 643 | |
| 644 | - if ( $invoice->get_template() == 'amount' || 1 === (int) $subscription_group_item['quantity'] ) { |
|
| 645 | - echo sanitize_text_field( $item_name ); |
|
| 644 | + if ($invoice->get_template() == 'amount' || 1 === (int) $subscription_group_item['quantity']) { |
|
| 645 | + echo sanitize_text_field($item_name); |
|
| 646 | 646 | } else { |
| 647 | - printf( '%1$s x %2$d', sanitize_text_field( $item_name ), (int) $subscription_group_item['quantity'] ); |
|
| 647 | + printf('%1$s x %2$d', sanitize_text_field($item_name), (int) $subscription_group_item['quantity']); |
|
| 648 | 648 | } |
| 649 | 649 | |
| 650 | 650 | break; |
| 651 | 651 | |
| 652 | 652 | case 'price': |
| 653 | - echo wpinv_price( $subscription_group_item['price'], $invoice->get_currency() ); |
|
| 653 | + echo wpinv_price($subscription_group_item['price'], $invoice->get_currency()); |
|
| 654 | 654 | break; |
| 655 | 655 | |
| 656 | 656 | case 'tax': |
| 657 | - echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() ); |
|
| 657 | + echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency()); |
|
| 658 | 658 | break; |
| 659 | 659 | |
| 660 | 660 | case 'discount': |
| 661 | - echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() ); |
|
| 661 | + echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency()); |
|
| 662 | 662 | break; |
| 663 | 663 | |
| 664 | 664 | case 'initial': |
| 665 | - echo wpinv_price( $subscription_group_item['subtotal'], $invoice->get_currency() ); |
|
| 665 | + echo wpinv_price($subscription_group_item['subtotal'], $invoice->get_currency()); |
|
| 666 | 666 | break; |
| 667 | 667 | |
| 668 | 668 | case 'recurring': |
| 669 | - echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>'; |
|
| 669 | + echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>'; |
|
| 670 | 670 | break; |
| 671 | 671 | |
| 672 | 672 | } |
@@ -679,24 +679,24 @@ discard block |
||
| 679 | 679 | |
| 680 | 680 | endforeach; |
| 681 | 681 | |
| 682 | - foreach( $subscription_group['fees'] as $subscription_group_fee ) : |
|
| 682 | + foreach ($subscription_group['fees'] as $subscription_group_fee) : |
|
| 683 | 683 | |
| 684 | 684 | echo '<tr>'; |
| 685 | 685 | |
| 686 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 686 | + foreach (array_keys($columns) as $key) { |
|
| 687 | 687 | |
| 688 | 688 | $class = 'text-left'; |
| 689 | 689 | |
| 690 | 690 | echo "<td class='p-2 $class'>"; |
| 691 | 691 | |
| 692 | - switch( $key ) { |
|
| 692 | + switch ($key) { |
|
| 693 | 693 | |
| 694 | 694 | case 'item_name': |
| 695 | - echo sanitize_text_field( $subscription_group_fee['name'] ); |
|
| 695 | + echo sanitize_text_field($subscription_group_fee['name']); |
|
| 696 | 696 | break; |
| 697 | 697 | |
| 698 | 698 | case 'price': |
| 699 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 699 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 700 | 700 | break; |
| 701 | 701 | |
| 702 | 702 | case 'tax': |
@@ -708,11 +708,11 @@ discard block |
||
| 708 | 708 | break; |
| 709 | 709 | |
| 710 | 710 | case 'initial': |
| 711 | - echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() ); |
|
| 711 | + echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency()); |
|
| 712 | 712 | break; |
| 713 | 713 | |
| 714 | 714 | case 'recurring': |
| 715 | - echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>'; |
|
| 715 | + echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>'; |
|
| 716 | 716 | break; |
| 717 | 717 | |
| 718 | 718 | } |
@@ -741,12 +741,12 @@ discard block |
||
| 741 | 741 | * @param WPInv_Subscription $subscription |
| 742 | 742 | * @param bool $skip_current |
| 743 | 743 | */ |
| 744 | -function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) { |
|
| 744 | +function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) { |
|
| 745 | 745 | |
| 746 | 746 | // Fetch the subscription groups. |
| 747 | - $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() ); |
|
| 747 | + $subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id()); |
|
| 748 | 748 | |
| 749 | - if ( empty( $subscription_groups ) ) { |
|
| 749 | + if (empty($subscription_groups)) { |
|
| 750 | 750 | return; |
| 751 | 751 | } |
| 752 | 752 | |
@@ -754,23 +754,23 @@ discard block |
||
| 754 | 754 | $columns = apply_filters( |
| 755 | 755 | 'getpaid_subscription_related_subscriptions_columns', |
| 756 | 756 | array( |
| 757 | - 'subscription' => __( 'Subscription', 'invoicing' ), |
|
| 758 | - 'start_date' => __( 'Start Date', 'invoicing' ), |
|
| 759 | - 'renewal_date' => __( 'Next Payment', 'invoicing' ), |
|
| 760 | - 'renewals' => __( 'Payments', 'invoicing' ), |
|
| 761 | - 'item' => __( 'Items', 'invoicing' ), |
|
| 762 | - 'status' => __( 'Status', 'invoicing' ), |
|
| 757 | + 'subscription' => __('Subscription', 'invoicing'), |
|
| 758 | + 'start_date' => __('Start Date', 'invoicing'), |
|
| 759 | + 'renewal_date' => __('Next Payment', 'invoicing'), |
|
| 760 | + 'renewals' => __('Payments', 'invoicing'), |
|
| 761 | + 'item' => __('Items', 'invoicing'), |
|
| 762 | + 'status' => __('Status', 'invoicing'), |
|
| 763 | 763 | ), |
| 764 | 764 | $subscription |
| 765 | 765 | ); |
| 766 | 766 | |
| 767 | - if ( $subscription->get_status() == 'pending' ) { |
|
| 768 | - unset( $columns['start_date'], $columns['renewal_date'] ); |
|
| 767 | + if ($subscription->get_status() == 'pending') { |
|
| 768 | + unset($columns['start_date'], $columns['renewal_date']); |
|
| 769 | 769 | } |
| 770 | 770 | |
| 771 | 771 | $table_class = 'w-100 bg-white'; |
| 772 | 772 | |
| 773 | - if ( ! is_admin() ) { |
|
| 773 | + if (!is_admin()) { |
|
| 774 | 774 | $table_class = 'table table-bordered'; |
| 775 | 775 | } |
| 776 | 776 | |
@@ -783,9 +783,9 @@ discard block |
||
| 783 | 783 | <tr> |
| 784 | 784 | <?php |
| 785 | 785 | |
| 786 | - foreach ( $columns as $key => $label ) { |
|
| 787 | - $key = esc_attr( $key ); |
|
| 788 | - $label = sanitize_text_field( $label ); |
|
| 786 | + foreach ($columns as $key => $label) { |
|
| 787 | + $key = esc_attr($key); |
|
| 788 | + $label = sanitize_text_field($label); |
|
| 789 | 789 | $class = 'text-left'; |
| 790 | 790 | |
| 791 | 791 | echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>"; |
@@ -798,62 +798,62 @@ discard block |
||
| 798 | 798 | |
| 799 | 799 | <?php |
| 800 | 800 | |
| 801 | - foreach( $subscription_groups as $subscription_group ) : |
|
| 801 | + foreach ($subscription_groups as $subscription_group) : |
|
| 802 | 802 | |
| 803 | 803 | // Do not list current subscription. |
| 804 | - if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) { |
|
| 804 | + if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) { |
|
| 805 | 805 | continue; |
| 806 | 806 | } |
| 807 | 807 | |
| 808 | 808 | // Ensure the subscription exists. |
| 809 | - $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] ); |
|
| 809 | + $_suscription = new WPInv_Subscription($subscription_group['subscription_id']); |
|
| 810 | 810 | |
| 811 | - if ( ! $_suscription->exists() ) { |
|
| 811 | + if (!$_suscription->exists()) { |
|
| 812 | 812 | continue; |
| 813 | 813 | } |
| 814 | 814 | |
| 815 | 815 | echo '<tr>'; |
| 816 | 816 | |
| 817 | - foreach ( array_keys( $columns ) as $key ) { |
|
| 817 | + foreach (array_keys($columns) as $key) { |
|
| 818 | 818 | |
| 819 | 819 | $class = 'text-left'; |
| 820 | 820 | |
| 821 | 821 | echo "<td class='p-2 $class'>"; |
| 822 | 822 | |
| 823 | - switch( $key ) { |
|
| 823 | + switch ($key) { |
|
| 824 | 824 | |
| 825 | 825 | case 'status': |
| 826 | 826 | echo $_suscription->get_status_label_html(); |
| 827 | 827 | break; |
| 828 | 828 | |
| 829 | 829 | case 'item': |
| 830 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
| 831 | - echo implode( ' | ', $markup ); |
|
| 830 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
| 831 | + echo implode(' | ', $markup); |
|
| 832 | 832 | break; |
| 833 | 833 | |
| 834 | 834 | case 'renewals': |
| 835 | 835 | $max_bills = $_suscription->get_bill_times(); |
| 836 | - echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "∞" : $max_bills ); |
|
| 836 | + echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "∞" : $max_bills); |
|
| 837 | 837 | break; |
| 838 | 838 | |
| 839 | 839 | case 'renewal_date': |
| 840 | - echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "—"; |
|
| 840 | + echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "—"; |
|
| 841 | 841 | break; |
| 842 | 842 | |
| 843 | 843 | case 'start_date': |
| 844 | - echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value( $_suscription->get_date_created() ); |
|
| 844 | + echo 'pending' == $_suscription->get_status() ? "—" : getpaid_format_date_value($_suscription->get_date_created()); |
|
| 845 | 845 | break; |
| 846 | 846 | |
| 847 | 847 | case 'subscription': |
| 848 | - $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url(); |
|
| 848 | + $url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url(); |
|
| 849 | 849 | printf( |
| 850 | 850 | '%1$s#%2$s%3$s', |
| 851 | - '<a href="' . esc_url( $url ) . '">', |
|
| 852 | - '<strong>' . intval( $_suscription->get_id() ) . '</strong>', |
|
| 851 | + '<a href="' . esc_url($url) . '">', |
|
| 852 | + '<strong>' . intval($_suscription->get_id()) . '</strong>', |
|
| 853 | 853 | '</a>' |
| 854 | 854 | ); |
| 855 | 855 | |
| 856 | - echo WPInv_Subscriptions_List_Table::column_amount( $_suscription ); |
|
| 856 | + echo WPInv_Subscriptions_List_Table::column_amount($_suscription); |
|
| 857 | 857 | break; |
| 858 | 858 | |
| 859 | 859 | } |