Passed
Push — master ( 0a8090...894ff0 )
by Brian
04:47
created
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +730 added lines, -730 removed lines patch added patch discarded remove patch
@@ -13,732 +13,732 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0   => '',
68
-			1   => __( 'Discount updated.', 'invoicing' ),
69
-			2   => __( 'Custom field updated.', 'invoicing' ),
70
-			3   => __( 'Custom field deleted.', 'invoicing' ),
71
-			4   => __( 'Discount updated.', 'invoicing' ),
72
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6   => __( 'Discount updated.', 'invoicing' ),
74
-			7   => __( 'Discount saved.', 'invoicing' ),
75
-			8   => __( 'Discount submitted.', 'invoicing' ),
76
-			9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10  => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0   => '',
82
-			1   => __( 'Payment Form updated.', 'invoicing' ),
83
-			2   => __( 'Custom field updated.', 'invoicing' ),
84
-			3   => __( 'Custom field deleted.', 'invoicing' ),
85
-			4   => __( 'Payment Form updated.', 'invoicing' ),
86
-			5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6   => __( 'Payment Form updated.', 'invoicing' ),
88
-			7   => __( 'Payment Form saved.', 'invoicing' ),
89
-			8   => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] =  sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] =  sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
144
-
145
-		}
146
-
147
-		return $actions;
148
-	}
149
-
150
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0   => '',
68
+            1   => __( 'Discount updated.', 'invoicing' ),
69
+            2   => __( 'Custom field updated.', 'invoicing' ),
70
+            3   => __( 'Custom field deleted.', 'invoicing' ),
71
+            4   => __( 'Discount updated.', 'invoicing' ),
72
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6   => __( 'Discount updated.', 'invoicing' ),
74
+            7   => __( 'Discount saved.', 'invoicing' ),
75
+            8   => __( 'Discount submitted.', 'invoicing' ),
76
+            9   => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10  => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0   => '',
82
+            1   => __( 'Payment Form updated.', 'invoicing' ),
83
+            2   => __( 'Custom field updated.', 'invoicing' ),
84
+            3   => __( 'Custom field deleted.', 'invoicing' ),
85
+            4   => __( 'Payment Form updated.', 'invoicing' ),
86
+            5   => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6   => __( 'Payment Form updated.', 'invoicing' ),
88
+            7   => __( 'Payment Form saved.', 'invoicing' ),
89
+            8   => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9   => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10  => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] =  sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] =  sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144
+
145
+        }
146
+
147
+        return $actions;
148
+    }
149
+
150
+    /**
151 151
      * Remove bulk edit option from admin side quote listing
152 152
      *
153 153
      * @since    1.0.0
154 154
      * @param array $actions post actions
155
-	 * @param WP_Post $post
155
+     * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158 158
     public static function filter_invoice_row_actions( $actions, $post ) {
159 159
 
160 160
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
161 161
 
162
-			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
164
-
165
-			$actions['edit'] =  sprintf(
166
-				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
169
-			);
170
-
171
-			if ( ! $invoice->is_draft() ) {
172
-
173
-				$actions['view'] =  sprintf(
174
-					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
176
-					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
-					)
180
-				);
181
-
182
-				$actions['send'] =  sprintf(
183
-					'<a href="%1$s">%2$s</a>',
184
-					esc_url(
185
-						wp_nonce_url(
186
-							add_query_arg(
187
-								array(
188
-									'getpaid-admin-action' => 'send_invoice',
189
-									'invoice_id'           => $invoice->get_id()
190
-								)
191
-							),
192
-							'getpaid-nonce',
193
-							'getpaid-nonce'
194
-						)
195
-					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
197
-				);
198
-
199
-			}
200
-
201
-			$actions['duplicate'] =  sprintf(
202
-				'<a href="%1$s">%2$s</a>',
203
-				esc_url(
204
-					wp_nonce_url(
205
-						add_query_arg(
206
-							array(
207
-								'getpaid-admin-action' => 'duplicate_invoice',
208
-								'invoice_id'           => $post->ID
209
-							)
210
-						),
211
-						'getpaid-nonce',
212
-						'getpaid-nonce'
213
-					)
214
-				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
216
-			);
162
+            $actions = array();
163
+            $invoice = new WPInv_Invoice( $post );
164
+
165
+            $actions['edit'] =  sprintf(
166
+                '<a href="%1$s">%2$s</a>',
167
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
+                esc_html( __( 'Edit', 'invoicing' ) )
169
+            );
170
+
171
+            if ( ! $invoice->is_draft() ) {
172
+
173
+                $actions['view'] =  sprintf(
174
+                    '<a href="%1$s">%2$s</a>',
175
+                    esc_url( $invoice->get_view_url() ),
176
+                    sprintf(
177
+                        esc_html( __( 'View %s', 'invoicing' ) ),
178
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
179
+                    )
180
+                );
181
+
182
+                $actions['send'] =  sprintf(
183
+                    '<a href="%1$s">%2$s</a>',
184
+                    esc_url(
185
+                        wp_nonce_url(
186
+                            add_query_arg(
187
+                                array(
188
+                                    'getpaid-admin-action' => 'send_invoice',
189
+                                    'invoice_id'           => $invoice->get_id()
190
+                                )
191
+                            ),
192
+                            'getpaid-nonce',
193
+                            'getpaid-nonce'
194
+                        )
195
+                    ),
196
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
197
+                );
198
+
199
+            }
200
+
201
+            $actions['duplicate'] =  sprintf(
202
+                '<a href="%1$s">%2$s</a>',
203
+                esc_url(
204
+                    wp_nonce_url(
205
+                        add_query_arg(
206
+                            array(
207
+                                'getpaid-admin-action' => 'duplicate_invoice',
208
+                                'invoice_id'           => $post->ID
209
+                            )
210
+                        ),
211
+                        'getpaid-nonce',
212
+                        'getpaid-nonce'
213
+                    )
214
+                ),
215
+                esc_html( __( 'Duplicate', 'invoicing' ) )
216
+            );
217 217
 
218 218
         }
219 219
 
220 220
         return $actions;
221
-	}
222
-
223
-	/**
224
-	 * Returns an array of invoice table columns.
225
-	 */
226
-	public static function invoice_columns( $columns ) {
227
-
228
-		$columns = array(
229
-			'cb'                => $columns['cb'],
230
-			'number'            => __( 'Invoice', 'invoicing' ),
231
-			'customer'          => __( 'Customer', 'invoicing' ),
232
-			'invoice_date'      => __( 'Created', 'invoicing' ),
233
-			'payment_date'      => __( 'Completed', 'invoicing' ),
234
-			'amount'            => __( 'Amount', 'invoicing' ),
235
-			'recurring'         => __( 'Recurring', 'invoicing' ),
236
-			'status'            => __( 'Status', 'invoicing' ),
237
-		);
238
-
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
240
-	}
241
-
242
-	/**
243
-	 * Displays invoice table columns.
244
-	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
246
-
247
-		$invoice = new WPInv_Invoice( $post_id );
248
-
249
-		switch ( $column_name ) {
250
-
251
-			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
-				echo "<span title='$date_time'>$date</span>";
255
-				break;
256
-
257
-			case 'payment_date' :
258
-
259
-				if ( $invoice->is_paid() ) {
260
-					$date_time = esc_attr( $invoice->get_completed_date() );
261
-					$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
-					echo "<span title='$date_time'>$date</span>";
263
-				} else {
264
-					echo "&mdash;";
265
-				}
221
+    }
222
+
223
+    /**
224
+     * Returns an array of invoice table columns.
225
+     */
226
+    public static function invoice_columns( $columns ) {
227
+
228
+        $columns = array(
229
+            'cb'                => $columns['cb'],
230
+            'number'            => __( 'Invoice', 'invoicing' ),
231
+            'customer'          => __( 'Customer', 'invoicing' ),
232
+            'invoice_date'      => __( 'Created', 'invoicing' ),
233
+            'payment_date'      => __( 'Completed', 'invoicing' ),
234
+            'amount'            => __( 'Amount', 'invoicing' ),
235
+            'recurring'         => __( 'Recurring', 'invoicing' ),
236
+            'status'            => __( 'Status', 'invoicing' ),
237
+        );
238
+
239
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
240
+    }
241
+
242
+    /**
243
+     * Displays invoice table columns.
244
+     */
245
+    public static function display_invoice_columns( $column_name, $post_id ) {
246
+
247
+        $invoice = new WPInv_Invoice( $post_id );
248
+
249
+        switch ( $column_name ) {
250
+
251
+            case 'invoice_date' :
252
+                $date_time = esc_attr( $invoice->get_created_date() );
253
+                $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
254
+                echo "<span title='$date_time'>$date</span>";
255
+                break;
256
+
257
+            case 'payment_date' :
258
+
259
+                if ( $invoice->is_paid() ) {
260
+                    $date_time = esc_attr( $invoice->get_completed_date() );
261
+                    $date      = getpaid_format_date_value( $date_time, "&mdash;", true );
262
+                    echo "<span title='$date_time'>$date</span>";
263
+                } else {
264
+                    echo "&mdash;";
265
+                }
266 266
 				
267
-				break;
267
+                break;
268 268
 
269
-			case 'amount' :
269
+            case 'amount' :
270 270
 
271
-				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
271
+                $amount = $invoice->get_total();
272
+                $formated_amount = wpinv_price( $amount, $invoice->get_currency() );
273 273
 
274
-				if ( $invoice->is_refunded() ) {
275
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
-					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
-				} else {
274
+                if ( $invoice->is_refunded() ) {
275
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
276
+                    echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277
+                } else {
278 278
 
279
-					$discount = $invoice->get_total_discount();
279
+                    $discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
-						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
-					} else {
285
-						echo $formated_amount;
286
-					}
281
+                    if ( ! empty( $discount ) ) {
282
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
283
+                        echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284
+                    } else {
285
+                        echo $formated_amount;
286
+                    }
287 287
 
288
-				}
288
+                }
289 289
 
290
-				break;
290
+                break;
291 291
 
292
-			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
292
+            case 'status' :
293
+                $status       = esc_html( $invoice->get_status() );
294
+                $status_label = esc_html( $invoice->get_status_nicename() );
295 295
 
296
-				// If it is paid, show the gateway title.
297
-				if ( $invoice->is_paid() ) {
298
-					$gateway = esc_html( $invoice->get_gateway_title() );
299
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
296
+                // If it is paid, show the gateway title.
297
+                if ( $invoice->is_paid() ) {
298
+                    $gateway = esc_html( $invoice->get_gateway_title() );
299
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), $gateway );
300 300
 
301
-					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
-				} else {
303
-					echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
-				}
301
+                    echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302
+                } else {
303
+                    echo "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>";
304
+                }
305 305
 
306
-				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
306
+                // If it is not paid, display the overdue and view status.
307
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
308 308
 
