Passed
Push — master ( a1d3e4...4cf75d )
by Brian
04:38
created
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +736 added lines, -736 removed lines patch added patch discarded remove patch
@@ -13,741 +13,741 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0   => '',
68
-			1   => __( 'Discount updated.', 'invoicing' ),
69
-			2   => __( 'Custom field updated.', 'invoicing' ),
70
-			3   => __( 'Custom field deleted.', 'invoicing' ),
71
-			4   => __( 'Discount updated.', 'invoicing' ),
72
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6   => __( 'Discount updated.', 'invoicing' ),
74
-			7   => __( 'Discount saved.', 'invoicing' ),
75
-			8   => __( 'Discount submitted.', 'invoicing' ),
76
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10  => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0   => '',
82
-			1   => __( 'Payment Form updated.', 'invoicing' ),
83
-			2   => __( 'Custom field updated.', 'invoicing' ),
84
-			3   => __( 'Custom field deleted.', 'invoicing' ),
85
-			4   => __( 'Payment Form updated.', 'invoicing' ),
86
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6   => __( 'Payment Form updated.', 'invoicing' ),
88
-			7   => __( 'Payment Form saved.', 'invoicing' ),
89
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] =  sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] =  sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
144
-
145
-		}
146
-
147
-		return $actions;
148
-	}
149
-
150
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0   => '',
68
+            1   => __( 'Discount updated.', 'invoicing' ),
69
+            2   => __( 'Custom field updated.', 'invoicing' ),
70
+            3   => __( 'Custom field deleted.', 'invoicing' ),
71
+            4   => __( 'Discount updated.', 'invoicing' ),
72
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6   => __( 'Discount updated.', 'invoicing' ),
74
+            7   => __( 'Discount saved.', 'invoicing' ),
75
+            8   => __( 'Discount submitted.', 'invoicing' ),
76
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10  => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0   => '',
82
+            1   => __( 'Payment Form updated.', 'invoicing' ),
83
+            2   => __( 'Custom field updated.', 'invoicing' ),
84
+            3   => __( 'Custom field deleted.', 'invoicing' ),
85
+            4   => __( 'Payment Form updated.', 'invoicing' ),
86
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6   => __( 'Payment Form updated.', 'invoicing' ),
88
+            7   => __( 'Payment Form saved.', 'invoicing' ),
89
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] =  sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] =  sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144
+
145
+        }
146
+
147
+        return $actions;
148
+    }
149
+
150
+    /**
151 151
      * Remove bulk edit option from admin side quote listing
152 152
      *
153 153
      * @since    1.0.0
154 154
      * @param array $actions post actions
155
-	 * @param WP_Post $post
155
+     * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158 158
     public static function filter_invoice_row_actions( $actions, $post ) {
159 159
 
160 160
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
161 161
 
162
-			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
164
-
165
-			$actions['edit'] =  sprintf(
166
-				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
169
-			);
170
-
171
-			if ( ! $invoice->is_draft() ) {
172
-
173
-				$actions['view'] =  sprintf(
174
-					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
176
-					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
-					)
180
-				);
181
-
182
-				$actions['send'] =  sprintf(
183
-					'<a href="%1$s">%2$s</a>',
184
-					esc_url(
185
-						wp_nonce_url(
186
-							add_query_arg(
187
-								array(
188
-									'getpaid-admin-action' => 'send_invoice',
189
-									'invoice_id'           => $invoice->get_id()
190
-								)
191
-							),
192
-							'getpaid-nonce',
193
-							'getpaid-nonce'
194
-						)
195
-					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
197
-				);
198
-
199
-			}
200
-
201
-			$actions['duplicate'] =  sprintf(
202
-				'<a href="%1$s">%2$s</a>',
203
-				esc_url(
204
-					wp_nonce_url(
205
-						add_query_arg(
206
-							array(
207
-								'getpaid-admin-action' => 'duplicate_invoice',
208
-								'invoice_id'           => $post->ID
209
-							)
210
-						),
211
-						'getpaid-nonce',
212
-						'getpaid-nonce'
213
-					)
214
-				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
216
-			);
162
+            $actions = array();
163
+            $invoice = new WPInv_Invoice( $post );
164
+
165
+            $actions['edit'] =  sprintf(
166
+                '<a href="%1$s">%2$s</a>',
167
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
+                esc_html( __( 'Edit', 'invoicing' ) )
169
+            );
170
+
171
+            if ( ! $invoice->is_draft() ) {
172
+
173
+                $actions['view'] =  sprintf(
174
+                    '<a href="%1$s">%2$s</a>',
175
+                    esc_url( $invoice->get_view_url() ),
176
+                    sprintf(
177
+                        esc_html( __( 'View %s', 'invoicing' ) ),
178
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
+                    )
180
+                );
181
+
182
+                $actions['send'] =  sprintf(
183
+                    '<a href="%1$s">%2$s</a>',
184
+                    esc_url(
185
+                        wp_nonce_url(
186
+                            add_query_arg(
187
+                                array(
188
+                                    'getpaid-admin-action' => 'send_invoice',
189
+                                    'invoice_id'           => $invoice->get_id()
190
+                                )
191
+                            ),
192
+                            'getpaid-nonce',
193
+                            'getpaid-nonce'
194
+                        )
195
+                    ),
196
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
197
+                );
198
+
199
+            }
200
+
201
+            $actions['duplicate'] =  sprintf(
202
+                '<a href="%1$s">%2$s</a>',
203
+                esc_url(
204
+                    wp_nonce_url(
205
+                        add_query_arg(
206
+                            array(
207
+                                'getpaid-admin-action' => 'duplicate_invoice',
208
+                                'invoice_id'           => $post->ID
209
+                            )
210
+                        ),
211
+                        'getpaid-nonce',
212
+                        'getpaid-nonce'
213
+                    )
214
+                ),
215
+                esc_html( __( 'Duplicate', 'invoicing' ) )
216
+            );
217 217
 
218 218
         }
219 219
 
220 220
         return $actions;
221
-	}
222
-
223
-	/**
224
-	 * Returns an array of invoice table columns.
225
-	 */
226
-	public static function invoice_columns( $columns ) {
227
-
228
-		$columns = array(
229
-			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
237
-		);
238
-
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
240
-	}
241
-
242
-	/**
243
-	 * Displays invoice table columns.
244
-	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
246
-
247
-		$invoice = new WPInv_Invoice( $post_id );
248
-
249
-		switch ( $column_name ) {
250
-
251
-			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
-				echo "<span title='$date_time'>$date</span>";
255
-				break;
256
-
257
-			case 'payment_date' :
258
-
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
-					echo "<span title='$date_time'>$date</span>";
263
-				} else {
264
-					echo "&mdash;";
265
-				}
221
+    }
222
+
223
+    /**
224
+     * Returns an array of invoice table columns.
225
+     */
226
+    public static function invoice_columns( $columns ) {
227
+
228
+        $columns = array(
229
+            'cb'                => $columns['cb'],
230
+            'number'            => __( 'Invoice', 'invoicing' ),
231
+            'customer'          => __( 'Customer', 'invoicing' ),
232
+            'invoice_date'      => __( 'Created', 'invoicing' ),
233
+            'payment_date'      => __( 'Completed', 'invoicing' ),
234
+            'amount'            => __( 'Amount', 'invoicing' ),
235
+            'recurring'         => __( 'Recurring', 'invoicing' ),
236
+            'status'            => __( 'Status', 'invoicing' ),
237
+        );
238
+
239
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
240
+    }
241
+
242
+    /**
243
+     * Displays invoice table columns.
244
+     */
245
+    public static function display_invoice_columns( $column_name, $post_id ) {
246
+
247
+        $invoice = new WPInv_Invoice( $post_id );
248
+
249
+        switch ( $column_name ) {
250
+
251
+            case 'invoice_date' :
252
+                $date_time = esc_attr( $invoice->get_created_date() );
253
+                $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
+                echo "<span title='$date_time'>$date</span>";
255
+                break;
256
+
257
+            case 'payment_date' :
258
+
259
+                if ( $invoice->is_paid() ) {
260
+                    $date_time = esc_attr( $invoice->get_completed_date() );
261
+                    $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
+                    echo "<span title='$date_time'>$date</span>";
263
+                } else {
264
+                    echo "&mdash;";
265
+                }
266 266
 				
267
-				break;
267
+                break;
268 268
 
269
-			case 'amount' :
269
+            case 'amount' :
270 270
 
271
-				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
271
+                $amount = $invoice->get_total();
272
+                $formated_amount = wpinv_price( $amount, $invoice->get_currency() );
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
-				} else {
274
+                if ( $invoice->is_refunded() ) {
275
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
+                } else {
278 278
 
279
-					$discount = $invoice->get_total_discount();
279
+                    $discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
-					} else {
285
-						echo $formated_amount;
286
-					}
281
+                    if ( ! empty( $discount ) ) {
282
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
+                    } else {
285
+                        echo $formated_amount;
286
+                    }
287 287
 
288
-				}
288
+                }
289 289
 
