Passed
Pull Request — master (#399)
by Brian
04:31
created
includes/admin/class-wpinv-subscriptions-list-table.php 3 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,9 @@
 block discarded – undo
8 8
 
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) exit;
11
+if ( ! defined( 'ABSPATH' ) ) {
12
+    exit;
13
+}
12 14
 
13 15
 
14 16
 // Load WP_List_Table if not loaded
Please login to merge, or discard this patch.
Indentation   +349 added lines, -349 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 
14 14
 // Load WP_List_Table if not loaded
15 15
 if( ! class_exists( 'WP_List_Table' ) ) {
16
-	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
16
+    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17 17
 }
18 18
 
19 19
 /**
@@ -23,102 +23,102 @@  discard block
 block discarded – undo
23 23
  */
24 24
 class WPInv_Subscription_Reports_Table extends WP_List_Table {
25 25
 
26
-	/**
27
-	 * Number of results to show per page
28
-	 *
29
-	 * @since       1.0.0
30
-	 */
31
-
32
-	public $per_page        = 20;
33
-	public $total_count     = 0;
34
-	public $active_count    = 0;
35
-	public $pending_count   = 0;
36
-	public $expired_count   = 0;
37
-	public $completed_count = 0;
38
-	public $trialling_count  = 0;
39
-	public $cancelled_count = 0;
40
-	public $failing_count   = 0;
41
-
42
-	/**
43
-	 * Get things started
44
-	 *
45
-	 * @access      private
46
-	 * @since       1.0.0
47
-	 * @return      void
48
-	 */
49
-	function __construct(){
50
-		global $status, $page;
51
-
52
-		// Set parent defaults
53
-		parent::__construct( array(
54
-			'singular'  => 'subscription',
55
-			'plural'    => 'subscriptions',
56
-			'ajax'      => false
57
-		) );
58
-
59
-		$this->get_subscription_counts();
60
-
61
-	}
62
-
63
-	/**
64
-	 * Retrieve the view types
65
-	 *
66
-	 * @access public
67
-	 * @since 1.0.0
68
-	 * @return array $views All the views available
69
-	 */
70
-	public function get_views() {
71
-
72
-		$current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
73
-		$total_count     = '&nbsp;<span class="count">(' . $this->total_count    . ')</span>';
74
-		$active_count    = '&nbsp;<span class="count">(' . $this->active_count . ')</span>';
75
-		$pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
76
-		$expired_count   = '&nbsp;<span class="count">(' . $this->expired_count  . ')</span>';
77
-		$completed_count = '&nbsp;<span class="count">(' . $this->completed_count . ')</span>';
78
-		$trialling_count  = '&nbsp;<span class="count">(' . $this->trialling_count   . ')</span>';
79
-		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count   . ')</span>';
80
-		$failing_count   = '&nbsp;<span class="count">(' . $this->failing_count   . ')</span>';
81
-
82
-		$views = array(
83
-			'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ),
84
-			'active'    => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ),
85
-			'pending'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ),
86
-			'expired'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ),
87
-			'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ),
88
-			'trialling'  => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ),
89
-			'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ),
90
-			'failing'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ),
91
-		);
92
-
93
-		return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views );
94
-	}
95
-
96
-	/**
97
-	 * Show the search field
98
-	 *
99
-	 * @since 2.5
100
-	 * @access public
101
-	 *
102
-	 * @param string $text Label for the search box
103
-	 * @param string $input_id ID of the search box
104
-	 *
105
-	 * @return void
106
-	 */
107
-	public function search_box( $text, $input_id ) {
108
-
109
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
110
-			return;
111
-		}
112
-
113
-		$input_id = $input_id . '-search-input';
114
-
115
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
116
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
117
-		}
118
-
119
-		if ( ! empty( $_REQUEST['order'] ) ) {
120
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
121
-		}
26
+    /**
27
+     * Number of results to show per page
28
+     *
29
+     * @since       1.0.0
30
+     */
31
+
32
+    public $per_page        = 20;
33
+    public $total_count     = 0;
34
+    public $active_count    = 0;
35
+    public $pending_count   = 0;
36
+    public $expired_count   = 0;
37
+    public $completed_count = 0;
38
+    public $trialling_count  = 0;
39
+    public $cancelled_count = 0;
40
+    public $failing_count   = 0;
41
+
42
+    /**
43
+     * Get things started
44
+     *
45
+     * @access      private
46
+     * @since       1.0.0
47
+     * @return      void
48
+     */
49
+    function __construct(){
50
+        global $status, $page;
51
+
52
+        // Set parent defaults
53
+        parent::__construct( array(
54
+            'singular'  => 'subscription',
55
+            'plural'    => 'subscriptions',
56
+            'ajax'      => false
57
+        ) );
58
+
59
+        $this->get_subscription_counts();
60
+
61
+    }
62
+
63
+    /**
64
+     * Retrieve the view types
65
+     *
66
+     * @access public
67
+     * @since 1.0.0
68
+     * @return array $views All the views available
69
+     */
70
+    public function get_views() {
71
+
72
+        $current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
73
+        $total_count     = '&nbsp;<span class="count">(' . $this->total_count    . ')</span>';
74
+        $active_count    = '&nbsp;<span class="count">(' . $this->active_count . ')</span>';
75
+        $pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
76
+        $expired_count   = '&nbsp;<span class="count">(' . $this->expired_count  . ')</span>';
77
+        $completed_count = '&nbsp;<span class="count">(' . $this->completed_count . ')</span>';
78
+        $trialling_count  = '&nbsp;<span class="count">(' . $this->trialling_count   . ')</span>';
79
+        $cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count   . ')</span>';
80
+        $failing_count   = '&nbsp;<span class="count">(' . $this->failing_count   . ')</span>';
81
+
82
+        $views = array(
83
+            'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ),
84
+            'active'    => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ),
85
+            'pending'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ),
86
+            'expired'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ),
87
+            'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ),
88
+            'trialling'  => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ),
89
+            'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ),
90
+            'failing'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ),
91
+        );
92
+
93
+        return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views );
94
+    }
95
+
96
+    /**
97
+     * Show the search field
98
+     *
99
+     * @since 2.5
100
+     * @access public
101
+     *
102
+     * @param string $text Label for the search box
103
+     * @param string $input_id ID of the search box
104
+     *
105
+     * @return void
106
+     */
107
+    public function search_box( $text, $input_id ) {
108
+
109
+        if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
110
+            return;
111
+        }
112
+
113
+        $input_id = $input_id . '-search-input';
114
+
115
+        if ( ! empty( $_REQUEST['orderby'] ) ) {
116
+            echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
117
+        }
118
+
119
+        if ( ! empty( $_REQUEST['order'] ) ) {
120
+            echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
121
+        }
122 122
 ?>
123 123
 		<p class="search-box">
124 124
 			<?php do_action( 'wpinv_recurring_subscription_search_box' ); ?>
@@ -127,18 +127,18 @@  discard block
 block discarded – undo
127 127
 			<?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/>
128 128
 		</p>
129 129
 <?php
130
-	}
131
-
132
-	/**
133
-	 * Render most columns
134
-	 *
135
-	 * @access      private
136
-	 * @since       1.0.0
137
-	 * @return      string
138
-	 */
139
-	function column_default( $item, $column_name ) {
140
-		return $item->$column_name;
141
-	}
130
+    }
131
+
132
+    /**
133
+     * Render most columns
134
+     *
135
+     * @access      private
136
+     * @since       1.0.0
137
+     * @return      string
138
+     */
139
+    function column_default( $item, $column_name ) {
140
+        return $item->$column_name;
141
+    }
142 142
 