309
-					// Invoice view status.
310
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
-					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
-					}
309
+                    // Invoice view status.
310
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
311
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="'. esc_attr__( 'Viewed by Customer', 'invoicing' ).'"></i>';
312
+                    } else {
313
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
314
+                    }
315 315
 
316
-					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
318
-						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
316
+                    // Display the overview status.
317
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
318
+                        $due_date = $invoice->get_due_date();
319
+                        $fomatted = getpaid_format_date( $due_date );
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
-							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
-						}
325
-					}
321
+                        if ( ! empty( $fomatted ) ) {
322
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
323
+                            echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324
+                        }
325
+                    }
326 326
 
327
-				}
327
+                }
328 328
 
329
-				break;
329
+                break;
330 330
 
331
-			case 'recurring':
331
+            case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
334
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
-				} else {
336
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
-				}
338
-				break;
333
+                if ( $invoice->is_recurring() ) {
334
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335
+                } else {
336
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
337
+                }
338
+                break;
339 339
 
340
-			case 'number' :
340
+            case 'number' :
341 341
 
342
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
-				$invoice_number  = esc_html( $invoice->get_number() );
344
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
342
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
343
+                $invoice_number  = esc_html( $invoice->get_number() );
344
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
345 345
 
346
-				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
346
+                echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
348
-				break;
348
+                break;
349 349
 
350
-			case 'customer' :
350
+            case 'customer' :
351 351
 	
352
-				$customer_name = $invoice->get_user_full_name();
352
+                $customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
355
-					$customer_name = $invoice->get_email();
356
-				}
354
+                if ( empty( $customer_name ) ) {
355
+                    $customer_name = $invoice->get_email();
356
+                }
357 357
 	
358
-				if ( ! empty( $customer_name ) ) {
359
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
-					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
-				} else {
363
-					echo '<div>&mdash;</div>';
364
-				}
358
+                if ( ! empty( $customer_name ) ) {
359
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
360
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
361
+                    echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362
+                } else {
363
+                    echo '<div>&mdash;</div>';
364
+                }
365 365
 
366
-				break;
366
+                break;
367 367
 
368
-		}
368
+        }
369 369
 
370
-	}
370
+    }
371 371
 
372
-	/**
373
-	 * Displays invoice bulk actions.
374
-	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
-		return $actions;
378
-	}
372
+    /**
373
+     * Displays invoice bulk actions.
374
+     */
375
+    public static function invoice_bulk_actions( $actions ) {
376
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
377
+        return $actions;
378
+    }
379 379
 
380
-	/**
381
-	 * Processes invoice bulk actions.
382
-	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
380
+    /**
381
+     * Processes invoice bulk actions.
382
+     */
383
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
384 384
 
385
-		if ( $action == 'resend-invoice' ) {
386
-			foreach ( $post_ids as $post_id ) {
387
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
388
-			}
389
-		}
385
+        if ( $action == 'resend-invoice' ) {
386
+            foreach ( $post_ids as $post_id ) {
387
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
388
+            }
389
+        }
390 390
 
391
-		return $redirect_url;
391
+        return $redirect_url;
392 392
 
393
-	}
393
+    }
394 394
 
395
-	/**
396
-	 * Returns an array of payment forms table columns.
397
-	 */
398
-	public static function payment_form_columns( $columns ) {
395
+    /**
396
+     * Returns an array of payment forms table columns.
397
+     */
398
+    public static function payment_form_columns( $columns ) {
399 399
 
400
-		$columns = array(
401
-			'cb'                => $columns['cb'],
402
-			'title'             => __( 'Name', 'invoicing' ),
403
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
404
-			'earnings'          => __( 'Revenue', 'invoicing' ),
405
-			'refunds'           => __( 'Refunded', 'invoicing' ),
406
-			'items'             => __( 'Items', 'invoicing' ),
407
-			'date'              => __( 'Date', 'invoicing' ),
408
-		);
400
+        $columns = array(
401
+            'cb'                => $columns['cb'],
402
+            'title'             => __( 'Name', 'invoicing' ),
403
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
404
+            'earnings'          => __( 'Revenue', 'invoicing' ),
405
+            'refunds'           => __( 'Refunded', 'invoicing' ),
406
+            'items'             => __( 'Items', 'invoicing' ),
407
+            'date'              => __( 'Date', 'invoicing' ),
408
+        );
409 409
 
410
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
410
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
411 411
 
412
-	}
412
+    }
413 413
 
414
-	/**
415
-	 * Displays payment form table columns.
416
-	 */
417
-	public static function display_payment_form_columns( $column_name, $post_id ) {
414
+    /**
415
+     * Displays payment form table columns.
416
+     */
417
+    public static function display_payment_form_columns( $column_name, $post_id ) {
418 418
 
419
-		// Retrieve the payment form.
420
-		$form = new GetPaid_Payment_Form( $post_id );
419
+        // Retrieve the payment form.
420
+        $form = new GetPaid_Payment_Form( $post_id );
421 421
 
422
-		switch ( $column_name ) {
422
+        switch ( $column_name ) {
423 423
 
424
-			case 'earnings' :
425
-				echo wpinv_price( $form->get_earned() );
426
-				break;
424
+            case 'earnings' :
425
+                echo wpinv_price( $form->get_earned() );
426
+                break;
427 427
 
428
-			case 'refunds' :
429
-				echo wpinv_price( $form->get_refunded() );
430
-				break;
428
+            case 'refunds' :
429
+                echo wpinv_price( $form->get_refunded() );
430
+                break;
431 431
 
432
-			case 'refunds' :
433
-				echo wpinv_price( $form->get_refunded() );
434
-				break;
432
+            case 'refunds' :
433
+                echo wpinv_price( $form->get_refunded() );
434
+                break;
435 435
 
436
-			case 'shortcode' :
436
+            case 'shortcode' :
437 437
 
438
-				if ( $form->is_default() ) {
439
-					echo '&mdash;';
440
-				} else {
441
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
442
-				}
438
+                if ( $form->is_default() ) {
439
+                    echo '&mdash;';
440
+                } else {
441
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
442
+                }
443 443
 
444
-				break;
444
+                break;
445 445
 
446
-			case 'items' :
446
+            case 'items' :
447 447
 
448
-				$items = $form->get_items();
448
+                $items = $form->get_items();
449 449
 
450
-				if ( $form->is_default() || empty( $items ) ) {
451
-					echo '&mdash;';
452
-					return;
453
-				}
450
+                if ( $form->is_default() || empty( $items ) ) {
451
+                    echo '&mdash;';
452
+                    return;
453
+                }
454 454
 
455
-				$_items = array();
455
+                $_items = array();
456 456
 
457
-				foreach ( $items as $item ) {
458
-					$url = $item->get_edit_url();
457
+                foreach ( $items as $item ) {
458
+                    $url = $item->get_edit_url();
459 459
 
460
-					if ( empty( $url ) ) {
461
-						$_items[] = esc_html( $item->get_name() );
462
-					} else {
463
-						$_items[] = sprintf(
464
-							'<a href="%s">%s</a>',
465
-							esc_url( $url ),
466
-							esc_html( $item->get_name() )
467
-						);
468
-					}
460
+                    if ( empty( $url ) ) {
461
+                        $_items[] = esc_html( $item->get_name() );
462
+                    } else {
463
+                        $_items[] = sprintf(
464
+                            '<a href="%s">%s</a>',
465
+                            esc_url( $url ),
466
+                            esc_html( $item->get_name() )
467
+                        );
468
+                    }
469 469
 
470
-				}
470
+                }
471 471
 
472
-				echo implode( '<br>', $_items );
472
+                echo implode( '<br>', $_items );
473 473
 
474
-				break;
474
+                break;
475 475
 
476
-		}
476
+        }
477 477
 
478
-	}
478
+    }
479 479
 
480
-	/**
481
-	 * Filters post states.
482
-	 */
483
-	public static function filter_payment_form_state( $post_states, $post ) {
480
+    /**
481
+     * Filters post states.
482
+     */
483
+    public static function filter_payment_form_state( $post_states, $post ) {
484 484
 
485
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
486
-			$post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
487
-		}
485
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
486
+            $post_states[ 'default_form' ] = __( 'Default Payment Form', 'invoicing' );
487
+        }
488 488
 	
