Passed
Pull Request — master (#834)
by Kiran
11:34 queued 04:44
created
includes/reports/class-getpaid-invoice-exporter.php 1 patch
Indentation   +232 added lines, -232 removed lines patch added patch discarded remove patch
@@ -12,236 +12,236 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Invoice_Exporter extends GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * Retrieves invoices query args.
17
-	 *
18
-	 * @param string $post_type post type to retrieve.
19
-	 * @param array $args Args to search for.
20
-	 * @return array
21
-	 */
22
-	public function get_invoice_query_args( $post_type, $args ) {
23
-
24
-		$query_args = array(
25
-			'post_type'              => $post_type,
26
-			'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
-			'posts_per_page'         => -1,
28
-			'no_found_rows'          => true,
29
-			'update_post_term_cache' => false,
30
-			'fields'                 => 'ids',
31
-		);
32
-
33
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
-			$query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
-		}
36
-
37
-		$date_query = array();
38
-		if ( ! empty( $args['to_date'] ) ) {
39
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
40
-		}
41
-
42
-		if ( ! empty( $args['from_date'] ) ) {
43
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
44
-		}
45
-
46
-		if ( ! empty( $date_query ) ) {
47
-			$date_query['inclusive']  = true;
48
-			$query_args['date_query'] = array( $date_query );
49
-		}
50
-
51
-		return $query_args;
52
-	}
53
-
54
-	/**
55
-	 * Retrieves invoices.
56
-	 *
57
-	 * @param array $query_args WP_Query args.
58
-	 * @return WPInv_Invoice[]
59
-	 */
60
-	public function get_invoices( $query_args ) {
61
-
62
-		// Get invoices.
63
-		$invoices = new WP_Query( $query_args );
64
-
65
-		// Prepare the results.
66
-		return array_map( 'wpinv_get_invoice', $invoices->posts );
67
-
68
-	}
69
-
70
-	/**
71
-	 * Handles the actual download.
72
-	 *
73
-	 */
74
-	public function export( $post_type, $args ) {
75
-
76
-		$invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
-		$stream    = $this->prepare_output();
78
-		$headers   = $this->get_export_fields( $post_type );
79
-		$file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
-
81
-		if ( 'csv' == $file_type ) {
82
-			$this->download_csv( $invoices, $stream, $headers );
83
-		} elseif ( 'xml' == $file_type ) {
84
-			$this->download_xml( $invoices, $stream, $headers );
85
-		} else {
86
-			$this->download_json( $invoices, $stream, $headers );
87
-		}
88
-
89
-		fclose( $stream );
90
-		exit;
91
-	}
92
-
93
-	/**
94
-	 * Prepares a single invoice for download.
95
-	 *
96
-	 * @param WPInv_Invoice $invoice The invoice to prepare..
97
-	 * @param array $fields The fields to stream.
98
-	 * @since       1.0.19
99
-	 * @return array
100
-	 */
101
-	public function prepare_row( $invoice, $fields ) {
102
-
103
-		$prepared      = array();
104
-		$amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
-		$meta_fields = $this->get_payment_form_meta( $invoice );
106
-
107
-		foreach ( $fields as $field ) {
108
-			$value  = '';
109
-			$method = "get_$field";
110
-
111
-			if ( method_exists( $invoice, $method ) ) {
112
-				$value  = $invoice->$method();
113
-			} else if( strpos( $field, '_' ) === 0 && isset( $meta_fields[ $field ] ) ) {
114
-				$value = $meta_fields[ $field ];
115
-			}
116
-
117
-			if ( in_array( $field, $amount_fields ) ) {
118
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
119
-			}
120
-
121
-			$prepared[ $field ] = wpinv_clean( $value );
122
-
123
-		}
124
-
125
-		return $prepared;
126
-	}
127
-
128
-	/**
129
-	 * Retrieves export fields.
130
-	 *
131
-	 * @param string $post_type
132
-	 * @since       1.0.19
133
-	 * @return array
134
-	 */
135
-	public function get_export_fields( $post_type ) {
136
-
137
-		$fields = array(
138
-			'id',
139
-			'parent_id',
140
-			'status',
141
-			'date_created',
142
-			'date_modified',
143
-			'date_due',
144
-			'date_completed',
145
-			'number',
146
-			'key',
147
-			'description',
148
-			'post_type',
149
-			'mode',
150
-			'customer_id',
151
-			'customer_first_name',
152
-			'customer_last_name',
153
-			'customer_phone',
154
-			'customer_email',
155
-			'customer_country',
156
-			'customer_city',
157
-			'customer_state',
158
-			'customer_zip',
159
-			'customer_company',
160
-			'customer_vat_number',
161
-			'customer_address',
162
-			'subtotal',
163
-			'total_discount',
164
-			'total_tax',
165
-			'total_fees',
166
-			'fees',
167
-			'discounts',
168
-			'taxes',
169
-			'cart_details',
170
-			'item_ids',
171
-			'payment_form',
172
-			'discount_code',
173
-			'gateway',
174
-			'transaction_id',
175
-			'currency',
176
-			'disable_taxes',
177
-			'subscription_id',
178
-			'remote_subscription_id',
179
-			'is_viewed',
180
-			'email_cc',
181
-			'template',
182
-			'created_via',
183
-    	);
184
-
185
-		// Payment form meta fields.
186
-		$meta_fields = getpaid_get_payment_form_custom_fields();
187
-
188
-		if ( ! empty( $meta_fields ) ) {
189
-			foreach ( $meta_fields as $field_key => $field_label ) {
190
-				$fields[] = $field_key;
191
-			}
192
-		}
193
-
194
-		return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
195
-	}
196
-
197
-	/**
198
-	 * Retrieves amount fields.
199
-	 *
200
-	 * @param string $post_type
201
-	 * @since       1.0.19
202
-	 * @return array
203
-	 */
204
-	public function get_amount_fields( $post_type ) {
205
-
206
-		$fields = array(
207
-			'subtotal',
208
-			'total_discount',
209
-			'total_tax',
210
-			'total_fees',
211
-    	);
212
-
213
-		return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
214
-	}
215
-
216
-	/**
217
-	 * Retrieves payment form meta fields.
218
-	 *
219
-	 * @since 2.8.23
220
-	 *
221
-	 * @return array
222
-	 */
223
-	public function get_payment_form_meta( $invoice ) {
224
-		// Payment form meta fields.
225
-		$field_keys = getpaid_get_payment_form_custom_fields();
226
-		$meta = get_post_meta( $invoice->get_id(), 'additional_meta_data', true );
227
-
228
-		$field_values = array();
229
-		if ( ! empty( $field_keys ) ) {
230
-			foreach ( $field_keys as $field_key => $field_label ) {
231
-				$value = '';
232
-
233
-				if ( ! empty( $meta ) ) {
234
-					foreach ( $meta as $meta_label => $meta_value ) {
235
-						if ( getpaid_strtolower( wpinv_clean( wp_unslash( $meta_label ) ) ) == getpaid_strtolower( $field_label ) ) {
236
-							$value = $meta_value;
237
-						}
238
-					}
239
-				}
240
-
241
-				$field_values[ $field_key ] = $value;
242
-			}
243
-		}
244
-
245
-		return $field_values;
246
-	}
15
+    /**
16
+     * Retrieves invoices query args.
17
+     *
18
+     * @param string $post_type post type to retrieve.
19
+     * @param array $args Args to search for.
20
+     * @return array
21
+     */
22
+    public function get_invoice_query_args( $post_type, $args ) {
23
+
24
+        $query_args = array(
25
+            'post_type'              => $post_type,
26
+            'post_status'            => array_keys( wpinv_get_invoice_statuses( true, false, $post_type ) ),
27
+            'posts_per_page'         => -1,
28
+            'no_found_rows'          => true,
29
+            'update_post_term_cache' => false,
30
+            'fields'                 => 'ids',
31
+        );
32
+
33
+        if ( ! empty( $args['status'] ) && in_array( $args['status'], $query_args['post_status'], true ) ) {
34
+            $query_args['post_status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
35
+        }
36
+
37
+        $date_query = array();
38
+        if ( ! empty( $args['to_date'] ) ) {
39
+            $date_query['before'] = wpinv_clean( $args['to_date'] );
40
+        }
41
+
42
+        if ( ! empty( $args['from_date'] ) ) {
43
+            $date_query['after'] = wpinv_clean( $args['from_date'] );
44
+        }
45
+
46
+        if ( ! empty( $date_query ) ) {
47
+            $date_query['inclusive']  = true;
48
+            $query_args['date_query'] = array( $date_query );
49
+        }
50
+
51
+        return $query_args;
52
+    }
53
+
54
+    /**
55
+     * Retrieves invoices.
56
+     *
57
+     * @param array $query_args WP_Query args.
58
+     * @return WPInv_Invoice[]
59
+     */
60
+    public function get_invoices( $query_args ) {
61
+
62
+        // Get invoices.
63
+        $invoices = new WP_Query( $query_args );
64
+
65
+        // Prepare the results.
66
+        return array_map( 'wpinv_get_invoice', $invoices->posts );
67
+
68
+    }
69
+
70
+    /**
71
+     * Handles the actual download.
72
+     *
73
+     */
74
+    public function export( $post_type, $args ) {
75
+
76
+        $invoices  = $this->get_invoices( $this->get_invoice_query_args( $post_type, $args ) );
77
+        $stream    = $this->prepare_output();
78
+        $headers   = $this->get_export_fields( $post_type );
79
+        $file_type = $this->prepare_file_type( strtolower( getpaid_get_post_type_label( $post_type ) ) );
80
+
81
+        if ( 'csv' == $file_type ) {
82
+            $this->download_csv( $invoices, $stream, $headers );
83
+        } elseif ( 'xml' == $file_type ) {
84
+            $this->download_xml( $invoices, $stream, $headers );
85
+        } else {
86
+            $this->download_json( $invoices, $stream, $headers );
87
+        }
88
+
89
+        fclose( $stream );
90
+        exit;
91
+    }
92
+
93
+    /**
94
+     * Prepares a single invoice for download.
95
+     *
96
+     * @param WPInv_Invoice $invoice The invoice to prepare..
97
+     * @param array $fields The fields to stream.
98
+     * @since       1.0.19
99
+     * @return array
100
+     */
101
+    public function prepare_row( $invoice, $fields ) {
102
+
103
+        $prepared      = array();
104
+        $amount_fields = $this->get_amount_fields( $invoice->get_post_type() );
105
+        $meta_fields = $this->get_payment_form_meta( $invoice );
106
+
107
+        foreach ( $fields as $field ) {
108
+            $value  = '';
109
+            $method = "get_$field";
110
+
111
+            if ( method_exists( $invoice, $method ) ) {
112
+                $value  = $invoice->$method();
113
+            } else if( strpos( $field, '_' ) === 0 && isset( $meta_fields[ $field ] ) ) {
114
+                $value = $meta_fields[ $field ];
115
+            }
116
+
117
+            if ( in_array( $field, $amount_fields ) ) {
118
+                $value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
119
+            }
120
+
121
+            $prepared[ $field ] = wpinv_clean( $value );
122
+
123
+        }
124
+
125
+        return $prepared;
126
+    }
127
+
128
+    /**
129
+     * Retrieves export fields.
130
+     *
131
+     * @param string $post_type
132
+     * @since       1.0.19
133
+     * @return array
134
+     */
135
+    public function get_export_fields( $post_type ) {
136
+
137
+        $fields = array(
138
+            'id',
139
+            'parent_id',
140
+            'status',
141
+            'date_created',
142
+            'date_modified',
143
+            'date_due',
144
+            'date_completed',
145
+            'number',
146
+            'key',
147
+            'description',
148
+            'post_type',
149
+            'mode',
150
+            'customer_id',
151
+            'customer_first_name',
152
+            'customer_last_name',
153
+            'customer_phone',
154
+            'customer_email',
155
+            'customer_country',
156
+            'customer_city',
157
+            'customer_state',
158
+            'customer_zip',
159
+            'customer_company',
160
+            'customer_vat_number',
161
+            'customer_address',
162
+            'subtotal',
163
+            'total_discount',
164
+            'total_tax',
165
+            'total_fees',
166
+            'fees',
167
+            'discounts',
168
+            'taxes',
169
+            'cart_details',
170
+            'item_ids',
171
+            'payment_form',
172
+            'discount_code',
173
+            'gateway',
174
+            'transaction_id',
175
+            'currency',
176
+            'disable_taxes',
177
+            'subscription_id',
178
+            'remote_subscription_id',
179
+            'is_viewed',
180
+            'email_cc',
181
+            'template',
182
+            'created_via',
183
+        );
184
+
185
+        // Payment form meta fields.
186
+        $meta_fields = getpaid_get_payment_form_custom_fields();
187
+
188
+        if ( ! empty( $meta_fields ) ) {
189
+            foreach ( $meta_fields as $field_key => $field_label ) {
190
+                $fields[] = $field_key;
191
+            }
192
+        }
193
+
194
+        return apply_filters( 'getpaid_invoice_exporter_get_fields', $fields, $post_type );
195
+    }
196
+
197
+    /**
198
+     * Retrieves amount fields.
199
+     *
200
+     * @param string $post_type
201
+     * @since       1.0.19
202
+     * @return array
203
+     */
204
+    public function get_amount_fields( $post_type ) {
205
+
206
+        $fields = array(
207
+            'subtotal',
208
+            'total_discount',
209
+            'total_tax',
210
+            'total_fees',
211
+        );
212
+
213
+        return apply_filters( 'getpaid_invoice_exporter_get_amount_fields', $fields, $post_type );
214
+    }
215
+
216
+    /**
217
+     * Retrieves payment form meta fields.
218
+     *
219
+     * @since 2.8.23
220
+     *
221
+     * @return array
222
+     */
223
+    public function get_payment_form_meta( $invoice ) {
224
+        // Payment form meta fields.
225
+        $field_keys = getpaid_get_payment_form_custom_fields();
226
+        $meta = get_post_meta( $invoice->get_id(), 'additional_meta_data', true );
227
+
228
+        $field_values = array();
229
+        if ( ! empty( $field_keys ) ) {
230
+            foreach ( $field_keys as $field_key => $field_label ) {
231
+                $value = '';
232
+
233
+                if ( ! empty( $meta ) ) {
234
+                    foreach ( $meta as $meta_label => $meta_value ) {
235
+                        if ( getpaid_strtolower( wpinv_clean( wp_unslash( $meta_label ) ) ) == getpaid_strtolower( $field_label ) ) {
236
+                            $value = $meta_value;
237
+                        }
238
+                    }
239
+                }
240
+
241
+                $field_values[ $field_key ] = $value;
242
+            }
243
+        }
244
+
245
+        return $field_values;
246
+    }
247 247
 }
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
  * @param string $default_path The root path to the default template. Defaults to invoicing/templates