143 143
     /**
144 144
      * Subscription id column
@@ -151,244 +151,244 @@  discard block
 block discarded – undo
151 151
         return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>';
152 152
     }
153 153
 
154
-	/**
155
-	 * Customer column
156
-	 *
157
-	 * @access      private
158
-	 * @since       1.0.0
159
-	 * @return      string
160
-	 */
161
-	function column_customer_id( $item ) {
162
-		$subscriber = get_userdata( $item->customer_id );
163
-		$customer   = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email;
164
-
165
-		return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>';
166
-	}
167
-
168
-	/**
169
-	 * Status column
170
-	 *
171
-	 * @access      private
172
-	 * @since       1.0.0
173
-	 * @return      string
174
-	 */
175
-	function column_status( $item ) {
176
-		return $item->get_status_label();
177
-	}
178
-
179
-	/**
180
-	 * Period column
181
-	 *
182
-	 * @access      private
183
-	 * @since       1.0.0
184
-	 * @return      string
185
-	 */
186
-	function column_period( $item ) {
187
-
188
-		$period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency );
189
-
190
-		return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period;
191
-	}
192
-
193
-	/**
194
-	 * Billing Times column
195
-	 *
196
-	 * @access      private
197
-	 * @since       1.0.0
198
-	 * @return      string
199
-	 */
200
-	function column_bill_times( $item ) {
201
-		return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $item->bill_times );
202
-	}
203
-
204
-	/**
205
-	 * Initial Amount column
206
-	 *
207
-	 * @access      private
208
-	 * @since       1.0.0
209
-	 * @return      string
210
-	 */
211
-	function column_initial_amount( $item ) {
212
-		return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) );
213
-	}
214
-
215
-	/**
216
-	 * Renewal date column
217
-	 *
218
-	 * @access      private
219
-	 * @since       1.0.0
220
-	 * @return      string
221
-	 */
222
-	function column_renewal_date( $item ) {
223
-		return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' );
224
-	}
225
-
226
-	/**
227
-	 * Payment column
228
-	 *
229
-	 * @access      private
230
-	 * @since       1.0.0
231
-	 * @return      string
232
-	 */
233
-	function column_parent_payment_id( $item ) {
234
-		return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>';
235
-	}
236
-
237
-	/**
238
-	 * Product ID column
239
-	 *
240
-	 * @access      private
241
-	 * @since       1.0.0
242
-	 * @return      string
243
-	 */
244
-	function column_product_id( $item ) {
245
-		return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>';
246
-	}
247
-
248
-	/**
249
-	 * Render the edit column
250
-	 *
251
-	 * @access      private
252
-	 * @since       2.0
253
-	 * @return      string
254
-	 */
255
-	function column_actions( $item ) {
256
-		return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>';
257
-	}
258
-
259
-
260
-	/**
261
-	 * Retrieve the table columns
262
-	 *
263
-	 * @access      private
264
-	 * @since       1.0.0
265
-	 * @return      array
266
-	 */
267
-
268
-	function get_columns(){
269
-		$columns = array(
270
-			'sub_id'            => __( 'ID', 'invoicing' ),
271
-			'customer_id'       => __( 'Customer', 'invoicing' ),
272
-			'status'            => __( 'Status', 'invoicing' ),
273
-			'period'            => __( 'Billing Cycle', 'invoicing' ),
274
-			'initial_amount'    => __( 'Initial Amount', 'invoicing' ),
275
-			'bill_times'        => __( 'Times Billed', 'invoicing' ),
276
-			'renewal_date'      => __( 'Renewal Date', 'invoicing' ),
277
-			'parent_payment_id' => __( 'Invoice', 'invoicing' ),
278
-			'product_id'        => __( 'Item', 'invoicing' ),
279
-			'actions'           => __( 'Actions', 'invoicing' ),
280
-		);
281
-
282
-		return apply_filters( 'wpinv_report_subscription_columns', $columns );
283
-	}
284
-
285
-	/**
286
-	 * Retrieve the current page number
287
-	 *
288
-	 * @access      private
289
-	 * @since       1.0.0
290
-	 * @return      int
291
-	 */
292
-	function get_paged() {
293
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
294
-	}
295
-
296
-	/**
297
-	 * Retrieve the subscription counts
298
-	 *
299
-	 * @access public
300
-	 * @since 1.4
301
-	 * @return void
302
-	 */
303
-	public function get_subscription_counts() {
304
-
305
-		global $wp_query;
306
-
307
-		$db = new WPInv_Subscriptions_DB;
308
-
309
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
310
-
311
-		$this->total_count     = $db->count();
312
-		$this->active_count    = $db->count( array( 'status' => 'active', 'search' => $search ) );
313
-		$this->pending_count   = $db->count( array( 'status' => 'pending', 'search' => $search ) );
314
-		$this->expired_count   = $db->count( array( 'status' => 'expired', 'search' => $search ) );
315
-		$this->trialling_count  = $db->count( array( 'status' => 'trialling', 'search' => $search ) );
316
-		$this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) );
317
-		$this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) );
318
-		$this->failing_count   = $db->count( array( 'status' => 'failing', 'search' => $search ) );
319
-
320
-	}
321
-
322
-	/**
323
-	 * Setup the final data for the table
324
-	 *
325
-	 * @access      private
326
-	 * @since       1.0.0
327
-	 * @uses        $this->_column_headers
328
-	 * @uses        $this->items
329
-	 * @uses        $this->get_columns()
330
-	 * @uses        $this->get_sortable_columns()
331
-	 * @uses        $this->get_pagenum()
332
-	 * @uses        $this->set_pagination_args()
333
-	 * @return      array
334
-	 */
335
-	function prepare_items() {
336
-
337
-		$columns  = $this->get_columns();
338
-		$hidden   = array(); // No hidden columns
339
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
340
-		$sortable = $this->get_sortable_columns();
341
-
342
-		$this->_column_headers = array( $columns, $hidden, $sortable );
343
-
344
-		$current_page = $this->get_pagenum();
345
-
346
-		$db     = new WPInv_Subscriptions_DB;
347
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
348
-		$args   = array(
349
-			'number' => $this->per_page,
350
-			'offset' => $this->per_page * ( $this->get_paged() - 1 ),
351
-			'search' => $search
352
-		);
353
-
354
-		if ( 'any' !== $status ) {
355
-			$args['status'] = $status;
356
-		}
357
-
358
-		$this->items = $db->get_subscriptions( $args );
359
-
360
-		switch ( $status ) {
361
-			case 'active':
362
-				$total_items = $this->active_count;
363
-				break;
364
-			case 'pending':
365
-				$total_items = $this->pending_count;
366
-				break;
367
-			case 'expired':
368
-				$total_items = $this->expired_count;
369
-				break;
370
-			case 'cancelled':
371
-				$total_items = $this->cancelled_count;
372
-				break;
373
-			case 'failing':
374
-				$total_items = $this->failing_count;
375
-				break;
376
-			case 'trialling':
377
-				$total_items = $this->trialling_count;
378
-				break;
379
-			case 'completed':
380
-				$total_items = $this->completed_count;
381
-				break;
382
-			case 'any':
383
-			default:
384
-				$total_items = $this->total_count;
385
-				break;
386
-		}
387
-
388
-		$this->set_pagination_args( array(
389
-			'total_items' => $total_items,
390
-			'per_page'    => $this->per_page,
391
-			'total_pages' => ceil( $total_items / $this->per_page )
392
-		) );
393
-	}
154
+    /**
155
+     * Customer column
156
+     *
157
+     * @access      private
158
+     * @since       1.0.0
159
+     * @return      string
160
+     */
161
+    function column_customer_id( $item ) {
162
+        $subscriber = get_userdata( $item->customer_id );
163
+        $customer   = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email;
164
+
165
+        return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>';
166
+    }
167
+
168
+    /**
169
+     * Status column
170
+     *
171
+     * @access      private
172
+     * @since       1.0.0
173
+     * @return      string
174
+     */
175
+    function column_status( $item ) {
176
+        return $item->get_status_label();
177
+    }
178
+
179
+    /**
180
+     * Period column
181
+     *
182
+     * @access      private
183
+     * @since       1.0.0
184
+     * @return      string
185
+     */
186
+    function column_period( $item ) {
187
+
188
+        $period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency );
189
+
190
+        return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period;
191
+    }
192
+
193
+    /**
194
+     * Billing Times column
195
+     *
196
+     * @access      private
197
+     * @since       1.0.0
198
+     * @return      string
199
+     */
200
+    function column_bill_times( $item ) {
201
+        return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $item->bill_times );
202
+    }
203
+
204
+    /**
205
+     * Initial Amount column
206
+     *
207
+     * @access      private
208
+     * @since       1.0.0
209
+     * @return      string
210
+     */
211
+    function column_initial_amount( $item ) {
212
+        return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) );
213
+    }
214
+
215
+    /**
216
+     * Renewal date column
217
+     *
218
+     * @access      private
219
+     * @since       1.0.0
220
+     * @return      string
221
+     */
222
+    function column_renewal_date( $item ) {
223
+        return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' );
224
+    }
225
+
226
+    /**
227
+     * Payment column
228
+     *
229
+     * @access      private
230
+     * @since       1.0.0
231
+     * @return      string
232
+     */
233
+    function column_parent_payment_id( $item ) {
234
+        return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>';
235
+    }
236
+
237
+    /**
238
+     * Product ID column
239
+     *
240
+     * @access      private
241
+     * @since       1.0.0
242
+     * @return      string
243
+     */
244
+    function column_product_id( $item ) {
245
+        return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>';
246
+    }
247
+
248
+    /**
249
+     * Render the edit column
250
+     *
251
+     * @access      private
252
+     * @since       2.0
253
+     * @return      string
254
+     */
255
+    function column_actions( $item ) {
256
+        return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>';
257
+    }
258
+
259
+
260
+    /**
261
+     * Retrieve the table columns
262
+     *
263
+     * @access      private
264
+     * @since       1.0.0
265
+     * @return      array
266
+     */
267
+
268
+    function get_columns(){
269
+        $columns = array(
270
+            'sub_id'            => __( 'ID', 'invoicing' ),
271
+            'customer_id'       => __( 'Customer', 'invoicing' ),
272
+            'status'            => __( 'Status', 'invoicing' ),
273
+            'period'            => __( 'Billing Cycle', 'invoicing' ),
274
+            'initial_amount'    => __( 'Initial Amount', 'invoicing' ),
275
+            'bill_times'        => __( 'Times Billed', 'invoicing' ),
276
+            'renewal_date'      => __( 'Renewal Date', 'invoicing' ),
277
+            'parent_payment_id' => __( 'Invoice', 'invoicing' ),
278
+            'product_id'        => __( 'Item', 'invoicing' ),
279
+            'actions'           => __( 'Actions', 'invoicing' ),
280
+        );
281
+
282
+        return apply_filters( 'wpinv_report_subscription_columns', $columns );
283
+    }
284
+
285
+    /**
286
+     * Retrieve the current page number
287
+     *
288
+     * @access      private
289
+     * @since       1.0.0
290
+     * @return      int
291
+     */
292
+    function get_paged() {
293
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
294
+    }
295
+
296
+    /**
297
+     * Retrieve the subscription counts
298
+     *
299
+     * @access public
300
+     * @since 1.4
301
+     * @return void
302
+     */
303
+    public function get_subscription_counts() {
304
+
305
+        global $wp_query;
306
+
307
+        $db = new WPInv_Subscriptions_DB;
308
+
309
+        $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
310
+
311
+        $this->total_count     = $db->count();
312
+        $this->active_count    = $db->count( array( 'status' => 'active', 'search' => $search ) );
313
+        $this->pending_count   = $db->count( array( 'status' => 'pending', 'search' => $search ) );
314
+        $this->expired_count   = $db->count( array( 'status' => 'expired', 'search' => $search ) );
315
+        $this->trialling_count  = $db->count( array( 'status' => 'trialling', 'search' => $search ) );
316
+        $this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) );
317
+        $this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) );
318
+        $this->failing_count   = $db->count( array( 'status' => 'failing', 'search' => $search ) );
319
+
320
+    }
321
+
322
+    /**
323
+     * Setup the final data for the table
324
+     *
325
+     * @access      private
326
+     * @since       1.0.0
327
+     * @uses        $this->_column_headers
328
+     * @uses        $this->items
329
+     * @uses        $this->get_columns()
330
+     * @uses        $this->get_sortable_columns()
331
+     * @uses        $this->get_pagenum()
332
+     * @uses        $this->set_pagination_args()
333
+     * @return      array
334
+     */
335
+    function prepare_items() {
336
+
337
+        $columns  = $this->get_columns();
338
+        $hidden   = array(); // No hidden columns
339
+        $status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
340
+        $sortable = $this->get_sortable_columns();
341
+
342
+        $this->_column_headers = array( $columns, $hidden, $sortable );
343
+
344
+        $current_page = $this->get_pagenum();
345
+
346
+        $db     = new WPInv_Subscriptions_DB;
347
+        $search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
348
+        $args   = array(
349
+            'number' => $this->per_page,
350
+            'offset' => $this->per_page * ( $this->get_paged() - 1 ),
351
+            'search' => $search
352
+        );
353
+
354
+        if ( 'any' !== $status ) {
355
+            $args['status'] = $status;
356
+        }
357
+
358
+        $this->items = $db->get_subscriptions( $args );
359
+
360
+        switch ( $status ) {
361
+            case 'active':
362
+                $total_items = $this->active_count;
363
+                break;
364
+            case 'pending':
365
+                $total_items = $this->pending_count;
366
+                break;
367
+            case 'expired':
368
+                $total_items = $this->expired_count;
369
+                break;
370
+            case 'cancelled':
371
+                $total_items = $this->cancelled_count;
372
+                break;
373
+            case 'failing':
374
+                $total_items = $this->failing_count;
375
+                break;
376
+            case 'trialling':
377
+                $total_items = $this->trialling_count;
378
+                break;
379
+            case 'completed':
380
+                $total_items = $this->completed_count;
381
+                break;
382
+            case 'any':
383
+            default:
384
+                $total_items = $this->total_count;
385
+                break;
386
+        }
387
+
388
+        $this->set_pagination_args( array(
389
+            'total_items' => $total_items,
390
+            'per_page'    => $this->per_page,
391
+            'total_pages' => ceil( $total_items / $this->per_page )
392
+        ) );
393
+    }
394 394
 }