489
-		return $post_states;
490
-
491
-	}
492
-
493
-	/**
494
-	 * Returns an array of coupon table columns.
495
-	 */
496
-	public static function discount_columns( $columns ) {
497
-
498
-		$columns = array(
499
-			'cb'                => $columns['cb'],
500
-			'title'             => __( 'Name', 'invoicing' ),
501
-			'code'              => __( 'Code', 'invoicing' ),
502
-			'amount'            => __( 'Amount', 'invoicing' ),
503
-			'usage'             => __( 'Usage / Limit', 'invoicing' ),
504
-			'start_date'        => __( 'Start Date', 'invoicing' ),
505
-			'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
506
-		);
507
-
508
-		return apply_filters( 'wpi_discount_table_columns', $columns );
509
-	}
510
-
511
-	/**
512
-	 * Filters post states.
513
-	 */
514
-	public static function filter_discount_state( $post_states, $post ) {
515
-
516
-		if ( 'wpi_discount' == $post->post_type ) {
517
-
518
-			$discount = new WPInv_Discount( $post );
519
-
520
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
521
-
522
-			if ( $status != 'publish' ) {
523
-				return array(
524
-					'discount_status' => wpinv_discount_status( $status ),
525
-				);
526
-			}
527
-
528
-			return array();
529
-
530
-		}
531
-
532
-		return $post_states;
533
-
534
-	}
535
-
536
-	/**
537
-	 * Returns an array of items table columns.
538
-	 */
539
-	public static function item_columns( $columns ) {
540
-
541
-		$columns = array(
542
-			'cb'                => $columns['cb'],
543
-			'title'             => __( 'Name', 'invoicing' ),
544
-			'price'             => __( 'Price', 'invoicing' ),
545
-			'vat_rule'          => __( 'VAT rule', 'invoicing' ),
546
-			'vat_class'         => __( 'VAT class', 'invoicing' ),
547
-			'type'              => __( 'Type', 'invoicing' ),
548
-			'shortcode'         => __( 'Shortcode', 'invoicing' ),
549
-		);
550
-
551
-		if ( ! wpinv_use_taxes() ) {
552
-			unset( $columns['vat_rule'] );
553
-			unset( $columns['vat_class'] );
554
-		}
555
-
556
-		return apply_filters( 'wpi_item_table_columns', $columns );
557
-	}
558
-
559
-	/**
560
-	 * Returns an array of sortable items table columns.
561
-	 */
562
-	public static function sortable_item_columns( $columns ) {
563
-
564
-		return array_merge(
565
-			$columns,
566
-			array(
567
-				'price'     => 'price',
568
-				'vat_rule'  => 'vat_rule',
569
-				'vat_class' => 'vat_class',
570
-				'type'      => 'type',
571
-			)
572
-		);
573
-
574
-	}
575
-
576
-	/**
577
-	 * Displays items table columns.
578
-	 */
579
-	public static function display_item_columns( $column_name, $post_id ) {
489
+        return $post_states;
490
+
491
+    }
492
+
493
+    /**
494
+     * Returns an array of coupon table columns.
495
+     */
496
+    public static function discount_columns( $columns ) {
497
+
498
+        $columns = array(
499
+            'cb'                => $columns['cb'],
500
+            'title'             => __( 'Name', 'invoicing' ),
501
+            'code'              => __( 'Code', 'invoicing' ),
502
+            'amount'            => __( 'Amount', 'invoicing' ),
503
+            'usage'             => __( 'Usage / Limit', 'invoicing' ),
504
+            'start_date'        => __( 'Start Date', 'invoicing' ),
505
+            'expiry_date'       => __( 'Expiry Date', 'invoicing' ),
506
+        );
507
+
508
+        return apply_filters( 'wpi_discount_table_columns', $columns );
509
+    }
510
+
511
+    /**
512
+     * Filters post states.
513
+     */
514
+    public static function filter_discount_state( $post_states, $post ) {
515
+
516
+        if ( 'wpi_discount' == $post->post_type ) {
517
+
518
+            $discount = new WPInv_Discount( $post );
519
+
520
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
521
+
522
+            if ( $status != 'publish' ) {
523
+                return array(
524
+                    'discount_status' => wpinv_discount_status( $status ),
525
+                );
526
+            }
527
+
528
+            return array();
529
+
530
+        }
531
+
532
+        return $post_states;
533
+
534
+    }
535
+
536
+    /**
537
+     * Returns an array of items table columns.
538
+     */
539
+    public static function item_columns( $columns ) {
540
+
541
+        $columns = array(
542
+            'cb'                => $columns['cb'],
543
+            'title'             => __( 'Name', 'invoicing' ),
544
+            'price'             => __( 'Price', 'invoicing' ),
545
+            'vat_rule'          => __( 'VAT rule', 'invoicing' ),
546
+            'vat_class'         => __( 'VAT class', 'invoicing' ),
547
+            'type'              => __( 'Type', 'invoicing' ),
548
+            'shortcode'         => __( 'Shortcode', 'invoicing' ),
549
+        );
550
+
551
+        if ( ! wpinv_use_taxes() ) {
552
+            unset( $columns['vat_rule'] );
553
+            unset( $columns['vat_class'] );
554
+        }
555
+
556
+        return apply_filters( 'wpi_item_table_columns', $columns );
557
+    }
558
+
559
+    /**
560
+     * Returns an array of sortable items table columns.
561
+     */
562
+    public static function sortable_item_columns( $columns ) {
563
+
564
+        return array_merge(
565
+            $columns,
566
+            array(
567
+                'price'     => 'price',
568
+                'vat_rule'  => 'vat_rule',
569
+                'vat_class' => 'vat_class',
570
+                'type'      => 'type',
571
+            )
572
+        );
573
+
574
+    }
575
+
576
+    /**
577
+     * Displays items table columns.
578
+     */
579
+    public static function display_item_columns( $column_name, $post_id ) {
580 580
  
581
-		$item = new WPInv_Item( $post_id );
581
+        $item = new WPInv_Item( $post_id );
582 582
 
583
-		switch ( $column_name ) {
583
+        switch ( $column_name ) {
584 584
 
585
-			case 'price' :
585
+            case 'price' :
586 586
 
587
-				if ( ! $item->is_recurring() ) {
588
-					echo $item->get_the_price();
589
-					break;
590
-				}
587
+                if ( ! $item->is_recurring() ) {
588
+                    echo $item->get_the_price();
589
+                    break;
590
+                }
591 591
 
592
-				$price = wp_sprintf(
593
-					__( '%s / %s', 'invoicing' ),
594
-					$item->get_the_price(),
595
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
596
-				);
592
+                $price = wp_sprintf(
593
+                    __( '%s / %s', 'invoicing' ),
594
+                    $item->get_the_price(),
595
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
596
+                );
597 597
 
598
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
599
-					echo $price;
600
-					break;
601
-				}
598
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
599
+                    echo $price;
600
+                    break;
601
+                }
602 602
 
603
-				echo $item->get_the_initial_price();
603
+                echo $item->get_the_initial_price();
604 604
 
605
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
606
-				break;
605
+                echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
606
+                break;
607 607
 
608
-			case 'vat_rule' :
609
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
610
-				break;
608
+            case 'vat_rule' :
609
+                echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
610
+                break;
611 611
 
612
-			case 'vat_class' :
613
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
614
-				break;
612
+            case 'vat_class' :
613
+                echo getpaid_get_tax_class_label( $item->get_vat_class() );
614
+                break;
615 615
 
616
-			case 'shortcode' :
616
+            case 'shortcode' :
617 617
 
618
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
619
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
620
-				} else {
621
-					echo "&mdash;";
622
-				}
618
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
619
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
620
+                } else {
621
+                    echo "&mdash;";
622
+                }
623 623
 				
624
-				break;
624
+                break;
625 625
 
626
-			case 'type' :
627
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628
-				break;
626
+            case 'type' :
627
+                echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628
+                break;
629 629
 
630
-		}
630
+        }
631 631
 
632
-	}
632
+    }
633 633
 