141 141
  */
142 142
 function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) {
143
-	return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
143
+    return getpaid_template()->get_template( $template_name, $args, $template_path, $default_path );
144 144
 }
145 145
 
146 146
 /**
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
  * @return string
159 159
  */
160 160
 function wpinv_get_theme_template_dir_name() {
161
-	return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
161
+    return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) );
162 162
 }
163 163
 
164 164
 /**
@@ -175,125 +175,125 @@  discard block
 block discarded – undo
175 175
 }
176 176
 
177 177
 function wpinv_get_template_part( $slug, $name = null, $load = true ) {
178
-	do_action( 'get_template_part_' . $slug, $slug, $name );
178
+    do_action( 'get_template_part_' . $slug, $slug, $name );
179 179
 
180
-	// Setup possible parts
181
-	$templates = array();
182
-	if ( isset( $name ) ) {
183
-		$templates[] = $slug . '-' . $name . '.php';
180
+    // Setup possible parts
181
+    $templates = array();
182
+    if ( isset( $name ) ) {
183
+        $templates[] = $slug . '-' . $name . '.php';
184 184
     }
185
-	$templates[] = $slug . '.php';
185
+    $templates[] = $slug . '.php';
186 186
 
187
-	// Allow template parts to be filtered
188
-	$templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
187
+    // Allow template parts to be filtered
188
+    $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name );
189 189
 
190
-	// Return the part that is found
191
-	return wpinv_locate_tmpl( $templates, $load, false );
190
+    // Return the part that is found
191
+    return wpinv_locate_tmpl( $templates, $load, false );
192 192
 }
193 193
 
194 194
 function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) {
195
-	// No file found yet
196
-	$located = false;
195
+    // No file found yet
196
+    $located = false;
197 197
 
198
-	// Try to find a template file
199
-	foreach ( (array)$template_names as $template_name ) {
198
+    // Try to find a template file
199
+    foreach ( (array)$template_names as $template_name ) {
200 200
 
201
-		// Continue if template is empty
202
-		if ( empty( $template_name ) ) {
203
-			continue;
201
+        // Continue if template is empty
202
+        if ( empty( $template_name ) ) {
203
+            continue;
204 204
         }
205 205
 
206
-		// Trim off any slashes from the template name
207
-		$template_name = ltrim( $template_name, '/' );
206
+        // Trim off any slashes from the template name
207
+        $template_name = ltrim( $template_name, '/' );
208 208
 
209
-		// try locating this template file by looping through the template paths
210
-		foreach ( wpinv_get_theme_template_paths() as $template_path ) {
209
+        // try locating this template file by looping through the template paths
210
+        foreach ( wpinv_get_theme_template_paths() as $template_path ) {
211 211
 
212
-			if ( file_exists( $template_path . $template_name ) ) {
213
-				$located = $template_path . $template_name;
214
-				break;
215
-			}
216
-		}
212
+            if ( file_exists( $template_path . $template_name ) ) {
213
+                $located = $template_path . $template_name;
214
+                break;
215
+            }
216
+        }
217 217
 
218
-		if ( ! empty( $located ) ) {
219
-			break;
220
-		}
221
-	}
218
+        if ( ! empty( $located ) ) {
219
+            break;
220
+        }
221
+    }
222 222
 
223
-	if ( ( true == $load ) && ! empty( $located ) ) {
224
-		load_template( $located, $require_once );
223
+    if ( ( true == $load ) && ! empty( $located ) ) {
224
+        load_template( $located, $require_once );
225 225
     }
226 226
 
227
-	return $located;
227
+    return $located;
228 228
 }
229 229
 
230 230
 function wpinv_get_theme_template_paths() {
231
-	$template_dir = wpinv_get_theme_template_dir_name();
231
+    $template_dir = wpinv_get_theme_template_dir_name();
232 232
 
233
-	$file_paths = array(
234
-		1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
-		10  => trailingslashit( get_template_directory() ) . $template_dir,
236
-		100 => wpinv_get_templates_dir(),
237
-	);
233
+    $file_paths = array(
234
+        1   => trailingslashit( get_stylesheet_directory() ) . $template_dir,
235
+        10  => trailingslashit( get_template_directory() ) . $template_dir,
236
+        100 => wpinv_get_templates_dir(),
237
+    );
238 238
 
239
-	$file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
239
+    $file_paths = apply_filters( 'wpinv_template_paths', $file_paths );
240 240
 
241
-	// sort the file paths based on priority
242
-	ksort( $file_paths, SORT_NUMERIC );
241
+    // sort the file paths based on priority
242
+    ksort( $file_paths, SORT_NUMERIC );
243 243
 
244
-	return array_map( 'trailingslashit', $file_paths );
244
+    return array_map( 'trailingslashit', $file_paths );
245 245
 }
246 246
 
247 247
 function wpinv_checkout_meta_tags() {
248 248
 
249
-	$pages   = array();
250
-	$pages[] = wpinv_get_option( 'success_page' );
251
-	$pages[] = wpinv_get_option( 'failure_page' );
252
-	$pages[] = wpinv_get_option( 'invoice_history_page' );
253
-	$pages[] = wpinv_get_option( 'invoice_subscription_page' );
249
+    $pages   = array();
250
+    $pages[] = wpinv_get_option( 'success_page' );
251
+    $pages[] = wpinv_get_option( 'failure_page' );
252
+    $pages[] = wpinv_get_option( 'invoice_history_page' );
253
+    $pages[] = wpinv_get_option( 'invoice_subscription_page' );
254 254
 
255
-	if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
-		return;
257
-	}
255
+    if ( ! wpinv_is_checkout() && ! is_page( $pages ) ) {
256
+        return;
257
+    }
258 258
 
259
-	echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
259
+    echo '<meta name="robots" content="noindex,nofollow" />' . "\n";
260 260
 }
261 261
 add_action( 'wp_head', 'wpinv_checkout_meta_tags' );
262 262
 
263 263
 function wpinv_add_body_classes( $class ) {
264
-	$classes = (array)$class;
264
+    $classes = (array)$class;
265 265
 
266
-	if ( wpinv_is_checkout() ) {
267
-		$classes[] = 'wpinv-checkout';
268
-		$classes[] = 'wpinv-page';
269
-	}
266
+    if ( wpinv_is_checkout() ) {
267
+        $classes[] = 'wpinv-checkout';
268
+        $classes[] = 'wpinv-page';
269
+    }
270 270
 
271
-	if ( wpinv_is_success_page() ) {
272
-		$classes[] = 'wpinv-success';
273
-		$classes[] = 'wpinv-page';
274
-	}
271
+    if ( wpinv_is_success_page() ) {
272
+        $classes[] = 'wpinv-success';
273
+        $classes[] = 'wpinv-page';
274
+    }
275 275
 
276
-	if ( wpinv_is_failed_transaction_page() ) {
277
-		$classes[] = 'wpinv-failed-transaction';
278
-		$classes[] = 'wpinv-page';
279
-	}
276
+    if ( wpinv_is_failed_transaction_page() ) {
277
+        $classes[] = 'wpinv-failed-transaction';
278
+        $classes[] = 'wpinv-page';
279
+    }
280 280
 
281
-	if ( wpinv_is_invoice_history_page() ) {
282
-		$classes[] = 'wpinv-history';
283
-		$classes[] = 'wpinv-page';
284
-	}
281
+    if ( wpinv_is_invoice_history_page() ) {
282
+        $classes[] = 'wpinv-history';
283
+        $classes[] = 'wpinv-page';
284
+    }
285 285
 
286
-	if ( wpinv_is_subscriptions_history_page() ) {
287
-		$classes[] = 'wpinv-subscription';
288
-		$classes[] = 'wpinv-page';
289
-	}
286
+    if ( wpinv_is_subscriptions_history_page() ) {
287
+        $classes[] = 'wpinv-subscription';
288
+        $classes[] = 'wpinv-page';
289
+    }
290 290
 
291
-	if ( wpinv_is_test_mode() ) {
292
-		$classes[] = 'wpinv-test-mode';
293
-		$classes[] = 'wpinv-page';
294
-	}
291
+    if ( wpinv_is_test_mode() ) {
292
+        $classes[] = 'wpinv-test-mode';
293
+        $classes[] = 'wpinv-page';
294
+    }
295 295
 
296
-	return array_unique( $classes );
296
+    return array_unique( $classes );
297 297
 }
298 298
 add_filter( 'body_class', 'wpinv_add_body_classes' );
299 299
 
@@ -467,16 +467,16 @@  discard block
 block discarded – undo
467 467
 
468 468
     wpinv_html_select(
469 469
         array(
470
-			'name'             => $args['name'],
471
-			'selected'         => $args['selected'],
472
-			'id'               => $args['id'],
473
-			'class'            => $args['class'],
474
-			'options'          => $options,
475
-			'multiple'         => $args['multiple'],
476
-			'placeholder'      => $args['placeholder'],
477
-			'show_option_all'  => $args['show_option_all'],
478
-			'show_option_none' => $args['show_option_none'],
479
-			'data'             => $args['data'],
470
+            'name'             => $args['name'],
471
+            'selected'         => $args['selected'],
472
+            'id'               => $args['id'],
473
+            'class'            => $args['class'],
474
+            'options'          => $options,
475
+            'multiple'         => $args['multiple'],
476
+            'placeholder'      => $args['placeholder'],
477
+            'show_option_all'  => $args['show_option_all'],
478
+            'show_option_none' => $args['show_option_none'],
479
+            'data'             => $args['data'],
480 480
         )
481 481
     );
482 482
 
@@ -776,21 +776,21 @@  discard block
 block discarded – undo
776 776
 
777 777
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
778 778
 
779
-	// Remove unavailable tags.
779
+    // Remove unavailable tags.
780 780
     $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
781 781
 
782 782
     // Clean up white space.
783
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
783
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
784 784
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
785 785
 
786 786
     // Break newlines apart and remove empty lines/trim commas and white space.
787
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
787
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
788 788
 
789 789
     // Add html breaks.
790
-	$formatted_address = implode( $separator, $formatted_address );
790
+    $formatted_address = implode( $separator, $formatted_address );
791 791
 
792
-	// We're done!
793
-	return $formatted_address;
792
+    // We're done!
793
+    return $formatted_address;
794 794
 
795 795
 }
796 796
 
@@ -836,7 +836,7 @@  discard block
 block discarded – undo
836 836
 function getpaid_display_invoice_subscriptions( $invoice ) {
837 837
 
838 838
     // Subscriptions.
839
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
839
+    $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
840 840
 
841 841
     if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
842 842
         return;
@@ -1052,7 +1052,7 @@  discard block
 block discarded – undo
1052 1052
 }
1053 1053
 
1054 1054
 function wpinv_empty_cart_message() {
1055
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1055
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1056 1056
 }
1057 1057
 
1058 1058
 /**
@@ -1250,9 +1250,9 @@  discard block
 block discarded – undo
1250 1250
 
1251 1251
     if ( 0 == count( $form->get_items() ) ) {
1252 1252
         aui()->alert(
1253
-			array(
1254
-				'type'    => 'warning',
1255
-				'content' => __( 'No published items found', 'invoicing' ),
1253
+            array(
1254
+                'type'    => 'warning',
1255
+                'content' => __( 'No published items found', 'invoicing' ),
1256 1256
             ),
1257 1257
             true
1258 1258
         );
@@ -1275,10 +1275,10 @@  discard block
 block discarded – undo
1275 1275
     $invoice = wpinv_get_invoice( $invoice_id );
1276 1276
 
1277 1277
     if ( empty( $invoice ) ) {
1278
-		aui()->alert(
1279
-			array(
1280
-				'type'    => 'warning',
1281
-				'content' => __( 'Invoice not found', 'invoicing' ),
1278
+        aui()->alert(
1279
+            array(
1280
+                'type'    => 'warning',
1281
+                'content' => __( 'Invoice not found', 'invoicing' ),
1282 1282
             ),
1283 1283
             true
1284 1284
         );
@@ -1286,10 +1286,10 @@  discard block
 block discarded – undo
1286 1286
     }
1287 1287
 
1288 1288
     if ( $invoice->is_paid() ) {
1289
-		aui()->alert(
1290
-			array(
1291
-				'type'    => 'warning',
1292
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1289
+        aui()->alert(
1290
+            array(
1291
+                'type'    => 'warning',
1292
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
1293 1293
             ),
1294 1294
             true
1295 1295
         );
@@ -1354,7 +1354,7 @@  discard block
 block discarded – undo
1354 1354
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1355 1355
     }
1356 1356
 
1357
-	if ( ! empty( $items ) ) {
1357
+    if ( ! empty( $items ) ) {
1358 1358
         $items  = esc_attr( $items );
1359 1359
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1360 1360
     }
@@ -1554,21 +1554,21 @@  discard block
 block discarded – undo
1554 1554
 
1555 1555
         return aui()->select(
1556 1556
             array(
1557
-				'options'          => $states,
1558
-				'name'             => esc_attr( $field_name ),
1559
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
-				'value'            => sanitize_text_field( $state ),
1561
-				'placeholder'      => $placeholder,
1562
-				'required'         => $required,
1563
-				'label'            => wp_kses_post( $label ),
1564
-				'label_type'       => 'vertical',
1565
-				'help_text'        => $help_text,
1566
-				'class'            => 'getpaid-address-field wpinv_state',
1567
-				'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1568
-				'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1569
-				'extra_attributes' => array(
1570
-					'autocomplete' => 'address-level1',
1571
-				),
1557
+                'options'          => $states,
1558
+                'name'             => esc_attr( $field_name ),
1559
+                'id'               => sanitize_html_class( $field_name ) . $uniqid,
1560
+                'value'            => sanitize_text_field( $state ),
1561
+                'placeholder'      => $placeholder,
1562
+                'required'         => $required,
1563
+                'label'            => wp_kses_post( $label ),
1564
+                'label_type'       => 'vertical',
1565
+                'help_text'        => $help_text,
1566
+                'class'            => 'getpaid-address-field wpinv_state',
1567
+                'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1568
+                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1569
+                'extra_attributes' => array(
1570
+                    'autocomplete' => 'address-level1',
1571
+                ),
1572 1572
             ),
1573 1573
             $echo
1574 1574
         );
@@ -1664,34 +1664,34 @@  discard block
 block discarded – undo
1664 1664
  * @return array Array of custom fields.
1665 1665
  */