290
-				break;
290
+                break;
291 291
 
292
-			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
292
+            case 'status' :
293
+                $status       = esc_html( $invoice->get_status() );
294
+                $status_label = esc_html( $invoice->get_status_nicename() );
295 295
 
296
-				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
296
+                // If it is paid, show the gateway title.
297
+                if ( $invoice->is_paid() ) {
298
+                    $gateway = esc_html( $invoice->get_gateway_title() );
299
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
300 300
 
301
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
-				} else {
303
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
-				}
301
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
+                } else {
303
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
+                }
305 305
 
306
-				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
306
+                // If it is not paid, display the overdue and view status.
307
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
308 308
 
309
-					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
-					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
-					}
309
+                    // Invoice view status.
310
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
+                    } else {
313
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
+                    }
315 315
 
316
-					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
318
-						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
316
+                    // Display the overview status.
317
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
318
+                        $due_date = $invoice->get_due_date();
319
+                        $fomatted = getpaid_format_date( $due_date );
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
-						}
325
-					}
321
+                        if ( ! empty( $fomatted ) ) {
322
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
+                        }
325
+                    }
326 326
 
327
-				}
327
+                }
328 328
 
329
-				break;
329
+                break;
330 330
 
331
-			case 'recurring':
331
+            case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
334
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
-				} else {
336
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
-				}
338
-				break;
333
+                if ( $invoice->is_recurring() ) {
334
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
+                } else {
336
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
+                }
338
+                break;
339 339
 