634
-	/**
635
-	 * Lets users filter items using taxes.
636
-	 */
637
-	public static function add_item_filters( $post_type ) {
634
+    /**
635
+     * Lets users filter items using taxes.
636
+     */
637
+    public static function add_item_filters( $post_type ) {
638 638
 
639
-		// Abort if we're not dealing with items.
640
-		if ( $post_type != 'wpi_item' ) {
641
-			return;
642
-		}
639
+        // Abort if we're not dealing with items.
640
+        if ( $post_type != 'wpi_item' ) {
641
+            return;
642
+        }
643 643
 
644
-		// Filter by vat rules.
645
-		if ( wpinv_use_taxes() ) {
644
+        // Filter by vat rules.
645
+        if ( wpinv_use_taxes() ) {
646 646
 	
647
-			// Sanitize selected vat rule.
648
-			$vat_rule   = '';
649
-			$vat_rules  = getpaid_get_tax_rules();
650
-			if ( isset( $_GET['vat_rule'] ) ) {
651
-				$vat_rule   =  $_GET['vat_rule'];
652
-			}
653
-
654
-			// Filter by VAT rule.
655
-			echo wpinv_html_select(
656
-				array(
657
-					'options'          => array_merge(
658
-						array(
659
-							'' => __( 'All VAT rules', 'invoicing' )
660
-						),
661
-						$vat_rules
662
-					),
663
-					'name'             => 'vat_rule',
664
-					'id'               => 'vat_rule',
665
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
666
-					'show_option_all'  => false,
667
-					'show_option_none' => false,
668
-				)
669
-			);
670
-
671
-			// Filter by VAT class.
647
+            // Sanitize selected vat rule.
648
+            $vat_rule   = '';
649
+            $vat_rules  = getpaid_get_tax_rules();
650
+            if ( isset( $_GET['vat_rule'] ) ) {
651
+                $vat_rule   =  $_GET['vat_rule'];
652
+            }
653
+
654
+            // Filter by VAT rule.
655
+            echo wpinv_html_select(
656
+                array(
657
+                    'options'          => array_merge(
658
+                        array(
659
+                            '' => __( 'All VAT rules', 'invoicing' )
660
+                        ),
661
+                        $vat_rules
662
+                    ),
663
+                    'name'             => 'vat_rule',
664
+                    'id'               => 'vat_rule',
665
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
666
+                    'show_option_all'  => false,
667
+                    'show_option_none' => false,
668
+                )
669
+            );
670
+
671
+            // Filter by VAT class.
672 672
 	
673
-			// Sanitize selected vat rule.
674
-			$vat_class   = '';
675
-			$vat_classes = getpaid_get_tax_classes();
676
-			if ( isset( $_GET['vat_class'] ) ) {
677
-				$vat_class   =  $_GET['vat_class'];
678
-			}
679
-
680
-			echo wpinv_html_select(
681
-				array(
682
-					'options'          => array_merge(
683
-						array(
684
-							'' => __( 'All VAT classes', 'invoicing' )
685
-						),
686
-						$vat_classes
687
-					),
688
-					'name'             => 'vat_class',
689
-					'id'               => 'vat_class',
690
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
691
-					'show_option_all'  => false,
692
-					'show_option_none' => false,
693
-				)
694
-			);
695
-
696
-		}
697
-
698
-		// Filter by item type.
699
-		$type   = '';
700
-		if ( isset( $_GET['type'] ) ) {
701
-			$type   =  $_GET['type'];
702
-		}
703
-
704
-		echo wpinv_html_select(
705
-			array(
706
-				'options'          => array_merge(
707
-					array(
708
-						'' => __( 'All item types', 'invoicing' )
709
-					),
710
-					wpinv_get_item_types()
711
-				),
712
-				'name'             => 'type',
713
-				'id'               => 'type',
714
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
715
-				'show_option_all'  => false,
716
-				'show_option_none' => false,
717
-			)
718
-		);
719
-
720
-	}
721
-
722
-	/**
723
-	 * Filters the item query.
724
-	 */
725
-	public static function filter_item_query( $query ) {
726
-
727
-		// modify the query only if it admin and main query.
728
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
729
-			return $query;
730
-		}
731
-
732
-		// we want to modify the query for our items.
733
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
734
-			return $query;
735
-		}
736
-
737
-		if ( empty( $query->query_vars['meta_query'] ) ) {
738
-			$query->query_vars['meta_query'] = array();
739
-		}
740
-
741
-		// Filter vat rule type
673
+            // Sanitize selected vat rule.
674
+            $vat_class   = '';
675
+            $vat_classes = getpaid_get_tax_classes();
676
+            if ( isset( $_GET['vat_class'] ) ) {
677
+                $vat_class   =  $_GET['vat_class'];
678
+            }
679
+
680
+            echo wpinv_html_select(
681
+                array(
682
+                    'options'          => array_merge(
683
+                        array(
684
+                            '' => __( 'All VAT classes', 'invoicing' )
685
+                        ),
686
+                        $vat_classes
687
+                    ),
688
+                    'name'             => 'vat_class',
689
+                    'id'               => 'vat_class',
690
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
691
+                    'show_option_all'  => false,
692
+                    'show_option_none' => false,
693
+                )
694
+            );
695
+
696
+        }
697
+
698
+        // Filter by item type.
699
+        $type   = '';
700
+        if ( isset( $_GET['type'] ) ) {
701
+            $type   =  $_GET['type'];
702
+        }
703
+
704
+        echo wpinv_html_select(
705
+            array(
706
+                'options'          => array_merge(
707
+                    array(
708
+                        '' => __( 'All item types', 'invoicing' )
709
+                    ),
710
+                    wpinv_get_item_types()
711
+                ),
712
+                'name'             => 'type',
713
+                'id'               => 'type',
714
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
715
+                'show_option_all'  => false,
716
+                'show_option_none' => false,
717
+            )
718
+        );
719
+
720
+    }
721
+
722
+    /**
723
+     * Filters the item query.
724
+     */
725
+    public static function filter_item_query( $query ) {
726
+
727
+        // modify the query only if it admin and main query.
728
+        if ( ! ( is_admin() && $query->is_main_query() ) ){ 
729
+            return $query;
730
+        }
731
+
732
+        // we want to modify the query for our items.
733
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
734
+            return $query;
735
+        }
736
+
737
+        if ( empty( $query->query_vars['meta_query'] ) ) {
738
+            $query->query_vars['meta_query'] = array();
739
+        }
740
+
741
+        // Filter vat rule type
742 742
         if ( ! empty( $_GET['vat_rule'] ) ) {
743 743
             $query->query_vars['meta_query'][] = array(
744 744
                 'key'     => '_wpinv_vat_rule',
@@ -763,97 +763,97 @@  discard block
 block discarded – undo
763 763
                 'value'   => sanitize_text_field( $_GET['type'] ),
764 764
                 'compare' => '='
765 765
             );
766
-		}
767
-
768
-	}
769
-
770
-	/**
771
-	 * Reorders items.
772
-	 */
773
-	public static function reorder_items( $vars ) {
774
-		global $typenow;
775
-
776
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
777
-			return $vars;
778
-		}
779
-
780
-		// By item type.
781
-		if ( 'type' == $vars['orderby'] ) {
782
-			return array_merge(
783
-				$vars,
784
-				array(
785
-					'meta_key' => '_wpinv_type',
786
-					'orderby'  => 'meta_value'
787
-				)
788
-			);
789
-		}
790
-
791
-		// By vat class.
792
-		if ( 'vat_class' == $vars['orderby'] ) {
793
-			return array_merge(
794
-				$vars,
795
-				array(
796
-					'meta_key' => '_wpinv_vat_class',
797
-					'orderby'  => 'meta_value'
798
-				)
799
-			);
800
-		}
801
-
802
-		// By vat rule.
803
-		if ( 'vat_rule' == $vars['orderby'] ) {
804
-			return array_merge(
805
-				$vars,
806
-				array(
807
-					'meta_key' => '_wpinv_vat_rule',
808
-					'orderby'  => 'meta_value'
809
-				)
810
-			);
811
-		}
812
-
813
-		// By price.
814
-		if ( 'price' == $vars['orderby'] ) {
815
-			return array_merge(
816
-				$vars,
817
-				array(
818
-					'meta_key' => '_wpinv_price',
819
-					'orderby'  => 'meta_value_num'
820
-				)
821
-			);
822
-		}
823
-
824
-		return $vars;
825
-
826
-	}
827
-
828
-	/**
829
-	 * Fired when deleting a post.
830
-	 */
831
-	public static function delete_post( $post_id ) {
832
-
833
-		switch ( get_post_type( $post_id ) ) {
834
-
835
-			case 'wpi_item' :
836
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
837
-				break;
838
-
839
-			case 'wpi_payment_form' :
840
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
841
-				break;
842
-
843
-			case 'wpi_discount' :
844
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
845
-				break;
846
-
847
-			case 'wpi_invoice' :
848
-				$invoice = new WPInv_Invoice( $post_id );
849
-				do_action( "getpaid_before_delete_invoice", $invoice );
850
-				$invoice->get_data_store()->delete_items( $invoice );
851
-				$invoice->get_data_store()->delete_special_fields( $invoice );
852
-				break;
853
-		}
854
-	}
855
-
856
-	/**
766
+        }
767
+
768
+    }
769
+
770
+    /**
771
+     * Reorders items.
772
+     */
773
+    public static function reorder_items( $vars ) {
774
+        global $typenow;
775
+
776
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
777
+            return $vars;
778
+        }
779
+
780
+        // By item type.
781
+        if ( 'type' == $vars['orderby'] ) {
782
+            return array_merge(
783
+                $vars,
784
+                array(
785
+                    'meta_key' => '_wpinv_type',
786
+                    'orderby'  => 'meta_value'
787
+                )
788
+            );
789
+        }
790
+
791
+        // By vat class.
792
+        if ( 'vat_class' == $vars['orderby'] ) {
793
+            return array_merge(
794
+                $vars,
795
+                array(
796
+                    'meta_key' => '_wpinv_vat_class',
797
+                    'orderby'  => 'meta_value'
798
+                )
799
+            );
800
+        }
801
+
802
+        // By vat rule.
803
+        if ( 'vat_rule' == $vars['orderby'] ) {
804
+            return array_merge(
805
+                $vars,
806
+                array(
807
+                    'meta_key' => '_wpinv_vat_rule',
808
+                    'orderby'  => 'meta_value'
809
+                )
810
+            );
811
+        }
812
+
813
+        // By price.
814
+        if ( 'price' == $vars['orderby'] ) {
815
+            return array_merge(
816
+                $vars,
817
+                array(
818
+                    'meta_key' => '_wpinv_price',
819
+                    'orderby'  => 'meta_value_num'
820
+                )
821
+            );
822
+        }
823
+
824
+        return $vars;
825
+
826
+    }
827
+
828
+    /**
829
+     * Fired when deleting a post.
830
+     */
831
+    public static function delete_post( $post_id ) {
832
+
833
+        switch ( get_post_type( $post_id ) ) {
834
+
835
+            case 'wpi_item' :
836
+                do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
837
+                break;
838
+
839
+            case 'wpi_payment_form' :
840
+                do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
841
+                break;
842
+
843
+            case 'wpi_discount' :
844
+                do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
845
+                break;
846
+
847
+            case 'wpi_invoice' :
848
+                $invoice = new WPInv_Invoice( $post_id );
849
+                do_action( "getpaid_before_delete_invoice", $invoice );
850
+                $invoice->get_data_store()->delete_items( $invoice );
851
+                $invoice->get_data_store()->delete_special_fields( $invoice );
852
+                break;
853
+        }
854
+    }
855
+
856
+    /**
857 857
      * Add a post display state for special GetPaid pages in the page list table.
858 858
      *
859 859
      * @param array   $post_states An array of post display states.
@@ -867,22 +867,22 @@  discard block
 block discarded – undo
867 867
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
868 868
         }
869 869
 
870
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
870
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
871 871
 
872
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
873
-				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
-					__( 'GetPaid %s History Page', 'invoicing' ),
875
-					$label
876
-				);
877
-			}
872
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
873
+                $post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
+                    __( 'GetPaid %s History Page', 'invoicing' ),
875
+                    $label
876
+                );
877
+            }
878 878
 
879
-		}
879
+        }
880 880
 		
881
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
881
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
882 882
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
883 883
         }
884 884
 
885
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
885
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
886 886
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
887 887
         }
888 888
 
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 1 patch
Indentation   +602 added lines, -602 removed lines patch added patch discarded remove patch
@@ -14,91 +14,91 @@  discard block
 block discarded – undo
14 14
 class GetPaid_Admin {
15 15
 
16 16
     /**
17
-	 * Local path to this plugins admin directory
18
-	 *
19
-	 * @var         string
20
-	 */
21
-	public $admin_path;
22
-
23
-	/**
24
-	 * Web path to this plugins admin directory
25
-	 *
26
-	 * @var         string
27
-	 */
28
-	public $admin_url;
17
+     * Local path to this plugins admin directory
18
+     *
19
+     * @var         string
20
+     */
21
+    public $admin_path;
22
+
23
+    /**
24
+     * Web path to this plugins admin directory
25
+     *
26
+     * @var         string
27
+     */
28
+    public $admin_url;
29 29
 	
30
-	/**
31
-	 * Reports components.
32
-	 *
33
-	 * @var GetPaid_Reports
34
-	 */
30
+    /**
31
+     * Reports components.
32
+     *
33
+     * @var GetPaid_Reports
34
+     */
35 35
     public $reports;
36 36
 