1666 1666
 function getpaid_get_payment_form_custom_fields() {
1667
-	global $wpdb, $payment_form_meta_fields;
1667
+    global $wpdb, $payment_form_meta_fields;
1668 1668
 
1669
-	if ( ! empty( $payment_form_meta_fields ) ) {
1670
-		return $payment_form_meta_fields;
1671
-	}
1669
+    if ( ! empty( $payment_form_meta_fields ) ) {
1670
+        return $payment_form_meta_fields;
1671
+    }
1672 1672
 
1673
-	$results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1673
+    $results = $wpdb->get_results( "SELECT `pm`.`meta_value` FROM `{$wpdb->postmeta}` AS pm LEFT JOIN `{$wpdb->posts}` AS p ON p.ID = pm.post_id WHERE `pm`.`meta_key` = 'wpinv_form_elements' AND `p`.`post_type` = 'wpi_payment_form'" );
1674 1674
 
1675
-	$meta_fields = array();
1675
+    $meta_fields = array();
1676 1676
 
1677
-	if ( ! empty( $results ) ) {
1678
-		foreach ( $results as $row ) {
1679
-			$fields = maybe_unserialize( $row->meta_value );
1677
+    if ( ! empty( $results ) ) {
1678
+        foreach ( $results as $row ) {
1679
+            $fields = maybe_unserialize( $row->meta_value );
1680 1680
 
1681
-			if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
-				foreach ( $fields as $field ) {
1683
-					$label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1681
+            if ( ! empty( $fields ) && is_array( $fields ) ) {
1682
+                foreach ( $fields as $field ) {
1683
+                    $label = ! empty( $field['add_meta'] ) && ! empty( $field['label'] ) ? wpinv_clean( wp_unslash( $field['label'] ) ) : '';
1684 1684
 
1685
-					if ( $label ) {
1686
-						$field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
-						$meta_fields[ $field_key ] = $label;
1688
-					}
1689
-				}
1690
-			}
1691
-		}
1692
-	}
1685
+                    if ( $label ) {
1686
+                        $field_key = '_' . str_replace( array( ' ', "'", '"', ',' ), array( '_', '', '', '_' ), getpaid_strtolower( $label ) );
1687
+                        $meta_fields[ $field_key ] = $label;
1688
+                    }
1689
+                }
1690
+            }
1691
+        }
1692
+    }
1693 1693
 
1694
-	$payment_form_meta_fields = $meta_fields;
1694
+    $payment_form_meta_fields = $meta_fields;
1695 1695
 
1696
-	return $meta_fields;
1696
+    return $meta_fields;
1697 1697
 }
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Indentation   +75 added lines, -75 removed lines patch added patch discarded remove patch
@@ -137,13 +137,13 @@  discard block
 block discarded – undo
137 137
  */
138 138
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
139 139
 
140
-	$invoice_statuses = array(
141
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
140
+    $invoice_statuses = array(
141
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
142 142
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
143 143
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
144
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
145
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
146
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
144
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
145
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
146
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
147 147
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
148 148
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
149 149
     );
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
         $invoice = $invoice->get_post_type();
161 161
     }
162 162
 
163
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
163
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
164 164
 }
165 165
 
166 166
 /**
@@ -278,25 +278,25 @@  discard block
 block discarded – undo
278 278
  * @return string
279 279
  */