340
-			case 'number' :
340
+            case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
+                $invoice_number  = esc_html( $invoice->get_number() );
344
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
345 345
 
346
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
346
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
348
-				break;
348
+                break;
349 349
 
350
-			case 'customer' :
350
+            case 'customer' :
351 351
 	
352
-				$customer_name = $invoice->get_user_full_name();
352
+                $customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
355
-					$customer_name = $invoice->get_email();
356
-				}
354
+                if ( empty( $customer_name ) ) {
355
+                    $customer_name = $invoice->get_email();
356
+                }
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
-				} else {
363
-					echo '<div>&mdash;</div>';
364
-				}
358
+                if ( ! empty( $customer_name ) ) {
359
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
+                } else {
363
+                    echo '<div>&mdash;</div>';
364
+                }
365 365
 
366
-				break;
366
+                break;
367 367
 
368
-		}
368
+        }
369 369
 
370
-	}
370
+    }
371 371
 
372
-	/**
373
-	 * Displays invoice bulk actions.
374
-	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
-		return $actions;
378
-	}
372
+    /**
373
+     * Displays invoice bulk actions.
374
+     */
375
+    public static function invoice_bulk_actions( $actions ) {
376
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
+        return $actions;
378
+    }
379 379
 
380
-	/**
381
-	 * Processes invoice bulk actions.
382
-	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
380
+    /**
381
+     * Processes invoice bulk actions.
382
+     */
383
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
385
+        if ( $action == 'resend-invoice' ) {
386 386
 
387
-			$success = false;
388
-			foreach ( $post_ids as $post_id ) {
389
-				$success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
390
-			}
387
+            $success = false;
388
+            foreach ( $post_ids as $post_id ) {
389
+                $success = getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
390
+            }
391 391
 
392
-			if ( $success ) {
393
-				getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
394
-			} else {
395
-				getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
396
-			}
392
+            if ( $success ) {
393
+                getpaid_admin()->show_success( __( 'Invoices were successfully sent', 'invoicing' ) );
394
+            } else {
395
+                getpaid_admin()->show_error( __( 'Could not send some invoices', 'invoicing' ) );
396
+            }
397 397
 
398
-		}
398
+        }
399 399
 
400
-		return $redirect_url;
400
+        return $redirect_url;
401 401
 
402
-	}
402
+    }
403 403
 