37 37
     /**
38
-	 * Class constructor.
39
-	 */
40
-	public function __construct(){
38
+     * Class constructor.
39
+     */
40
+    public function __construct(){
41 41
 
42 42
         $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
44
-		$this->reports     = new GetPaid_Reports();
43
+        $this->admin_url   = plugins_url( '/', __FILE__ );
44
+        $this->reports     = new GetPaid_Reports();
45 45
 
46 46
         if ( is_admin() ) {
47
-			$this->init_admin_hooks();
47
+            $this->init_admin_hooks();
48 48
         }
49 49
 
50 50
     }
51 51
 
52 52
     /**
53
-	 * Init action and filter hooks
54
-	 *
55
-	 */
56
-	private function init_admin_hooks() {
53
+     * Init action and filter hooks
54
+     *
55
+     */
56
+    private function init_admin_hooks() {
57 57
         add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58 58
         add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59 59
         add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60 60
         add_action( 'admin_init', array( $this, 'activation_redirect') );
61 61
         add_action( 'admin_init', array( $this, 'maybe_do_admin_action') );
62
-		add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
-		add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
-		add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
-		add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
-		add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
-		add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
62
+        add_action( 'admin_notices', array( $this, 'show_notices' ) );
63
+        add_action( 'getpaid_authenticated_admin_action_rate_plugin', array( $this, 'redirect_to_wordpress_rating_page' ) );
64
+        add_action( 'getpaid_authenticated_admin_action_duplicate_form', array( $this, 'duplicate_payment_form' ) );
65
+        add_action( 'getpaid_authenticated_admin_action_duplicate_invoice', array( $this, 'duplicate_invoice' ) );
66
+        add_action( 'getpaid_authenticated_admin_action_send_invoice', array( $this, 'send_customer_invoice' ) );
67
+        add_action( 'getpaid_authenticated_admin_action_send_invoice_reminder', array( $this, 'send_customer_payment_reminder' ) );
68 68
         add_action( 'getpaid_authenticated_admin_action_reset_tax_rates', array( $this, 'admin_reset_tax_rates' ) );
69
-		add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
-		add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
-		add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
-		add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
-		add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
-		add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
-		add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
-		add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
-		do_action( 'getpaid_init_admin_hooks', $this );
78
-
79
-		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( $_GET['page'] ) {
82
-				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
-					break;
85
-			}
86
-		}
87
-
88
-    }
89
-
90
-    /**
91
-	 * Register admin scripts
92
-	 *
93
-	 */
94
-	public function enqeue_scripts() {
69
+        add_action( 'getpaid_authenticated_admin_action_create_missing_pages', array( $this, 'admin_create_missing_pages' ) );
70
+        add_action( 'getpaid_authenticated_admin_action_create_missing_tables', array( $this, 'admin_create_missing_tables' ) );
71
+        add_action( 'getpaid_authenticated_admin_action_migrate_old_invoices', array( $this, 'admin_migrate_old_invoices' ) );
72
+        add_action( 'getpaid_authenticated_admin_action_download_customers', array( $this, 'admin_download_customers' ) );
73
+        add_action( 'getpaid_authenticated_admin_action_recalculate_discounts', array( $this, 'admin_recalculate_discounts' ) );
74
+        add_action( 'getpaid_authenticated_admin_action_install_plugin', array( $this, 'admin_install_plugin' ) );
75
+        add_action( 'getpaid_authenticated_admin_action_connect_gateway', array( $this, 'admin_connect_gateway' ) );
76
+        add_filter( 'admin_footer_text', array( $this, 'admin_footer_text' ) );
77
+        do_action( 'getpaid_init_admin_hooks', $this );
78
+
79
+        // Setup/welcome
80
+        if ( ! empty( $_GET['page'] ) ) {
81
+            switch ( $_GET['page'] ) {
82
+                case 'gp-setup' :
83
+                    include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
84
+                    break;
85
+            }
86
+        }
87
+
88
+    }
89
+
90
+    /**
91
+     * Register admin scripts
92
+     *
93
+     */
94
+    public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
98
-		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
97
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
98
+        $editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100 100
         if ( ! empty( $current_screen->post_type ) ) {
101
-			$page = $current_screen->post_type;
101
+            $page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
@@ -119,54 +119,54 @@  discard block
 block discarded – undo
119 119
         }
120 120
 
121 121
         // Payment form scripts.
122
-		if ( 'wpi_payment_form' == $page && $editing ) {
122
+        if ( 'wpi_payment_form' == $page && $editing ) {
123 123
             $this->load_payment_form_scripts();
124 124
         }
125 125
 
126
-		if ( $page == 'wpinv-subscriptions' ) {
127
-			wp_enqueue_script( 'postbox' );
128
-		}
126
+        if ( $page == 'wpinv-subscriptions' ) {
127
+            wp_enqueue_script( 'postbox' );
128
+        }
129 129
 
130 130
     }
131 131
 
132 132
     /**
133
-	 * Returns admin js translations.
134
-	 *
135
-	 */
136
-	protected function get_admin_i18() {
133
+     * Returns admin js translations.
134
+     *
135
+     */
136
+    protected function get_admin_i18() {
137 137
         global $post;
138 138
 
139
-		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
-		);
139
+        $date_range = array(
140
+            'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
141
+        );
142 142
 
143
-		if ( $date_range['period'] == 'custom' ) {
143
+        if ( $date_range['period'] == 'custom' ) {
144 144
 			
145
-			if ( isset( $_GET['from'] ) ) {
146
-				$date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
-			}
145
+            if ( isset( $_GET['from'] ) ) {
146
+                $date_range[ 'after' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['from'] ), current_time( 'timestamp' ) ) - DAY_IN_SECONDS );
147
+            }
148 148
 
149
-			if ( isset( $_GET['to'] ) ) {
150
-				$date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
-			}
149
+            if ( isset( $_GET['to'] ) ) {
150
+                $date_range[ 'before' ] = date( 'Y-m-d', strtotime( sanitize_text_field( $_GET['to'] ), current_time( 'timestamp' ) ) + DAY_IN_SECONDS );
151
+            }
152 152
 
153
-		}
153
+        }
154 154
 
155 155
         $i18n = array(
156 156
             'ajax_url'                  => admin_url( 'admin-ajax.php' ),
157 157
             'post_ID'                   => isset( $post->ID ) ? $post->ID : '',
158
-			'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
-			'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
-			'rest_root'                 => esc_url_raw( rest_url() ),
161
-			'date_range'                => $date_range,
158
+            'wpinv_nonce'               => wp_create_nonce( 'wpinv-nonce' ),
159
+            'rest_nonce'                => wp_create_nonce( 'wp_rest' ),
160
+            'rest_root'                 => esc_url_raw( rest_url() ),
161
+            'date_range'                => $date_range,
162 162
             'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163 163
             'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164 164
             'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165 165
             'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168
-			'currency_symbol'           => wpinv_currency_symbol(),
169
-			'currency'                  => wpinv_get_currency(),
168
+            'currency_symbol'           => wpinv_currency_symbol(),
169
+            'currency'                  => wpinv_get_currency(),
170 170
             'currency_pos'              => wpinv_currency_position(),
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
@@ -186,118 +186,118 @@  discard block
 block discarded – undo
186 186
             'item_description'          => __( 'Item Description', 'invoicing' ),
187 187
             'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
188 188
             'discount_description'      => __( 'Discount Description', 'invoicing' ),
189
-			'searching'                 => __( 'Searching', 'invoicing' ),
190
-			'loading'                   => __( 'Loading...', 'invoicing' ),
191
-			'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
-			'search_items'              => __( 'Enter item name', 'invoicing' ),
189
+            'searching'                 => __( 'Searching', 'invoicing' ),
190
+            'loading'                   => __( 'Loading...', 'invoicing' ),
191
+            'search_customers'          => __( 'Enter customer name or email', 'invoicing' ),
192
+            'search_items'              => __( 'Enter item name', 'invoicing' ),
193 193
         );
194 194
 
195
-		if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
195
+        if ( ! empty( $post ) && getpaid_is_invoice_post_type( $post->post_type ) ) {
196 196
 
197
-			$invoice              = new WPInv_Invoice( $post );
198
-			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
201
-			);
197
+            $invoice              = new WPInv_Invoice( $post );
198
+            $i18n['save_invoice'] = sprintf(
199
+                __( 'Save %s', 'invoicing' ),
200
+                ucfirst( $invoice->get_invoice_quote_type() )
201
+            );
202 202
 
203
-			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
206
-			);
203
+            $i18n['invoice_description'] = sprintf(
204
+                __( '%s Description', 'invoicing' ),
205
+                ucfirst( $invoice->get_invoice_quote_type() )
206
+            );
207 207
 
208
-		}
209
-		return $i18n;
210
-	}
208
+        }
209
+        return $i18n;
210
+    }
211 211
 