280 280
 function getpaid_get_price_format() {
281
-	$currency_pos = wpinv_currency_position();
282
-	$format       = '%1$s%2$s';
283
-
284
-	switch ( $currency_pos ) {
285
-		case 'left':
286
-			$format = '%1$s%2$s';
287
-			break;
288
-		case 'right':
289
-			$format = '%2$s%1$s';
290
-			break;
291
-		case 'left_space':
292
-			$format = '%1$s&nbsp;%2$s';
293
-			break;
294
-		case 'right_space':
295
-			$format = '%2$s&nbsp;%1$s';
296
-			break;
297
-	}
298
-
299
-	return apply_filters( 'getpaid_price_format', $format, $currency_pos );
281
+    $currency_pos = wpinv_currency_position();
282
+    $format       = '%1$s%2$s';
283
+
284
+    switch ( $currency_pos ) {
285
+        case 'left':
286
+            $format = '%1$s%2$s';
287
+            break;
288
+        case 'right':
289
+            $format = '%2$s%1$s';
290
+            break;
291
+        case 'left_space':
292
+            $format = '%1$s&nbsp;%2$s';
293
+            break;
294
+        case 'right_space':
295
+            $format = '%2$s&nbsp;%1$s';
296
+            break;
297
+    }
298
+
299
+    return apply_filters( 'getpaid_price_format', $format, $currency_pos );
300 300
 }
301 301
 
302 302
 /**
@@ -402,13 +402,13 @@  discard block
 block discarded – undo
402 402
  * @param mixed  $value Value.
403 403
  */
404 404
 function getpaid_maybe_define_constant( $name, $value ) {
405
-	if ( ! defined( $name ) ) {
406
-		define( $name, $value );
407
-	}
405
+    if ( ! defined( $name ) ) {
406
+        define( $name, $value );
407
+    }
408 408
 }
409 409
 
410 410
 function wpinv_get_php_arg_separator_output() {
411
-	return ini_get( 'arg_separator.output' );
411
+    return ini_get( 'arg_separator.output' );
412 412
 }
413 413
 
414 414
 function wpinv_rgb_from_hex( $color ) {
@@ -719,16 +719,16 @@  discard block
 block discarded – undo
719 719
     return wp_kses(
720 720
         html_entity_decode( $var ),
721 721
         array(
722
-			'br'     => array(),
723
-			'em'     => array(),
724
-			'strong' => array(),
725
-			'b'      => array(),
726
-			'small'  => array(),
727
-			'span'   => array(),
728
-			'ul'     => array(),
729
-			'li'     => array(),
730
-			'ol'     => array(),
731
-			'p'      => array(),
722
+            'br'     => array(),
723
+            'em'     => array(),
724
+            'strong' => array(),
725
+            'b'      => array(),
726
+            'small'  => array(),
727
+            'span'   => array(),
728
+            'ul'     => array(),
729
+            'li'     => array(),
730
+            'ol'     => array(),
731
+            'p'      => array(),
732 732
         )
733 733
     );
734 734
 }
@@ -779,11 +779,11 @@  discard block
 block discarded – undo
779 779
         $list = array();
780 780
     }
781 781
 
782
-	if ( ! is_array( $list ) ) {
783
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
784
-	}
782
+    if ( ! is_array( $list ) ) {
783
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
784
+    }
785 785
 
786
-	return $list;
786
+    return $list;
787 787
 }
788 788
 
789 789
 /**
@@ -824,17 +824,17 @@  discard block
 block discarded – undo
824 824
  */
