Passed
Push — master ( 0a8090...894ff0 )
by Brian
04:47
created
includes/admin/class-getpaid-post-types-admin.php 2 patches
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.
Spacing   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,74 +21,74 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 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 );
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 29
 
30 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 );
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 35
 
36 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 );
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 43
 
44 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 );
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 48
 
49 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 );
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 52
 
53 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 );
54
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
55
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
56 56
 
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
57
+		add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Post updated messages.
62 62
 	 */
63
-	public static function post_updated_messages( $messages ) {
63
+	public static function post_updated_messages($messages) {
64 64
 		global $post;
65 65
 
66 66
 		$messages['wpi_discount'] = array(
67 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' ),
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 78
 		);
79 79
 
80 80
 		$messages['wpi_payment_form'] = array(
81 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' ),
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 92
 		);
93 93
 
94 94
 		return $messages;
@@ -98,19 +98,19 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Post row actions.
100 100
 	 */
101
-	public static function post_row_actions( $actions, $post ) {
101
+	public static function post_row_actions($actions, $post) {
102 102
 
103
-		$post = get_post( $post );
103
+		$post = get_post($post);
104 104
 
105 105
 		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
106
+		if ('wpi_payment_form' == $post->post_type) {
107 107
 
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
108
+			if ($post->ID == wpinv_get_default_payment_form()) {
109
+				unset($actions['trash']);
110
+				unset($actions['inline hide-if-no-js']);
111 111
 			}
112 112
 
113
-			$actions['duplicate'] =  sprintf(
113
+			$actions['duplicate'] = sprintf(
114 114
 				'<a href="%1$s">%2$s</a>',
115 115
 				esc_url(
116 116
 					wp_nonce_url(
@@ -124,20 +124,20 @@  discard block
 block discarded – undo
124 124
 						'getpaid-nonce'
125 125
 					)
126 126
 				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
127
+				esc_html(__('Duplicate', 'invoicing'))
128 128
 			);
129 129
 
130 130
 		}
131 131
 
132 132
 		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
133
+		if ('wpi_item' == $post->post_type) {
134 134
 
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
135
+			if (in_array(get_post_meta($post->ID, '_wpinv_type', true), array('', 'fee', 'custom'))) {
136 136
 
137
-				$actions['buy'] =  sprintf(
137
+				$actions['buy'] = sprintf(
138 138
 					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
139
+					esc_url(getpaid_embed_url(false, $post->ID . '|0')),
140
+					esc_html(__('Buy', 'invoicing'))
141 141
 				);
142 142
 
143 143
 			}
@@ -155,31 +155,31 @@  discard block
 block discarded – undo
155 155
 	 * @param WP_Post $post
156 156
      * @return array $actions actions without edit option
157 157
      */
158
-    public static function filter_invoice_row_actions( $actions, $post ) {
158
+    public static function filter_invoice_row_actions($actions, $post) {
159 159
 
160
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160
+        if (getpaid_is_invoice_post_type($post->post_type)) {
161 161
 
162 162
 			$actions = array();
163
-			$invoice = new WPInv_Invoice( $post );
163
+			$invoice = new WPInv_Invoice($post);
164 164
 
165
-			$actions['edit'] =  sprintf(
165
+			$actions['edit'] = sprintf(
166 166
 				'<a href="%1$s">%2$s</a>',
167
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
168
-				esc_html( __( 'Edit', 'invoicing' ) )
167
+				esc_url(get_edit_post_link($invoice->get_id())),
168
+				esc_html(__('Edit', 'invoicing'))
169 169
 			);
170 170
 
171
-			if ( ! $invoice->is_draft() ) {
171
+			if (!$invoice->is_draft()) {
172 172
 
173
-				$actions['view'] =  sprintf(
173
+				$actions['view'] = sprintf(
174 174
 					'<a href="%1$s">%2$s</a>',
175
-					esc_url( $invoice->get_view_url() ),
175
+					esc_url($invoice->get_view_url()),
176 176
 					sprintf(
177
-						esc_html( __( 'View %s', 'invoicing' ) ),
178
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
177
+						esc_html(__('View %s', 'invoicing')),
178
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
179 179
 					)
180 180
 				);
181 181
 
182
-				$actions['send'] =  sprintf(
182
+				$actions['send'] = sprintf(
183 183
 					'<a href="%1$s">%2$s</a>',
184 184
 					esc_url(
185 185
 						wp_nonce_url(
@@ -193,12 +193,12 @@  discard block
 block discarded – undo
193 193
 							'getpaid-nonce'
194 194
 						)
195 195
 					),
196
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+					esc_html(__('Send to Customer', 'invoicing'))
197 197
 				);
198 198
 
199 199
 			}
200 200
 
201
-			$actions['duplicate'] =  sprintf(
201
+			$actions['duplicate'] = sprintf(
202 202
 				'<a href="%1$s">%2$s</a>',
203 203
 				esc_url(
204 204
 					wp_nonce_url(
@@ -212,7 +212,7 @@  discard block
 block discarded – undo
212 212
 						'getpaid-nonce'
213 213
 					)
214 214
 				),
215
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
+				esc_html(__('Duplicate', 'invoicing'))
216 216
 			);
217 217
 
218 218
         }
@@ -223,42 +223,42 @@  discard block
 block discarded – undo
223 223
 	/**
224 224
 	 * Returns an array of invoice table columns.
225 225
 	 */
226
-	public static function invoice_columns( $columns ) {
226
+	public static function invoice_columns($columns) {
227 227
 
228 228
 		$columns = array(
229 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' ),
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 237
 		);
238 238
 
239
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+		return apply_filters('wpi_invoice_table_columns', $columns);
240 240
 	}
241 241
 
242 242
 	/**
243 243
 	 * Displays invoice table columns.
244 244
 	 */
245
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
+	public static function display_invoice_columns($column_name, $post_id) {
246 246
 
247
-		$invoice = new WPInv_Invoice( $post_id );
247
+		$invoice = new WPInv_Invoice($post_id);
248 248
 
249
-		switch ( $column_name ) {
249
+		switch ($column_name) {
250 250
 
251 251
 			case 'invoice_date' :
252
-				$date_time = esc_attr( $invoice->get_created_date() );
253
-				$date      = getpaid_format_date_value( $date_time, "&mdash;", true );
252
+				$date_time = esc_attr($invoice->get_created_date());
253
+				$date      = getpaid_format_date_value($date_time, "&mdash;", true);
254 254
 				echo "<span title='$date_time'>$date</span>";
255 255
 				break;
256 256
 
257 257
 			case 'payment_date' :
258 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 );
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 262
 					echo "<span title='$date_time'>$date</span>";
263 263
 				} else {
264 264
 					echo "&mdash;";
@@ -269,17 +269,17 @@  discard block
 block discarded – undo
269 269
 			case 'amount' :
270 270
 
271 271
 				$amount = $invoice->get_total();
272
-				$formated_amount = wpinv_price( $amount, $invoice->get_currency() );
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() );
274
+				if ($invoice->is_refunded()) {
275
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
276 276
 					echo "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>";
277 277
 				} else {
278 278
 
279 279
 					$discount = $invoice->get_total_discount();
280 280
 
281
-					if ( ! empty( $discount ) ) {
282
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
281
+					if (!empty($discount)) {
282
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
283 283
 						echo "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>";
284 284
 					} else {
285 285
 						echo $formated_amount;
@@ -290,13 +290,13 @@  discard block
 block discarded – undo
290 290
 				break;
291 291
 
292 292
 			case 'status' :
293
-				$status       = esc_html( $invoice->get_status() );
294
-				$status_label = esc_html( $invoice->get_status_nicename() );
293
+				$status       = esc_html($invoice->get_status());
294
+				$status_label = esc_html($invoice->get_status_nicename());
295 295
 
296 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 );
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 301
 					echo "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>";
302 302
 				} else {
@@ -304,22 +304,22 @@  discard block
 block discarded – undo
304 304
 				}
305 305
 
306 306
 				// If it is not paid, display the overdue and view status.
307
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
307
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
308 308
 
309 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>';
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 312
 					} else {
313
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="'. esc_attr__( 'Not Viewed by Customer', 'invoicing' ).'"></i>';
313
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
314 314
 					}
315 315
 
316 316
 					// Display the overview status.
317
-					if ( wpinv_get_option( 'overdue_active' ) ) {
317
+					if (wpinv_get_option('overdue_active')) {
318 318
 						$due_date = $invoice->get_due_date();
319
-						$fomatted = getpaid_format_date( $due_date );
319
+						$fomatted = getpaid_format_date($due_date);
320 320
 
321
-						if ( ! empty( $fomatted ) ) {
322
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
321
+						if (!empty($fomatted)) {
322
+							$date = wp_sprintf(__('Due %s', 'invoicing'), $fomatted);
323 323
 							echo "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>";
324 324
 						}
325 325
 					}
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 
331 331
 			case 'recurring':
332 332
 
333
-				if ( $invoice->is_recurring() ) {
333
+				if ($invoice->is_recurring()) {
334 334
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
335 335
 				} else {
336 336
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 
340 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 346
 				echo "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>";
347 347
 
@@ -351,13 +351,13 @@  discard block
 block discarded – undo
351 351
 	
352 352
 				$customer_name = $invoice->get_user_full_name();
353 353
 	
354
-				if ( empty( $customer_name ) ) {
354
+				if (empty($customer_name)) {
355 355
 					$customer_name = $invoice->get_email();
356 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' ) ) );
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 361
 					echo "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>";
362 362
 				} else {
363 363
 					echo '<div>&mdash;</div>';
@@ -372,19 +372,19 @@  discard block
 block discarded – undo
372 372
 	/**
373 373
 	 * Displays invoice bulk actions.
374 374
 	 */
375
-	public static function invoice_bulk_actions( $actions ) {
376
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
375
+	public static function invoice_bulk_actions($actions) {
376
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
377 377
 		return $actions;
378 378
 	}
379 379
 
380 380
 	/**
381 381
 	 * Processes invoice bulk actions.
382 382
 	 */
383
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
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 );
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 388
 			}
389 389
 		}
390 390
 
@@ -395,50 +395,50 @@  discard block
 block discarded – undo
395 395
 	/**
396 396
 	 * Returns an array of payment forms table columns.
397 397
 	 */
398
-	public static function payment_form_columns( $columns ) {
398
+	public static function payment_form_columns($columns) {
399 399
 
400 400
 		$columns = array(
401 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' ),
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 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 414
 	/**
415 415
 	 * Displays payment form table columns.
416 416
 	 */
417
-	public static function display_payment_form_columns( $column_name, $post_id ) {
417
+	public static function display_payment_form_columns($column_name, $post_id) {
418 418
 
419 419
 		// Retrieve the payment form.
420
-		$form = new GetPaid_Payment_Form( $post_id );
420
+		$form = new GetPaid_Payment_Form($post_id);
421 421
 
422
-		switch ( $column_name ) {
422
+		switch ($column_name) {
423 423
 
424 424
 			case 'earnings' :
425
-				echo wpinv_price( $form->get_earned() );
425
+				echo wpinv_price($form->get_earned());
426 426
 				break;
427 427
 
428 428
 			case 'refunds' :
429
-				echo wpinv_price( $form->get_refunded() );
429
+				echo wpinv_price($form->get_refunded());
430 430
 				break;
431 431
 
432 432
 			case 'refunds' :
433
-				echo wpinv_price( $form->get_refunded() );
433
+				echo wpinv_price($form->get_refunded());
434 434
 				break;
435 435
 
436 436
 			case 'shortcode' :
437 437
 
438
-				if ( $form->is_default() ) {
438
+				if ($form->is_default()) {
439 439
 					echo '&mdash;';
440 440
 				} else {
441
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
441
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
442 442
 				}
443 443
 
444 444
 				break;
@@ -447,29 +447,29 @@  discard block
 block discarded – undo
447 447
 
448 448
 				$items = $form->get_items();
449 449
 
450
-				if ( $form->is_default() || empty( $items ) ) {
450
+				if ($form->is_default() || empty($items)) {
451 451
 					echo '&mdash;';
452 452
 					return;
453 453
 				}
454 454
 
455 455
 				$_items = array();
456 456
 
457
-				foreach ( $items as $item ) {
457
+				foreach ($items as $item) {
458 458
 					$url = $item->get_edit_url();
459 459
 
460
-					if ( empty( $url ) ) {
461
-						$_items[] = esc_html( $item->get_name() );
460
+					if (empty($url)) {
461
+						$_items[] = esc_html($item->get_name());
462 462
 					} else {
463 463
 						$_items[] = sprintf(
464 464
 							'<a href="%s">%s</a>',
465
-							esc_url( $url ),
466
-							esc_html( $item->get_name() )
465
+							esc_url($url),
466
+							esc_html($item->get_name())
467 467
 						);
468 468
 					}
469 469
 
470 470
 				}
471 471
 
472
-				echo implode( '<br>', $_items );
472
+				echo implode('<br>', $_items);
473 473
 
474 474
 				break;
475 475
 
@@ -480,10 +480,10 @@  discard block
 block discarded – undo
480 480
 	/**
481 481
 	 * Filters post states.
482 482
 	 */
483
-	public static function filter_payment_form_state( $post_states, $post ) {
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' );
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 487
 		}
488 488
 	
489 489
 		return $post_states;
@@ -493,35 +493,35 @@  discard block
 block discarded – undo
493 493
 	/**
494 494
 	 * Returns an array of coupon table columns.
495 495
 	 */
496
-	public static function discount_columns( $columns ) {
496
+	public static function discount_columns($columns) {
497 497
 
498 498
 		$columns = array(
499 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' ),
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 506
 		);
507 507
 
508
-		return apply_filters( 'wpi_discount_table_columns', $columns );
508
+		return apply_filters('wpi_discount_table_columns', $columns);
509 509
 	}
510 510
 
511 511
 	/**
512 512
 	 * Filters post states.
513 513
 	 */
514
-	public static function filter_discount_state( $post_states, $post ) {
514
+	public static function filter_discount_state($post_states, $post) {
515 515
 
516
-		if ( 'wpi_discount' == $post->post_type ) {
516
+		if ('wpi_discount' == $post->post_type) {
517 517
 
518
-			$discount = new WPInv_Discount( $post );
518
+			$discount = new WPInv_Discount($post);
519 519
 
520 520
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
521 521
 
522
-			if ( $status != 'publish' ) {
522
+			if ($status != 'publish') {
523 523
 				return array(
524
-					'discount_status' => wpinv_discount_status( $status ),
524
+					'discount_status' => wpinv_discount_status($status),
525 525
 				);
526 526
 			}
527 527
 
@@ -536,30 +536,30 @@  discard block
 block discarded – undo
536 536
 	/**
537 537
 	 * Returns an array of items table columns.
538 538
 	 */
539
-	public static function item_columns( $columns ) {
539
+	public static function item_columns($columns) {
540 540
 
541 541
 		$columns = array(
542 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' ),
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 549
 		);
550 550
 
551
-		if ( ! wpinv_use_taxes() ) {
552
-			unset( $columns['vat_rule'] );
553
-			unset( $columns['vat_class'] );
551
+		if (!wpinv_use_taxes()) {
552
+			unset($columns['vat_rule']);
553
+			unset($columns['vat_class']);
554 554
 		}
555 555
 
556
-		return apply_filters( 'wpi_item_table_columns', $columns );
556
+		return apply_filters('wpi_item_table_columns', $columns);
557 557
 	}
558 558
 
559 559
 	/**
560 560
 	 * Returns an array of sortable items table columns.
561 561
 	 */
562
-	public static function sortable_item_columns( $columns ) {
562
+	public static function sortable_item_columns($columns) {
563 563
 
564 564
 		return array_merge(
565 565
 			$columns,
@@ -576,47 +576,47 @@  discard block
 block discarded – undo
576 576
 	/**
577 577
 	 * Displays items table columns.
578 578
 	 */
579
-	public static function display_item_columns( $column_name, $post_id ) {
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 585
 			case 'price' :
586 586
 
587
-				if ( ! $item->is_recurring() ) {
587
+				if (!$item->is_recurring()) {
588 588
 					echo $item->get_the_price();
589 589
 					break;
590 590
 				}
591 591
 
592 592
 				$price = wp_sprintf(
593
-					__( '%s / %s', 'invoicing' ),
593
+					__('%s / %s', 'invoicing'),
594 594
 					$item->get_the_price(),
595
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
595
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
596 596
 				);
597 597
 
598
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
598
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
599 599
 					echo $price;
600 600
 					break;
601 601
 				}
602 602
 
603 603
 				echo $item->get_the_initial_price();
604 604
 
605
-				echo '<span class="meta">' . wp_sprintf( __( 'then %s', 'invoicing' ), $price )  .'</span>';
605
+				echo '<span class="meta">' . wp_sprintf(__('then %s', 'invoicing'), $price) . '</span>';
606 606
 				break;
607 607
 
608 608
 			case 'vat_rule' :
609
-				echo getpaid_get_tax_rule_label( $item->get_vat_rule() );
609
+				echo getpaid_get_tax_rule_label($item->get_vat_rule());
610 610
 				break;
611 611
 
612 612
 			case 'vat_class' :
613
-				echo getpaid_get_tax_class_label( $item->get_vat_class() );
613
+				echo getpaid_get_tax_class_label($item->get_vat_class());
614 614
 				break;
615 615
 
616 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/>';
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 620
 				} else {
621 621
 					echo "&mdash;";
622 622
 				}
@@ -624,7 +624,7 @@  discard block
 block discarded – undo
624 624
 				break;
625 625
 
626 626
 			case 'type' :
627
-				echo wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
627
+				echo wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>';
628 628
 				break;
629 629
 
630 630
 		}
@@ -634,21 +634,21 @@  discard block
 block discarded – undo
634 634
 	/**
635 635
 	 * Lets users filter items using taxes.
636 636
 	 */
637
-	public static function add_item_filters( $post_type ) {
637
+	public static function add_item_filters($post_type) {
638 638
 
639 639
 		// Abort if we're not dealing with items.
640
-		if ( $post_type != 'wpi_item' ) {
640
+		if ($post_type != 'wpi_item') {
641 641
 			return;
642 642
 		}
643 643
 
644 644
 		// Filter by vat rules.
645
-		if ( wpinv_use_taxes() ) {
645
+		if (wpinv_use_taxes()) {
646 646
 	
647 647
 			// Sanitize selected vat rule.
648 648
 			$vat_rule   = '';
649 649
 			$vat_rules  = getpaid_get_tax_rules();
650
-			if ( isset( $_GET['vat_rule'] ) ) {
651
-				$vat_rule   =  $_GET['vat_rule'];
650
+			if (isset($_GET['vat_rule'])) {
651
+				$vat_rule = $_GET['vat_rule'];
652 652
 			}
653 653
 
654 654
 			// Filter by VAT rule.
@@ -656,13 +656,13 @@  discard block
 block discarded – undo
656 656
 				array(
657 657
 					'options'          => array_merge(
658 658
 						array(
659
-							'' => __( 'All VAT rules', 'invoicing' )
659
+							'' => __('All VAT rules', 'invoicing')
660 660
 						),
661 661
 						$vat_rules
662 662
 					),
663 663
 					'name'             => 'vat_rule',
664 664
 					'id'               => 'vat_rule',
665
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
665
+					'selected'         => in_array($vat_rule, array_keys($vat_rules)) ? $vat_rule : '',
666 666
 					'show_option_all'  => false,
667 667
 					'show_option_none' => false,
668 668
 				)
@@ -673,21 +673,21 @@  discard block
 block discarded – undo
673 673
 			// Sanitize selected vat rule.
674 674
 			$vat_class   = '';
675 675
 			$vat_classes = getpaid_get_tax_classes();
676
-			if ( isset( $_GET['vat_class'] ) ) {
677
-				$vat_class   =  $_GET['vat_class'];
676
+			if (isset($_GET['vat_class'])) {
677
+				$vat_class = $_GET['vat_class'];
678 678
 			}
679 679
 
680 680
 			echo wpinv_html_select(
681 681
 				array(
682 682
 					'options'          => array_merge(
683 683
 						array(
684
-							'' => __( 'All VAT classes', 'invoicing' )
684
+							'' => __('All VAT classes', 'invoicing')
685 685
 						),
686 686
 						$vat_classes
687 687
 					),
688 688
 					'name'             => 'vat_class',
689 689
 					'id'               => 'vat_class',
690
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
690
+					'selected'         => in_array($vat_class, array_keys($vat_classes)) ? $vat_class : '',
691 691
 					'show_option_all'  => false,
692 692
 					'show_option_none' => false,
693 693
 				)
@@ -696,22 +696,22 @@  discard block
 block discarded – undo
696 696
 		}
697 697
 
698 698
 		// Filter by item type.
699
-		$type   = '';
700
-		if ( isset( $_GET['type'] ) ) {
701
-			$type   =  $_GET['type'];
699
+		$type = '';
700
+		if (isset($_GET['type'])) {
701
+			$type = $_GET['type'];
702 702
 		}
703 703
 
704 704
 		echo wpinv_html_select(
705 705
 			array(
706 706
 				'options'          => array_merge(
707 707
 					array(
708
-						'' => __( 'All item types', 'invoicing' )
708
+						'' => __('All item types', 'invoicing')
709 709
 					),
710 710
 					wpinv_get_item_types()
711 711
 				),
712 712
 				'name'             => 'type',
713 713
 				'id'               => 'type',
714
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
714
+				'selected'         => in_array($type, wpinv_item_types()) ? $type : '',
715 715
 				'show_option_all'  => false,
716 716
 				'show_option_none' => false,
717 717
 			)
@@ -722,45 +722,45 @@  discard block
 block discarded – undo
722 722
 	/**
723 723
 	 * Filters the item query.
724 724
 	 */
725
-	public static function filter_item_query( $query ) {
725
+	public static function filter_item_query($query) {
726 726
 
727 727
 		// modify the query only if it admin and main query.
728
-		if ( ! ( is_admin() && $query->is_main_query() ) ){ 
728
+		if (!(is_admin() && $query->is_main_query())) { 
729 729
 			return $query;
730 730
 		}
731 731
 
732 732
 		// we want to modify the query for our items.
733
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ){
733
+		if (empty($query->query['post_type']) || 'wpi_item' != $query->query['post_type']) {
734 734
 			return $query;
735 735
 		}
736 736
 
737
-		if ( empty( $query->query_vars['meta_query'] ) ) {
737
+		if (empty($query->query_vars['meta_query'])) {
738 738
 			$query->query_vars['meta_query'] = array();
739 739
 		}
740 740
 
741 741
 		// Filter vat rule type
742
-        if ( ! empty( $_GET['vat_rule'] ) ) {
742
+        if (!empty($_GET['vat_rule'])) {
743 743
             $query->query_vars['meta_query'][] = array(
744 744
                 'key'     => '_wpinv_vat_rule',
745
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ),
745
+                'value'   => sanitize_text_field($_GET['vat_rule']),
746 746
                 'compare' => '='
747 747
             );
748 748
         }
749 749
 
750 750
         // Filter vat class
751
-        if ( ! empty( $_GET['vat_class'] ) ) {
751
+        if (!empty($_GET['vat_class'])) {
752 752
             $query->query_vars['meta_query'][] = array(
753 753
                 'key'     => '_wpinv_vat_class',
754
-                'value'   => sanitize_text_field( $_GET['vat_class'] ),
754
+                'value'   => sanitize_text_field($_GET['vat_class']),
755 755
                 'compare' => '='
756 756
             );
757 757
         }
758 758
 
759 759
         // Filter item type
760
-        if ( ! empty( $_GET['type'] ) ) {
760
+        if (!empty($_GET['type'])) {
761 761
             $query->query_vars['meta_query'][] = array(
762 762
                 'key'     => '_wpinv_type',
763
-                'value'   => sanitize_text_field( $_GET['type'] ),
763
+                'value'   => sanitize_text_field($_GET['type']),
764 764
                 'compare' => '='
765 765
             );
766 766
 		}
@@ -770,15 +770,15 @@  discard block
 block discarded – undo
770 770
 	/**
771 771
 	 * Reorders items.
772 772
 	 */
773
-	public static function reorder_items( $vars ) {
773
+	public static function reorder_items($vars) {
774 774
 		global $typenow;
775 775
 
776
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
776
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
777 777
 			return $vars;
778 778
 		}
779 779
 
780 780
 		// By item type.
781
-		if ( 'type' == $vars['orderby'] ) {
781
+		if ('type' == $vars['orderby']) {
782 782
 			return array_merge(
783 783
 				$vars,
784 784
 				array(
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 		}
790 790
 
791 791
 		// By vat class.
792
-		if ( 'vat_class' == $vars['orderby'] ) {
792
+		if ('vat_class' == $vars['orderby']) {
793 793
 			return array_merge(
794 794
 				$vars,
795 795
 				array(
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		}
801 801
 
802 802
 		// By vat rule.
803
-		if ( 'vat_rule' == $vars['orderby'] ) {
803
+		if ('vat_rule' == $vars['orderby']) {
804 804
 			return array_merge(
805 805
 				$vars,
806 806
 				array(
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
 		}
812 812
 
813 813
 		// By price.
814
-		if ( 'price' == $vars['orderby'] ) {
814
+		if ('price' == $vars['orderby']) {
815 815
 			return array_merge(
816 816
 				$vars,
817 817
 				array(
@@ -828,27 +828,27 @@  discard block
 block discarded – undo
828 828
 	/**
829 829
 	 * Fired when deleting a post.
830 830
 	 */
831
-	public static function delete_post( $post_id ) {
831
+	public static function delete_post($post_id) {
832 832
 
833
-		switch ( get_post_type( $post_id ) ) {
833
+		switch (get_post_type($post_id)) {
834 834
 
835 835
 			case 'wpi_item' :
836
-				do_action( "getpaid_before_delete_item", new WPInv_Item( $post_id ) );
836
+				do_action("getpaid_before_delete_item", new WPInv_Item($post_id));
837 837
 				break;
838 838
 
839 839
 			case 'wpi_payment_form' :
840
-				do_action( "getpaid_before_delete_payment_form", new GetPaid_Payment_Form( $post_id ) );
840
+				do_action("getpaid_before_delete_payment_form", new GetPaid_Payment_Form($post_id));
841 841
 				break;
842 842
 
843 843
 			case 'wpi_discount' :
844
-				do_action( "getpaid_before_delete_discount", new WPInv_Discount( $post_id ) );
844
+				do_action("getpaid_before_delete_discount", new WPInv_Discount($post_id));
845 845
 				break;
846 846
 
847 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 );
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 852
 				break;
853 853
 		}
854 854
 	}
@@ -861,29 +861,29 @@  discard block
 block discarded – undo
861 861
      *
862 862
      * @return mixed
863 863
      */
864
-    public static function add_display_post_states( $post_states, $post ) {
864
+    public static function add_display_post_states($post_states, $post) {
865 865
 
866
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
867
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
866
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
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 ) {
872
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
873 873
 				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
874
-					__( 'GetPaid %s History Page', 'invoicing' ),
874
+					__('GetPaid %s History Page', 'invoicing'),
875 875
 					$label
876 876
 				);
877 877
 			}
878 878
 
879 879
 		}
880 880
 		
881
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
882
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
881
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
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 ) {
886
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
885
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
886
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
887 887
         }
888 888
 
889 889
         return $post_states;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-address.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,14 +21,14 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 
26 26
         // Prepare the invoice.
27
-        $invoice  = new WPInv_Invoice( $post );
28
-        $customer = $invoice->exists() ? $invoice->get_user_id( 'edit' ) : get_current_user_id();
29
-        $customer = new WP_User( $customer );
30
-        $display  = sprintf( _x( '%1$s (%2$s)', 'user dropdown', 'invoicing' ), $customer->display_name, $customer->user_email );
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
27
+        $invoice  = new WPInv_Invoice($post);
28
+        $customer = $invoice->exists() ? $invoice->get_user_id('edit') : get_current_user_id();
29
+        $customer = new WP_User($customer);
30
+        $display  = sprintf(_x('%1$s (%2$s)', 'user dropdown', 'invoicing'), $customer->display_name, $customer->user_email);
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         ?>
34 34
 
@@ -43,11 +43,11 @@  discard block
 block discarded – undo
43 43
                         <div class="col-12 col-sm-6">
44 44
                             <div id="getpaid-invoice-user-id-wrapper" class="form-group">
45 45
                                 <div>
46
-                                    <label for="post_author_override"><?php _e( 'Customer', 'invoicing' );?></label>
46
+                                    <label for="post_author_override"><?php _e('Customer', 'invoicing'); ?></label>
47 47
                                 </div>
48 48
                                 <div>
49
-                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e( 'Search for a customer by email or name', 'invoicing' ); ?>">
50
-                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html( $display ); ?> </option>)
49
+                                    <select name="post_author_override" id="wpinv_post_author_override" class="getpaid-customer-search form-control regular-text" data-placeholder="<?php esc_attr_e('Search for a customer by email or name', 'invoicing'); ?>">
50
+                                        <option selected="selected" value="<?php echo (int) $customer->ID; ?>"><?php echo esc_html($display); ?> </option>)
51 51
                                     </select>
52 52
                                 </div>
53 53
                             </div>
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
                                             'type'        => 'text',
61 61
                                             'id'          => 'getpaid-invoice-new-user-email',
62 62
                                             'name'        => 'wpinv_email',
63
-                                            'label'       => __( 'Email', 'invoicing' ) . '<span class="required">*</span>',
63
+                                            'label'       => __('Email', 'invoicing') . '<span class="required">*</span>',
64 64
                                             'label_type'  => 'vertical',
65 65
                                             'placeholder' => '[email protected]',
66 66
                                             'class'       => 'form-control-sm',
@@ -70,18 +70,18 @@  discard block
 block discarded – undo
70 70
                             </div>
71 71
                         </div>
72 72
                         <div class="col-12 col-sm-6 form-group mt-sm-4">
73
-                            <?php if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) : ?>
73
+                            <?php if (!$invoice->is_paid() && !$invoice->is_refunded()) : ?>
74 74
                                 <a id="getpaid-invoice-fill-user-details" class="button button-small button-secondary" href="javascript:void(0)">
75 75
                                     <i aria-hidden="true" class="fa fa-refresh"></i>
76
-                                    <?php _e( 'Fill User Details', 'invoicing' );?>
76
+                                    <?php _e('Fill User Details', 'invoicing'); ?>
77 77
                                 </a>
78 78
                                 <a id="getpaid-invoice-create-new-user-button" class="button button-small button-secondary" href="javascript:void(0)">
79 79
                                     <i aria-hidden="true" class="fa fa-plus"></i>
80
-                                    <?php _e( 'Add New User', 'invoicing' );?>
80
+                                    <?php _e('Add New User', 'invoicing'); ?>
81 81
                                 </a>
82 82
                                 <a id="getpaid-invoice-cancel-create-new-user" class="button button-small button-secondary d-none" href="javascript:void(0)">
83 83
                                     <i aria-hidden="true" class="fa fa-close"></i>
84
-                                    <?php _e( 'Cancel', 'invoicing' );?>
84
+                                    <?php _e('Cancel', 'invoicing'); ?>
85 85
                                 </a>
86 86
                             <?php endif; ?>
87 87
                         </div>
@@ -94,11 +94,11 @@  discard block
 block discarded – undo
94 94
                                         'type'        => 'text',
95 95
                                         'id'          => 'wpinv_first_name',
96 96
                                         'name'        => 'wpinv_first_name',
97
-                                        'label'       => __( 'First Name', 'invoicing' ),
97
+                                        'label'       => __('First Name', 'invoicing'),
98 98
                                         'label_type'  => 'vertical',
99 99
                                         'placeholder' => '',
100 100
                                         'class'       => 'form-control-sm',
101
-                                        'value'       => $invoice->get_first_name( 'edit' ),
101
+                                        'value'       => $invoice->get_first_name('edit'),
102 102
                                     )
103 103
                                 );
104 104
                             ?>
@@ -110,11 +110,11 @@  discard block
 block discarded – undo
110 110
                                         'type'        => 'text',
111 111
                                         'id'          => 'wpinv_last_name',
112 112
                                         'name'        => 'wpinv_last_name',
113
-                                        'label'       => __( 'Last Name', 'invoicing' ),
113
+                                        'label'       => __('Last Name', 'invoicing'),
114 114
                                         'label_type'  => 'vertical',
115 115
                                         'placeholder' => '',
116 116
                                         'class'       => 'form-control-sm',
117
-                                        'value'       => $invoice->get_last_name( 'edit' ),
117
+                                        'value'       => $invoice->get_last_name('edit'),
118 118
                                     )
119 119
                                 );
120 120
                             ?>
@@ -129,11 +129,11 @@  discard block
 block discarded – undo
129 129
                                         'type'        => 'text',
130 130
                                         'id'          => 'wpinv_company',
131 131
                                         'name'        => 'wpinv_company',
132
-                                        'label'       => __( 'Company', 'invoicing' ),
132
+                                        'label'       => __('Company', 'invoicing'),
133 133
                                         'label_type'  => 'vertical',
134 134
                                         'placeholder' => '',
135 135
                                         'class'       => 'form-control-sm',
136
-                                        'value'       => $invoice->get_company( 'edit' ),
136
+                                        'value'       => $invoice->get_company('edit'),
137 137
                                     )
138 138
                                 );
139 139
                             ?>
@@ -145,11 +145,11 @@  discard block
 block discarded – undo
145 145
                                         'type'        => 'text',
146 146
                                         'id'          => 'wpinv_vat_number',
147 147
                                         'name'        => 'wpinv_vat_number',
148
-                                        'label'       => __( 'Vat Number', 'invoicing' ),
148
+                                        'label'       => __('Vat Number', 'invoicing'),
149 149
                                         'label_type'  => 'vertical',
150 150
                                         'placeholder' => '',
151 151
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
152
-                                        'value'       => $invoice->get_vat_number( 'edit' ),
152
+                                        'value'       => $invoice->get_vat_number('edit'),
153 153
                                     )
154 154
                                 );
155 155
                             ?>
@@ -164,11 +164,11 @@  discard block
 block discarded – undo
164 164
                                         'type'        => 'text',
165 165
                                         'id'          => 'wpinv_address',
166 166
                                         'name'        => 'wpinv_address',
167
-                                        'label'       => __( 'Address', 'invoicing' ),
167
+                                        'label'       => __('Address', 'invoicing'),
168 168
                                         'label_type'  => 'vertical',
169 169
                                         'placeholder' => '',
170 170
                                         'class'       => 'form-control-sm',
171
-                                        'value'       => $invoice->get_address( 'edit' ),
171
+                                        'value'       => $invoice->get_address('edit'),
172 172
                                     )
173 173
                                 );
174 174
                             ?>
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
                                         'type'        => 'text',
181 181
                                         'id'          => 'wpinv_city',
182 182
                                         'name'        => 'wpinv_city',
183
-                                        'label'       => __( 'City', 'invoicing' ),
183
+                                        'label'       => __('City', 'invoicing'),
184 184
                                         'label_type'  => 'vertical',
185 185
                                         'placeholder' => '',
186 186
                                         'class'       => 'form-control-sm',
187
-                                        'value'       => $invoice->get_city( 'edit' ),
187
+                                        'value'       => $invoice->get_city('edit'),
188 188
                                     )
189 189
                                 );
190 190
                             ?>
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
                                     array(
199 199
                                         'id'          => 'wpinv_country',
200 200
                                         'name'        => 'wpinv_country',
201
-                                        'label'       => __( 'Country', 'invoicing' ),
201
+                                        'label'       => __('Country', 'invoicing'),
202 202
                                         'label_type'  => 'vertical',
203
-                                        'placeholder' => __( 'Choose a country', 'invoicing' ),
203
+                                        'placeholder' => __('Choose a country', 'invoicing'),
204 204
                                         'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
205
-                                        'value'       => $invoice->get_country( 'edit' ),
205
+                                        'value'       => $invoice->get_country('edit'),
206 206
                                         'options'     => wpinv_get_country_list(),
207 207
                                         'data-allow-clear' => 'false',
208 208
                                         'select2'          => true,
@@ -213,20 +213,20 @@  discard block
 block discarded – undo
213 213
                         <div class="col-12 col-sm-6">
214 214
                             <?php
215 215
 
216
-                                $states = wpinv_get_country_states( $invoice->get_country( 'edit' ) );
216
+                                $states = wpinv_get_country_states($invoice->get_country('edit'));
217 217
 
218
-                                if ( empty( $states ) ) {
218
+                                if (empty($states)) {
219 219
 
220 220
                                     echo aui()->input(
221 221
                                         array(
222 222
                                             'type'        => 'text',
223 223
                                             'id'          => 'wpinv_state',
224 224
                                             'name'        => 'wpinv_state',
225
-                                            'label'       => __( 'State', 'invoicing' ),
225
+                                            'label'       => __('State', 'invoicing'),
226 226
                                             'label_type'  => 'vertical',
227 227
                                             'placeholder' => '',
228 228
                                             'class'       => 'form-control-sm',
229
-                                            'value'       => $invoice->get_state( 'edit' ),
229
+                                            'value'       => $invoice->get_state('edit'),
230 230
                                         )
231 231
                                     );
232 232
 
@@ -236,11 +236,11 @@  discard block
 block discarded – undo
236 236
                                         array(
237 237
                                             'id'          => 'wpinv_state',
238 238
                                             'name'        => 'wpinv_state',
239
-                                            'label'       => __( 'State', 'invoicing' ),
239
+                                            'label'       => __('State', 'invoicing'),
240 240
                                             'label_type'  => 'vertical',
241
-                                            'placeholder' => __( 'Select a state', 'invoicing' ),
241
+                                            'placeholder' => __('Select a state', 'invoicing'),
242 242
                                             'class'       => 'form-control-sm',
243
-                                            'value'       => $invoice->get_state( 'edit' ),
243
+                                            'value'       => $invoice->get_state('edit'),
244 244
                                             'options'     => $states,
245 245
                                             'data-allow-clear' => 'false',
246 246
                                             'select2'          => true,
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
                                         'type'        => 'text',
262 262
                                         'id'          => 'wpinv_zip',
263 263
                                         'name'        => 'wpinv_zip',
264
-                                        'label'       => __( 'Zip / Postal Code', 'invoicing' ),
264
+                                        'label'       => __('Zip / Postal Code', 'invoicing'),
265 265
                                         'label_type'  => 'vertical',
266 266
                                         'placeholder' => '',
267 267
                                         'class'       => 'form-control-sm',
268
-                                        'value'       => $invoice->get_zip( 'edit' ),
268
+                                        'value'       => $invoice->get_zip('edit'),
269 269
                                     )
270 270
                                 );
271 271
                             ?>
@@ -277,19 +277,19 @@  discard block
 block discarded – undo
277 277
                                         'type'        => 'text',
278 278
                                         'id'          => 'wpinv_phone',
279 279
                                         'name'        => 'wpinv_phone',
280
-                                        'label'       => __( 'Phone', 'invoicing' ),
280
+                                        'label'       => __('Phone', 'invoicing'),
281 281
                                         'label_type'  => 'vertical',
282 282
                                         'placeholder' => '',
283 283
                                         'class'       => 'form-control-sm',
284
-                                        'value'       => $invoice->get_phone( 'edit' ),
284
+                                        'value'       => $invoice->get_phone('edit'),
285 285
                                     )
286 286
                                 );
287 287
                             ?>
288 288
                         </div>
289 289
                     </div>
290 290
 
291
-                    <?php if ( ! apply_filters( 'getpaid_use_new_invoice_items_metabox', false ) ) : ?>
292
-                        <?php do_action( 'wpinv_meta_box_before_invoice_template_row', $invoice->get_id() ); ?>
291
+                    <?php if (!apply_filters('getpaid_use_new_invoice_items_metabox', false)) : ?>
292
+                        <?php do_action('wpinv_meta_box_before_invoice_template_row', $invoice->get_id()); ?>
293 293
 
294 294
                         <div class="row">
295 295
                             <div class="col-12 col-sm-6">
@@ -298,14 +298,14 @@  discard block
 block discarded – undo
298 298
                                         array(
299 299
                                             'id'          => 'wpinv_template',
300 300
                                             'name'        => 'wpinv_template',
301
-                                            'label'       => __( 'Template', 'invoicing' ),
301
+                                            'label'       => __('Template', 'invoicing'),
302 302
                                             'label_type'  => 'vertical',
303
-                                            'placeholder' => __( 'Choose a template', 'invoicing' ),
303
+                                            'placeholder' => __('Choose a template', 'invoicing'),
304 304
                                             'class'       => 'form-control-sm',
305
-                                            'value'       => $invoice->get_template( 'edit' ),
305
+                                            'value'       => $invoice->get_template('edit'),
306 306
                                             'options'     => array(
307
-                                                'quantity' => __( 'Quantity', 'invoicing' ),
308
-                                                'hours'    => __( 'Hours', 'invoicing' ),
307
+                                                'quantity' => __('Quantity', 'invoicing'),
308
+                                                'hours'    => __('Hours', 'invoicing'),
309 309
                                                 //'amount'   => __( 'Amount Only', 'invoicing' ),
310 310
                                             ),
311 311
                                             'data-allow-clear' => 'false',
@@ -322,11 +322,11 @@  discard block
 block discarded – undo
322 322
                                         array(
323 323
                                             'id'          => 'wpinv_currency',
324 324
                                             'name'        => 'wpinv_currency',
325
-                                            'label'       => __( 'Currency', 'invoicing' ),
325
+                                            'label'       => __('Currency', 'invoicing'),
326 326
                                             'label_type'  => 'vertical',
327
-                                            'placeholder' => __( 'Select Invoice Currency', 'invoicing' ),
327
+                                            'placeholder' => __('Select Invoice Currency', 'invoicing'),
328 328
                                             'class'       => 'form-control-sm getpaid-recalculate-prices-on-change',
329
-                                            'value'       => $invoice->get_currency( 'edit' ),
329
+                                            'value'       => $invoice->get_currency('edit'),
330 330
                                             'required'    => false,
331 331
                                             'data-allow-clear' => 'false',
332 332
                                             'select2'          => true,
@@ -338,7 +338,7 @@  discard block
 block discarded – undo
338 338
                             </div>
339 339
                         </div>
340 340
 
341
-                        <?php do_action( 'wpinv_meta_box_invoice_template_row', $invoice->get_id() ); ?>
341
+                        <?php do_action('wpinv_meta_box_invoice_template_row', $invoice->get_id()); ?>
342 342
                     <?php endif; ?>
343 343
 
344 344
                     <div class="row">
@@ -349,18 +349,18 @@  discard block
 block discarded – undo
349 349
                                         'type'        => 'text',
350 350
                                         'id'          => 'wpinv_company_id',
351 351
                                         'name'        => 'wpinv_company_id',
352
-                                        'label'       => __( 'Company ID', 'invoicing' ),
352
+                                        'label'       => __('Company ID', 'invoicing'),
353 353
                                         'label_type'  => 'vertical',
354 354
                                         'placeholder' => '',
355 355
                                         'class'       => 'form-control-sm',
356
-                                        'value'       => $invoice->get_company_id( 'edit' ),
356
+                                        'value'       => $invoice->get_company_id('edit'),
357 357
                                     )
358 358
                                 );
359 359
                             ?>
360 360
                         </div>
361 361
                     </div>
362 362
 
363
-                    <?php do_action( 'getpaid_after_metabox_invoice_address', $invoice ); ?>
363
+                    <?php do_action('getpaid_after_metabox_invoice_address', $invoice); ?>
364 364
             </div>
365 365
         <?php
366 366
     }
@@ -370,51 +370,51 @@  discard block
 block discarded – undo
370 370
 	 *
371 371
 	 * @param int $post_id
372 372
 	 */
373
-	public static function save( $post_id ) {
373
+	public static function save($post_id) {
374 374
 
375 375
         // Prepare the invoice.
376
-        $invoice = new WPInv_Invoice( $post_id );
376
+        $invoice = new WPInv_Invoice($post_id);
377 377
 
378 378
         // Load new data.
379 379
         $invoice->set_props(
380 380
 			array(
381
-                'template'             => isset( $_POST['wpinv_template'] ) ? wpinv_clean( $_POST['wpinv_template'] ) : null,
382
-                'email_cc'             => isset( $_POST['wpinv_cc'] ) ? wpinv_clean( $_POST['wpinv_cc'] ) : null,
383
-                'disable_taxes'        => ! empty( $_POST['disable_taxes'] ),
384
-                'currency'             => isset( $_POST['wpinv_currency'] ) ? wpinv_clean( $_POST['wpinv_currency'] ) : null,
385
-                'gateway'              => ( $invoice->needs_payment() && isset( $_POST['wpinv_gateway'] ) ) ? wpinv_clean( $_POST['wpinv_gateway'] ) : null,
386
-                'address'              => isset( $_POST['wpinv_address'] ) ? wpinv_clean( $_POST['wpinv_address'] ) : null,
387
-                'vat_number'           => isset( $_POST['wpinv_vat_number'] ) ? wpinv_clean( $_POST['wpinv_vat_number'] ) : null,
388
-                'company'              => isset( $_POST['wpinv_company'] ) ? wpinv_clean( $_POST['wpinv_company'] ) : null,
389
-                'company_id'           => isset( $_POST['wpinv_company_id'] ) ? wpinv_clean( $_POST['wpinv_company_id'] ) : null,
390
-                'zip'                  => isset( $_POST['wpinv_zip'] ) ? wpinv_clean( $_POST['wpinv_zip'] ) : null,
391
-                'state'                => isset( $_POST['wpinv_state'] ) ? wpinv_clean( $_POST['wpinv_state'] ) : null,
392
-                'city'                 => isset( $_POST['wpinv_city'] ) ? wpinv_clean( $_POST['wpinv_city'] ) : null,
393
-                'country'              => isset( $_POST['wpinv_country'] ) ? wpinv_clean( $_POST['wpinv_country'] ) : null,
394
-                'phone'                => isset( $_POST['wpinv_phone'] ) ? wpinv_clean( $_POST['wpinv_phone'] ) : null,
395
-                'first_name'           => isset( $_POST['wpinv_first_name'] ) ? wpinv_clean( $_POST['wpinv_first_name'] ) : null,
396
-                'last_name'            => isset( $_POST['wpinv_last_name'] ) ? wpinv_clean( $_POST['wpinv_last_name'] ) : null,
397
-                'author'               => isset( $_POST['post_author_override'] ) ? wpinv_clean( $_POST['post_author_override'] ) : null,
398
-                'date_created'         => isset( $_POST['date_created'] ) ? wpinv_clean( $_POST['date_created'] ) : null,
399
-                'date_completed'       => isset( $_POST['wpinv_date_completed'] ) ? wpinv_clean( $_POST['wpinv_date_completed'] ) : null,
400
-                'due_date'             => isset( $_POST['wpinv_due_date'] ) ? wpinv_clean( $_POST['wpinv_due_date'] ) : null,
401
-                'number'               => isset( $_POST['wpinv_number'] ) ? wpinv_clean( $_POST['wpinv_number'] ) : null,
402
-                'status'               => isset( $_POST['wpinv_status'] ) ? wpinv_clean( $_POST['wpinv_status'] ) : null,
381
+                'template'             => isset($_POST['wpinv_template']) ? wpinv_clean($_POST['wpinv_template']) : null,
382
+                'email_cc'             => isset($_POST['wpinv_cc']) ? wpinv_clean($_POST['wpinv_cc']) : null,
383
+                'disable_taxes'        => !empty($_POST['disable_taxes']),
384
+                'currency'             => isset($_POST['wpinv_currency']) ? wpinv_clean($_POST['wpinv_currency']) : null,
385
+                'gateway'              => ($invoice->needs_payment() && isset($_POST['wpinv_gateway'])) ? wpinv_clean($_POST['wpinv_gateway']) : null,
386
+                'address'              => isset($_POST['wpinv_address']) ? wpinv_clean($_POST['wpinv_address']) : null,
387
+                'vat_number'           => isset($_POST['wpinv_vat_number']) ? wpinv_clean($_POST['wpinv_vat_number']) : null,
388
+                'company'              => isset($_POST['wpinv_company']) ? wpinv_clean($_POST['wpinv_company']) : null,
389
+                'company_id'           => isset($_POST['wpinv_company_id']) ? wpinv_clean($_POST['wpinv_company_id']) : null,
390
+                'zip'                  => isset($_POST['wpinv_zip']) ? wpinv_clean($_POST['wpinv_zip']) : null,
391
+                'state'                => isset($_POST['wpinv_state']) ? wpinv_clean($_POST['wpinv_state']) : null,
392
+                'city'                 => isset($_POST['wpinv_city']) ? wpinv_clean($_POST['wpinv_city']) : null,
393
+                'country'              => isset($_POST['wpinv_country']) ? wpinv_clean($_POST['wpinv_country']) : null,
394
+                'phone'                => isset($_POST['wpinv_phone']) ? wpinv_clean($_POST['wpinv_phone']) : null,
395
+                'first_name'           => isset($_POST['wpinv_first_name']) ? wpinv_clean($_POST['wpinv_first_name']) : null,
396
+                'last_name'            => isset($_POST['wpinv_last_name']) ? wpinv_clean($_POST['wpinv_last_name']) : null,
397
+                'author'               => isset($_POST['post_author_override']) ? wpinv_clean($_POST['post_author_override']) : null,
398
+                'date_created'         => isset($_POST['date_created']) ? wpinv_clean($_POST['date_created']) : null,
399
+                'date_completed'       => isset($_POST['wpinv_date_completed']) ? wpinv_clean($_POST['wpinv_date_completed']) : null,
400
+                'due_date'             => isset($_POST['wpinv_due_date']) ? wpinv_clean($_POST['wpinv_due_date']) : null,
401
+                'number'               => isset($_POST['wpinv_number']) ? wpinv_clean($_POST['wpinv_number']) : null,
402
+                'status'               => isset($_POST['wpinv_status']) ? wpinv_clean($_POST['wpinv_status']) : null,
403 403
 			)
404 404
         );
405 405
 
406 406
         // Discount code.
407
-        if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
407
+        if (!$invoice->is_paid() && !$invoice->is_refunded()) {
408 408
 
409
-            if ( isset( $_POST['wpinv_discount_code'] ) ) {
410
-                $invoice->set_discount_code( wpinv_clean( $_POST['wpinv_discount_code'] ) );
409
+            if (isset($_POST['wpinv_discount_code'])) {
410
+                $invoice->set_discount_code(wpinv_clean($_POST['wpinv_discount_code']));
411 411
             }
412 412
 
413
-            $discount = new WPInv_Discount( $invoice->get_discount_code() );
414
-            if ( $discount->exists() ) {
415
-                $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
413
+            $discount = new WPInv_Discount($invoice->get_discount_code());
414
+            if ($discount->exists()) {
415
+                $invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
416 416
             } else {
417
-                $invoice->remove_discount( 'discount_code' );
417
+                $invoice->remove_discount('discount_code');
418 418
             }
419 419
 
420 420
             // Recalculate totals.
@@ -423,17 +423,17 @@  discard block
 block discarded – undo
423 423
         }
424 424
 
425 425
         // If we're creating a new user...
426
-        if ( ! empty( $_POST['wpinv_new_user'] ) && is_email( stripslashes( $_POST['wpinv_email'] ) ) ) {
426
+        if (!empty($_POST['wpinv_new_user']) && is_email(stripslashes($_POST['wpinv_email']))) {
427 427
 
428 428
             // Attempt to create the user.
429
-            $user = wpinv_create_user( sanitize_email( stripslashes( $_POST['wpinv_email'] ) ) );
429
+            $user = wpinv_create_user(sanitize_email(stripslashes($_POST['wpinv_email'])));
430 430
 
431 431
 
432 432
             // If successful, update the invoice author.
433
-            if ( is_numeric( $user ) ) {
434
-                $invoice->set_author( $user );
433
+            if (is_numeric($user)) {
434
+                $invoice->set_author($user);
435 435
             } else {
436
-                wpinv_error_log( $user->get_error_message(), __( 'Invoice add new user', 'invoicing' ), __FILE__, __LINE__ );
436
+                wpinv_error_log($user->get_error_message(), __('Invoice add new user', 'invoicing'), __FILE__, __LINE__);
437 437
             }
438 438
         }
439 439
 
@@ -447,16 +447,16 @@  discard block
 block discarded – undo
447 447
         $GLOBALS['wpinv_skip_invoice_notification'] = false;
448 448
 
449 449
         // (Maybe) send new user notification.
450
-        $should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
451
-        if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ) ) ) {
452
-            wp_send_new_user_notifications( $user, 'user' );
450
+        $should_send_notification = wpinv_get_option('disable_new_user_emails');
451
+        if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification))) {
452
+            wp_send_new_user_notifications($user, 'user');
453 453
         }
454 454
 
455
-        if ( ! empty( $_POST['send_to_customer'] ) && ! $invoice->is_draft() ) {
456
-            getpaid()->get( 'invoice_emails' )->user_invoice( $invoice, true );
455
+        if (!empty($_POST['send_to_customer']) && !$invoice->is_draft()) {
456
+            getpaid()->get('invoice_emails')->user_invoice($invoice, true);
457 457
         }
458 458
 
459 459
         // Fires after an invoice is saved.
460
-		do_action( 'wpinv_invoice_metabox_saved', $invoice );
460
+		do_action('wpinv_invoice_metabox_saved', $invoice);
461 461
 	}
462 462
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-admin.php 2 patches
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.
Spacing   +277 added lines, -277 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * The main admin class.
@@ -37,13 +37,13 @@  discard block
 block discarded – undo
37 37
     /**
38 38
 	 * Class constructor.
39 39
 	 */
40
-	public function __construct(){
40
+	public function __construct() {
41 41
 
42
-        $this->admin_path  = plugin_dir_path( __FILE__ );
43
-		$this->admin_url   = plugins_url( '/', __FILE__ );
42
+        $this->admin_path = plugin_dir_path(__FILE__);
43
+		$this->admin_url   = plugins_url('/', __FILE__);
44 44
 		$this->reports     = new GetPaid_Reports();
45 45
 
46
-        if ( is_admin() ) {
46
+        if (is_admin()) {
47 47
 			$this->init_admin_hooks();
48 48
         }
49 49
 
@@ -54,33 +54,33 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 */
56 56
 	private function init_admin_hooks() {
57
-        add_action( 'admin_enqueue_scripts', array( $this, 'enqeue_scripts' ), 9 );
58
-        add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
59
-        add_action( 'admin_init', array( $this, 'init_ayecode_connect_helper' ) );
60
-        add_action( 'admin_init', array( $this, 'activation_redirect') );
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' ) );
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 );
57
+        add_action('admin_enqueue_scripts', array($this, 'enqeue_scripts'), 9);
58
+        add_filter('admin_body_class', array($this, 'admin_body_class'));
59
+        add_action('admin_init', array($this, 'init_ayecode_connect_helper'));
60
+        add_action('admin_init', array($this, 'activation_redirect'));
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'));
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 78
 
79 79
 		// Setup/welcome
80
-		if ( ! empty( $_GET['page'] ) ) {
81
-			switch ( $_GET['page'] ) {
80
+		if (!empty($_GET['page'])) {
81
+			switch ($_GET['page']) {
82 82
 				case 'gp-setup' :
83
-					include_once( dirname( __FILE__ ) . '/class-getpaid-admin-setup-wizard.php' );
83
+					include_once(dirname(__FILE__) . '/class-getpaid-admin-setup-wizard.php');
84 84
 					break;
85 85
 			}
86 86
 		}
@@ -94,37 +94,37 @@  discard block
 block discarded – undo
94 94
 	public function enqeue_scripts() {
95 95
         global $current_screen, $pagenow;
96 96
 
97
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
97
+		$page    = isset($_GET['page']) ? $_GET['page'] : '';
98 98
 		$editing = $pagenow == 'post.php' || $pagenow == 'post-new.php';
99 99
 
100
-        if ( ! empty( $current_screen->post_type ) ) {
100
+        if (!empty($current_screen->post_type)) {
101 101
 			$page = $current_screen->post_type;
102 102
         }
103 103
 
104 104
         // General styles.
105
-        if ( false !== stripos( $page, 'wpi' ) || false !== stripos( $page, 'getpaid' ) || 'gp-setup' == $page ) {
105
+        if (false !== stripos($page, 'wpi') || false !== stripos($page, 'getpaid') || 'gp-setup' == $page) {
106 106
 
107 107
             // Styles.
108
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/css/admin.css' );
109
-            wp_enqueue_style( 'wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array( 'wp-color-picker' ), $version );
110
-            wp_enqueue_style( 'select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all' );
108
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/css/admin.css');
109
+            wp_enqueue_style('wpinv_admin_style', WPINV_PLUGIN_URL . 'assets/css/admin.css', array('wp-color-picker'), $version);
110
+            wp_enqueue_style('select2', WPINV_PLUGIN_URL . 'assets/css/select2/select2.min.css', array(), '4.0.13', 'all');
111 111
 
112 112
             // Scripts.
113
-            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array( 'jquery' ), WPINV_VERSION );
113
+            wp_enqueue_script('select2', WPINV_PLUGIN_URL . 'assets/js/select2/select2.full.min.js', array('jquery'), WPINV_VERSION);
114 114
 
115
-            $version = filemtime( WPINV_PLUGIN_DIR . 'assets/js/admin.js' );
116
-            wp_enqueue_script( 'wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array( 'jquery', 'wp-color-picker', 'jquery-ui-tooltip' ),  $version );
117
-            wp_localize_script( 'wpinv-admin-script', 'WPInv_Admin', apply_filters( 'wpinv_admin_js_localize', $this->get_admin_i18() ) );
115
+            $version = filemtime(WPINV_PLUGIN_DIR . 'assets/js/admin.js');
116
+            wp_enqueue_script('wpinv-admin-script', WPINV_PLUGIN_URL . 'assets/js/admin.js', array('jquery', 'wp-color-picker', 'jquery-ui-tooltip'), $version);
117
+            wp_localize_script('wpinv-admin-script', 'WPInv_Admin', apply_filters('wpinv_admin_js_localize', $this->get_admin_i18()));
118 118
 
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' );
126
+		if ($page == 'wpinv-subscriptions') {
127
+			wp_enqueue_script('postbox');
128 128
 		}
129 129
 
130 130
     }
@@ -137,32 +137,32 @@  discard block
 block discarded – undo
137 137
         global $post;
138 138
 
139 139
 		$date_range = array(
140
-			'period' => isset( $_GET['date_range'] ) ? sanitize_text_field( $_GET['date_range'] ) : '7_days'
140
+			'period' => isset($_GET['date_range']) ? sanitize_text_field($_GET['date_range']) : '7_days'
141 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 );
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 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 );
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 151
 			}
152 152
 
153 153
 		}
154 154
 
155 155
         $i18n = array(
156
-            'ajax_url'                  => admin_url( 'admin-ajax.php' ),
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() ),
156
+            'ajax_url'                  => admin_url('admin-ajax.php'),
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 161
 			'date_range'                => $date_range,
162
-            'add_invoice_note_nonce'    => wp_create_nonce( 'add-invoice-note' ),
163
-            'delete_invoice_note_nonce' => wp_create_nonce( 'delete-invoice-note' ),
164
-            'invoice_item_nonce'        => wp_create_nonce( 'invoice-item' ),
165
-            'billing_details_nonce'     => wp_create_nonce( 'get-billing-details' ),
162
+            'add_invoice_note_nonce'    => wp_create_nonce('add-invoice-note'),
163
+            'delete_invoice_note_nonce' => wp_create_nonce('delete-invoice-note'),
164
+            'invoice_item_nonce'        => wp_create_nonce('invoice-item'),
165
+            'billing_details_nonce'     => wp_create_nonce('get-billing-details'),
166 166
             'tax'                       => wpinv_tax_amount(),
167 167
             'discount'                  => 0,
168 168
 			'currency_symbol'           => wpinv_currency_symbol(),
@@ -171,38 +171,38 @@  discard block
 block discarded – undo
171 171
             'thousand_sep'              => wpinv_thousands_separator(),
172 172
             'decimal_sep'               => wpinv_decimal_separator(),
173 173
             'decimals'                  => wpinv_decimals(),
174
-            'save_invoice'              => __( 'Save Invoice', 'invoicing' ),
175
-            'status_publish'            => wpinv_status_nicename( 'publish' ),
176
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
177
-            'delete_tax_rate'           => __( 'Are you sure you wish to delete this tax rate?', 'invoicing' ),
178
-            'status_pending'            => wpinv_status_nicename( 'wpi-pending' ),
179
-            'FillBillingDetails'        => __( 'Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing' ),
180
-            'confirmCalcTotals'         => __( 'Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing' ),
181
-            'AreYouSure'                => __( 'Are you sure?', 'invoicing' ),
182
-            'errDeleteItem'             => __( 'This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing' ),
183
-            'delete_subscription'       => __( 'Are you sure you want to delete this subscription?', 'invoicing' ),
184
-            'action_edit'               => __( 'Edit', 'invoicing' ),
185
-            'action_cancel'             => __( 'Cancel', 'invoicing' ),
186
-            'item_description'          => __( 'Item Description', 'invoicing' ),
187
-            'invoice_description'       => __( 'Invoice Description', 'invoicing' ),
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' ),
174
+            'save_invoice'              => __('Save Invoice', 'invoicing'),
175
+            'status_publish'            => wpinv_status_nicename('publish'),
176
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
177
+            'delete_tax_rate'           => __('Are you sure you wish to delete this tax rate?', 'invoicing'),
178
+            'status_pending'            => wpinv_status_nicename('wpi-pending'),
179
+            'FillBillingDetails'        => __('Fill the user\'s billing information? This will remove any currently entered billing information', 'invoicing'),
180
+            'confirmCalcTotals'         => __('Recalculate totals? This will recalculate totals based on the user billing country. If no billing country is set it will use the base country.', 'invoicing'),
181
+            'AreYouSure'                => __('Are you sure?', 'invoicing'),
182
+            'errDeleteItem'             => __('This item is in use! Before delete this item, you need to delete all the invoice(s) using this item.', 'invoicing'),
183
+            'delete_subscription'       => __('Are you sure you want to delete this subscription?', 'invoicing'),
184
+            'action_edit'               => __('Edit', 'invoicing'),
185
+            'action_cancel'             => __('Cancel', 'invoicing'),
186
+            'item_description'          => __('Item Description', 'invoicing'),
187
+            'invoice_description'       => __('Invoice Description', 'invoicing'),
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'),
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 );
197
+			$invoice              = new WPInv_Invoice($post);
198 198
 			$i18n['save_invoice'] = sprintf(
199
-				__( 'Save %s', 'invoicing' ),
200
-				ucfirst( $invoice->get_invoice_quote_type() )
199
+				__('Save %s', 'invoicing'),
200
+				ucfirst($invoice->get_invoice_quote_type())
201 201
 			);
202 202
 
203 203
 			$i18n['invoice_description'] = sprintf(
204
-				__( '%s Description', 'invoicing' ),
205
-				ucfirst( $invoice->get_invoice_quote_type() )
204
+				__('%s Description', 'invoicing'),
205
+				ucfirst($invoice->get_invoice_quote_type())
206 206
 			);
207 207
 
208 208
 		}
@@ -216,24 +216,24 @@  discard block
 block discarded – undo
216 216
 	 * @param  string $footer_text
217 217
 	 * @return string
218 218
 	 */
219
-	public function admin_footer_text( $footer_text ) {
219
+	public function admin_footer_text($footer_text) {
220 220
 		global $current_screen;
221 221
 
222
-		$page    = isset( $_GET['page'] ) ? $_GET['page'] : '';
222
+		$page = isset($_GET['page']) ? $_GET['page'] : '';
223 223
 
224
-        if ( ! empty( $current_screen->post_type ) ) {
224
+        if (!empty($current_screen->post_type)) {
225 225
 			$page = $current_screen->post_type;
226 226
         }
227 227
 
228 228
         // General styles.
229
-        if ( apply_filters( 'getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing() ) && false !== stripos( $page, 'wpi' ) ) {
229
+        if (apply_filters('getpaid_display_admin_footer_text', wpinv_current_user_can_manage_invoicing()) && false !== stripos($page, 'wpi')) {
230 230
 
231 231
 			// Change the footer text
232
-			if ( ! get_user_meta( get_current_user_id(), 'getpaid_admin_footer_text_rated', true ) ) {
232
+			if (!get_user_meta(get_current_user_id(), 'getpaid_admin_footer_text_rated', true)) {
233 233
 
234
-				$rating_url  = esc_url(
234
+				$rating_url = esc_url(
235 235
 					wp_nonce_url(
236
-						admin_url( 'admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin' ),
236
+						admin_url('admin.php?page=wpinv-reports&getpaid-admin-action=rate_plugin'),
237 237
 						'getpaid-nonce',
238 238
 						'getpaid-nonce'
239 239
 						)
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 
242 242
 				$footer_text = sprintf(
243 243
 					/* translators: %s: five stars */
244
-					__( 'If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing' ),
244
+					__('If you like <strong>GetPaid</strong>, please leave us a %s rating. A huge thanks in advance!', 'invoicing'),
245 245
 					"<a href='$rating_url'>&#9733;&#9733;&#9733;&#9733;&#9733;</a>"
246 246
 				);
247 247
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 				$footer_text = sprintf(
251 251
 					/* translators: %s: GetPaid */
252
-					__( 'Thank you for using %s!', 'invoicing' ),
252
+					__('Thank you for using %s!', 'invoicing'),
253 253
 					"<a href='https://wpgetpaid.com/' target='_blank'><strong>GetPaid</strong></a>"
254 254
 				);
255 255
 
@@ -266,8 +266,8 @@  discard block
 block discarded – undo
266 266
 	 * @since  2.0.0
267 267
 	 */
268 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' );
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 271
 		exit;
272 272
 	}
273 273
 
@@ -278,30 +278,30 @@  discard block
 block discarded – undo
278 278
 	protected function load_payment_form_scripts() {
279 279
         global $post;
280 280
 
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 );
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);
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 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 ),
292
+				'elements'      => wpinv_get_data('payment-form-elements'),
293
+				'form_elements' => getpaid_get_payment_form_elements($post->ID),
294 294
 				'currency'      => wpinv_currency_symbol(),
295 295
 				'position'      => wpinv_currency_position(),
296 296
 				'decimals'      => (int) wpinv_decimals(),
297 297
 				'thousands_sep' => wpinv_thousands_separator(),
298 298
 				'decimals_sep'  => wpinv_decimal_separator(),
299
-				'form_items'    => gepaid_get_form_items( $post->ID ),
299
+				'form_items'    => gepaid_get_form_items($post->ID),
300 300
 				'is_default'    => $post->ID == wpinv_get_default_payment_form(),
301 301
             )
302 302
         );
303 303
 
304
-        wp_enqueue_script( 'wpinv-admin-payment-form-script' );
304
+        wp_enqueue_script('wpinv-admin-payment-form-script');
305 305
 
306 306
     }
307 307
 
@@ -312,25 +312,25 @@  discard block
 block discarded – undo
312 312
      * @return string
313 313
 	 *
314 314
 	 */
315
-    public function admin_body_class( $classes ) {
315
+    public function admin_body_class($classes) {
316 316
 		global $pagenow, $post, $current_screen;
317 317
 
318 318
 
319
-        $page = isset( $_GET['page'] ) ? $_GET['page'] : '';
319
+        $page = isset($_GET['page']) ? $_GET['page'] : '';
320 320
 
321
-        if ( ! empty( $current_screen->post_type ) ) {
321
+        if (!empty($current_screen->post_type)) {
322 322
 			$page = $current_screen->post_type;
323 323
         }
324 324
 
325
-        if ( false !== stripos( $page, 'wpi' ) ) {
326
-            $classes .= ' wpi-' . sanitize_key( $page );
325
+        if (false !== stripos($page, 'wpi')) {
326
+            $classes .= ' wpi-' . sanitize_key($page);
327 327
         }
328 328
 
329
-        if ( in_array( $page, wpinv_parse_list( 'wpi_invoice wpi_payment_form wpi_quote' ) ) ) {
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
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
     /**
341 341
 	 * Maybe show the AyeCode Connect Notice.
342 342
 	 */
343
-	public function init_ayecode_connect_helper(){
343
+	public function init_ayecode_connect_helper() {
344 344
 
345 345
 		// Register with the deactivation survey class.
346 346
 		AyeCode_Deactivation_Survey::instance(array(
@@ -348,20 +348,20 @@  discard block
 block discarded – undo
348 348
 			'version'	        => WPINV_VERSION,
349 349
 			'support_url'       => 'https://wpgetpaid.com/support/',
350 350
 			'documentation_url' => 'https://docs.wpgetpaid.com/',
351
-			'activated'         => (int) get_option( 'gepaid_installed_on' ),
351
+			'activated'         => (int) get_option('gepaid_installed_on'),
352 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
-            array( 'wpi-addons' )
364
+            array('wpi-addons')
365 365
         );
366 366
 
367 367
     }
@@ -373,20 +373,20 @@  discard block
 block discarded – undo
373 373
 	 */
374 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' ) ) {
378
+		if (!empty($redirected) || wp_doing_ajax() || !current_user_can('manage_options')) {
379 379
 			return;
380 380
 		}
381 381
 
382 382
 		// Bail if activating from network, or bulk
383
-		if ( is_network_admin() || isset( $_GET['activate-multi'] ) ) {
383
+		if (is_network_admin() || isset($_GET['activate-multi'])) {
384 384
 			return;
385 385
 		}
386 386
 
387
-	    update_option( 'wpinv_redirected_to_settings', 1 );
387
+	    update_option('wpinv_redirected_to_settings', 1);
388 388
 
389
-        wp_safe_redirect( admin_url( 'index.php?page=gp-setup' ) );
389
+        wp_safe_redirect(admin_url('index.php?page=gp-setup'));
390 390
         exit;
391 391
 
392 392
 	}
@@ -396,9 +396,9 @@  discard block
 block discarded – undo
396 396
      */
397 397
     public function maybe_do_admin_action() {
398 398
 
399
-        if ( wpinv_current_user_can_manage_invoicing() && isset( $_REQUEST['getpaid-admin-action'] ) && isset( $_REQUEST['getpaid-nonce'] ) && wp_verify_nonce( $_REQUEST['getpaid-nonce'], 'getpaid-nonce' ) ) {
400
-            $key = sanitize_key( $_REQUEST['getpaid-admin-action'] );
401
-            do_action( "getpaid_authenticated_admin_action_$key", $_REQUEST );
399
+        if (wpinv_current_user_can_manage_invoicing() && isset($_REQUEST['getpaid-admin-action']) && isset($_REQUEST['getpaid-nonce']) && wp_verify_nonce($_REQUEST['getpaid-nonce'], 'getpaid-nonce')) {
400
+            $key = sanitize_key($_REQUEST['getpaid-admin-action']);
401
+            do_action("getpaid_authenticated_admin_action_$key", $_REQUEST);
402 402
         }
403 403
 
404 404
     }
@@ -408,24 +408,24 @@  discard block
 block discarded – undo
408 408
 	 * 
409 409
 	 * @param array $args
410 410
      */
411
-    public function duplicate_invoice( $args ) {
411
+    public function duplicate_invoice($args) {
412 412
 
413
-		if ( empty( $args['invoice_id'] ) ) {
413
+		if (empty($args['invoice_id'])) {
414 414
 			return;
415 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() ) {
419
+		if (!$invoice->exists()) {
420 420
 			return;
421 421
 		}
422 422
 
423
-		$new_invoice = getpaid_duplicate_invoice( $invoice );
423
+		$new_invoice = getpaid_duplicate_invoice($invoice);
424 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 430
 			wp_safe_redirect(
431 431
 				add_query_arg(
@@ -433,14 +433,14 @@  discard block
 block discarded – undo
433 433
 						'action' => 'edit',
434 434
 						'post' => $new_invoice->get_id(),
435 435
 					),
436
-					admin_url( 'post.php' )
436
+					admin_url('post.php')
437 437
 				)
438 438
 			);
439 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
 
@@ -449,34 +449,34 @@  discard block
 block discarded – undo
449 449
 	 * 
450 450
 	 * @param array $args
451 451
      */
452
-    public function duplicate_payment_form( $args ) {
452
+    public function duplicate_payment_form($args) {
453 453
 
454
-		if ( empty( $args['form_id'] ) ) {
454
+		if (empty($args['form_id'])) {
455 455
 			return;
456 456
 		}
457 457
 
458
-		$form = new GetPaid_Payment_Form( (int) $args['form_id'] );
458
+		$form = new GetPaid_Payment_Form((int) $args['form_id']);
459 459
 
460
-		if ( ! $form->exists() ) {
460
+		if (!$form->exists()) {
461 461
 			return;
462 462
 		}
463 463
 
464 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' ) );
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 469
 		$new_form->save();
470 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' );
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 474
 		} else {
475
-			$this->show_error( __( 'Unable to duplicate form', 'invoicing' ) );
476
-			$url = remove_query_arg( array( 'getpaid-admin-action', 'form_id', 'getpaid-nonce' ) );
475
+			$this->show_error(__('Unable to duplicate form', 'invoicing'));
476
+			$url = remove_query_arg(array('getpaid-admin-action', 'form_id', 'getpaid-nonce'));
477 477
 		}
478 478
 
479
-		wp_redirect( $url );
479
+		wp_redirect($url);
480 480
 		exit;
481 481
 	}
482 482
 
@@ -485,9 +485,9 @@  discard block
 block discarded – undo
485 485
 	 * 
486 486
 	 * @param array $args
487 487
      */
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' ) ) );
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 491
 		exit;
492 492
 	}
493 493
 
@@ -496,16 +496,16 @@  discard block
 block discarded – undo
496 496
 	 * 
497 497
 	 * @param array $args
498 498
      */
499
-    public function send_customer_payment_reminder( $args ) {
500
-		$sent = getpaid()->get( 'invoice_emails' )->force_send_overdue_notice( new WPInv_Invoice( $args['invoice_id'] ) );
499
+    public function send_customer_payment_reminder($args) {
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' ) );
502
+		if ($sent) {
503
+			$this->show_success(__('Payment reminder was successfully sent to the customer', 'invoicing'));
504 504
 		} else {
505
-			$this->show_error( __( 'Could not sent payment reminder to the customer', 'invoicing' ) );
505
+			$this->show_error(__('Could not sent payment reminder to the customer', 'invoicing'));
506 506
 		}
507 507
 
508
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce', 'invoice_id' ) ) );
508
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce', 'invoice_id')));
509 509
 		exit;
510 510
 	}
511 511
 
@@ -515,8 +515,8 @@  discard block
 block discarded – undo
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' ) ) );
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 520
 		exit;
521 521
 
522 522
 	}
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
     public function admin_create_missing_pages() {
529 529
 		$installer = new GetPaid_Installer();
530 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' ) ) );
531
+		$this->show_success(__('GetPaid pages updated.', 'invoicing'));
532
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
533 533
 		exit;
534 534
 	}
535 535
 
@@ -541,35 +541,35 @@  discard block
 block discarded – undo
541 541
 		global $wpdb;
542 542
 		$installer = new GetPaid_Installer();
543 543
 
544
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'" ) != $wpdb->prefix . 'wpinv_subscriptions' ) {
544
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}wpinv_subscriptions'") != $wpdb->prefix . 'wpinv_subscriptions') {
545 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 );
547
+			if ($wpdb->last_error !== '') {
548
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'" ) != $wpdb->prefix . 'getpaid_invoices' ) {
552
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoices'") != $wpdb->prefix . 'getpaid_invoices') {
553 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 );
555
+			if ($wpdb->last_error !== '') {
556
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
557 557
 			}
558 558
 		}
559 559
 
560
-		if ( $wpdb->get_var( "SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'" ) != $wpdb->prefix . 'getpaid_invoice_items' ) {
560
+		if ($wpdb->get_var("SHOW TABLES LIKE '{$wpdb->prefix}getpaid_invoice_items'") != $wpdb->prefix . 'getpaid_invoice_items') {
561 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 );
563
+			if ($wpdb->last_error !== '') {
564
+				$this->show_error(__('Your GetPaid tables have been updated:', 'invoicing') . ' ' . $wpdb->last_error);
565 565
 			}
566 566
 		}
567 567
 
568
-		if ( ! $this->has_notices() ) {
569
-			$this->show_success( __( 'Your GetPaid tables have been updated.', 'invoicing' ) );
568
+		if (!$this->has_notices()) {
569
+			$this->show_success(__('Your GetPaid tables have been updated.', 'invoicing'));
570 570
 		}
571 571
 
572
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
572
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
573 573
 		exit;
574 574
 	}
575 575
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 		$installer->migrate_old_invoices();
585 585
 
586 586
 		// Show an admin message.
587
-		$this->show_success( __( 'Your invoices have been migrated.', 'invoicing' ) );
587
+		$this->show_success(__('Your invoices have been migrated.', 'invoicing'));
588 588
 
589 589
 		// Redirect the admin.
590
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
590
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
591 591
 		exit;
592 592
 
593 593
 	}
@@ -599,18 +599,18 @@  discard block
 block discarded – undo
599 599
     public function admin_download_customers() {
600 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 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 );
609
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
610
+			$post_types .= $wpdb->prepare("post_type=%s OR ", $post_type);
611 611
 		}
612 612
 
613
-		$post_types = rtrim( $post_types, ' OR' );
613
+		$post_types = rtrim($post_types, ' OR');
614 614
 
615 615
 		$customers = $wpdb->get_col(
616 616
 			$wpdb->prepare(
@@ -619,58 +619,58 @@  discard block
 block discarded – undo
619 619
 		);
620 620
 
621 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' ),
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 635
 		);
636 636
 
637 637
 		// Output the csv column headers.
638
-		fputcsv( $output, array_values( $columns ) );
638
+		fputcsv($output, array_values($columns));
639 639
 
640 640
 		// Loop through
641 641
 		$table = new WPInv_Customers_Table();
642
-		foreach ( $customers as $customer_id ) {
642
+		foreach ($customers as $customer_id) {
643 643
 
644
-			$user = get_user_by( 'id', $customer_id );
644
+			$user = get_user_by('id', $customer_id);
645 645
 			$row  = array();
646
-			if ( empty( $user ) ) {
646
+			if (empty($user)) {
647 647
 				continue;
648 648
 			}
649 649
 
650
-			foreach ( array_keys( $columns ) as $column ) {
650
+			foreach (array_keys($columns) as $column) {
651 651
 
652 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 ) );
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 660
 				}
661 661
 
662
-				if ( empty( $value ) ) {
663
-					$value = esc_html( get_user_meta( $user->ID, '_wpinv_' . $column, true ) );
662
+				if (empty($value)) {
663
+					$value = esc_html(get_user_meta($user->ID, '_wpinv_' . $column, true));
664 664
 				}
665 665
 
666 666
 				$row[] = $value;
667 667
 
668 668
 			}
669 669
 
670
-			fputcsv( $output, $row );
670
+			fputcsv($output, $row);
671 671
 		}
672 672
 
673
-		fclose( $output );
673
+		fclose($output);
674 674
 		exit;
675 675
 
676 676
 	}
@@ -680,29 +680,29 @@  discard block
 block discarded – undo
680 680
 	 *
681 681
 	 * @param array $data
682 682
      */
683
-    public function admin_install_plugin( $data ) {
683
+    public function admin_install_plugin($data) {
684 684
 
685
-		if ( ! empty( $data['plugins'] ) ) {
685
+		if (!empty($data['plugins'])) {
686 686
 			include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
687 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 );
694
+				if (!is_wp_error($installed) && $installed) {
695
+					activate_plugin($file, '', false, true);
696 696
 				} else {
697
-					wpinv_error_log( $upgrader->skin->get_upgrade_messages(), false );
697
+					wpinv_error_log($upgrader->skin->get_upgrade_messages(), false);
698 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 );
704
+		$redirect = isset($data['redirect']) ? esc_url_raw($data['redirect']) : admin_url('plugins.php');
705
+		wp_safe_redirect($redirect);
706 706
 		exit;
707 707
 
708 708
 	}
@@ -712,42 +712,42 @@  discard block
 block discarded – undo
712 712
 	 *
713 713
 	 * @param array $data
714 714
      */
715
-    public function admin_connect_gateway( $data ) {
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 );
722
+			if (!empty($connect_url)) {
723
+				wp_redirect($connect_url);
724 724
 				exit;
725 725
 			}
726 726
 
727
-			if ( 'stripe' == $data['plugin'] ) {
727
+			if ('stripe' == $data['plugin']) {
728 728
 				require_once ABSPATH . 'wp-admin/includes/plugin.php';
729 729
 				include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
730 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 );
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 736
 				}
737 737
 
738
-				activate_plugin( 'getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true );
738
+				activate_plugin('getpaid-stripe-payments/getpaid-stripe-payments.php', '', false, true);
739 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 );
741
+			$connect_url = apply_filters("getpaid_get_{$gateway}_connect_url", false, $data);
742
+			if (!empty($connect_url)) {
743
+				wp_redirect($connect_url);
744 744
 				exit;
745 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 );
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 751
 		exit;
752 752
 
753 753
 	}
@@ -761,36 +761,36 @@  discard block
 block discarded – undo
761 761
 
762 762
 		// Fetch all invoices that have discount codes.
763 763
 		$table    = $wpdb->prefix . 'getpaid_invoices';
764
-		$invoices = $wpdb->get_col( "SELECT `post_id` FROM `$table` WHERE `discount` = 0 && `discount_code` <> ''" );
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() ) {
770
+			if (!$invoice->exists()) {
771 771
 				continue;
772 772
 			}
773 773
 
774 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() ) {
775
+			$discount = new WPInv_Discount($invoice->get_discount_code());
776
+			if (!$discount->exists()) {
777 777
 				continue;
778 778
 			}
779 779
 
780
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
780
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
781 781
 			$invoice->recalculate_total();
782 782
 
783
-			if ( $invoice->get_total_discount() > 0 ) {
783
+			if ($invoice->get_total_discount() > 0) {
784 784
 				$invoice->save();
785 785
 			}
786 786
 
787 787
 		}
788 788
 
789 789
 		// Show an admin message.
790
-		$this->show_success( __( 'Discounts have been recalculated.', 'invoicing' ) );
790
+		$this->show_success(__('Discounts have been recalculated.', 'invoicing'));
791 791
 
792 792
 		// Redirect the admin.
793
-		wp_safe_redirect( remove_query_arg( array( 'getpaid-admin-action', 'getpaid-nonce' ) ) );
793
+		wp_safe_redirect(remove_query_arg(array('getpaid-admin-action', 'getpaid-nonce')));
794 794
 		exit;
795 795
 
796 796
 	}
@@ -802,8 +802,8 @@  discard block
 block discarded – undo
802 802
      * @return array
803 803
 	 */
804 804
 	public function get_notices() {
805
-		$notices = get_option( 'wpinv_admin_notices' );
806
-        return is_array( $notices ) ? $notices : array();
805
+		$notices = get_option('wpinv_admin_notices');
806
+        return is_array($notices) ? $notices : array();
807 807
 	}
808 808
 
809 809
 	/**
@@ -813,7 +813,7 @@  discard block
 block discarded – undo
813 813
      * @return array
814 814
 	 */
815 815
 	public function has_notices() {
816
-		return count( $this->get_notices() ) > 0;
816
+		return count($this->get_notices()) > 0;
817 817
 	}
818 818
 
819 819
 	/**
@@ -823,7 +823,7 @@  discard block
 block discarded – undo
823 823
 	 * @since       1.0.19
824 824
 	 */
825 825
 	public function clear_notices() {
826
-		delete_option( 'wpinv_admin_notices' );
826
+		delete_option('wpinv_admin_notices');
827 827
 	}
828 828
 
829 829
 	/**
@@ -832,16 +832,16 @@  discard block
 block discarded – undo
832 832
 	 * @access      public
833 833
 	 * @since       1.0.19
834 834
 	 */
835
-	public function save_notice( $type, $message ) {
835
+	public function save_notice($type, $message) {
836 836
 		$notices = $this->get_notices();
837 837
 
838
-		if ( empty( $notices[ $type ] ) || ! is_array( $notices[ $type ]) ) {
839
-			$notices[ $type ] = array();
838
+		if (empty($notices[$type]) || !is_array($notices[$type])) {
839
+			$notices[$type] = array();
840 840
 		}
841 841
 
842
-		$notices[ $type ][] = $message;
842
+		$notices[$type][] = $message;
843 843
 
844
-		update_option( 'wpinv_admin_notices', $notices );
844
+		update_option('wpinv_admin_notices', $notices);
845 845
 	}
846 846
 
847 847
 	/**
@@ -851,8 +851,8 @@  discard block
 block discarded – undo
851 851
 	 * @access      public
852 852
 	 * @since       1.0.19
853 853
 	 */
854
-	public function show_success( $msg ) {
855
-		$this->save_notice( 'success', $msg );
854
+	public function show_success($msg) {
855
+		$this->save_notice('success', $msg);
856 856
 	}
857 857
 
858 858
 	/**
@@ -862,8 +862,8 @@  discard block
 block discarded – undo
862 862
 	 * @param       string $msg The message to qeue.
863 863
 	 * @since       1.0.19
864 864
 	 */
865
-	public function show_error( $msg ) {
866
-		$this->save_notice( 'error', $msg );
865
+	public function show_error($msg) {
866
+		$this->save_notice('error', $msg);
867 867
 	}
868 868
 
869 869
 	/**
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @param       string $msg The message to qeue.
874 874
 	 * @since       1.0.19
875 875
 	 */
876
-	public function show_warning( $msg ) {
877
-		$this->save_notice( 'warning', $msg );
876
+	public function show_warning($msg) {
877
+		$this->save_notice('warning', $msg);
878 878
 	}
879 879
 
880 880
 	/**
@@ -884,8 +884,8 @@  discard block
 block discarded – undo
884 884
 	 * @param       string $msg The message to qeue.
885 885
 	 * @since       1.0.19
886 886
 	 */
887
-	public function show_info( $msg ) {
888
-		$this->save_notice( 'info', $msg );
887
+	public function show_info($msg) {
888
+		$this->save_notice('info', $msg);
889 889
 	}
890 890
 
891 891
 	/**
@@ -899,30 +899,30 @@  discard block
 block discarded – undo
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 ) ) {
904
+			if (!is_array($messages)) {
905 905
 				continue;
906 906
 			}
907 907
 
908
-            $type  = sanitize_key( $type );
909
-			foreach ( $messages as $message ) {
910
-                $message = wp_kses_post( $message );
908
+            $type = sanitize_key($type);
909
+			foreach ($messages as $message) {
910
+                $message = wp_kses_post($message);
911 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 ) {
916
+		foreach (array('checkout_page', 'invoice_history_page', 'success_page', 'failure_page', 'invoice_subscription_page') as $page) {
917 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' ),
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 921
 					'getpaid-nonce',
922 922
 					'getpaid-nonce'
923 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' );
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 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 927
 				break;
928 928
 			}
Please login to merge, or discard this patch.