404
-	/**
405
-	 * Returns an array of payment forms table columns.
406
-	 */
407
-	public static function payment_form_columns( $columns ) {
404
+    /**
405
+     * Returns an array of payment forms table columns.
406
+     */
407
+    public static function payment_form_columns( $columns ) {
408 408
 
409
-		$columns = array(
410
-			'cb'                => $columns['cb'],
411
-			'title'             => __( 'Name', 'invoicing' ),
412
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
413
-			'earnings'          => __( 'Revenue', 'invoicing' ),
414
-			'refunds'           => __( 'Refunded', 'invoicing' ),
415
-			'items'             => __( 'Items', 'invoicing' ),
416
-			'date'              => __( 'Date', 'invoicing' ),
417
-		);
409
+        $columns = array(
410
+            'cb'                => $columns['cb'],
411
+            'title'             => __( 'Name', 'invoicing' ),
412
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
413
+            'earnings'          => __( 'Revenue', 'invoicing' ),
414
+            'refunds'           => __( 'Refunded', 'invoicing' ),
415
+            'items'             => __( 'Items', 'invoicing' ),
416
+            'date'              => __( 'Date', 'invoicing' ),
417
+        );
418 418
 
419
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
419
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
424
-	 * Displays payment form table columns.
425
-	 */
426
-	public static function display_payment_form_columns( $column_name, $post_id ) {
423
+    /**
424
+     * Displays payment form table columns.
425
+     */
426
+    public static function display_payment_form_columns( $column_name, $post_id ) {
427 427
 
428
-		// Retrieve the payment form.
429
-		$form = new GetPaid_Payment_Form( $post_id );
428
+        // Retrieve the payment form.
429
+        $form = new GetPaid_Payment_Form( $post_id );
430 430
 
431
-		switch ( $column_name ) {
431
+        switch ( $column_name ) {
432 432
 
433
-			case 'earnings' :
434
-				echo wpinv_price( $form->get_earned() );
435
-				break;
433
+            case 'earnings' :
434
+                echo wpinv_price( $form->get_earned() );
435
+                break;
436 436
 
437
-			case 'refunds' :
438
-				echo wpinv_price( $form->get_refunded() );
439
-				break;
437
+            case 'refunds' :
438
+                echo wpinv_price( $form->get_refunded() );
439
+                break;
440 440
 
441
-			case 'refunds' :
442
-				echo wpinv_price( $form->get_refunded() );
443
-				break;
441
+            case 'refunds' :
442
+                echo wpinv_price( $form->get_refunded() );
443
+                break;
444 444
 
445
-			case 'shortcode' :
445
+            case 'shortcode' :
446 446
 
447
-				if ( $form->is_default() ) {
448
-					echo '&mdash;';
449
-				} else {
450
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
451
-				}
447
+                if ( $form->is_default() ) {
448
+                    echo '&mdash;';
449
+                } else {
450
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
451
+                }
452 452
 
453
-				break;
453
+                break;
454 454
 
455
-			case 'items' :
455
+            case 'items' :
456 456
 
457
-				$items = $form->get_items();
457
+                $items = $form->get_items();
458 458
 
459
-				if ( $form->is_default() || empty( $items ) ) {
460
-					echo '&mdash;';
461
-					return;
462
-				}
459
+                if ( $form->is_default() || empty( $items ) ) {
460
+                    echo '&mdash;';
461
+                    return;
462
+                }
463 463
 
464
-				$_items = array();
464
+                $_items = array();
465 465
 
466
-				foreach ( $items as $item ) {
467
-					$url = $item->get_edit_url();
466
+                foreach ( $items as $item ) {
467
+                    $url = $item->get_edit_url();
468 468
 
469
-					if ( empty( $url ) ) {
470
-						$_items[] = esc_html( $item->get_name() );
471
-					} else {
472
-						$_items[] = sprintf(
473
-							'<a href="%s">%s</a>',
474
-							esc_url( $url ),
475
-							esc_html( $item->get_name() )
476
-						);
477
-					}
469
+                    if ( empty( $url ) ) {
470
+                        $_items[] = esc_html( $item->get_name() );
471
+                    } else {
472
+                        $_items[] = sprintf(
473
+                            '<a href="%s">%s</a>',
474
+                            esc_url( $url ),
475
+                            esc_html( $item->get_name() )
476
+                        );
477
+                    }
478 478
 
479
-				}
479
+                }
480 480
 
481
-				echo implode( '<br>', $_items );
481
+                echo implode( '<br>', $_items );
482 482
 
483
-				break;
483
+                break;
484 484
 
485
-		}
485
+        }
486 486
 
487
-	}
487
+    }
488 488
 
489
-	/**
490
-	 * Filters post states.
491
-	 */
492
-	public static function filter_payment_form_state( $post_states, $post ) {
489
+    /**
490
+     * Filters post states.
491
+     */
492
+    public static function filter_payment_form_state( $post_states, $post ) {
493 493
 
494
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
495
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
496
-		}
494
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
495
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
496
+        }
497 497
 	
498
-		return $post_states;
499
-
500
-	}
501
-
502
-	/**
503
-	 * Returns an array of coupon table columns.
504
-	 */
505
-	public static function discount_columns( $columns ) {
506
-
507
-		$columns = array(
508
-			'cb'                => $columns['cb'],
509
-			'title'             => __( 'Name', 'invoicing' ),
510
-			'code'              => __( 'Code', 'invoicing' ),
511
-			'amount'            => __( 'Amount', 'invoicing' ),
512
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
513
-			'start_date'        => __( 'Start Date', 'invoicing' ),
514
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
515
-		);
516
-
517
-		return apply_filters( 'wpi_discount_table_columns', $columns );
518
-	}
519
-
520
-	/**
521
-	 * Filters post states.
522
-	 */
523
-	public static function filter_discount_state( $post_states, $post ) {
524
-
525
-		if ( 'wpi_discount' == $post->post_type ) {
526
-
527
-			$discount = new WPInv_Discount( $post );
528
-
529
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
530
-
531
-			if ( $status != 'publish' ) {
532
-				return array(
533
-					'discount_status' => wpinv_discount_status( $status ),
534
-				);
535
-			}
536
-
537
-			return array();
538
-
539
-		}
540
-
541
-		return $post_states;
542
-
543
-	}
544
-
545
-	/**
546
-	 * Returns an array of items table columns.
547
-	 */
548
-	public static function item_columns( $columns ) {
549
-
550
-		$columns = array(
551
-			'cb'                => $columns['cb'],
552
-			'title'             => __( 'Name', 'invoicing' ),
553
-			'price'             => __( 'Price', 'invoicing' ),
554
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
555
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
556
-			'type'              => __( 'Type', 'invoicing' ),
557
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
558
-		);
559
-
560
-		if ( ! wpinv_use_taxes() ) {
561
-			unset( $columns['vat_rule'] );
562
-			unset( $columns['vat_class'] );
563
-		}
564
-
565
-		return apply_filters( 'wpi_item_table_columns', $columns );
566
-	}
567
-
568
-	/**
569
-	 * Returns an array of sortable items table columns.
570
-	 */
571
-	public static function sortable_item_columns( $columns ) {
572
-
573
-		return array_merge(
574
-			$columns,
575
-			array(
576
-				'price'     => 'price',
577
-				'vat_rule'  => 'vat_rule',
578
-				'vat_class' => 'vat_class',
579
-				'type'      => 'type',
580
-			)
581
-		);
582
-
583
-	}
584
-
585
-	/**
586
-	 * Displays items table columns.
587
-	 */
588
-	public static function display_item_columns( $column_name, $post_id ) {
498
+        return $post_states;
499
+
500
+    }
501
+
502
+    /**
503
+     * Returns an array of coupon table columns.
504
+     */
505
+    public static function discount_columns( $columns ) {
506
+
507
+        $columns = array(
508
+            'cb'                => $columns['cb'],
509
+            'title'             => __( 'Name', 'invoicing' ),
510
+            'code'              => __( 'Code', 'invoicing' ),
511
+            'amount'            => __( 'Amount', 'invoicing' ),
512
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
513
+            'start_date'        => __( 'Start Date', 'invoicing' ),
514
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
515
+        );
516
+
517
+        return apply_filters( 'wpi_discount_table_columns', $columns );
518
+    }
519
+
520
+    /**
521
+     * Filters post states.
522
+     */
523
+    public static function filter_discount_state( $post_states, $post ) {
524
+
525
+        if ( 'wpi_discount' == $post->post_type ) {
526
+
527
+            $discount = new WPInv_Discount( $post );
528
+
529
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
530
+
531
+            if ( $status != 'publish' ) {
532
+                return array(
533
+                    'discount_status' => wpinv_discount_status( $status ),
534
+                );
535
+            }
536
+
537
+            return array();
538
+
539
+        }
540
+
541
+        return $post_states;
542
+
543
+    }
544
+
545
+    /**
546
+     * Returns an array of items table columns.
547
+     */
548
+    public static function item_columns( $columns ) {
549
+
550
+        $columns = array(
551
+            'cb'                => $columns['cb'],
552
+            'title'             => __( 'Name', 'invoicing' ),
553
+            'price'             => __( 'Price', 'invoicing' ),
554
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
555
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
556
+            'type'              => __( 'Type', 'invoicing' ),
557
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
558
+        );
559
+
560
+        if ( ! wpinv_use_taxes() ) {
561
+            unset( $columns['vat_rule'] );
562
+            unset( $columns['vat_class'] );
563
+        }
564
+
565
+        return apply_filters( 'wpi_item_table_columns', $columns );
566
+    }
567
+
568
+    /**
569
+     * Returns an array of sortable items table columns.
570
+     */
571
+    public static function sortable_item_columns( $columns ) {
572
+
573
+        return array_merge(
574
+            $columns,
575
+            array(
576
+                'price'     => 'price',
577
+                'vat_rule'  => 'vat_rule',
578
+                'vat_class' => 'vat_class',
579
+                'type'      => 'type',
580
+            )
581
+        );
582
+
583
+    }
584
+
585
+    /**
586
+     * Displays items table columns.
587
+     */
588
+    public static function display_item_columns( $column_name, $post_id ) {
589 589
  
590
-		$item = new WPInv_Item( $post_id );
590
+        $item = new WPInv_Item( $post_id );
591 591
 
592
-		switch ( $column_name ) {
592
+        switch ( $column_name ) {
593 593
 
594
-			case 'price' :
594
+            case 'price' :
595 595
 
596
-				if ( ! $item->is_recurring() ) {
597
-					echo $item->get_the_price();
598
-					break;
599
-				}
596
+                if ( ! $item->is_recurring() ) {
597
+                    echo $item->get_the_price();
598
+                    break;
599
+                }
600 600
 
601
-				$price = wp_sprintf(
602
-					__( '%s / %s', 'invoicing' ),
603
-					$item->get_the_price(),
604
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
605
-				);
601
+                $price = wp_sprintf(
602
+                    __( '%s / %s', 'invoicing' ),
603
+                    $item->get_the_price(),
604
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
605
+                );
606 606
 
607
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
608
-					echo $price;
609
-					break;
610
-				}
607
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
608
+                    echo $price;
609
+                    break;
610
+                }
611 611
 
612
-				echo $item->get_the_initial_price();
612
+                echo $item->get_the_initial_price();
613 613
 
614
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
615
-				break;
614
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
615
+                break;
616 616
 
617
-			case 'vat_rule' :
618
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
619
-				break;
617
+            case 'vat_rule' :
618
+                echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
619
+                break;
620 620
 
621
-			case 'vat_class' :
622
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
623
-				break;
621
+            case 'vat_class' :
622
+                echo getpaid_get_tax_class_label( $item->get_vat_class() );
623
+                break;
624 624
 
625
-			case 'shortcode' :
625
+            case 'shortcode' :
626 626
 
627
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629
-				} else {
630
-					echo "&mdash;";
631
-				}
627
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
628
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
629
+                } else {
630
+                    echo "&mdash;";
631
+                }
632 632
 				