825 825
 function wpinv_clean( $var ) {
826 826
 
827
-	if ( is_array( $var ) ) {
828
-		return array_map( 'wpinv_clean', $var );
827
+    if ( is_array( $var ) ) {
828
+        return array_map( 'wpinv_clean', $var );
829 829
     }
830 830
 
831 831
     if ( is_object( $var ) ) {
832
-		$object_vars = get_object_vars( $var );
833
-		foreach ( $object_vars as $property_name => $property_value ) {
834
-			$var->$property_name = wpinv_clean( $property_value );
832
+        $object_vars = get_object_vars( $var );
833
+        foreach ( $object_vars as $property_name => $property_value ) {
834
+            $var->$property_name = wpinv_clean( $property_value );
835 835
         }
836 836
         return $var;
837
-	}
837
+    }
838 838
 
839 839
     return is_string( $var ) ? sanitize_text_field( stripslashes( $var ) ) : $var;
840 840
 }
@@ -847,7 +847,7 @@  discard block
 block discarded – undo
847 847
  */
848 848
 function getpaid_convert_price_string_to_options( $str ) {
849 849
 
850
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
850
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
851 851
     $options     = array();
852 852
 
853 853
     foreach ( $raw_options as $option ) {
@@ -936,7 +936,7 @@  discard block
 block discarded – undo
936 936
  * @return string
937 937
  */
938 938
 function getpaid_date_format() {
939
-	return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
939
+    return apply_filters( 'getpaid_date_format', get_option( 'date_format' ) );
940 940
 }
941 941
 
942 942
 /**
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
  * @return string
946 946
  */
947 947
 function getpaid_time_format() {
948
-	return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
948
+    return apply_filters( 'getpaid_time_format', get_option( 'time_format' ) );
949 949
 }
950 950
 
951 951
 /**
@@ -958,15 +958,15 @@  discard block
 block discarded – undo
958 958
 function getpaid_limit_length( $string, $limit ) {
959 959
     $str_limit = $limit - 3;
960 960
 
961
-	if ( function_exists( 'mb_strimwidth' ) ) {
962
-		if ( mb_strlen( $string ) > $limit ) {
963
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
964
-		}
965
-	} else {
966
-		if ( strlen( $string ) > $limit ) {
967
-			$string = substr( $string, 0, $str_limit ) . '...';
968
-		}
969
-	}
961
+    if ( function_exists( 'mb_strimwidth' ) ) {
962
+        if ( mb_strlen( $string ) > $limit ) {
963
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
964
+        }
965
+    } else {
966
+        if ( strlen( $string ) > $limit ) {
967
+            $string = substr( $string, 0, $str_limit ) . '...';
968
+        }
969
+    }
970 970
     return $string;
971 971
 
972 972
 }
@@ -1096,12 +1096,12 @@  discard block
 block discarded – undo
1096 1096
     $types = get_allowed_mime_types();
1097 1097
 
1098 1098
     if ( isset( $types['htm|html'] ) ) {
1099
-		unset( $types['htm|html'] );
1100
-	}
1099
+        unset( $types['htm|html'] );
1100
+    }
1101 1101
 
1102 1102
     if ( isset( $types['js'] ) ) {
1103
-		unset( $types['js'] );
1104
-	}
1103
+        unset( $types['js'] );
1104
+    }
1105 1105
 
1106 1106
     return $types;
1107 1107
 
@@ -1157,11 +1157,11 @@  discard block
 block discarded – undo
1157 1157
  * @return string Returns converted string.
1158 1158
  */
1159 1159
 function getpaid_strtolower( $string, $charset = 'UTF-8' ) {
1160
-	if ( function_exists( 'mb_convert_case' ) ) {
1161
-		return mb_convert_case( $string, MB_CASE_LOWER, $charset );
1162
-	} else {
1163
-		return strtolower( $string );
1164
-	}
1160
+    if ( function_exists( 'mb_convert_case' ) ) {
1161
+        return mb_convert_case( $string, MB_CASE_LOWER, $charset );
1162
+    } else {
1163
+        return strtolower( $string );
1164
+    }
1165 1165
 }
1166 1166
 
1167 1167
 /**
@@ -1174,9 +1174,9 @@  discard block
 block discarded – undo
1174 1174
  * @return string Returns converted string.
1175 1175
  */
1176 1176
 function getpaid_strtoupper( $string, $charset = 'UTF-8' ) {
1177
-	if ( function_exists( 'mb_convert_case' ) ) {
1178
-		return mb_convert_case( $string, MB_CASE_UPPER, $charset );
1179
-	} else {
1180
-		return strtoupper( $string );
1181
-	}
1177
+    if ( function_exists( 'mb_convert_case' ) ) {
1178
+        return mb_convert_case( $string, MB_CASE_UPPER, $charset );
1179
+    } else {
1180
+        return strtoupper( $string );
1181
+    }
1182 1182
 }
1183 1183
\ No newline at end of file
Please login to merge, or discard this patch.
invoicing.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@  discard block
 block discarded – undo
19 19
 
20 20
 // Define constants.
21 21
 if ( ! defined( 'WPINV_PLUGIN_FILE' ) ) {
22
-	define( 'WPINV_PLUGIN_FILE', __FILE__ );
22
+    define( 'WPINV_PLUGIN_FILE', __FILE__ );
23 23
 }
24 24
 
25 25
 if ( ! defined( 'WPINV_VERSION' ) ) {
26
-	define( 'WPINV_VERSION', '2.8.23' );
26
+    define( 'WPINV_VERSION', '2.8.23' );
27 27
 }
28 28
 
29 29
 // Include the main Invoicing class.
30 30
 if ( ! class_exists( 'WPInv_Plugin', false ) ) {
31
-	require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
31
+    require_once plugin_dir_path( WPINV_PLUGIN_FILE ) . 'includes/class-wpinv.php';
32 32
 }
33 33
 
34 34
 /**
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $GLOBALS['invoicing'] = new WPInv_Plugin();
44 44
     }
45 45
 
46
-	return $GLOBALS['invoicing'];
46
+    return $GLOBALS['invoicing'];
47 47
 }
48 48
 
49 49
 /**
Please login to merge, or discard this patch.
templates/payment-forms/elements/checkbox.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -13,19 +13,19 @@
 block discarded – undo
13 13
 $label_class = sanitize_key( preg_replace( '/[^A-Za-z0-9_-]/', '-', $label ) );
14 14
 
15 15
 if ( ! empty( $required ) ) {
16
-	$label .= "<span class='text-danger'> *</span>";
16
+    $label .= "<span class='text-danger'> *</span>";
17 17
 }
18 18
 
19 19
 aui()->input(
20
-	array(
21
-		'type'      => 'checkbox',
22
-		'name'      => esc_attr( $id ),
23
-		'id'        => esc_attr( $element_id ),
24
-		'required'  => ! empty( $required ),
25
-		'label'     => $label,
26
-		'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
-		'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
28
-		'class'     => $label_class
29
-	),
30
-	true
20
+    array(
21
+        'type'      => 'checkbox',
22
+        'name'      => esc_attr( $id ),
23
+        'id'        => esc_attr( $element_id ),
24
+        'required'  => ! empty( $required ),
25
+        'label'     => $label,
26
+        'value'     => esc_attr__( 'Yes', 'invoicing' ),
27
+        'help_text' => empty( $description ) ? '' : wp_kses_post( $description ),
28
+        'class'     => $label_class
29
+    ),
30
+    true
31 31
 );
Please login to merge, or discard this patch.
templates/payment-forms/elements/address.php 1 patch
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@  discard block
 block discarded – undo
10 10
 defined( 'ABSPATH' ) || exit;
11 11
 
12 12
 if ( empty( $fields ) ) {
13
-	return;
13
+    return;
14 14
 }
15 15
 
16 16
 // A prefix for all ids (so that a form can be included in the same page multiple times).
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 
19 19
 // Prepare the user's country.
20 20
 if ( ! empty( $form->invoice ) ) {
21
-	$country = $form->invoice->get_country();
21
+    $country = $form->invoice->get_country();
22 22
 }
23 23
 
24 24
 if ( empty( $country ) ) {
25
-	$country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
-	$country = empty( $country ) ? wpinv_get_default_country() : $country;
25
+    $country = empty( $country ) ? getpaid_get_ip_country() : $country;
26
+    $country = empty( $country ) ? wpinv_get_default_country() : $country;
27 27
 }
28 28
 
29 29
 // A prefix for all ids (so that a form can be included in the same page multiple times).
@@ -50,32 +50,32 @@  discard block
 block discarded – undo
50 50
 	<!-- Start Billing Address -->
51 51
 	<div class="getpaid-billing-address-wrapper">
52 52
 		<?php
53
-			$field_type = 'billing';
53
+            $field_type = 'billing';
54 54
 
55
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
55
+            wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
56 56
 
57
-			do_action( 'getpaid_after_payment_form_billing_fields', $form );
58
-		?>
57
+            do_action( 'getpaid_after_payment_form_billing_fields', $form );
58
+        ?>
59 59
 	</div>
60 60
 	<!-- End Billing Address -->
61 61
 <?php endif; ?>
62 62
 
63 63
 <?php if ( 'both' === $address_type ) : ?>
64 64
 	<?php
65
-		aui()->input(
66
-			array(
67
-				'type'     => 'checkbox',
68
-				'name'     => 'same-shipping-address',
69
-				'id'       => "shipping-toggle$uniqid",
70
-				'required' => false,
71
-				'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
72
-				'value'    => 1,
73
-				'checked'  => true,
74
-				'class'    => 'chkbox-same-shipping-address'
75
-			),
76
-			true
77
-		);
78
-	?>
65
+        aui()->input(
66
+            array(
67
+                'type'     => 'checkbox',
68
+                'name'     => 'same-shipping-address',
69
+                'id'       => "shipping-toggle$uniqid",
70
+                'required' => false,
71
+                'label'    => empty( $shipping_address_toggle ) ? esc_html__( 'Same billing & shipping address.', 'invoicing' ) : wp_kses_post( $shipping_address_toggle ),
72
+                'value'    => 1,
73
+                'checked'  => true,
74
+                'class'    => 'chkbox-same-shipping-address'
75
+            ),
76
+            true
77
+        );
78
+    ?>
79 79
 	<!-- Start Shipping Address Title -->
80 80
 	<h4 class="mb-3 getpaid-shipping-address-title">
81 81
 		<?php esc_html_e( 'Shipping Address', 'invoicing' ); ?>
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	<!-- Start Shipping Address -->
88 88
 	<div class="getpaid-shipping-address-wrapper">
89 89
 		<?php
90
-			$field_type = 'shipping';
90
+            $field_type = 'shipping';
91 91
 
92
-			wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
92
+            wpinv_get_template( 'payment-forms/elements/address-fields.php', array( 'form' => $form, 'fields' => $fields, 'address_type' => $address_type, 'field_type' => $field_type, 'uniqid' => $uniqid, 'country' => $country ) );
93 93
 
94
-			do_action( 'getpaid_after_payment_form_shipping_fields', $form );
95
-		?>
94
+            do_action( 'getpaid_after_payment_form_shipping_fields', $form );
95
+        ?>
96 96
 	</div>
97 97
 	<!-- End Shipping Address -->
98 98
 <?php endif; ?>
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +813 added lines, -813 removed lines patch added patch discarded remove patch
@@ -13,756 +13,756 @@  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 ( wpinv_get_default_payment_form() === $post->ID ) {
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
-			$actions['reset'] = sprintf(
131
-				'<a href="%1$s" style="color: #800">%2$s</a>',
132
-				esc_url(
133
-					wp_nonce_url(
134
-						add_query_arg(
135
-							array(
136
-								'getpaid-admin-action' => 'reset_form_stats',
137
-								'form_id'              => $post->ID,
138
-							)
139
-						),
140
-						'getpaid-nonce',
141
-						'getpaid-nonce'
142
-					)
143
-				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
145
-			);
146
-		}
147
-
148
-		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-			if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
-				$actions['buy'] = sprintf(
152
-					'<a href="%1$s">%2$s</a>',
153
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
-					esc_html( __( 'Buy', 'invoicing' ) )
155
-				);
156
-			}
157
-		}
158
-
159
-		return $actions;
160
-	}
161
-
162
-	/**
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 ( wpinv_get_default_payment_form() === $post->ID ) {
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
+            $actions['reset'] = sprintf(
131
+                '<a href="%1$s" style="color: #800">%2$s</a>',
132
+                esc_url(
133
+                    wp_nonce_url(
134
+                        add_query_arg(
135
+                            array(
136
+                                'getpaid-admin-action' => 'reset_form_stats',
137
+                                'form_id'              => $post->ID,
138
+                            )
139
+                        ),
140
+                        'getpaid-nonce',
141
+                        'getpaid-nonce'
142
+                    )
143
+                ),
144
+                esc_html( __( 'Reset Stats', 'invoicing' ) )
145
+            );
146
+        }
147
+
148
+        // Link to item payment form.
149
+        if ( 'wpi_item' == $post->post_type ) {
150
+            if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
+                $actions['buy'] = sprintf(
152
+                    '<a href="%1$s">%2$s</a>',
153
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
+                    esc_html( __( 'Buy', 'invoicing' ) )
155
+                );
156
+            }
157
+        }
158
+
159
+        return $actions;
160
+    }
161
+
162
+    /**
163 163
      * Remove bulk edit option from admin side quote listing
164 164
      *
165 165
      * @since    1.0.0
166 166
      * @param array $actions post actions
167
-	 * @param WP_Post $post
167
+     * @param WP_Post $post
168 168
      * @return array $actions actions without edit option
169 169
      */
170 170
     public static function filter_invoice_row_actions( $actions, $post ) {
171 171
 
172 172
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
173 173
 
174
-			$actions = array();
175
-			$invoice = new WPInv_Invoice( $post );
176
-
177
-			$actions['edit'] = sprintf(
178
-				'<a href="%1$s">%2$s</a>',
179
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
-				esc_html( __( 'Edit', 'invoicing' ) )
181
-			);
182
-
183
-			if ( ! $invoice->is_draft() ) {
184
-
185
-				$actions['view'] = sprintf(
186
-					'<a href="%1$s">%2$s</a>',
187
-					esc_url( $invoice->get_view_url() ),
188
-					sprintf(
189
-						// translators: %s is the invoice type
190
-						esc_html__( 'View %s', 'invoicing' ),
191
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
-					)
193
-				);
194
-
195
-				$actions['send'] = sprintf(
196
-					'<a href="%1$s">%2$s</a>',
197
-					esc_url(
198
-						wp_nonce_url(
199
-							add_query_arg(
200
-								array(
201
-									'getpaid-admin-action' => 'send_invoice',
202
-									'invoice_id'           => $invoice->get_id(),
203
-								)
204
-							),
205
-							'getpaid-nonce',
206
-							'getpaid-nonce'
207
-						)
208
-					),
209
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
210
-				);
211
-
212
-			}
213
-
214
-			$actions['duplicate'] = sprintf(
215
-				'<a href="%1$s">%2$s</a>',
216
-				esc_url(
217
-					wp_nonce_url(
218
-						add_query_arg(
219
-							array(
220
-								'getpaid-admin-action' => 'duplicate_invoice',
221
-								'invoice_id'           => $post->ID,
222
-							)
223
-						),
224
-						'getpaid-nonce',
225
-						'getpaid-nonce'
226
-					)
227
-				),
228
-				esc_html( __( 'Duplicate', 'invoicing' ) )
229
-			);
174
+            $actions = array();
175
+            $invoice = new WPInv_Invoice( $post );
176
+
177
+            $actions['edit'] = sprintf(
178
+                '<a href="%1$s">%2$s</a>',
179
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
+                esc_html( __( 'Edit', 'invoicing' ) )
181
+            );
182
+
183
+            if ( ! $invoice->is_draft() ) {
184
+
185
+                $actions['view'] = sprintf(
186
+                    '<a href="%1$s">%2$s</a>',
187
+                    esc_url( $invoice->get_view_url() ),
188
+                    sprintf(
189
+                        // translators: %s is the invoice type
190
+                        esc_html__( 'View %s', 'invoicing' ),
191
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
+                    )
193
+                );
194
+
195
+                $actions['send'] = sprintf(
196
+                    '<a href="%1$s">%2$s</a>',
197
+                    esc_url(
198
+                        wp_nonce_url(
199
+                            add_query_arg(
200
+                                array(
201
+                                    'getpaid-admin-action' => 'send_invoice',
202
+                                    'invoice_id'           => $invoice->get_id(),
203
+                                )
204
+                            ),
205
+                            'getpaid-nonce',
206
+                            'getpaid-nonce'
207
+                        )
208
+                    ),
209
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
210
+                );
211
+
212
+            }
213
+
214
+            $actions['duplicate'] = sprintf(
215
+                '<a href="%1$s">%2$s</a>',
216
+                esc_url(
217
+                    wp_nonce_url(
218
+                        add_query_arg(
219
+                            array(
220
+                                'getpaid-admin-action' => 'duplicate_invoice',
221
+                                'invoice_id'           => $post->ID,
222
+                            )
223
+                        ),
224
+                        'getpaid-nonce',
225
+                        'getpaid-nonce'
226
+                    )
227
+                ),
228
+                esc_html( __( 'Duplicate', 'invoicing' ) )
229
+            );
230 230
 
231 231
         }
232 232
 
233 233
         return $actions;
234
-	}
235
-
236
-	/**
237
-	 * Returns an array of invoice table columns.
238
-	 */
239
-	public static function invoice_columns( $columns ) {
240
-
241
-		$columns = array(
242
-			'cb'           => $columns['cb'],
243
-			'number'       => __( 'Invoice', 'invoicing' ),
244
-			'customer'     => __( 'Customer', 'invoicing' ),
245
-			'invoice_date' => __( 'Created', 'invoicing' ),
246
-			'payment_date' => __( 'Completed', 'invoicing' ),
247
-			'amount'       => __( 'Amount', 'invoicing' ),
248
-			'recurring'    => __( 'Recurring', 'invoicing' ),
249
-			'status'       => __( 'Status', 'invoicing' ),
250
-		);
251
-
252
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
253
-	}
254
-
255
-	/**
256
-	 * Displays invoice table columns.
257
-	 */
258
-	public static function display_invoice_columns( $column_name, $post_id ) {
259
-
260
-		$invoice = new WPInv_Invoice( $post_id );
261
-
262
-		switch ( $column_name ) {
263
-
264
-			case 'invoice_date':
265
-				$date_time = esc_attr( $invoice->get_created_date() );
266
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
-				break;
269
-
270
-			case 'payment_date':
271
-				if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
-					$date_time = esc_attr( $invoice->get_completed_date() );
273
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
-
276
-					if ( $_gateway = $invoice->get_gateway() ) {
277
-						$gateway_label = wpinv_get_gateway_admin_label( $_gateway );
278
-
279
-						if ( $transaction_url = $invoice->get_transaction_url() ) {
280
-							$gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
281
-						}
282
-
283
-						$gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
284
-					} else {
285
-						$gateway = '';
286
-					}
287
-
288
-					$gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
289
-
290
-					if ( $gateway ) {
291
-						echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292
-					}
293
-				} else {
294
-					echo '&mdash;';
295
-				}
296
-
297
-				break;
298
-
299
-			case 'amount':
300
-				$amount = $invoice->get_total();
301
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
302
-
303
-				if ( $invoice->is_refunded() ) {
304
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
306
-				} else {
307
-
308
-					$discount = $invoice->get_total_discount();
309
-
310
-					if ( ! empty( $discount ) ) {
311
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
313
-					} else {
314
-						echo wp_kses_post( $formated_amount );
315
-					}
316
-				}
317
-
318
-				break;
319
-
320
-			case 'status':
321
-				$status       = esc_html( $invoice->get_status() );
322
-				$status_label = esc_html( $invoice->get_status_nicename() );
323
-
324
-				// If it is paid, show the gateway title.
325
-				if ( $invoice->is_paid() ) {
326
-					$gateway = esc_html( $invoice->get_gateway_title() );
327
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
328
-
329
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
330
-				} else {
331
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
332
-				}
333
-
334
-				// If it is not paid, display the overdue and view status.
335
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
336
-
337
-					// Invoice view status.
338
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
339
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
340
-					} else {
341
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
342
-					}
343
-
344
-					// Display the overview status.
345
-					if ( wpinv_get_option( 'overdue_active' ) ) {
346
-						$due_date = $invoice->get_due_date();
347
-						$fomatted = getpaid_format_date( $due_date );
348
-
349
-						if ( ! empty( $fomatted ) ) {
350
-							$date = wp_sprintf(
351
-								// translators: %s is the due date.
352
-								__( 'Due %s', 'invoicing' ),
353
-								$fomatted
354
-							);
355
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
356
-						}
357
-					}
358
-				}
359
-
360
-				break;
361
-
362
-			case 'recurring':
363
-				if ( $invoice->is_recurring() ) {
364
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
365
-				} else {
366
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
367
-				}
368
-				break;
369
-
370
-			case 'number':
371
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
372
-				$invoice_number  = esc_html( $invoice->get_number() );
373
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
374
-
375
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
376
-
377
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
378
-				break;
379
-
380
-			case 'customer':
381
-				$customer_name = $invoice->get_user_full_name();
382
-
383
-				if ( empty( $customer_name ) ) {
384
-					$customer_name = $invoice->get_email();
385
-				}
386
-
387
-				if ( ! empty( $customer_name ) ) {
388
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
389
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
390
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
391
-				} else {
392
-					echo '<div>&mdash;</div>';
393
-				}
394
-
395
-				break;
396
-
397
-		}
398
-
399
-	}
400
-
401
-	/**
402
-	 * Displays invoice bulk actions.
403
-	 */
404
-	public static function invoice_bulk_actions( $actions ) {
405
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
406
-		return $actions;
407
-	}
408
-
409
-	/**
410
-	 * Processes invoice bulk actions.
411
-	 */
412
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
413
-
414
-		if ( 'resend-invoice' === $action ) {
415
-			foreach ( $post_ids as $post_id ) {
416
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
417
-			}
418
-		}
419
-
420
-		return $redirect_url;
421
-
422
-	}
423
-
424
-	/**
425
-	 * Returns an array of payment forms table columns.
426
-	 */
427
-	public static function payment_form_columns( $columns ) {
428
-
429
-		$columns = array(
430
-			'cb'        => $columns['cb'],
431
-			'title'     => __( 'Name', 'invoicing' ),
432
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
433
-			'earnings'  => __( 'Revenue', 'invoicing' ),
434
-			'refunds'   => __( 'Refunded', 'invoicing' ),
435
-			'items'     => __( 'Items', 'invoicing' ),
436
-			'date'      => __( 'Date', 'invoicing' ),
437
-		);
438
-
439
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
440
-
441
-	}
442
-
443
-	/**
444
-	 * Displays payment form table columns.
445
-	 */
446
-	public static function display_payment_form_columns( $column_name, $post_id ) {
447
-
448
-		// Retrieve the payment form.
449
-		$form = new GetPaid_Payment_Form( $post_id );
450
-
451
-		switch ( $column_name ) {
452
-
453
-			case 'earnings':
454
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
455
-				break;
456
-
457
-			case 'refunds':
458
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
459
-				break;
460
-
461
-			case 'refunds':
462
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
463
-				break;
464
-
465
-			case 'shortcode':
466
-				if ( $form->is_default() ) {
467
-					echo '&mdash;';
468
-				} else {
469
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
470
-				}
471
-
472
-				break;
234
+    }
235
+
236
+    /**
237
+     * Returns an array of invoice table columns.
238
+     */
239
+    public static function invoice_columns( $columns ) {
240
+
241
+        $columns = array(
242
+            'cb'           => $columns['cb'],
243
+            'number'       => __( 'Invoice', 'invoicing' ),
244
+            'customer'     => __( 'Customer', 'invoicing' ),
245
+            'invoice_date' => __( 'Created', 'invoicing' ),
246
+            'payment_date' => __( 'Completed', 'invoicing' ),
247
+            'amount'       => __( 'Amount', 'invoicing' ),
248
+            'recurring'    => __( 'Recurring', 'invoicing' ),
249
+            'status'       => __( 'Status', 'invoicing' ),
250
+        );
251
+
252
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
253
+    }
254
+
255
+    /**
256
+     * Displays invoice table columns.
257
+     */
258
+    public static function display_invoice_columns( $column_name, $post_id ) {
259
+
260
+        $invoice = new WPInv_Invoice( $post_id );
261
+
262
+        switch ( $column_name ) {
263
+
264
+            case 'invoice_date':
265
+                $date_time = esc_attr( $invoice->get_created_date() );
266
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
+                break;
269
+
270
+            case 'payment_date':
271
+                if ( $invoice->is_paid() || $invoice->is_refunded() ) {
272
+                    $date_time = esc_attr( $invoice->get_completed_date() );
273
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
+
276
+                    if ( $_gateway = $invoice->get_gateway() ) {
277
+                        $gateway_label = wpinv_get_gateway_admin_label( $_gateway );
278
+
279
+                        if ( $transaction_url = $invoice->get_transaction_url() ) {
280
+                            $gateway_label = '<a href="' . esc_url( $transaction_url ) . '" target="_blank" title="' . esc_attr__( 'Open transaction link', 'invoicing' ) . '">' . $gateway_label . '</a>';
281
+                        }
282
+
283
+                        $gateway = '<small class="meta bsui"><span class="fs-xs text-muted fst-normal">' . wp_sprintf( _x( 'Via %s', 'Paid via gateway', 'invoicing' ), $gateway_label ) . '</span></small>';
284
+                    } else {
285
+                        $gateway = '';
286
+                    }
287
+
288
+                    $gateway = apply_filters( 'getpaid_admin_invoices_list_table_gateway', $gateway, $invoice );
289
+
290
+                    if ( $gateway ) {
291
+                        echo wp_kses_post( $gateway ); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
292
+                    }
293
+                } else {
294
+                    echo '&mdash;';
295
+                }
296
+
297
+                break;
298
+
299
+            case 'amount':
300
+                $amount = $invoice->get_total();
301
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
302
+
303
+                if ( $invoice->is_refunded() ) {
304
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
305
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
306
+                } else {
307
+
308
+                    $discount = $invoice->get_total_discount();
309
+
310
+                    if ( ! empty( $discount ) ) {
311
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
312
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
313
+                    } else {
314
+                        echo wp_kses_post( $formated_amount );
315
+                    }
316
+                }
317
+
318
+                break;
319
+
320
+            case 'status':
321
+                $status       = esc_html( $invoice->get_status() );
322
+                $status_label = esc_html( $invoice->get_status_nicename() );
323
+
324
+                // If it is paid, show the gateway title.
325
+                if ( $invoice->is_paid() ) {
326
+                    $gateway = esc_html( $invoice->get_gateway_title() );
327
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
328
+
329
+                    echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
330
+                } else {
331
+                    echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
332
+                }
333
+
334
+                // If it is not paid, display the overdue and view status.
335
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
336
+
337
+                    // Invoice view status.
338
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
339
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
340
+                    } else {
341
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
342
+                    }
343
+
344
+                    // Display the overview status.
345
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
346
+                        $due_date = $invoice->get_due_date();
347
+                        $fomatted = getpaid_format_date( $due_date );
348
+
349
+                        if ( ! empty( $fomatted ) ) {
350
+                            $date = wp_sprintf(
351
+                                // translators: %s is the due date.
352
+                                __( 'Due %s', 'invoicing' ),
353
+                                $fomatted
354
+                            );
355
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
356
+                        }
357
+                    }
358
+                }
359
+
360
+                break;
361
+
362
+            case 'recurring':
363
+                if ( $invoice->is_recurring() ) {
364
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
365
+                } else {
366
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
367
+                }
368
+                break;
369
+
370
+            case 'number':
371
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
372
+                $invoice_number  = esc_html( $invoice->get_number() );
373
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
374
+
375
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
376
+
377
+                do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
378
+                break;
379
+
380
+            case 'customer':
381
+                $customer_name = $invoice->get_user_full_name();
382
+
383
+                if ( empty( $customer_name ) ) {
384
+                    $customer_name = $invoice->get_email();
385
+                }
386
+
387
+                if ( ! empty( $customer_name ) ) {
388
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
389
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
390
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
391
+                } else {
392
+                    echo '<div>&mdash;</div>';
393
+                }
394
+
395
+                break;
473 396
 
