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