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