474
-			case 'items':
475
-				$items = $form->get_items();
476
-
477
-				if ( $form->is_default() || empty( $items ) ) {
478
-					echo '&mdash;';
479
-					return;
480
-				}
481
-
482
-				$_items = array();
483
-
484
-				foreach ( $items as $item ) {
485
-					$url = $item->get_edit_url();
486
-
487
-					if ( empty( $url ) ) {
488
-						$_items[] = esc_html( $item->get_name() );
489
-					} else {
490
-						$_items[] = sprintf(
491
-							'<a href="%s">%s</a>',
492
-							esc_url( $url ),
493
-							esc_html( $item->get_name() )
494
-						);
495
-					}
397
+        }
398
+
399
+    }
400
+
401
+    /**
402
+     * Displays invoice bulk actions.
403
+     */
404
+    public static function invoice_bulk_actions( $actions ) {
405
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
406
+        return $actions;
407
+    }
408
+
409
+    /**
410
+     * Processes invoice bulk actions.
411
+     */
412
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
413
+
414
+        if ( 'resend-invoice' === $action ) {
415
+            foreach ( $post_ids as $post_id ) {
416
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
417
+            }
418
+        }
419
+
420
+        return $redirect_url;
421
+
422
+    }
423
+
424
+    /**
425
+     * Returns an array of payment forms table columns.
426
+     */
427
+    public static function payment_form_columns( $columns ) {
428
+
429
+        $columns = array(
430
+            'cb'        => $columns['cb'],
431
+            'title'     => __( 'Name', 'invoicing' ),
432
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
433
+            'earnings'  => __( 'Revenue', 'invoicing' ),
434
+            'refunds'   => __( 'Refunded', 'invoicing' ),
435
+            'items'     => __( 'Items', 'invoicing' ),
436
+            'date'      => __( 'Date', 'invoicing' ),
437
+        );
438
+
439
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
440
+
441
+    }
442
+
443
+    /**
444
+     * Displays payment form table columns.
445
+     */
446
+    public static function display_payment_form_columns( $column_name, $post_id ) {
447
+
448
+        // Retrieve the payment form.
449
+        $form = new GetPaid_Payment_Form( $post_id );
450
+
451
+        switch ( $column_name ) {
452
+
453
+            case 'earnings':
454
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
455
+                break;
456
+
457
+            case 'refunds':
458
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
459
+                break;
460
+
461
+            case 'refunds':
462
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
463
+                break;
464
+
465
+            case 'shortcode':
466
+                if ( $form->is_default() ) {
467
+                    echo '&mdash;';
468
+                } else {
469
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
470
+                }
471
+
472
+                break;
473
+
474
+            case 'items':
475
+                $items = $form->get_items();
476
+
477
+                if ( $form->is_default() || empty( $items ) ) {
478
+                    echo '&mdash;';
479
+                    return;
480
+                }
481
+
482
+                $_items = array();
483
+
484
+                foreach ( $items as $item ) {
485
+                    $url = $item->get_edit_url();
486
+
487
+                    if ( empty( $url ) ) {
488
+                        $_items[] = esc_html( $item->get_name() );
489
+                    } else {
490
+                        $_items[] = sprintf(
491
+                            '<a href="%s">%s</a>',
492
+                            esc_url( $url ),
493
+                            esc_html( $item->get_name() )
494
+                        );
495
+                    }
496 496
 }
497 497
 
498
-				echo wp_kses_post( implode( '<br>', $_items ) );
498
+                echo wp_kses_post( implode( '<br>', $_items ) );
499
+
500
+                break;
501
+
502
+        }
503
+
504
+    }
505
+
506
+    /**
507
+     * Filters post states.
508
+     */
509
+    public static function filter_payment_form_state( $post_states, $post ) {
510
+
511
+        if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
512
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
513
+        }
514
+
515
+        return $post_states;
516
+
517
+    }
518
+
519
+    /**
520
+     * Returns an array of coupon table columns.
521
+     */
522
+    public static function discount_columns( $columns ) {
523
+
524
+        $columns = array(
525
+            'cb'          => $columns['cb'],
526
+            'title'       => __( 'Name', 'invoicing' ),
527
+            'code'        => __( 'Code', 'invoicing' ),
528
+            'amount'      => __( 'Amount', 'invoicing' ),
529
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
530
+            'start_date'  => __( 'Start Date', 'invoicing' ),
531
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
532
+        );
533
+
534
+        return apply_filters( 'wpi_discount_table_columns', $columns );
535
+    }
499 536
 