212
-	/**
213
-	 * Change the admin footer text on GetPaid admin pages.
214
-	 *
215
-	 * @since  2.0.0
216
-	 * @param  string $footer_text
217
-	 * @return string
218
-	 */
219
-	public function admin_footer_text( $footer_text ) {
220
-		global $current_screen;
212
+    /**
213
+     * Change the admin footer text on GetPaid admin pages.
214
+     *
215
+     * @since  2.0.0
216
+     * @param  string $footer_text
217
+     * @return string
218
+     */
219
+    public function admin_footer_text( $footer_text ) {
220
+        global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222
+        $page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
223 223
 
224 224
         if ( ! empty( $current_screen->post_type ) ) {
225
-			$page = $current_screen->post_type;
225
+            $page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229 229
         if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
230 230
 
231
-			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
-
234
-				$rating_url  = esc_url(
235
-					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
-						'getpaid-nonce',
238
-						'getpaid-nonce'
239
-						)
240
-				);
241
-
242
-				$footer_text = sprintf(
243
-					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
-					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
-				);
247
-
248
-			} else {
249
-
250
-				$footer_text = sprintf(
251
-					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
253
-					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
-				);
255
-
256
-			}
257
-
258
-		}
259
-
260
-		return $footer_text;
261
-	}
262
-
263
-	/**
264
-	 * Redirects to wp.org to rate the plugin.
265
-	 *
266
-	 * @since  2.0.0
267
-	 */
268
-	public function redirect_to_wordpress_rating_page() {
269
-		update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
-		wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
-		exit;
272
-	}
273
-
274
-    /**
275
-	 * Loads payment form js.
276
-	 *
277
-	 */
278
-	protected function load_payment_form_scripts() {
231
+            // Change the footer text
232
+            if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
233
+
234
+                $rating_url  = esc_url(
235
+                    wp_nonce_url(
236
+                        admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
237
+                        'getpaid-nonce',
238
+                        'getpaid-nonce'
239
+                        )
240
+                );
241
+
242
+                $footer_text = sprintf(
243
+                    /* translators: %s: five stars */
244
+                    __( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
245
+                    "<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246
+                );
247
+
248
+            } else {
249
+
250
+                $footer_text = sprintf(
251
+                    /* translators: %s: GetPaid */
252
+                    __( 'Thank you for using %s!', 'invoicing' ),
253
+                    "<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254
+                );
255
+
256
+            }
257
+
258
+        }
259
+
260
+        return $footer_text;
261
+    }
262
+
263
+    /**
264
+     * Redirects to wp.org to rate the plugin.
265
+     *
266
+     * @since  2.0.0
267
+     */
268
+    public function redirect_to_wordpress_rating_page() {
269
+        update_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', 1 );
270
+        wp_redirect( 'https://wordpress.org/support/plugin/invoicing/reviews?rate=5#new-post' );
271
+        exit;
272
+    }
273
+
274
+    /**
275
+     * Loads payment form js.
276
+     *
277
+     */
278
+    protected function load_payment_form_scripts() {
279 279
         global $post;
280 280
 
281 281
         wp_enqueue_script( 'vue', WPINV_PLUGIN_URL . 'assets/js/vue/vue.min.js', array(), WPINV_VERSION );
282
-		wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
-		wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
282
+        wp_enqueue_script( 'sortable', WPINV_PLUGIN_URL . 'assets/js/sortable.min.js', array(), WPINV_VERSION );
283
+        wp_enqueue_script( 'vue_draggable', WPINV_PLUGIN_URL . 'assets/js/vue/vuedraggable.min.js', array( 'sortable', 'vue' ), WPINV_VERSION );
284 284
 
285
-		$version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
-		wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
285
+        $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin-payment-forms.js' );
286
+        wp_register_script( 'wpinv-admin-payment-form-script', WPINV_PLUGIN_URL . 'assets/js/admin-payment-forms.js', array( 'wpinv-admin-script', 'vue_draggable', 'wp-hooks' ),  $version );
287 287
 
288
-		wp_localize_script(
288
+        wp_localize_script(
289 289
             'wpinv-admin-payment-form-script',
290 290
             'wpinvPaymentFormAdmin',
291 291
             array(
292
-				'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
-				'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
-				'currency'      => wpinv_currency_symbol(),
295
-				'position'      => wpinv_currency_position(),
296
-				'decimals'      => (int) wpinv_decimals(),
297
-				'thousands_sep' => wpinv_thousands_separator(),
298
-				'decimals_sep'  => wpinv_decimal_separator(),
299
-				'form_items'    => gepaid_get_form_items( $post->ID ),
300
-				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
292
+                'elements'      => wpinv_get_data( 'payment-form-elements' ),
293
+                'form_elements' => getpaid_get_payment_form_elements( $post->ID ),
294
+                'currency'      => wpinv_currency_symbol(),
295
+                'position'      => wpinv_currency_position(),
296
+                'decimals'      => (int) wpinv_decimals(),
297
+                'thousands_sep' => wpinv_thousands_separator(),
298
+                'decimals_sep'  => wpinv_decimal_separator(),
299
+                'form_items'    => gepaid_get_form_items( $post->ID ),
300
+                'is_default'    => $post->ID == wpinv_get_default_payment_form(),
301 301
             )
302 302
         );
303 303
 
@@ -306,20 +306,20 @@  discard block
 block discarded – undo
306 306
     }
307 307
 
308 308
     /**
309
-	 * Add our classes to admin pages.
309
+     * Add our classes to admin pages.
310 310
      *
311 311
      * @param string $classes
312 312
      * @return string
313
-	 *
314
-	 */
313
+     *
314
+     */
315 315
     public function admin_body_class( $classes ) {
316
-		global $pagenow, $post, $current_screen;
316
+        global $pagenow, $post, $current_screen;
317 317
 
318 318
 
319 319
         $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
320 320
 
321 321
         if ( ! empty( $current_screen->post_type ) ) {
322
-			$page = $current_screen->post_type;
322
+            $page = $current_screen->post_type;
323 323
         }
324 324
 
325 325
         if ( false !== stripos( $page, 'wpi' ) ) {
@@ -328,68 +328,68 @@  discard block
 block discarded – undo
328 328
 
329 329
         if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
330 330
             $classes .= ' wpinv-cpt wpinv';
331
-		}
331
+        }
332 332
 		
333
-		if ( getpaid_is_invoice_post_type( $page ) ) {
333
+        if ( getpaid_is_invoice_post_type( $page ) ) {
334 334
             $classes .= ' getpaid-is-invoice-cpt';
335 335
         }
336 336
 
337
-		return $classes;
337
+        return $classes;
338 338
     }
339 339
 
340 340
     /**
341
-	 * Maybe show the AyeCode Connect Notice.
342
-	 */
343
-	public function init_ayecode_connect_helper(){
341
+     * Maybe show the AyeCode Connect Notice.
342
+     */
343
+    public function init_ayecode_connect_helper(){
344 344
 
345
-		// Register with the deactivation survey class.
346
-		AyeCode_Deactivation_Survey::instance(array(
347
-			'slug'		        => 'invoicing',
348
-			'version'	        => WPINV_VERSION,
349
-			'support_url'       => 'https://wpgetpaid.com/support/',
350
-			'documentation_url' => 'https://docs.wpgetpaid.com/',
351
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
-		));
345
+        // Register with the deactivation survey class.
346
+        AyeCode_Deactivation_Survey::instance(array(
347
+            'slug'		        => 'invoicing',
348
+            'version'	        => WPINV_VERSION,
349
+            'support_url'       => 'https://wpgetpaid.com/support/',
350
+            'documentation_url' => 'https://docs.wpgetpaid.com/',
351
+            'activated'         => (int) get_option( 'gepaid_installed_on' ),
352
+        ));
353 353
 
354 354
         new AyeCode_Connect_Helper(
355 355
             array(
356
-				'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
-				'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
-				'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
-				'connect_button'    => __("Connect Site","invoicing"),
360
-				'connecting_button'    => __("Connecting...","invoicing"),
361
-				'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
-				'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
356
+                'connect_title' => __("WP Invoicing - an AyeCode product!","invoicing"),
357
+                'connect_external'  => __( "Please confirm you wish to connect your site?","invoicing" ),
358
+                'connect'           => sprintf( __( "<strong>Have a license?</strong> Forget about entering license keys or downloading zip files, connect your site for instant access. %slearn more%s","invoicing" ),"<a href='https://ayecode.io/introducing-ayecode-connect/' target='_blank'>","</a>" ),
359
+                'connect_button'    => __("Connect Site","invoicing"),
360
+                'connecting_button'    => __("Connecting...","invoicing"),
361
+                'error_localhost'   => __( "This service will only work with a live domain, not a localhost.","invoicing" ),
362
+                'error'             => __( "Something went wrong, please refresh and try again.","invoicing" ),
363 363
             ),
364 364
             array( 'wpi-addons' )
365 365
         );
366 366
 
367 367
     }
368 368
 
369
-	/**
370
-	 * Redirect users to settings on activation.
371
-	 *
372
-	 * @return void
373
-	 */
374
-	public function activation_redirect() {
369
+    /**
370
+     * Redirect users to settings on activation.
371
+     *
372
+     * @return void
373
+     */
374
+    public function activation_redirect() {
375 375
 
376
-		$redirected = get_option( 'wpinv_redirected_to_settings' );
376
+        $redirected = get_option( 'wpinv_redirected_to_settings' );
377 377
 
378
-		if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
-			return;
380
-		}
378
+        if ( ! empty( $redirected ) || wp_doing_ajax() || ! current_user_can( 'manage_options' ) ) {
379
+            return;
380
+        }
381 381
 
382
-		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
-			return;
385
-		}
382
+        // Bail if activating from network, or bulk
383
+        if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
384
+            return;
385
+        }
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+        update_option( 'wpinv_redirected_to_settings', 1 );
388 388
 
389 389
         wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
390 390
         exit;
391 391
 
392
-	}
392
+    }
393 393
 
394 394
     /**
395 395
      * Fires an admin action after verifying that a user can fire them.
@@ -403,532 +403,532 @@  discard block
 block discarded – undo
403 403
 
404 404
     }
405 405
 
406
-	/**
406
+    /**
407 407
      * Duplicate invoice.
408
-	 * 
409
-	 * @param array $args
408
+     * 
409
+     * @param array $args
410 410
      */
411 411
     public function duplicate_invoice( $args ) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
414
-			return;
415
-		}
413
+        if ( empty( $args['invoice_id'] ) ) {
414
+            return;
415
+        }
416 416
 
417
-		$invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
417
+        $invoice = new WPInv_Invoice( (int) $args['invoice_id'] );
418 418
 
419
-		if ( ! $invoice->exists() ) {
420
-			return;
421
-		}
419
+        if ( ! $invoice->exists() ) {
420
+            return;
421
+        }
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
424
-		$new_invoice->save();
423
+        $new_invoice = getpaid_duplicate_invoice( $invoice );
424
+        $new_invoice->save();
425 425
 
426
-		if ( $new_invoice->exists() ) {
426
+        if ( $new_invoice->exists() ) {
427 427
 
428
-			getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
428
+            getpaid_admin()->show_success( __( 'Invoice duplicated successfully.', 'newsletter-optin-box' ) );
429 429
 
430
-			wp_safe_redirect(
431
-				add_query_arg(
432
-					array(
433
-						'action' => 'edit',
434
-						'post' => $new_invoice->get_id(),
435
-					),
436
-					admin_url( 'post.php' )
437
-				)
438
-			);
439
-			exit;
430
+            wp_safe_redirect(
431
+                add_query_arg(
432
+                    array(
433
+                        'action' => 'edit',
434
+                        'post' => $new_invoice->get_id(),
435
+                    ),
436
+                    admin_url( 'post.php' )
437
+                )
438
+            );
439
+            exit;
440 440
 
441
-		}
441
+        }
442 442
 
443
-		getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
443
+        getpaid_admin()->show_error( __( 'There was an error duplicating this invoice. Please try again.', 'newsletter-optin-box' ) );
444 444
 
445
-	}
445
+    }
446 446
 
447
-	/**
447
+    /**
448 448
      * Sends a payment reminder to a customer.
449
-	 * 
450
-	 * @param array $args
449
+     * 
450
+     * @param array $args
451 451
      */
452 452
     public function duplicate_payment_form( $args ) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
455
-			return;
456
-		}
457
-
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
454
+        if ( empty( $args['form_id'] ) ) {
455
+            return;
456
+        }
459 457
 
460
-		if ( ! $form->exists() ) {
461
-			return;
462
-		}
458
+        $form = new GetPaid_Payment_Form( (int) $args['form_id'] );
463 459
 
464
-		$new_form = new GetPaid_Payment_Form();
465
-		$new_form->set_author( $form->get_author( 'edit' ) );
466
-		$new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
-		$new_form->set_elements( $form->get_elements( 'edit' ) );
468
-		$new_form->set_items( $form->get_items( 'edit' ) );
469
-		$new_form->save();
460
+        if ( ! $form->exists() ) {
461
+            return;
462
+        }
470 463
 
471
-		if ( $new_form->exists() ) {
472
-			$this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
-			$url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
-		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
-		}
464
+        $new_form = new GetPaid_Payment_Form();
465
+        $new_form->set_author( $form->get_author( 'edit' ) );
466
+        $new_form->set_name( $form->get_name( 'edit' ) . __( '(copy)', 'invoicing' ) );
467
+        $new_form->set_elements( $form->get_elements( 'edit' ) );
468
+        $new_form->set_items( $form->get_items( 'edit' ) );
469
+        $new_form->save();
470
+
471
+        if ( $new_form->exists() ) {
472
+            $this->show_success( __( 'Form duplicated successfully', 'invoicing' ) );
473
+            $url = get_edit_post_link( $new_form->get_id(), 'edit' );
474
+        } else {
475
+            $this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
+            $url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
477
+        }
478 478
 
479
-		wp_redirect( $url );
480
-		exit;
481
-	}
479
+        wp_redirect( $url );
480
+        exit;
481
+    }
482 482
 
483
-	/**
483
+    /**
484 484
      * Sends a payment reminder to a customer.
485
-	 * 
486
-	 * @param array $args
485
+     * 
486
+     * @param array $args
487 487
      */
488 488
     public function send_customer_invoice( $args ) {
489
-		getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
491
-		exit;
492
-	}
489
+        getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $args['invoice_id'] ), true );
490
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
491
+        exit;
492
+    }
493 493
 
494
-	/**
494
+    /**
495 495
      * Sends a payment reminder to a customer.
496
-	 * 
497
-	 * @param array $args
496
+     * 
497
+     * @param array $args
498 498
      */
499 499
     public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
500
+        $sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
501 501
 
502
-		if ( $sent ) {
503
-			$this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
504
-		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
-		}
502
+        if ( $sent ) {
503
+            $this->show_success( __( 'Payment reminder was successfully sent to the customer', 'invoicing' ) );
504
+        } else {
505
+            $this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
506
+        }
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
-		exit;
510
-	}
508
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
509
+        exit;
510
+    }
511 511
 
512
-	/**
512
+    /**
513 513
      * Resets tax rates.
514
-	 * 
514
+     * 
515 515
      */
516 516
     public function admin_reset_tax_rates() {
517 517
 
518
-		update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
520
-		exit;
518
+        update_option( 'wpinv_tax_rates', wpinv_get_data( 'tax-rates' ) );
519
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
520
+        exit;
521 521
 
522
-	}
522
+    }
523 523
 
524
-	/**
524
+    /**
525 525
      * Resets admin pages.
526
-	 * 
526
+     * 
527 527
      */