Please login to merge, or discard this patch.
Spacing   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -8,11 +8,11 @@  discard block
 block discarded – undo
8 8
 
9 9
 
10 10
 // Exit if accessed directly
11
-if ( ! defined( 'ABSPATH' ) ) exit;
11
+if (!defined('ABSPATH')) exit;
12 12
 
13 13
 
14 14
 // Load WP_List_Table if not loaded
15
-if( ! class_exists( 'WP_List_Table' ) ) {
15
+if (!class_exists('WP_List_Table')) {
16 16
 	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
17 17
 }
18 18
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	public $pending_count   = 0;
36 36
 	public $expired_count   = 0;
37 37
 	public $completed_count = 0;
38
-	public $trialling_count  = 0;
38
+	public $trialling_count = 0;
39 39
 	public $cancelled_count = 0;
40 40
 	public $failing_count   = 0;
41 41
 
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
 	 * @since       1.0.0
47 47
 	 * @return      void
48 48
 	 */
49
-	function __construct(){
49
+	function __construct() {
50 50
 		global $status, $page;
51 51
 
52 52
 		// Set parent defaults
53
-		parent::__construct( array(
53
+		parent::__construct(array(
54 54
 			'singular'  => 'subscription',
55 55
 			'plural'    => 'subscriptions',
56 56
 			'ajax'      => false
57
-		) );
57
+		));
58 58
 
59 59
 		$this->get_subscription_counts();
60 60
 
@@ -69,28 +69,28 @@  discard block
 block discarded – undo
69 69
 	 */
70 70
 	public function get_views() {
71 71
 
72
-		$current         = isset( $_GET['status'] ) ? $_GET['status'] : '';
73
-		$total_count     = '&nbsp;<span class="count">(' . $this->total_count    . ')</span>';
72
+		$current         = isset($_GET['status']) ? $_GET['status'] : '';
73
+		$total_count     = '&nbsp;<span class="count">(' . $this->total_count . ')</span>';
74 74
 		$active_count    = '&nbsp;<span class="count">(' . $this->active_count . ')</span>';
75 75
 		$pending_count   = '&nbsp;<span class="count">(' . $this->pending_count . ')</span>';
76
-		$expired_count   = '&nbsp;<span class="count">(' . $this->expired_count  . ')</span>';
76
+		$expired_count   = '&nbsp;<span class="count">(' . $this->expired_count . ')</span>';
77 77
 		$completed_count = '&nbsp;<span class="count">(' . $this->completed_count . ')</span>';
78
-		$trialling_count  = '&nbsp;<span class="count">(' . $this->trialling_count   . ')</span>';
79
-		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count   . ')</span>';
80
-		$failing_count   = '&nbsp;<span class="count">(' . $this->failing_count   . ')</span>';
78
+		$trialling_count = '&nbsp;<span class="count">(' . $this->trialling_count . ')</span>';
79
+		$cancelled_count = '&nbsp;<span class="count">(' . $this->cancelled_count . ')</span>';
80
+		$failing_count   = '&nbsp;<span class="count">(' . $this->failing_count . ')</span>';
81 81
 
82 82
 		$views = array(
83
-			'all'       => sprintf( '<a href="%s"%s>%s</a>', remove_query_arg( array( 'status', 'paged' ) ), $current === 'all' || $current == '' ? ' class="current"' : '', __('All','invoicing' ) . $total_count ),
84
-			'active'    => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'active', 'paged' => FALSE ) ), $current === 'active' ? ' class="current"' : '', __('Active','invoicing' ) . $active_count ),
85
-			'pending'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'pending', 'paged' => FALSE ) ), $current === 'pending' ? ' class="current"' : '', __('Pending','invoicing' ) . $pending_count ),
86
-			'expired'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'expired', 'paged' => FALSE ) ), $current === 'expired' ? ' class="current"' : '', __('Expired','invoicing' ) . $expired_count ),
87
-			'completed' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'completed', 'paged' => FALSE ) ), $current === 'completed' ? ' class="current"' : '', __('Completed','invoicing' ) . $completed_count ),
88
-			'trialling'  => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'trialling', 'paged' => FALSE ) ), $current === 'trialling' ? ' class="current"' : '', __('Trialling','invoicing' ) . $trialling_count ),
89
-			'cancelled' => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'cancelled', 'paged' => FALSE ) ), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled','invoicing' ) . $cancelled_count ),
90
-			'failing'   => sprintf( '<a href="%s"%s>%s</a>', add_query_arg( array( 'status' => 'failing', 'paged' => FALSE ) ), $current === 'failing' ? ' class="current"' : '', __('Failing','invoicing' ) . $failing_count ),
83
+			'all'       => sprintf('<a href="%s"%s>%s</a>', remove_query_arg(array('status', 'paged')), $current === 'all' || $current == '' ? ' class="current"' : '', __('All', 'invoicing') . $total_count),
84
+			'active'    => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'active', 'paged' => FALSE)), $current === 'active' ? ' class="current"' : '', __('Active', 'invoicing') . $active_count),
85
+			'pending'   => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'pending', 'paged' => FALSE)), $current === 'pending' ? ' class="current"' : '', __('Pending', 'invoicing') . $pending_count),
86
+			'expired'   => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'expired', 'paged' => FALSE)), $current === 'expired' ? ' class="current"' : '', __('Expired', 'invoicing') . $expired_count),
87
+			'completed' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'completed', 'paged' => FALSE)), $current === 'completed' ? ' class="current"' : '', __('Completed', 'invoicing') . $completed_count),
88
+			'trialling'  => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'trialling', 'paged' => FALSE)), $current === 'trialling' ? ' class="current"' : '', __('Trialling', 'invoicing') . $trialling_count),
89
+			'cancelled' => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'cancelled', 'paged' => FALSE)), $current === 'cancelled' ? ' class="current"' : '', __('Cancelled', 'invoicing') . $cancelled_count),
90
+			'failing'   => sprintf('<a href="%s"%s>%s</a>', add_query_arg(array('status' => 'failing', 'paged' => FALSE)), $current === 'failing' ? ' class="current"' : '', __('Failing', 'invoicing') . $failing_count),
91 91
 		);