500
-				break;
537
+    /**
538
+     * Filters post states.
539
+     */
540
+    public static function filter_discount_state( $post_states, $post ) {
501 541
 
502
-		}
542
+        if ( 'wpi_discount' === $post->post_type ) {
503 543
 
504
-	}
544
+            $discount = new WPInv_Discount( $post );
505 545
 
506
-	/**
507
-	 * Filters post states.
508
-	 */
509
-	public static function filter_payment_form_state( $post_states, $post ) {
546
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
510 547
 
511
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
512
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
513
-		}
548
+            if ( 'publish' !== $status ) {
549
+                return array(
550
+                    'discount_status' => wpinv_discount_status( $status ),
551
+                );
552
+            }
553
+
554
+            return array();
555
+
556
+        }
557
+
558
+        return $post_states;
514 559
 
515
-		return $post_states;
560
+    }
516 561
 
517
-	}
562
+    /**
563
+     * Returns an array of items table columns.
564
+     */
565
+    public static function item_columns( $columns ) {
566
+
567
+        $columns = array(
568
+            'cb'        => $columns['cb'],
569
+            'title'     => __( 'Name', 'invoicing' ),
570
+            'price'     => __( 'Price', 'invoicing' ),
571
+            'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
572
+            'vat_class' => __( 'Tax Class', 'invoicing' ),
573
+            'type'      => __( 'Type', 'invoicing' ),
574
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
575
+        );
576
+
577
+        if ( ! wpinv_use_taxes() ) {
578
+            unset( $columns['vat_rule'] );
579
+            unset( $columns['vat_class'] );
580
+        }
518 581
 
519
-	/**
520
-	 * Returns an array of coupon table columns.
521
-	 */
522
-	public static function discount_columns( $columns ) {
582
+        return apply_filters( 'wpi_item_table_columns', $columns );
583
+    }
523 584
 
524
-		$columns = array(
525
-			'cb'          => $columns['cb'],
526
-			'title'       => __( 'Name', 'invoicing' ),
527
-			'code'        => __( 'Code', 'invoicing' ),
528
-			'amount'      => __( 'Amount', 'invoicing' ),
529
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
530
-			'start_date'  => __( 'Start Date', 'invoicing' ),
531
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
532
-		);
585
+    /**
586
+     * Returns an array of sortable items table columns.
587
+     */
588
+    public static function sortable_item_columns( $columns ) {
589
+
590
+        return array_merge(
591
+            $columns,
592
+            array(
593
+                'price'     => 'price',
594
+                'vat_rule'  => 'vat_rule',
595
+                'vat_class' => 'vat_class',
596
+                'type'      => 'type',
597
+            )
598
+        );
533 599
 
534
-		return apply_filters( 'wpi_discount_table_columns', $columns );
535
-	}
600
+    }
536 601
 
537
-	/**
538
-	 * Filters post states.
539
-	 */
540
-	public static function filter_discount_state( $post_states, $post ) {
602
+    /**
603
+     * Displays items table columns.
604
+     */
605
+    public static function display_item_columns( $column_name, $post_id ) {
541 606
 
542
-		if ( 'wpi_discount' === $post->post_type ) {
607
+        $item = new WPInv_Item( $post_id );
543 608
 
544
-			$discount = new WPInv_Discount( $post );
609
+        switch ( $column_name ) {
545 610
 
546
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
611
+            case 'price':
612
+                if ( ! $item->is_recurring() ) {
613
+                    echo wp_kses_post( $item->get_the_price() );
614
+                    break;
615
+                }
547 616
 
548
-			if ( 'publish' !== $status ) {
549
-				return array(
550
-					'discount_status' => wpinv_discount_status( $status ),
551
-				);
552
-			}
617
+                $price = wp_sprintf(
618
+                    __( '%1$s / %2$s', 'invoicing' ),
619
+                    $item->get_the_price(),
620
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
621
+                );
553 622
 
554
-			return array();
623
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
624
+                    echo wp_kses_post( $price );
625
+                    break;
626
+                }
555 627
 
556
-		}
628
+                echo wp_kses_post( $item->get_the_initial_price() );
557 629
 
558
-		return $post_states;
630
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
631
+                break;
559 632
 
560
-	}
633
+            case 'vat_rule':
634
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
635
+                break;
561 636
 
562
-	/**
563
-	 * Returns an array of items table columns.
564
-	 */
565
-	public static function item_columns( $columns ) {
637
+            case 'vat_class':
638
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
639
+                break;
566 640
 
567
-		$columns = array(
568
-			'cb'        => $columns['cb'],
569
-			'title'     => __( 'Name', 'invoicing' ),
570
-			'price'     => __( 'Price', 'invoicing' ),
571
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
572
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
573
-			'type'      => __( 'Type', 'invoicing' ),
574
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
575
-		);
641
+            case 'shortcode':
642
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
643
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
644
+                } else {
645
+                    echo '&mdash;';
646
+                }
576 647
 
577
-		if ( ! wpinv_use_taxes() ) {
578
-			unset( $columns['vat_rule'] );
579
-			unset( $columns['vat_class'] );
580
-		}
648
+                break;
581 649
 
582
-		return apply_filters( 'wpi_item_table_columns', $columns );
583
-	}
650
+            case 'type':
651
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
652
+                break;
584 653
 
