Passed
Push — master ( 514302...5ba00a )
by Brian
05:19
created
templates/subscriptions/subscription-details.php 1 patch
Indentation   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -46,64 +46,64 @@  discard block
 block discarded – undo
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'>&nbsp;";
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'>&nbsp;";
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 ) ? "&infin;" : $max_activations );
98
+                                $max_activations = (int) $subscription->get_bill_times();
99
+                                echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "&infin;" : $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
 block discarded – undo
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>&nbsp;&nbsp;',
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>&nbsp;&nbsp;',
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>
Please login to merge, or discard this patch.
widgets/subscriptions.php 1 patch
Indentation   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -14,144 +14,144 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 1 patch
Indentation   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 ) ? "&infin;" : $max_bills );
293
+    $max_bills = $subscription->get_bill_times();
294
+    echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $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
 block discarded – undo
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
 block discarded – undo
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 "&mdash;";
329
-	}
325
+    if ( ! empty( $gateway ) ) {
326
+        echo sanitize_text_field( wpinv_get_gateway_admin_label( $gateway ) );
327
+    } else {
328
+        echo "&mdash;";
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
 block discarded – undo
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
 block discarded – undo
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 '&nbsp;<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 '&nbsp;<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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 "&mdash;";
704
-												break;
702
+                                            case 'tax':
703
+                                                echo "&mdash;";
704
+                                                break;
705 705
 
706
-											case 'discount':
707
-												echo "&mdash;";
708
-												break;
706
+                                            case 'discount':
707
+                                                echo "&mdash;";
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 ) ? "&infin;" : $max_bills );
837
-												break;
834
+                                            case 'renewals':
835
+                                                $max_bills = $_suscription->get_bill_times();
836
+                                                echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
837
+                                                break;
838 838
 
839
-											case 'renewal_date':
840
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
841
-												break;
839
+                                            case 'renewal_date':
840
+                                                echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
841
+                                                break;
842 842
 
843
-											case 'start_date':
844
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
845
-												break;
843
+                                            case 'start_date':
844
+                                                echo 'pending' == $_suscription->get_status() ? "&mdash;" : 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
 
Please login to merge, or discard this patch.