633
-				break;
633
+                break;
634 634
 
635
-			case 'type' :
636
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
637
-				break;
635
+            case 'type' :
636
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
637
+                break;
638 638
 
639
-		}
639
+        }
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
644
-	 * Lets users filter items using taxes.
645
-	 */
646
-	public static function add_item_filters( $post_type ) {
643
+    /**
644
+     * Lets users filter items using taxes.
645
+     */
646
+    public static function add_item_filters( $post_type ) {
647 647
 
648
-		// Abort if we're not dealing with items.
649
-		if ( $post_type != 'wpi_item' ) {
650
-			return;
651
-		}
648
+        // Abort if we're not dealing with items.
649
+        if ( $post_type != 'wpi_item' ) {
650
+            return;
651
+        }
652 652
 
653
-		// Filter by vat rules.
654
-		if ( wpinv_use_taxes() ) {
653
+        // Filter by vat rules.
654
+        if ( wpinv_use_taxes() ) {
655 655
 	
656
-			// Sanitize selected vat rule.
657
-			$vat_rule   = '';
658
-			$vat_rules  = getpaid_get_tax_rules();
659
-			if ( isset( $_GET['vat_rule'] ) ) {
660
-				$vat_rule   =  $_GET['vat_rule'];
661
-			}
662
-
663
-			// Filter by VAT rule.
664
-			echo wpinv_html_select(
665
-				array(
666
-					'options'          => array_merge(
667
-						array(
668
-							'' => __( 'All VAT rules', 'invoicing' )
669
-						),
670
-						$vat_rules
671
-					),
672
-					'name'             => 'vat_rule',
673
-					'id'               => 'vat_rule',
674
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
675
-					'show_option_all'  => false,
676
-					'show_option_none' => false,
677
-				)
678
-			);
679
-
680
-			// Filter by VAT class.
656
+            // Sanitize selected vat rule.
657
+            $vat_rule   = '';
658
+            $vat_rules  = getpaid_get_tax_rules();
659
+            if ( isset( $_GET['vat_rule'] ) ) {
660
+                $vat_rule   =  $_GET['vat_rule'];
661
+            }
662
+
663
+            // Filter by VAT rule.
664
+            echo wpinv_html_select(
665
+                array(
666
+                    'options'          => array_merge(
667
+                        array(
668
+                            '' => __( 'All VAT rules', 'invoicing' )
669
+                        ),
670
+                        $vat_rules
671
+                    ),
672
+                    'name'             => 'vat_rule',
673
+                    'id'               => 'vat_rule',
674
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
675
+                    'show_option_all'  => false,
676
+                    'show_option_none' => false,
677
+                )
678
+            );
679
+
680
+            // Filter by VAT class.
681 681
 	
682
-			// Sanitize selected vat rule.
683
-			$vat_class   = '';
684
-			$vat_classes = getpaid_get_tax_classes();
685
-			if ( isset( $_GET['vat_class'] ) ) {
686
-				$vat_class   =  $_GET['vat_class'];
687
-			}
688
-
689
-			echo wpinv_html_select(
690
-				array(
691
-					'options'          => array_merge(
692
-						array(
693
-							'' => __( 'All VAT classes', 'invoicing' )
694
-						),
695
-						$vat_classes
696
-					),
697
-					'name'             => 'vat_class',
698
-					'id'               => 'vat_class',
699
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
700
-					'show_option_all'  => false,
701
-					'show_option_none' => false,
702
-				)
703
-			);
704
-
705
-		}
706
-
707
-		// Filter by item type.
708
-		$type   = '';
709
-		if ( isset( $_GET['type'] ) ) {
710
-			$type   =  $_GET['type'];
711
-		}
712
-
713
-		echo wpinv_html_select(
714
-			array(
715
-				'options'          => array_merge(
716
-					array(
717
-						'' => __( 'All item types', 'invoicing' )
718
-					),
719
-					wpinv_get_item_types()
720
-				),
721
-				'name'             => 'type',
722
-				'id'               => 'type',
723
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
724
-				'show_option_all'  => false,
725
-				'show_option_none' => false,
726
-			)
727
-		);
728
-
729
-	}
730
-
731
-	/**
732
-	 * Filters the item query.
733
-	 */
734
-	public static function filter_item_query( $query ) {
735
-
736
-		// modify the query only if it admin and main query.
737
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
738
-			return $query;
739
-		}
740
-
741
-		// we want to modify the query for our items.
742
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
743
-			return $query;
744
-		}
745
-
746
-		if ( empty( $query->query_vars['meta_query'] ) ) {
747
-			$query->query_vars['meta_query'] = array();
748
-		}
749
-
750
-		// Filter vat rule type
682
+            // Sanitize selected vat rule.
683
+            $vat_class   = '';
684
+            $vat_classes = getpaid_get_tax_classes();
685
+            if ( isset( $_GET['vat_class'] ) ) {
686
+                $vat_class   =  $_GET['vat_class'];
687
+            }
688
+
689
+            echo wpinv_html_select(
690
+                array(
691
+                    'options'          => array_merge(
692
+                        array(
693
+                            '' => __( 'All VAT classes', 'invoicing' )
694
+                        ),
695
+                        $vat_classes
696
+                    ),
697
+                    'name'             => 'vat_class',
698
+                    'id'               => 'vat_class',
699
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
700
+                    'show_option_all'  => false,
701
+                    'show_option_none' => false,
702
+                )
703
+            );
704
+
705
+        }
706
+
707
+        // Filter by item type.
708
+        $type   = '';
709
+        if ( isset( $_GET['type'] ) ) {
710
+            $type   =  $_GET['type'];
711
+        }
712
+
713
+        echo wpinv_html_select(
714
+            array(
715
+                'options'          => array_merge(
716
+                    array(
717
+                        '' => __( 'All item types', 'invoicing' )
718
+                    ),
719
+                    wpinv_get_item_types()
720
+                ),
721
+                'name'             => 'type',
722
+                'id'               => 'type',
723
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
724
+                'show_option_all'  => false,
725
+                'show_option_none' => false,
726
+            )
727
+        );
728
+
729
+    }
730
+
731
+    /**
732
+     * Filters the item query.
733
+     */
734
+    public static function filter_item_query( $query ) {
735
+
736
+        // modify the query only if it admin and main query.
737
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
738
+            return $query;
739
+        }
740
+
741
+        // we want to modify the query for our items.
742
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
743
+            return $query;
744
+        }
745
+
746
+        if ( empty( $query->query_vars['meta_query'] ) ) {
747
+            $query->query_vars['meta_query'] = array();
748
+        }
749
+
750
+        // Filter vat rule type
751 751
         if ( ! empty( $_GET['vat_rule'] ) ) {
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_rule',
@@ -772,97 +772,97 @@  discard block
 block discarded – undo
772 772
                 'value'   => sanitize_text_field( $_GET['type'] ),
773 773
                 'compare' => '='
774 774
             );