528 528
     public function admin_create_missing_pages() {
529
-		$installer = new GetPaid_Installer();
530
-		$installer->create_pages();
531
-		$this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
533
-		exit;
534
-	}
535
-
536
-	/**
529
+        $installer = new GetPaid_Installer();
530
+        $installer->create_pages();
531
+        $this->show_success( __( 'GetPaid pages updated.', 'invoicing' ) );
532
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
533
+        exit;
534
+    }
535
+
536
+    /**
537 537
      * Creates an missing admin tables.
538
-	 * 
538
+     * 
539 539
      */
540 540
     public function admin_create_missing_tables() {
541
-		global $wpdb;
542
-		$installer = new GetPaid_Installer();
541
+        global $wpdb;
542
+        $installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
-			$installer->create_subscriptions_table();
544
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
545
+            $installer->create_subscriptions_table();
546 546
 
547
-			if ( $wpdb->last_error !== '' ) {
548
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
549
-			}
550
-		}
547
+            if ( $wpdb->last_error !== '' ) {
548
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
549
+            }
550
+        }
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
-			$installer->create_invoices_table();
552
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
553
+            $installer->create_invoices_table();
554 554
 
555
-			if ( $wpdb->last_error !== '' ) {
556
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
557
-			}
558
-		}
555
+            if ( $wpdb->last_error !== '' ) {
556
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
557
+            }
558
+        }
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
-			$installer->create_invoice_items_table();
560
+        if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
561
+            $installer->create_invoice_items_table();
562 562
 
563
-			if ( $wpdb->last_error !== '' ) {
564
-				$this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
565
-			}
566
-		}
563
+            if ( $wpdb->last_error !== '' ) {
564
+                $this->show_error( __( 'Your GetPaid tables have been updated:', 'invoicing' ) . ' ' . $wpdb->last_error );
565
+            }
566
+        }
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
570
-		}
568
+        if ( ! $this->has_notices() ) {
569
+            $this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
570
+        }
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
-		exit;
574
-	}
572
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
573
+        exit;
574
+    }
575 575
 
576
-	/**
576
+    /**
577 577
      * Migrates old invoices to the new database tables.
578
-	 * 
578
+     * 
579 579
      */
580 580
     public function admin_migrate_old_invoices() {
581 581
 
582
-		// Migrate the invoices.
583
-		$installer = new GetPaid_Installer();
584
-		$installer->migrate_old_invoices();
582
+        // Migrate the invoices.
583
+        $installer = new GetPaid_Installer();
584
+        $installer->migrate_old_invoices();
585 585
 
586
-		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
586
+        // Show an admin message.
587
+        $this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
588 588
 
589
-		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
-		exit;
589
+        // Redirect the admin.
590
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
591
+        exit;
592 592
 
593
-	}
593
+    }
594 594
 
595
-	/**
595
+    /**
596 596
      * Download customers.
597
-	 * 
597
+     * 
598 598
      */
599 599
     public function admin_download_customers() {
600
-		global $wpdb;
600
+        global $wpdb;
601 601
 
602
-		$output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
602
+        $output = fopen( 'php://output', 'w' ) or die( __( 'Unsupported server', 'invoicing' ) );
603 603
 
604
-		header( "Content-Type:text/csv" );
605
-		header( "Content-Disposition:attachment;filename=customers.csv" );
604
+        header( "Content-Type:text/csv" );
605
+        header( "Content-Disposition:attachment;filename=customers.csv" );
606 606
 
607
-		$post_types = '';
607
+        $post_types = '';
608 608
 
609
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
610
-			$post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
611
-		}
609
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
610
+            $post_types .= $wpdb->prepare( "post_type=%s OR ", $post_type );
611
+        }
612 612
 
613
-		$post_types = rtrim( $post_types, ' OR' );
613
+        $post_types = rtrim( $post_types, ' OR' );
614 614
 
615
-		$customers = $wpdb->get_col(
616
-			$wpdb->prepare(
617
-				"SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
618
-			)
619
-		);
615
+        $customers = $wpdb->get_col(
616
+            $wpdb->prepare(
617
+                "SELECT DISTINCT( post_author ) FROM $wpdb->posts WHERE $post_types"
618
+            )
619
+        );
620 620
 
621
-		$columns = array(
622
-			'name'     => __( 'Name', 'invoicing' ),
623
-			'email'    => __( 'Email', 'invoicing' ),
624
-			'country'  => __( 'Country', 'invoicing' ),
625
-			'state'    => __( 'State', 'invoicing' ),
626
-			'city'     => __( 'City', 'invoicing' ),
627
-			'zip'      => __( 'ZIP', 'invoicing' ),
628
-			'address'  => __( 'Address', 'invoicing' ),
629
-			'phone'    => __( 'Phone', 'invoicing' ),
630
-			'company'  => __( 'Company', 'invoicing' ),
631
-			'company_id'  => __( 'Company ID', 'invoicing' ),
632
-			'invoices' => __( 'Invoices', 'invoicing' ),
633
-			'total_raw' => __( 'Total Spend', 'invoicing' ),
634
-			'signup'   => __( 'Date created', 'invoicing' ),
635
-		);
621
+        $columns = array(
622
+            'name'     => __( 'Name', 'invoicing' ),
623
+            'email'    => __( 'Email', 'invoicing' ),
624
+            'country'  => __( 'Country', 'invoicing' ),
625
+            'state'    => __( 'State', 'invoicing' ),
626
+            'city'     => __( 'City', 'invoicing' ),
627
+            'zip'      => __( 'ZIP', 'invoicing' ),
628
+            'address'  => __( 'Address', 'invoicing' ),
629
+            'phone'    => __( 'Phone', 'invoicing' ),
630
+            'company'  => __( 'Company', 'invoicing' ),
631
+            'company_id'  => __( 'Company ID', 'invoicing' ),
632
+            'invoices' => __( 'Invoices', 'invoicing' ),
633
+            'total_raw' => __( 'Total Spend', 'invoicing' ),
634
+            'signup'   => __( 'Date created', 'invoicing' ),
635
+        );
636 636
 
637
-		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
637
+        // Output the csv column headers.
638
+        fputcsv( $output, array_values( $columns ) );
639 639
 
640
-		// Loop through
641
-		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
640
+        // Loop through
641
+        $table = new WPInv_Customers_Table();
642
+        foreach ( $customers as $customer_id ) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
645
-			$row  = array();
646
-			if ( empty( $user ) ) {
647
-				continue;
648
-			}
644
+            $user = get_user_by( 'id', $customer_id );
645
+            $row  = array();
646
+            if ( empty( $user ) ) {
647
+                continue;
648
+            }
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+            foreach ( array_keys( $columns ) as $column ) {
651 651
 
652
-				$method = 'column_' . $column;
652
+                $method = 'column_' . $column;
653 653
 
654
-				if ( 'name' == $column ) {
655
-					$value = esc_html( $user->display_name );
656
-				} else if( 'email' == $column ) {
657
-					$value = sanitize_email( $user->user_email );
658
-				} else if ( is_callable( array( $table, $method ) ) ) {
659
-					$value = strip_tags( $table->$method( $user ) );
660
-				}
654
+                if ( 'name' == $column ) {
655
+                    $value = esc_html( $user->display_name );
656
+                } else if( 'email' == $column ) {
657
+                    $value = sanitize_email( $user->user_email );
658
+                } else if ( is_callable( array( $table, $method ) ) ) {
659
+                    $value = strip_tags( $table->$method( $user ) );
660
+                }
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
664
-				}
662
+                if ( empty( $value ) ) {
663
+                    $value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
664
+                }
665 665
 
666
-				$row[] = $value;
666
+                $row[] = $value;
667 667
 
668
-			}
668
+            }
669 669
 
670
-			fputcsv( $output, $row );
671
-		}
670
+            fputcsv( $output, $row );
671
+        }
672 672
 
673
-		fclose( $output );
674
-		exit;
673
+        fclose( $output );
674
+        exit;
675 675
 
676
-	}
676
+    }
677 677
 
678
-	/**
678
+    /**
679 679
      * Installs a plugin.
680
-	 *
681
-	 * @param array $data
680
+     *
681
+     * @param array $data
682 682
      */
683 683
     public function admin_install_plugin( $data ) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
686
-			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687
-			wp_cache_flush();
685
+        if ( ! empty( $data['plugins'] ) ) {
686
+            include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687
+            wp_cache_flush();
688 688
 
689
-			foreach ( $data['plugins'] as $slug => $file ) {
690
-				$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
-				$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
-				$installed  = $upgrader->install( $plugin_zip );
689
+            foreach ( $data['plugins'] as $slug => $file ) {
690
+                $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/' . $slug . '.latest-stable.zip' );
691
+                $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
692
+                $installed  = $upgrader->install( $plugin_zip );
693 693
 
694
-				if ( ! is_wp_error( $installed ) && $installed ) {
695
-					activate_plugin( $file, '', false, true );
696
-				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
-				}
694
+                if ( ! is_wp_error( $installed ) && $installed ) {
695
+                    activate_plugin( $file, '', false, true );
696
+                } else {
697
+                    wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
698
+                }
699 699
 
700
-			}
700
+            }
701 701
 
702
-		}
702
+        }
703 703
 
704
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
705
-		wp_safe_redirect( $redirect );
706
-		exit;
704
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( $data['redirect'] ) : admin_url( 'plugins.php' );
705
+        wp_safe_redirect( $redirect );
706
+        exit;
707 707
 
708
-	}
708
+    }
709 709
 
710
-	/**
710
+    /**
711 711
      * Connects a gateway.
712
-	 *
713
-	 * @param array $data
712
+     *
713
+     * @param array $data
714 714
      */
715 715
     public function admin_connect_gateway( $data ) {
716 716
 
717
-		if ( ! empty( $data['plugin'] ) ) {
717
+        if ( ! empty( $data['plugin'] ) ) {
718 718
 
719
-			$gateway     = sanitize_key( $data['plugin'] );
720
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
719
+            $gateway     = sanitize_key( $data['plugin'] );
720
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
721 721
 
722
-			if ( ! empty( $connect_url ) ) {
723
-				wp_redirect( $connect_url );
724
-				exit;
725
-			}
722
+            if ( ! empty( $connect_url ) ) {
723
+                wp_redirect( $connect_url );
724
+                exit;
725
+            }
726 726
 
727
-			if ( 'stripe' == $data['plugin'] ) {
728
-				require_once ABSPATH . 'wp-admin/includes/plugin.php';
729
-				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
730
-				wp_cache_flush();
727
+            if ( 'stripe' == $data['plugin'] ) {
728
+                require_once ABSPATH . 'wp-admin/includes/plugin.php';
729
+                include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
730
+                wp_cache_flush();
731 731
 
732
-				if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
733
-					$plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
734
-					$upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
735
-					$upgrader->install( $plugin_zip );
736
-				}
732
+                if ( ! array_key_exists( 'getpaid-stripe-payments/getpaid-stripe-payments.php', get_plugins() ) ) {
733
+                    $plugin_zip = esc_url( 'https://downloads.wordpress.org/plugin/getpaid-stripe-payments.latest-stable.zip' );
734
+                    $upgrader   = new Plugin_Upgrader( new Automatic_Upgrader_Skin() );
735
+                    $upgrader->install( $plugin_zip );
736
+                }
737 737
 
738
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
739
-			}
738
+                activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
739
+            }
740 740
 
741
-			$connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
742
-			if ( ! empty( $connect_url ) ) {
743
-				wp_redirect( $connect_url );
744
-				exit;
745
-			}
741
+            $connect_url = apply_filters( "getpaid_get_{$gateway}_connect_url", false, $data );
742
+            if ( ! empty( $connect_url ) ) {
743
+                wp_redirect( $connect_url );
744
+                exit;
745
+            }
746 746
 
747
-		}
747
+        }
748 748
 