585
-	/**
586
-	 * Returns an array of sortable items table columns.
587
-	 */
588
-	public static function sortable_item_columns( $columns ) {
589
-
590
-		return array_merge(
591
-			$columns,
592
-			array(
593
-				'price'     => 'price',
594
-				'vat_rule'  => 'vat_rule',
595
-				'vat_class' => 'vat_class',
596
-				'type'      => 'type',
597
-			)
598
-		);
599
-
600
-	}
601
-
602
-	/**
603
-	 * Displays items table columns.
604
-	 */
605
-	public static function display_item_columns( $column_name, $post_id ) {
606
-
607
-		$item = new WPInv_Item( $post_id );
608
-
609
-		switch ( $column_name ) {
610
-
611
-			case 'price':
612
-				if ( ! $item->is_recurring() ) {
613
-					echo wp_kses_post( $item->get_the_price() );
614
-					break;
615
-				}
616
-
617
-				$price = wp_sprintf(
618
-					__( '%1$s / %2$s', 'invoicing' ),
619
-					$item->get_the_price(),
620
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
621
-				);
622
-
623
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
624
-					echo wp_kses_post( $price );
625
-					break;
626
-				}
627
-
628
-				echo wp_kses_post( $item->get_the_initial_price() );
629
-
630
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
631
-				break;
632
-
633
-			case 'vat_rule':
634
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
635
-				break;
636
-
637
-			case 'vat_class':
638
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
639
-				break;
640
-
641
-			case 'shortcode':
642
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
643
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
644
-				} else {
645
-					echo '&mdash;';
646
-				}
647
-
648
-				break;
649
-
650
-			case 'type':
651
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
652
-				break;
653
-
654
-		}
655
-
656
-	}
657
-
658
-	/**
659
-	 * Lets users filter items using taxes.
660
-	 */
661
-	public static function add_item_filters( $post_type ) {
662
-
663
-		// Abort if we're not dealing with items.
664
-		if ( 'wpi_item' !== $post_type ) {
665
-			return;
666
-		}
667
-
668
-		// Filter by vat rules.
669
-		if ( wpinv_use_taxes() ) {
670
-
671
-			// Sanitize selected vat rule.
672
-			$vat_rule   = '';
673
-			$vat_rules  = getpaid_get_tax_rules();
674
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
676
-			}
677
-
678
-			// Filter by VAT rule.
679
-			wpinv_html_select(
680
-				array(
681
-					'options'          => array_merge(
682
-						array(
683
-							'' => __( 'All Tax Rules', 'invoicing' ),
684
-						),
685
-						$vat_rules
686
-					),
687
-					'name'             => 'vat_rule',
688
-					'id'               => 'vat_rule',
689
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
690
-					'show_option_all'  => false,
691
-					'show_option_none' => false,
692
-				)
693
-			);
694
-
695
-			// Filter by VAT class.
696
-
697
-			// Sanitize selected vat rule.
698
-			$vat_class   = '';
699
-			$vat_classes = getpaid_get_tax_classes();
700
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
702
-			}
703
-
704
-			wpinv_html_select(
705
-				array(
706
-					'options'          => array_merge(
707
-						array(
708
-							'' => __( 'All Tax Classes', 'invoicing' ),
709
-						),
710
-						$vat_classes
711
-					),
712
-					'name'             => 'vat_class',
713
-					'id'               => 'vat_class',
714
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
715
-					'show_option_all'  => false,
716
-					'show_option_none' => false,
717
-				)
718
-			);
719
-
720
-		}
721
-
722
-		// Filter by item type.
723
-		$type   = '';
724
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
726
-		}
727
-
728
-		wpinv_html_select(
729
-			array(
730
-				'options'          => array_merge(
731
-					array(
732
-						'' => __( 'All item types', 'invoicing' ),
733
-					),
734
-					wpinv_get_item_types()
735
-				),
736
-				'name'             => 'type',
737
-				'id'               => 'type',
738
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
739
-				'show_option_all'  => false,
740
-				'show_option_none' => false,
741
-			)
742
-		);
743
-
744
-	}
745
-
746
-	/**
747
-	 * Filters the item query.
748
-	 */
749
-	public static function filter_item_query( $query ) {
750
-
751
-		// modify the query only if it admin and main query.
752
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
753
-			return $query;
754
-		}
755
-
756
-		// we want to modify the query for our items.
757
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
758
-			return $query;
759
-		}
760
-
761
-		if ( empty( $query->query_vars['meta_query'] ) ) {
762
-			$query->query_vars['meta_query'] = array();
763
-		}
764
-
765
-		// Filter vat rule type
654
+        }
655
+
656
+    }
657
+
658
+    /**
659
+     * Lets users filter items using taxes.
660
+     */
661
+    public static function add_item_filters( $post_type ) {
662
+
663
+        // Abort if we're not dealing with items.
664
+        if ( 'wpi_item' !== $post_type ) {
665
+            return;
666
+        }
667
+
668
+        // Filter by vat rules.
669
+        if ( wpinv_use_taxes() ) {
670
+
671
+            // Sanitize selected vat rule.
672
+            $vat_rule   = '';
673
+            $vat_rules  = getpaid_get_tax_rules();
674
+            if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
675
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
676
+            }
677
+
678
+            // Filter by VAT rule.
679
+            wpinv_html_select(
680
+                array(
681
+                    'options'          => array_merge(
682
+                        array(
683
+                            '' => __( 'All Tax Rules', 'invoicing' ),
684
+                        ),
685
+                        $vat_rules
686
+                    ),
687
+                    'name'             => 'vat_rule',
688
+                    'id'               => 'vat_rule',
689
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
690
+                    'show_option_all'  => false,
691
+                    'show_option_none' => false,
692
+                )
693
+            );
694
+
695
+            // Filter by VAT class.
696
+
697
+            // Sanitize selected vat rule.
698
+            $vat_class   = '';
699
+            $vat_classes = getpaid_get_tax_classes();
700
+            if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
701
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
702
+            }
703
+
704
+            wpinv_html_select(
705
+                array(
706
+                    'options'          => array_merge(
707
+                        array(
708
+                            '' => __( 'All Tax Classes', 'invoicing' ),
709
+                        ),
710
+                        $vat_classes
711
+                    ),
712
+                    'name'             => 'vat_class',
713
+                    'id'               => 'vat_class',
714
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
715
+                    'show_option_all'  => false,
716
+                    'show_option_none' => false,
717
+                )
718
+            );
719
+
720
+        }
721
+
722
+        // Filter by item type.
723
+        $type   = '';
724
+        if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
725
+            $type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
726
+        }
727
+
728
+        wpinv_html_select(
729
+            array(
730
+                'options'          => array_merge(
731
+                    array(
732
+                        '' => __( 'All item types', 'invoicing' ),
733
+                    ),
734
+                    wpinv_get_item_types()
735
+                ),
736
+                'name'             => 'type',
737
+                'id'               => 'type',
738
+                'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
739
+                'show_option_all'  => false,
740
+                'show_option_none' => false,
741
+            )
742
+        );
743
+
744
+    }
745
+
746
+    /**
747
+     * Filters the item query.
748
+     */
749
+    public static function filter_item_query( $query ) {
750
+
751
+        // modify the query only if it admin and main query.
752
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
753
+            return $query;
754
+        }
755
+
756
+        // we want to modify the query for our items.
757
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
758
+            return $query;
759
+        }
760
+
761
+        if ( empty( $query->query_vars['meta_query'] ) ) {
762
+            $query->query_vars['meta_query'] = array();
763
+        }
764
+
765
+        // Filter vat rule type
766 766
         if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
767 767
             $query->query_vars['meta_query'][] = array(
768 768
                 'key'     => '_wpinv_vat_rule',
@@ -787,101 +787,101 @@  discard block
 block discarded – undo
787 787
                 'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
788 788
                 'compare' => '=',
789 789
             );
790
-		}
791
-
792
-		$query->query_vars['meta_query'][] = array(
793
-			'key'     => '_wpinv_one_time',
794
-			'compare' => 'NOT EXISTS',
795
-		);
796
-	}
797
-
798
-	/**
799
-	 * Reorders items.
800
-	 */
801
-	public static function reorder_items( $vars ) {
802
-		global $typenow;
803
-
804
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
805
-			return $vars;
806
-		}
807
-
808
-		// By item type.
809
-		if ( 'type' === $vars['orderby'] ) {
810
-			return array_merge(
811
-				$vars,
812
-				array(
813
-					'meta_key' => '_wpinv_type',
814
-					'orderby'  => 'meta_value',
815
-				)
816
-			);
817
-		}
818
-
819
-		// By vat class.
820
-		if ( 'vat_class' === $vars['orderby'] ) {
821
-			return array_merge(
822
-				$vars,
823
-				array(
824
-					'meta_key' => '_wpinv_vat_class',
825
-					'orderby'  => 'meta_value',
826
-				)
827
-			);
828
-		}
829
-
830
-		// By vat rule.
831
-		if ( 'vat_rule' === $vars['orderby'] ) {
832
-			return array_merge(
833
-				$vars,
834
-				array(
835
-					'meta_key' => '_wpinv_vat_rule',
836
-					'orderby'  => 'meta_value',
837
-				)
838
-			);
839
-		}
840
-
841
-		// By price.
842
-		if ( 'price' === $vars['orderby'] ) {
843
-			return array_merge(
844
-				$vars,
845
-				array(
846
-					'meta_key' => '_wpinv_price',
847
-					'orderby'  => 'meta_value_num',
848
-				)
849
-			);
850
-		}
851
-
852
-		return $vars;
853
-
854
-	}
855
-
856
-	/**
857
-	 * Fired when deleting a post.
858
-	 */
859
-	public static function delete_post( $post_id ) {
860
-
861
-		switch ( get_post_type( $post_id ) ) {
862
-
863
-			case 'wpi_item':
864
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
865
-				break;
866
-
867
-			case 'wpi_payment_form':
868
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
869
-				break;
870
-
871
-			case 'wpi_discount':
872
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
873
-				break;
874
-
875
-			case 'wpi_invoice':
876
-				$invoice = new WPInv_Invoice( $post_id );
877
-				do_action( 'getpaid_before_delete_invoice', $invoice );
878
-				$invoice->get_data_store()->delete_items( $invoice );
879
-				$invoice->get_data_store()->delete_special_fields( $invoice );
880
-				break;
881
-		}
882
-	}
883
-
884
-	/**
790
+        }
791
+
792
+        $query->query_vars['meta_query'][] = array(
793
+            'key'     => '_wpinv_one_time',
794
+            'compare' => 'NOT EXISTS',
795
+        );
796
+    }
797
+
798
+    /**
799
+     * Reorders items.
800
+     */
801
+    public static function reorder_items( $vars ) {
802
+        global $typenow;
803
+
804
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
805
+            return $vars;
806
+        }
807
+
808
+        // By item type.
809
+        if ( 'type' === $vars['orderby'] ) {
810
+            return array_merge(
811
+                $vars,
812
+                array(
813
+                    'meta_key' => '_wpinv_type',
814
+                    'orderby'  => 'meta_value',
815
+                )
816
+            );
817
+        }
818
+
819
+        // By vat class.
820
+        if ( 'vat_class' === $vars['orderby'] ) {
821
+            return array_merge(
822
+                $vars,
823
+                array(
824
+                    'meta_key' => '_wpinv_vat_class',
825
+                    'orderby'  => 'meta_value',
826
+                )
827
+            );
828
+        }
829
+
830
+        // By vat rule.
831
+        if ( 'vat_rule' === $vars['orderby'] ) {
832
+            return array_merge(
833
+                $vars,
834
+                array(
835
+                    'meta_key' => '_wpinv_vat_rule',
836
+                    'orderby'  => 'meta_value',
837
+                )
838
+            );
839
+        }
840
+
841
+        // By price.
842
+        if ( 'price' === $vars['orderby'] ) {
843
+            return array_merge(
844
+                $vars,
845
+                array(
846
+                    'meta_key' => '_wpinv_price',
847
+                    'orderby'  => 'meta_value_num',
848
+                )
849
+            );
850
+        }
851
+
852
+        return $vars;
853
+
854
+    }
855
+
856
+    /**
857
+     * Fired when deleting a post.
858
+     */
859
+    public static function delete_post( $post_id ) {
860
+
861
+        switch ( get_post_type( $post_id ) ) {
862
+
863
+            case 'wpi_item':
864
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
865
+                break;
866
+
867
+            case 'wpi_payment_form':
868
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
869
+                break;
870
+
871
+            case 'wpi_discount':
872
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
873
+                break;
874
+
875
+            case 'wpi_invoice':
876
+                $invoice = new WPInv_Invoice( $post_id );
877
+                do_action( 'getpaid_before_delete_invoice', $invoice );
878
+                $invoice->get_data_store()->delete_items( $invoice );
879
+                $invoice->get_data_store()->delete_special_fields( $invoice );
880
+                break;
881
+        }
882
+    }
883
+
884
+    /**
885 885
      * Add a post display state for special GetPaid pages in the page list table.
886 886
      *
887 887
      * @param array   $post_states An array of post display states.
@@ -895,21 +895,21 @@  discard block
 block discarded – undo
895 895
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
896 896
         }
897 897
 
898
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
898
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
899 899
 
900
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
901
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
902
-					__( 'GetPaid %s History Page', 'invoicing' ),
903
-					$label
904
-				);
905
-			}
900
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
901
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
902
+                    __( 'GetPaid %s History Page', 'invoicing' ),
903
+                    $label
904
+                );
905
+            }
906 906
 }
907 907
 
908
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
908
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
909 909
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
910 910
         }
911 911
 
912
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
912
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
913 913
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
914 914
         }
915 915
 
Please login to merge, or discard this patch.