775
-		}
776
-
777
-	}
778
-
779
-	/**
780
-	 * Reorders items.
781
-	 */
782
-	public static function reorder_items( $vars ) {
783
-		global $typenow;
784
-
785
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
-			return $vars;
787
-		}
788
-
789
-		// By item type.
790
-		if ( 'type' == $vars['orderby'] ) {
791
-			return array_merge(
792
-				$vars,
793
-				array(
794
-					'meta_key' => '_wpinv_type',
795
-					'orderby'  => 'meta_value'
796
-				)
797
-			);
798
-		}
799
-
800
-		// By vat class.
801
-		if ( 'vat_class' == $vars['orderby'] ) {
802
-			return array_merge(
803
-				$vars,
804
-				array(
805
-					'meta_key' => '_wpinv_vat_class',
806
-					'orderby'  => 'meta_value'
807
-				)
808
-			);
809
-		}
810
-
811
-		// By vat rule.
812
-		if ( 'vat_rule' == $vars['orderby'] ) {
813
-			return array_merge(
814
-				$vars,
815
-				array(
816
-					'meta_key' => '_wpinv_vat_rule',
817
-					'orderby'  => 'meta_value'
818
-				)
819
-			);
820
-		}
821
-
822
-		// By price.
823
-		if ( 'price' == $vars['orderby'] ) {
824
-			return array_merge(
825
-				$vars,
826
-				array(
827
-					'meta_key' => '_wpinv_price',
828
-					'orderby'  => 'meta_value_num'
829
-				)
830
-			);
831
-		}
832
-
833
-		return $vars;
834
-
835
-	}
836
-
837
-	/**
838
-	 * Fired when deleting a post.
839
-	 */
840
-	public static function delete_post( $post_id ) {
841
-
842
-		switch ( get_post_type( $post_id ) ) {
843
-
844
-			case 'wpi_item' :
845
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
846
-				break;
847
-
848
-			case 'wpi_payment_form' :
849
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
850
-				break;
851
-
852
-			case 'wpi_discount' :
853
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
854
-				break;
855
-
856
-			case 'wpi_invoice' :
857
-				$invoice = new WPInv_Invoice( $post_id );
858
-				do_action( "getpaid_before_delete_invoice", $invoice );
859
-				$invoice->get_data_store()->delete_items( $invoice );
860
-				$invoice->get_data_store()->delete_special_fields( $invoice );
861
-				break;
862
-		}
863
-	}
864
-
865
-	/**
775
+        }
776
+
777
+    }
778
+
779
+    /**
780
+     * Reorders items.
781
+     */
782
+    public static function reorder_items( $vars ) {
783
+        global $typenow;
784
+
785
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
+            return $vars;
787
+        }
788
+
789
+        // By item type.
790
+        if ( 'type' == $vars['orderby'] ) {
791
+            return array_merge(
792
+                $vars,
793
+                array(
794
+                    'meta_key' => '_wpinv_type',
795
+                    'orderby'  => 'meta_value'
796
+                )
797
+            );
798
+        }
799
+
800
+        // By vat class.
801
+        if ( 'vat_class' == $vars['orderby'] ) {
802
+            return array_merge(
803
+                $vars,
804
+                array(
805
+                    'meta_key' => '_wpinv_vat_class',
806
+                    'orderby'  => 'meta_value'
807
+                )
808
+            );
809
+        }
810
+
811
+        // By vat rule.
812
+        if ( 'vat_rule' == $vars['orderby'] ) {
813
+            return array_merge(
814
+                $vars,
815
+                array(
816
+                    'meta_key' => '_wpinv_vat_rule',
817
+                    'orderby'  => 'meta_value'
818
+                )
819
+            );
820
+        }
821
+
822
+        // By price.
823
+        if ( 'price' == $vars['orderby'] ) {
824
+            return array_merge(
825
+                $vars,
826
+                array(
827
+                    'meta_key' => '_wpinv_price',
828
+                    'orderby'  => 'meta_value_num'
829
+                )
830
+            );
831
+        }
832
+
833
+        return $vars;
834
+
835
+    }
836
+
837
+    /**
838
+     * Fired when deleting a post.
839
+     */
840
+    public static function delete_post( $post_id ) {
841
+
842
+        switch ( get_post_type( $post_id ) ) {
843
+
844
+            case 'wpi_item' :
845
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
846
+                break;
847
+
848
+            case 'wpi_payment_form' :
849
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
850
+                break;
851
+
852
+            case 'wpi_discount' :
853
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
854
+                break;
855
+
856
+            case 'wpi_invoice' :
857
+                $invoice = new WPInv_Invoice( $post_id );
858
+                do_action( "getpaid_before_delete_invoice", $invoice );
859
+                $invoice->get_data_store()->delete_items( $invoice );
860
+                $invoice->get_data_store()->delete_special_fields( $invoice );
861
+                break;
862
+        }
863
+    }
864
+
865
+    /**
866 866
      * Add a post display state for special GetPaid pages in the page list table.
867 867
      *
868 868
      * @param array   $post_states An array of post display states.
@@ -876,22 +876,22 @@  discard block
 block discarded – undo
876 876
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
877 877
         }
878 878
 
879
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
879
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
880 880
 
881
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
882
-				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
883
-					__( 'GetPaid %s History Page', 'invoicing' ),
884
-					$label
885
-				);
886
-			}
881
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
882
+                $post_states["getpaid_{$post_type}_history_page"] = sprintf(
883
+                    __( 'GetPaid %s History Page', 'invoicing' ),
884
+                    $label
885
+                );
886
+            }
887 887
 
888
-		}
888
+        }
889 889
 		
890
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
890
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
891 891
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
892 892
         }
893 893
 
894
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
894
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
895 895
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
896 896
         }
897 897
 
Please login to merge, or discard this patch.