92 92
 
93
-		return apply_filters( 'wpinv_recurring_subscriptions_table_views', $views );
93
+		return apply_filters('wpinv_recurring_subscriptions_table_views', $views);
94 94
 	}
95 95
 
96 96
 	/**
@@ -104,27 +104,27 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @return void
106 106
 	 */
107
-	public function search_box( $text, $input_id ) {
107
+	public function search_box($text, $input_id) {
108 108
 
109
-		if ( empty( $_REQUEST['s'] ) && ! $this->has_items() ) {
109
+		if (empty($_REQUEST['s']) && !$this->has_items()) {
110 110
 			return;
111 111
 		}
112 112
 
113 113
 		$input_id = $input_id . '-search-input';
114 114
 
115
-		if ( ! empty( $_REQUEST['orderby'] ) ) {
116
-			echo '<input type="hidden" name="orderby" value="' . esc_attr( $_REQUEST['orderby'] ) . '" />';
115
+		if (!empty($_REQUEST['orderby'])) {
116
+			echo '<input type="hidden" name="orderby" value="' . esc_attr($_REQUEST['orderby']) . '" />';
117 117
 		}
118 118
 
119
-		if ( ! empty( $_REQUEST['order'] ) ) {
120
-			echo '<input type="hidden" name="order" value="' . esc_attr( $_REQUEST['order'] ) . '" />';
119
+		if (!empty($_REQUEST['order'])) {
120
+			echo '<input type="hidden" name="order" value="' . esc_attr($_REQUEST['order']) . '" />';
121 121
 		}
122 122
 ?>
123 123
 		<p class="search-box">
124
-			<?php do_action( 'wpinv_recurring_subscription_search_box' ); ?>
124
+			<?php do_action('wpinv_recurring_subscription_search_box'); ?>
125 125
 			<label class="screen-reader-text" for="<?php echo $input_id ?>"><?php echo $text; ?>:</label>
126 126
 			<input type="search" id="<?php echo $input_id ?>" name="s" value="<?php _admin_search_query(); ?>" />
127
-			<?php submit_button( $text, 'button', false, false, array('ID' => 'search-submit') ); ?><br/>
127
+			<?php submit_button($text, 'button', false, false, array('ID' => 'search-submit')); ?><br/>
128 128
 		</p>
129 129
 <?php
130 130
 	}
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @since       1.0.0
137 137
 	 * @return      string
138 138
 	 */
139
-	function column_default( $item, $column_name ) {
139
+	function column_default($item, $column_name) {
140 140
 		return $item->$column_name;
141 141
 	}
142 142
 
@@ -147,8 +147,8 @@  discard block
 block discarded – undo
147 147
      * @since       1.0.0
148 148
      * @return      string
149 149
      */
150
-    function column_sub_id( $item ) {
151
-        return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" target="_blank">' . $item->id . '</a>';
150
+    function column_sub_id($item) {
151
+        return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" target="_blank">' . $item->id . '</a>';
152 152
     }
153 153
 
154 154
 	/**
@@ -158,11 +158,11 @@  discard block
 block discarded – undo
158 158
 	 * @since       1.0.0
159 159
 	 * @return      string
160 160
 	 */
161
-	function column_customer_id( $item ) {
162
-		$subscriber = get_userdata( $item->customer_id );
163
-		$customer   = ! empty( $subscriber->display_name ) ? $subscriber->display_name : $subscriber->user_email;
161
+	function column_customer_id($item) {
162
+		$subscriber = get_userdata($item->customer_id);
163
+		$customer   = !empty($subscriber->display_name) ? $subscriber->display_name : $subscriber->user_email;
164 164
 
165
-		return '<a href="' . esc_url( get_edit_user_link( $item->customer_id ) ) . '" target="_blank">' . $customer . '</a>';
165
+		return '<a href="' . esc_url(get_edit_user_link($item->customer_id)) . '" target="_blank">' . $customer . '</a>';
166 166
 	}
167 167
 
168 168
 	/**
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @since       1.0.0
173 173
 	 * @return      string
174 174
 	 */
175
-	function column_status( $item ) {
175
+	function column_status($item) {
176 176
 		return $item->get_status_label();
177 177
 	}
178 178
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 	 * @since       1.0.0
184 184
 	 * @return      string
185 185
 	 */
186
-	function column_period( $item ) {
186
+	function column_period($item) {
187 187
 
188
-		$period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->period,$item->frequency );
188
+		$period = WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->period, $item->frequency);
189 189
 
190
-		return wpinv_price( wpinv_format_amount( $item->recurring_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) ) . ' / ' . $period;
190
+		return wpinv_price(wpinv_format_amount($item->recurring_amount), wpinv_get_invoice_currency_code($item->parent_payment_id)) . ' / ' . $period;
191 191
 	}
192 192
 
193 193
 	/**
@@ -197,8 +197,8 @@  discard block
 block discarded – undo
197 197
 	 * @since       1.0.0
198 198
 	 * @return      string
199 199
 	 */
200
-	function column_bill_times( $item ) {
201
-		return $item->get_times_billed() . ' / ' . ( ( $item->bill_times == 0 ) ? __( 'Until Cancelled', 'invoicing' ) : $item->bill_times );
200
+	function column_bill_times($item) {
201
+		return $item->get_times_billed() . ' / ' . (($item->bill_times == 0) ? __('Until Cancelled', 'invoicing') : $item->bill_times);
202 202
 	}
203 203
 
204 204
 	/**
@@ -208,8 +208,8 @@  discard block
 block discarded – undo
208 208
 	 * @since       1.0.0
209 209
 	 * @return      string
210 210
 	 */
211
-	function column_initial_amount( $item ) {
212
-		return wpinv_price( wpinv_format_amount( $item->initial_amount ), wpinv_get_invoice_currency_code( $item->parent_payment_id ) );
211
+	function column_initial_amount($item) {
212
+		return wpinv_price(wpinv_format_amount($item->initial_amount), wpinv_get_invoice_currency_code($item->parent_payment_id));
213 213
 	}
214 214
 
215 215
 	/**
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
 	 * @since       1.0.0
220 220
 	 * @return      string
221 221
 	 */
222
-	function column_renewal_date( $item ) {
223
-		return $renewal_date = ! empty( $item->expiration ) ? date_i18n( get_option( 'date_format' ), strtotime( $item->expiration ) ) : __( 'N/A', 'invoicing' );
222
+	function column_renewal_date($item) {
223
+		return $renewal_date = !empty($item->expiration) ? date_i18n(get_option('date_format'), strtotime($item->expiration)) : __('N/A', 'invoicing');
224 224
 	}
225 225
 
226 226
 	/**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
 	 * @since       1.0.0
231 231
 	 * @return      string
232 232
 	 */
233
-	function column_parent_payment_id( $item ) {
234
-		return '<a href="' . get_edit_post_link( $item->parent_payment_id ) . '" target="_blank">' . wpinv_get_invoice_number( $item->parent_payment_id ) . '</a>';
233
+	function column_parent_payment_id($item) {
234
+		return '<a href="' . get_edit_post_link($item->parent_payment_id) . '" target="_blank">' . wpinv_get_invoice_number($item->parent_payment_id) . '</a>';
235 235
 	}
236 236
 
237 237
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
 	 * @since       1.0.0
242 242
 	 * @return      string
243 243
 	 */
244
-	function column_product_id( $item ) {
245
-		return '<a href="' . esc_url( admin_url( 'post.php?action=edit&post=' . $item->product_id ) ) . '" target="_blank">' . get_the_title( $item->product_id ) . '</a>';
244
+	function column_product_id($item) {
245
+		return '<a href="' . esc_url(admin_url('post.php?action=edit&post=' . $item->product_id)) . '" target="_blank">' . get_the_title($item->product_id) . '</a>';
246 246
 	}
247 247
 
248 248
 	/**
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @since       2.0
253 253
 	 * @return      string
254 254
 	 */
255
-	function column_actions( $item ) {
256
-		return '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . $item->id ) ) . '" title="' . esc_attr( __( 'View or edit subscription', 'invoicing' ) ) . '" target="_blank">' . __( 'View', 'invoicing' ) . '</a>';
255
+	function column_actions($item) {
256
+		return '<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . $item->id)) . '" title="' . esc_attr(__('View or edit subscription', 'invoicing')) . '" target="_blank">' . __('View', 'invoicing') . '</a>';
257 257
 	}
258 258
 
259 259
 
@@ -265,21 +265,21 @@  discard block
 block discarded – undo
265 265
 	 * @return      array
266 266
 	 */
267 267
 
268
-	function get_columns(){
268
+	function get_columns() {
269 269
 		$columns = array(
270
-			'sub_id'            => __( 'ID', 'invoicing' ),
271
-			'customer_id'       => __( 'Customer', 'invoicing' ),
272
-			'status'            => __( 'Status', 'invoicing' ),
273
-			'period'            => __( 'Billing Cycle', 'invoicing' ),
274
-			'initial_amount'    => __( 'Initial Amount', 'invoicing' ),
275
-			'bill_times'        => __( 'Times Billed', 'invoicing' ),
276
-			'renewal_date'      => __( 'Renewal Date', 'invoicing' ),
277
-			'parent_payment_id' => __( 'Invoice', 'invoicing' ),
278
-			'product_id'        => __( 'Item', 'invoicing' ),
279
-			'actions'           => __( 'Actions', 'invoicing' ),
270
+			'sub_id'            => __('ID', 'invoicing'),
271
+			'customer_id'       => __('Customer', 'invoicing'),
272
+			'status'            => __('Status', 'invoicing'),
273
+			'period'            => __('Billing Cycle', 'invoicing'),
274
+			'initial_amount'    => __('Initial Amount', 'invoicing'),
275
+			'bill_times'        => __('Times Billed', 'invoicing'),
276
+			'renewal_date'      => __('Renewal Date', 'invoicing'),
277
+			'parent_payment_id' => __('Invoice', 'invoicing'),
278
+			'product_id'        => __('Item', 'invoicing'),
279
+			'actions'           => __('Actions', 'invoicing'),
280 280
 		);
281 281
 
282
-		return apply_filters( 'wpinv_report_subscription_columns', $columns );
282
+		return apply_filters('wpinv_report_subscription_columns', $columns);
283 283
 	}
284 284
 
285 285
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return      int
291 291
 	 */
292 292
 	function get_paged() {
293
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
293
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
294 294
 	}
295 295
 
296 296
 	/**
@@ -306,16 +306,16 @@  discard block
 block discarded – undo
306 306
 
307 307
 		$db = new WPInv_Subscriptions_DB;
308 308
 
309
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
309
+		$search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
310 310
 
311 311
 		$this->total_count     = $db->count();
312
-		$this->active_count    = $db->count( array( 'status' => 'active', 'search' => $search ) );
313
-		$this->pending_count   = $db->count( array( 'status' => 'pending', 'search' => $search ) );
314
-		$this->expired_count   = $db->count( array( 'status' => 'expired', 'search' => $search ) );
315
-		$this->trialling_count  = $db->count( array( 'status' => 'trialling', 'search' => $search ) );
316
-		$this->cancelled_count = $db->count( array( 'status' => 'cancelled', 'search' => $search ) );
317
-		$this->completed_count = $db->count( array( 'status' => 'completed', 'search' => $search ) );
318
-		$this->failing_count   = $db->count( array( 'status' => 'failing', 'search' => $search ) );
312
+		$this->active_count    = $db->count(array('status' => 'active', 'search' => $search));
313
+		$this->pending_count   = $db->count(array('status' => 'pending', 'search' => $search));
314
+		$this->expired_count   = $db->count(array('status' => 'expired', 'search' => $search));
315
+		$this->trialling_count = $db->count(array('status' => 'trialling', 'search' => $search));
316
+		$this->cancelled_count = $db->count(array('status' => 'cancelled', 'search' => $search));
317
+		$this->completed_count = $db->count(array('status' => 'completed', 'search' => $search));
318
+		$this->failing_count   = $db->count(array('status' => 'failing', 'search' => $search));
319 319
 
320 320
 	}
321 321
 
@@ -336,28 +336,28 @@  discard block
 block discarded – undo
336 336
 
337 337
 		$columns  = $this->get_columns();
338 338
 		$hidden   = array(); // No hidden columns
339
-		$status   = isset( $_GET['status'] ) ? $_GET['status'] : 'any';
339
+		$status   = isset($_GET['status']) ? $_GET['status'] : 'any';
340 340
 		$sortable = $this->get_sortable_columns();
341 341
 
342
-		$this->_column_headers = array( $columns, $hidden, $sortable );
342
+		$this->_column_headers = array($columns, $hidden, $sortable);
343 343
 
344 344
 		$current_page = $this->get_pagenum();
345 345
 
346 346
 		$db     = new WPInv_Subscriptions_DB;
347
-		$search = ! empty( $_GET['s'] ) ? sanitize_text_field( $_GET['s'] ) : '';
347
+		$search = !empty($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
348 348
 		$args   = array(
349 349
 			'number' => $this->per_page,
350
-			'offset' => $this->per_page * ( $this->get_paged() - 1 ),
350
+			'offset' => $this->per_page * ($this->get_paged() - 1),
351 351
 			'search' => $search
352 352
 		);
353 353
 
354
-		if ( 'any' !== $status ) {
354
+		if ('any' !== $status) {
355 355
 			$args['status'] = $status;
356 356
 		}
357 357
 
358
-		$this->items = $db->get_subscriptions( $args );
358
+		$this->items = $db->get_subscriptions($args);
359 359
 
360
-		switch ( $status ) {
360
+		switch ($status) {
361 361
 			case 'active':
362 362
 				$total_items = $this->active_count;
363 363
 				break;
@@ -385,10 +385,10 @@  discard block
 block discarded – undo
385 385
 				break;
386 386
 		}
387 387
 
388
-		$this->set_pagination_args( array(
388
+		$this->set_pagination_args(array(
389 389
 			'total_items' => $total_items,
390 390
 			'per_page'    => $this->per_page,
391
-			'total_pages' => ceil( $total_items / $this->per_page )
392
-		) );
391
+			'total_pages' => ceil($total_items / $this->per_page)
392
+		));
393 393
 	}
394 394
 }
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions.php 2 patches
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined( 'ABSPATH' ) ) {
4
+    exit;
5
+}
4 6
 
5 7
 function wpinv_subscription_init() {
6 8
     return WPInv_Subscriptions::instance();
Please login to merge, or discard this patch.
Spacing   +67 added lines, -67 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly.
3
-if (!defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5 5
 function wpinv_subscription_init() {
6 6
     return WPInv_Subscriptions::instance();
7 7
 }
8
-add_action( 'plugins_loaded', 'wpinv_subscription_init', 100 );
8
+add_action('plugins_loaded', 'wpinv_subscription_init', 100);
9 9
 
10 10
 /**
11 11
  * WPInv_Subscriptions Class.
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      * Main WPInv_Subscriptions Instance
21 21
      */
22 22
     public static function instance() {
23
-        if ( ! isset( self::$instance ) ) {
23
+        if (!isset(self::$instance)) {
24 24
             self::$instance = new WPInv_Subscriptions;
25 25
 
26 26
             self::$instance->init();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
      *
35 35
      * @since 1.0.0
36 36
      */
37
-    private function __construct(){
37
+    private function __construct() {
38 38
 
39 39
     }
40 40
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
     private function setup_constants() {
64 64
 
65 65
         // Make sure CAL_GREGORIAN is defined.
66
-        if ( ! defined( 'CAL_GREGORIAN' ) ) {
67
-            define( 'CAL_GREGORIAN', 1 );
66
+        if (!defined('CAL_GREGORIAN')) {
67
+            define('CAL_GREGORIAN', 1);
68 68
         }
69 69
     }
70 70
 
@@ -76,13 +76,13 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function actions() {
78 78
 
79
-        add_action( 'admin_menu', array( $this, 'wpinv_subscriptions_list' ), 40 );
80
-        add_action( 'admin_notices', array( $this, 'notices' ) );
81
-        add_action( 'init', array( $this, 'wpinv_post_actions' ) );
82
-        add_action( 'init', array( $this, 'wpinv_get_actions' ) );
83
-        add_action( 'wpinv_cancel_subscription', array( $this, 'wpinv_process_cancellation' ) );
84
-        add_action( 'getpaid_checkout_before_gateway', array( $this, 'add_subscription' ), -999 );
85
-        add_action( 'wpinv_subscriptions_front_notices', array( $this, 'notices' ) );
79
+        add_action('admin_menu', array($this, 'wpinv_subscriptions_list'), 40);
80
+        add_action('admin_notices', array($this, 'notices'));
81
+        add_action('init', array($this, 'wpinv_post_actions'));
82
+        add_action('init', array($this, 'wpinv_get_actions'));
83
+        add_action('wpinv_cancel_subscription', array($this, 'wpinv_process_cancellation'));
84
+        add_action('getpaid_checkout_before_gateway', array($this, 'add_subscription'), -999);
85
+        add_action('wpinv_subscriptions_front_notices', array($this, 'notices'));
86 86
     }
87 87
 
88 88
     /**
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
     public function wpinv_subscriptions_list() {
105 105
         add_submenu_page(
106 106
             'wpinv',
107
-            __( 'Subscriptions', 'invoicing' ),
108
-            __( 'Subscriptions', 'invoicing' ),
107
+            __('Subscriptions', 'invoicing'),
108
+            __('Subscriptions', 'invoicing'),
109 109
             wpinv_get_capability(),
110 110
             'wpinv-subscriptions',
111 111
             'wpinv_subscriptions_page'
@@ -114,37 +114,37 @@  discard block
 block discarded – undo
114 114
 
115 115
     public function notices() {
116 116
 
117
-        if( empty( $_GET['wpinv-message'] ) ) {
117
+        if (empty($_GET['wpinv-message'])) {
118 118
             return;
119 119
         }
120 120
 
121 121
         $type    = 'updated';
122 122
         $message = '';
123 123
 
124
-        switch( strtolower( $_GET['wpinv-message'] ) ) {
124
+        switch (strtolower($_GET['wpinv-message'])) {
125 125
 
126 126
             case 'updated' :
127 127
 
128
-                $message = __( 'Subscription updated successfully.', 'invoicing' );
128
+                $message = __('Subscription updated successfully.', 'invoicing');
129 129
 
130 130
                 break;
131 131
 
132 132
             case 'deleted' :
133 133
 
134
-                $message = __( 'Subscription deleted successfully.', 'invoicing' );
134
+                $message = __('Subscription deleted successfully.', 'invoicing');
135 135
 
136 136
                 break;
137 137
 
138 138
             case 'cancelled' :
139 139
 
140
-                $message = __( 'Subscription cancelled successfully.', 'invoicing' );
140
+                $message = __('Subscription cancelled successfully.', 'invoicing');
141 141
 
142 142
                 break;
143 143
 
144 144
         }
145 145
 
146
-        if ( ! empty( $message ) ) {
147
-            echo '<div class="' . esc_attr( $type ) . '"><p>' . $message . '</p></div>';
146
+        if (!empty($message)) {
147
+            echo '<div class="' . esc_attr($type) . '"><p>' . $message . '</p></div>';
148 148
         }
149 149
 
150 150
     }
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
      * @return void
158 158
      */
159 159
     function wpinv_get_actions() {
160
-        if ( isset( $_GET['wpinv_action'] ) ) {
161
-            do_action( 'wpinv_' . $_GET['wpinv_action'], $_GET );
160
+        if (isset($_GET['wpinv_action'])) {
161
+            do_action('wpinv_' . $_GET['wpinv_action'], $_GET);
162 162
         }
163 163
     }
164 164
 
@@ -170,8 +170,8 @@  discard block
 block discarded – undo
170 170
      * @return void
171 171
      */
172 172
     function wpinv_post_actions() {
173
-        if ( isset( $_POST['wpinv_action'] ) ) {
174
-            do_action( 'wpinv_' . $_POST['wpinv_action'], $_POST );
173
+        if (isset($_POST['wpinv_action'])) {
174
+            do_action('wpinv_' . $_POST['wpinv_action'], $_POST);
175 175
         }
176 176
     }
177 177
 
@@ -182,29 +182,29 @@  discard block
 block discarded – undo
182 182
      * @param int $frequency_count The frequency of the period.
183 183
      * @return mixed|string|void
184 184
      */
185
-    public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) {
185
+    public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) {
186 186
 
187 187
         $frequency = '';
188 188
         //Format period details
189
-        switch ( strtolower( $period ) ) {
189
+        switch (strtolower($period)) {
190 190
             case 'day' :
191 191
             case 'd' :
192
-                $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
192
+                $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
193 193
                 break;
194 194
             case 'week' :
195 195
             case 'w' :
196
-                $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
196
+                $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
197 197
                 break;
198 198
             case 'month' :
199 199
             case 'm' :
200
-                $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
200
+                $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
201 201
                 break;
202 202
             case 'year' :
203 203
             case 'y' :
204
-                $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
204
+                $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
205 205
                 break;
206 206
             default :
207
-                $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count );
207
+                $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count);
208 208
                 break;
209 209
         }
210 210
 
@@ -219,50 +219,50 @@  discard block
 block discarded – undo
219 219
      * @since       1.0.0
220 220
      * @return      void
221 221
      */
222
-    public function wpinv_process_cancellation( $data ) {
222
+    public function wpinv_process_cancellation($data) {
223 223
 
224 224
 
225
-        if( empty( $data['sub_id'] ) ) {
225
+        if (empty($data['sub_id'])) {
226 226
             return;
227 227
         }
228 228
 
229
-        if( ! is_user_logged_in() ) {
229
+        if (!is_user_logged_in()) {
230 230
             return;
231 231
         }
232 232
 
233
-        if( ! wp_verify_nonce( $data['_wpnonce'], 'wpinv-recurring-cancel' ) ) {
234
-            wp_die( __( 'Error', 'invoicing' ), __( 'Nonce verification failed', 'invoicing' ), array( 'response' => 403 ) );
233
+        if (!wp_verify_nonce($data['_wpnonce'], 'wpinv-recurring-cancel')) {
234
+            wp_die(__('Error', 'invoicing'), __('Nonce verification failed', 'invoicing'), array('response' => 403));
235 235
         }
236 236
 
237
-        $data['sub_id'] = absint( $data['sub_id'] );
238
-        $subscription   = new WPInv_Subscription( $data['sub_id'] );
237
+        $data['sub_id'] = absint($data['sub_id']);
238
+        $subscription   = new WPInv_Subscription($data['sub_id']);
239 239
 
240
-        if( ! $subscription->can_cancel() ) {
241
-            wp_die( __( 'Error', 'invoicing' ), __( 'This subscription cannot be cancelled', 'invoicing' ), array( 'response' => 403 ) );
240
+        if (!$subscription->can_cancel()) {
241
+            wp_die(__('Error', 'invoicing'), __('This subscription cannot be cancelled', 'invoicing'), array('response' => 403));
242 242
         }
243 243
 
244 244
         try {
245 245
 
246
-            do_action( 'wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true );
246
+            do_action('wpinv_recurring_cancel_' . $subscription->gateway . '_subscription', $subscription, true);
247 247
 
248 248
             $subscription->cancel();
249 249
 
250
-            if( is_admin() ) {
250
+            if (is_admin()) {
251 251
 
252
-                wp_redirect( admin_url( 'admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id ) );
252
+                wp_redirect(admin_url('admin.php?page=wpinv-subscriptions&wpinv-message=cancelled&id=' . $subscription->id));
253 253
                 exit;
254 254
 
255 255
             } else {
256 256
 
257
-                $redirect = remove_query_arg( array( '_wpnonce', 'wpinv_action', 'sub_id' ), add_query_arg( array( 'wpinv-message' => 'cancelled' ) ) );
258
-                $redirect = apply_filters( 'wpinv_recurring_cancellation_redirect', $redirect, $subscription );
259
-                wp_safe_redirect( $redirect );
257
+                $redirect = remove_query_arg(array('_wpnonce', 'wpinv_action', 'sub_id'), add_query_arg(array('wpinv-message' => 'cancelled')));
258
+                $redirect = apply_filters('wpinv_recurring_cancellation_redirect', $redirect, $subscription);
259
+                wp_safe_redirect($redirect);
260 260
                 exit;
261 261
 
262 262
             }
263 263
 
264
-        } catch ( Exception $e ) {
265
-            wp_die( __( 'Error', 'invoicing' ), $e->getMessage(), array( 'response' => 403 ) );
264
+        } catch (Exception $e) {
265
+            wp_die(__('Error', 'invoicing'), $e->getMessage(), array('response' => 403));
266 266
         }
267 267
 
268 268
     }
@@ -275,33 +275,33 @@  discard block
 block discarded – undo
275 275
      * @since       1.0.0
276 276
      * @return      void
277 277
      */
278
-    public function add_subscription( $invoice ) {
278
+    public function add_subscription($invoice) {
279 279
 
280
-        $invoice = new WPInv_Invoice( $invoice );
280
+        $invoice = new WPInv_Invoice($invoice);
281 281
 
282 282
         // Abort if it is not recurring.
283
-        if ( ! $invoice->is_recurring() || $invoice->is_renewal() ) {
283
+        if (!$invoice->is_recurring() || $invoice->is_renewal()) {
284 284
             return;
285 285
         }
286 286
 
287 287
         // Should we create a subscription for the invoice?
288
-        if ( apply_filters( 'wpinv_skip_invoice_subscription_creation', false, $invoice ) ) {
288
+        if (apply_filters('wpinv_skip_invoice_subscription_creation', false, $invoice)) {
289 289
             return;
290 290
         }
291 291
 
292 292
         // Get the recurring item.
293
-        $subscription_item = $invoice->get_recurring( true );
293
+        $subscription_item = $invoice->get_recurring(true);
294 294
 
295 295
         // Prepare the subscription details.
296
-        $period       = $subscription_item->get_recurring_period( true );
296
+        $period       = $subscription_item->get_recurring_period(true);
297 297
         $interval     = $subscription_item->get_recurring_interval();
298 298
         $add_period   = $interval . ' ' . $period;
299 299
         $trial_period = '';
300 300
 
301
-        if ( $invoice->has_free_trial() ) {
301
+        if ($invoice->has_free_trial()) {
302 302
 
303
-            if ( $subscription_item->has_free_trial() ) {
304
-                $trial_period   = $subscription_item->get_trial_period( true );
303
+            if ($subscription_item->has_free_trial()) {
304
+                $trial_period   = $subscription_item->get_trial_period(true);
305 305
                 $free_interval  = $subscription_item->get_trial_interval();
306 306
             } else {
307 307
                 $trial_period   = $period;
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
         }
315 315
 
316 316
         // Calculate the next renewal date.
317
-        $expiration = date( 'Y-m-d H:i:s', strtotime( "+ $add_period", current_time( 'timestamp' ) ) );
317
+        $expiration = date('Y-m-d H:i:s', strtotime("+ $add_period", current_time('timestamp')));
318 318
 
319 319
         // Subscription arguments.
320 320
         $args = array(
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
             'initial_amount'    => $invoice->get_initial_total(),
328 328
             'recurring_amount'  => $invoice->get_recurring_total(),
329 329
             'bill_times'        => $subscription_item->get_recurring_limit(),
330
-            'created'           => current_time( 'mysql' ),
330
+            'created'           => current_time('mysql'),
331 331
             'expiration'        => $expiration,
332 332
             'trial_period'      => $trial_period,
333 333
             'profile_id'        => '',
@@ -335,19 +335,19 @@  discard block
 block discarded – undo
335 335
         );
336 336
 
337 337
         // Create or update the subscription.
338
-        $subscription = wpinv_get_subscription( $invoice );
338
+        $subscription = wpinv_get_subscription($invoice);
339 339
 
340
-        if ( empty( $subscription ) ) {
340
+        if (empty($subscription)) {
341 341
 
342 342
             $subscription = new WPInv_Subscription();
343
-            $subscription->create( $args );
343
+            $subscription->create($args);
344 344
 
345 345
         } else {
346 346
 
347 347
 
348
-            unset( $args['transaction_id'] );
349
-            unset( $args['profile_id'] );
350
-            $subscription->update( $args );
348
+            unset($args['transaction_id']);
349
+            unset($args['profile_id']);
350
+            $subscription->update($args);
351 351
 
352 352
         }
353 353
 
Please login to merge, or discard this patch.
templates/emails/wpinv-email-completed_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-refunded_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-onhold_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-new_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-failed_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-cancelled_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
templates/emails/wpinv-email-processing_invoice.php 2 patches
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,8 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if ( !defined('ABSPATH') ) {
4 4
     die('-1');
5
+}
5 6
 
6 7
 do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
7 8
 
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,18 +1,18 @@
 block discarded – undo
1 1
 <?php
2 2
 // don't load directly
3
-if ( !defined('ABSPATH') )
3
+if (!defined('ABSPATH'))
4 4
     die('-1');
5 5
 
6
-do_action( 'wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin );
6
+do_action('wpinv_email_header', $email_heading, $invoice, $email_type, $sent_to_admin);
7 7
 
8
-if ( ! empty( $message_body ) ) {
9
-    echo wpautop( wptexturize( $message_body ) );
8
+if (!empty($message_body)) {
9
+    echo wpautop(wptexturize($message_body));
10 10
 }
11 11
 
12
-do_action( 'wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin );
12
+do_action('wpinv_email_invoice_details', $invoice, $email_type, $sent_to_admin);
13 13
 
14
-do_action( 'wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin );
14
+do_action('wpinv_email_invoice_items', $invoice, $email_type, $sent_to_admin);
15 15
 
16
-do_action( 'wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin );
16
+do_action('wpinv_email_billing_details', $invoice, $email_type, $sent_to_admin);
17 17
 
18
-do_action( 'wpinv_email_footer', $invoice, $email_type, $sent_to_admin );
19 18
\ No newline at end of file
19
+do_action('wpinv_email_footer', $invoice, $email_type, $sent_to_admin);
20 20
\ No newline at end of file
Please login to merge, or discard this patch.