749
-		$redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
750
-		wp_safe_redirect( $redirect );
751
-		exit;
749
+        $redirect = isset( $data['redirect'] ) ? esc_url_raw( urldecode( $data['redirect'] ) ) : admin_url( 'admin.php?page=wpinv-settings&tab=gateways' );
750
+        wp_safe_redirect( $redirect );
751
+        exit;
752 752
 
753
-	}
753
+    }
754 754
 
755
-	/**
755
+    /**
756 756
      * Recalculates discounts.
757
-	 * 
757
+     * 
758 758
      */
759 759
     public function admin_recalculate_discounts() {
760
-		global $wpdb;
760
+        global $wpdb;
761 761
 
762
-		// Fetch all invoices that have discount codes.
763
-		$table    = $wpdb->prefix . 'getpaid_invoices';
764
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
762
+        // Fetch all invoices that have discount codes.
763
+        $table    = $wpdb->prefix . 'getpaid_invoices';
764
+        $invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
765 765
 
766
-		foreach ( $invoices as $invoice ) {
766
+        foreach ( $invoices as $invoice ) {
767 767
 
768
-			$invoice = new WPInv_Invoice( $invoice );
768
+            $invoice = new WPInv_Invoice( $invoice );
769 769
 
770
-			if ( ! $invoice->exists() ) {
771
-				continue;
772
-			}
770
+            if ( ! $invoice->exists() ) {
771
+                continue;
772
+            }
773 773
 
774
-			// Abort if the discount does not exist or does not apply here.
775
-			$discount = new WPInv_Discount( $invoice->get_discount_code() );
776
-			if ( ! $discount->exists() ) {
777
-				continue;
778
-			}
774
+            // Abort if the discount does not exist or does not apply here.
775
+            $discount = new WPInv_Discount( $invoice->get_discount_code() );
776
+            if ( ! $discount->exists() ) {
777
+                continue;
778
+            }
779 779
 
780
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
781
-			$invoice->recalculate_total();
780
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
781
+            $invoice->recalculate_total();
782 782
 
783
-			if ( $invoice->get_total_discount() > 0 ) {
784
-				$invoice->save();
785
-			}
783
+            if ( $invoice->get_total_discount() > 0 ) {
784
+                $invoice->save();
785
+            }
786 786
 
787
-		}
787
+        }
788 788
 
789
-		// Show an admin message.
790
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
789
+        // Show an admin message.
790
+        $this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
791 791
 
792
-		// Redirect the admin.
793
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
794
-		exit;
792
+        // Redirect the admin.
793
+        wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
794
+        exit;
795 795
 
796
-	}
796
+    }
797 797
 
798 798
     /**
799
-	 * Returns an array of admin notices.
800
-	 *
801
-	 * @since       1.0.19
799
+     * Returns an array of admin notices.
800
+     *
801
+     * @since       1.0.19
802 802
      * @return array
803
-	 */
804
-	public function get_notices() {
805
-		$notices = get_option( 'wpinv_admin_notices' );
803
+     */
804
+    public function get_notices() {
805
+        $notices = get_option( 'wpinv_admin_notices' );
806 806
         return is_array( $notices ) ? $notices : array();
807
-	}
807
+    }
808 808
 
809
-	/**
810
-	 * Checks if we have any admin notices.
811
-	 *
812
-	 * @since       2.0.4
809
+    /**
810
+     * Checks if we have any admin notices.
811
+     *
812
+     * @since       2.0.4
813 813
      * @return array
814
-	 */
815
-	public function has_notices() {
816
-		return count( $this->get_notices() ) > 0;
817
-	}
818
-
819
-	/**
820
-	 * Clears all admin notices
821
-	 *
822
-	 * @access      public
823
-	 * @since       1.0.19
824
-	 */
825
-	public function clear_notices() {
826
-		delete_option( 'wpinv_admin_notices' );
827
-	}
828
-
829
-	/**
830
-	 * Saves a new admin notice
831
-	 *
832
-	 * @access      public
833
-	 * @since       1.0.19
834
-	 */
835
-	public function save_notice( $type, $message ) {
836
-		$notices = $this->get_notices();
837
-
838
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
839
-			$notices[ $type ] = array();
840
-		}
841
-
842
-		$notices[ $type ][] = $message;
843
-
844
-		update_option( 'wpinv_admin_notices', $notices );
845
-	}
846
-
847
-	/**
848
-	 * Displays a success notice
849
-	 *
850
-	 * @param       string $msg The message to qeue.
851
-	 * @access      public
852
-	 * @since       1.0.19
853
-	 */
854
-	public function show_success( $msg ) {
855
-		$this->save_notice( 'success', $msg );
856
-	}
857
-
858
-	/**
859
-	 * Displays a error notice
860
-	 *
861
-	 * @access      public
862
-	 * @param       string $msg The message to qeue.
863
-	 * @since       1.0.19
864
-	 */
865
-	public function show_error( $msg ) {
866
-		$this->save_notice( 'error', $msg );
867
-	}
868
-
869
-	/**
870
-	 * Displays a warning notice
871
-	 *
872
-	 * @access      public
873
-	 * @param       string $msg The message to qeue.
874
-	 * @since       1.0.19
875
-	 */
876
-	public function show_warning( $msg ) {
877
-		$this->save_notice( 'warning', $msg );
878
-	}
879
-
880
-	/**
881
-	 * Displays a info notice
882
-	 *
883
-	 * @access      public
884
-	 * @param       string $msg The message to qeue.
885
-	 * @since       1.0.19
886
-	 */
887
-	public function show_info( $msg ) {
888
-		$this->save_notice( 'info', $msg );
889
-	}
890
-
891
-	/**
892
-	 * Show notices
893
-	 *
894
-	 * @access      public
895
-	 * @since       1.0.19
896
-	 */
897
-	public function show_notices() {
814
+     */
815
+    public function has_notices() {
816
+        return count( $this->get_notices() ) > 0;
817
+    }
818
+
819
+    /**
820
+     * Clears all admin notices
821
+     *
822
+     * @access      public
823
+     * @since       1.0.19
824
+     */
825
+    public function clear_notices() {
826
+        delete_option( 'wpinv_admin_notices' );
827
+    }
828
+
829
+    /**
830
+     * Saves a new admin notice
831
+     *
832
+     * @access      public
833
+     * @since       1.0.19
834
+     */
835
+    public function save_notice( $type, $message ) {
836
+        $notices = $this->get_notices();
837
+
838
+        if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
839
+            $notices[ $type ] = array();
840
+        }
841
+
842
+        $notices[ $type ][] = $message;
843
+
844
+        update_option( 'wpinv_admin_notices', $notices );
845
+    }
846
+
847
+    /**
848
+     * Displays a success notice
849
+     *
850
+     * @param       string $msg The message to qeue.
851
+     * @access      public
852
+     * @since       1.0.19
853
+     */
854
+    public function show_success( $msg ) {
855
+        $this->save_notice( 'success', $msg );
856
+    }
857
+
858
+    /**
859
+     * Displays a error notice
860
+     *
861
+     * @access      public
862
+     * @param       string $msg The message to qeue.
863
+     * @since       1.0.19
864
+     */
865
+    public function show_error( $msg ) {
866
+        $this->save_notice( 'error', $msg );
867
+    }
868
+
869
+    /**
870
+     * Displays a warning notice
871
+     *
872
+     * @access      public
873
+     * @param       string $msg The message to qeue.
874
+     * @since       1.0.19
875
+     */
876
+    public function show_warning( $msg ) {
877
+        $this->save_notice( 'warning', $msg );
878
+    }
879
+
880
+    /**
881
+     * Displays a info notice
882
+     *
883
+     * @access      public
884
+     * @param       string $msg The message to qeue.
885
+     * @since       1.0.19
886
+     */
887
+    public function show_info( $msg ) {
888
+        $this->save_notice( 'info', $msg );
889
+    }
890
+
891
+    /**
892
+     * Show notices
893
+     *
894
+     * @access      public
895
+     * @since       1.0.19
896
+     */
897
+    public function show_notices() {
898 898
 
899 899
         $notices = $this->get_notices();
900 900
         $this->clear_notices();
901 901
 
902
-		foreach ( $notices as $type => $messages ) {
902
+        foreach ( $notices as $type => $messages ) {
903 903
 
904
-			if ( ! is_array( $messages ) ) {
905
-				continue;
906
-			}
904
+            if ( ! is_array( $messages ) ) {
905
+                continue;
906
+            }
907 907
 
908 908
             $type  = sanitize_key( $type );
909
-			foreach ( $messages as $message ) {
909
+            foreach ( $messages as $message ) {
910 910
                 $message = wp_kses_post( $message );
911
-				echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
911
+                echo "<div class='notice notice-$type is-dismissible'><p>$message</p></div>";
912 912
             }
913 913
 
914 914
         }
915 915
 
916
-		foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
917
-
918
-			if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
919
-				$url     = wp_nonce_url(
920
-					add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
921
-					'getpaid-nonce',
922
-					'getpaid-nonce'
923
-				);
924
-				$message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
925
-				$message2 = __( 'Generate Pages', 'invoicing' );
926
-				echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
927
-				break;
928
-			}
916
+        foreach ( array( 'checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page' ) as $page ) {
917
+
918
+            if ( ! is_numeric( wpinv_get_option( $page, false ) ) ) {
919
+                $url     = wp_nonce_url(
920
+                    add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
921
+                    'getpaid-nonce',
922
+                    'getpaid-nonce'
923
+                );
924
+                $message  = __( 'Some GetPaid pages are missing. To use GetPaid without any issues, click the button below to generate the missing pages.', 'invoicing' );
925
+                $message2 = __( 'Generate Pages', 'invoicing' );
926
+                echo "<div class='notice notice-warning is-dismissible'><p>$message<br><br><a href='$url' class='button button-primary'>$message2</a></p></div>";
927
+                break;
928
+            }
929 929
 
930
-		}
930
+        }
931 931
 
932
-	}
932
+    }
933 933
 
934 934
 }
Please login to merge, or discard this patch.