Passed
Push — master ( 47b6fc...99ae46 )
by Brian
05:46 queued 20s
created
includes/admin/class-getpaid-post-types-admin.php 1 patch
Indentation   +757 added lines, -757 removed lines patch added patch discarded remove patch
@@ -13,719 +13,719 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( $post->ID == wpinv_get_default_payment_form() ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-		}
131
-
132
-		// Link to item payment form.
133
-		if ( 'wpi_item' == $post->post_type ) {
134
-
135
-			if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
-
137
-				$actions['buy'] = sprintf(
138
-					'<a href="%1$s">%2$s</a>',
139
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
-					esc_html( __( 'Buy', 'invoicing' ) )
141
-				);
142
-
143
-			}
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( $post->ID == wpinv_get_default_payment_form() ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+        }
131
+
132
+        // Link to item payment form.
133
+        if ( 'wpi_item' == $post->post_type ) {
134
+
135
+            if ( in_array( get_post_meta( $post->ID, '_wpinv_type', true ), array( '', 'fee', 'custom' ) ) ) {
136
+
137
+                $actions['buy'] = sprintf(
138
+                    '<a href="%1$s">%2$s</a>',
139
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
140
+                    esc_html( __( 'Buy', 'invoicing' ) )
141
+                );
142
+
143
+            }
144 144
 }
145 145
 
146
-		return $actions;
147
-	}
146
+        return $actions;
147
+    }
148 148
 
149
-	/**
149
+    /**
150 150
      * Remove bulk edit option from admin side quote listing
151 151
      *
152 152
      * @since    1.0.0
153 153
      * @param array $actions post actions
154
-	 * @param WP_Post $post
154
+     * @param WP_Post $post
155 155
      * @return array $actions actions without edit option
156 156
      */
157 157
     public static function filter_invoice_row_actions( $actions, $post ) {
158 158
 
159 159
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
160 160
 
161
-			$actions = array();
162
-			$invoice = new WPInv_Invoice( $post );
163
-
164
-			$actions['edit'] = sprintf(
165
-				'<a href="%1$s">%2$s</a>',
166
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
-				esc_html( __( 'Edit', 'invoicing' ) )
168
-			);
169
-
170
-			if ( ! $invoice->is_draft() ) {
171
-
172
-				$actions['view'] = sprintf(
173
-					'<a href="%1$s">%2$s</a>',
174
-					esc_url( $invoice->get_view_url() ),
175
-					sprintf(
176
-						esc_html( __( 'View %s', 'invoicing' ) ),
177
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
178
-					)
179
-				);
180
-
181
-				$actions['send'] = sprintf(
182
-					'<a href="%1$s">%2$s</a>',
183
-					esc_url(
184
-						wp_nonce_url(
185
-							add_query_arg(
186
-								array(
187
-									'getpaid-admin-action' => 'send_invoice',
188
-									'invoice_id'           => $invoice->get_id(),
189
-								)
190
-							),
191
-							'getpaid-nonce',
192
-							'getpaid-nonce'
193
-						)
194
-					),
195
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
196
-				);
197
-
198
-			}
199
-
200
-			$actions['duplicate'] = sprintf(
201
-				'<a href="%1$s">%2$s</a>',
202
-				esc_url(
203
-					wp_nonce_url(
204
-						add_query_arg(
205
-							array(
206
-								'getpaid-admin-action' => 'duplicate_invoice',
207
-								'invoice_id'           => $post->ID,
208
-							)
209
-						),
210
-						'getpaid-nonce',
211
-						'getpaid-nonce'
212
-					)
213
-				),
214
-				esc_html( __( 'Duplicate', 'invoicing' ) )
215
-			);
161
+            $actions = array();
162
+            $invoice = new WPInv_Invoice( $post );
163
+
164
+            $actions['edit'] = sprintf(
165
+                '<a href="%1$s">%2$s</a>',
166
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
167
+                esc_html( __( 'Edit', 'invoicing' ) )
168
+            );
169
+
170
+            if ( ! $invoice->is_draft() ) {
171
+
172
+                $actions['view'] = sprintf(
173
+                    '<a href="%1$s">%2$s</a>',
174
+                    esc_url( $invoice->get_view_url() ),
175
+                    sprintf(
176
+                        esc_html( __( 'View %s', 'invoicing' ) ),
177
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
178
+                    )
179
+                );
180
+
181
+                $actions['send'] = sprintf(
182
+                    '<a href="%1$s">%2$s</a>',
183
+                    esc_url(
184
+                        wp_nonce_url(
185
+                            add_query_arg(
186
+                                array(
187
+                                    'getpaid-admin-action' => 'send_invoice',
188
+                                    'invoice_id'           => $invoice->get_id(),
189
+                                )
190
+                            ),
191
+                            'getpaid-nonce',
192
+                            'getpaid-nonce'
193
+                        )
194
+                    ),
195
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
196
+                );
197
+
198
+            }
199
+
200
+            $actions['duplicate'] = sprintf(
201
+                '<a href="%1$s">%2$s</a>',
202
+                esc_url(
203
+                    wp_nonce_url(
204
+                        add_query_arg(
205
+                            array(
206
+                                'getpaid-admin-action' => 'duplicate_invoice',
207
+                                'invoice_id'           => $post->ID,
208
+                            )
209
+                        ),
210
+                        'getpaid-nonce',
211
+                        'getpaid-nonce'
212
+                    )
213
+                ),
214
+                esc_html( __( 'Duplicate', 'invoicing' ) )
215
+            );
216 216
 
217 217
         }
218 218
 
219 219
         return $actions;
220
-	}
221
-
222
-	/**
223
-	 * Returns an array of invoice table columns.
224
-	 */
225
-	public static function invoice_columns( $columns ) {
226
-
227
-		$columns = array(
228
-			'cb'           => $columns['cb'],
229
-			'number'       => __( 'Invoice', 'invoicing' ),
230
-			'customer'     => __( 'Customer', 'invoicing' ),
231
-			'invoice_date' => __( 'Created', 'invoicing' ),
232
-			'payment_date' => __( 'Completed', 'invoicing' ),
233
-			'amount'       => __( 'Amount', 'invoicing' ),
234
-			'recurring'    => __( 'Recurring', 'invoicing' ),
235
-			'status'       => __( 'Status', 'invoicing' ),
236
-		);
237
-
238
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
239
-	}
240
-
241
-	/**
242
-	 * Displays invoice table columns.
243
-	 */
244
-	public static function display_invoice_columns( $column_name, $post_id ) {
245
-
246
-		$invoice = new WPInv_Invoice( $post_id );
247
-
248
-		switch ( $column_name ) {
249
-
250
-			case 'invoice_date':
251
-				$date_time = esc_attr( $invoice->get_created_date() );
252
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
254
-				break;
255
-
256
-			case 'payment_date':
257
-				if ( $invoice->is_paid() ) {
258
-					$date_time = esc_attr( $invoice->get_completed_date() );
259
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
261
-				} else {
262
-					echo '&mdash;';
263
-				}
264
-
265
-				break;
266
-
267
-			case 'amount':
268
-				$amount = $invoice->get_total();
269
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
270
-
271
-				if ( $invoice->is_refunded() ) {
272
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
274
-				} else {
275
-
276
-					$discount = $invoice->get_total_discount();
277
-
278
-					if ( ! empty( $discount ) ) {
279
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
281
-					} else {
282
-						echo wp_kses_post( $formated_amount );
283
-					}
220
+    }
221
+
222
+    /**
223
+     * Returns an array of invoice table columns.
224
+     */
225
+    public static function invoice_columns( $columns ) {
226
+
227
+        $columns = array(
228
+            'cb'           => $columns['cb'],
229
+            'number'       => __( 'Invoice', 'invoicing' ),
230
+            'customer'     => __( 'Customer', 'invoicing' ),
231
+            'invoice_date' => __( 'Created', 'invoicing' ),
232
+            'payment_date' => __( 'Completed', 'invoicing' ),
233
+            'amount'       => __( 'Amount', 'invoicing' ),
234
+            'recurring'    => __( 'Recurring', 'invoicing' ),
235
+            'status'       => __( 'Status', 'invoicing' ),
236
+        );
237
+
238
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
239
+    }
240
+
241
+    /**
242
+     * Displays invoice table columns.
243
+     */
244
+    public static function display_invoice_columns( $column_name, $post_id ) {
245
+
246
+        $invoice = new WPInv_Invoice( $post_id );
247
+
248
+        switch ( $column_name ) {
249
+
250
+            case 'invoice_date':
251
+                $date_time = esc_attr( $invoice->get_created_date() );
252
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
253
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
254
+                break;
255
+
256
+            case 'payment_date':
257
+                if ( $invoice->is_paid() ) {
258
+                    $date_time = esc_attr( $invoice->get_completed_date() );
259
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
260
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
261
+                } else {
262
+                    echo '&mdash;';
263
+                }
264
+
265
+                break;
266
+
267
+            case 'amount':
268
+                $amount = $invoice->get_total();
269
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
270
+
271
+                if ( $invoice->is_refunded() ) {
272
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
273
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
274
+                } else {
275
+
276
+                    $discount = $invoice->get_total_discount();
277
+
278
+                    if ( ! empty( $discount ) ) {
279
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
280
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
281
+                    } else {
282
+                        echo wp_kses_post( $formated_amount );
283
+                    }
284 284
 }
285 285
 
286
-				break;
287
-
288
-			case 'status':
289
-				$status       = esc_html( $invoice->get_status() );
290
-				$status_label = esc_html( $invoice->get_status_nicename() );
291
-
292
-				// If it is paid, show the gateway title.
293
-				if ( $invoice->is_paid() ) {
294
-					$gateway = esc_html( $invoice->get_gateway_title() );
295
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
296
-
297
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
298
-				} else {
299
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
300
-				}
301
-
302
-				// If it is not paid, display the overdue and view status.
303
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
304
-
305
-					// Invoice view status.
306
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
308
-					} else {
309
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
310
-					}
311
-
312
-					// Display the overview status.
313
-					if ( wpinv_get_option( 'overdue_active' ) ) {
314
-						$due_date = $invoice->get_due_date();
315
-						$fomatted = getpaid_format_date( $due_date );
316
-
317
-						if ( ! empty( $fomatted ) ) {
318
-							$date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
320
-						}
321
-					}
286
+                break;
287
+
288
+            case 'status':
289
+                $status       = esc_html( $invoice->get_status() );
290
+                $status_label = esc_html( $invoice->get_status_nicename() );
291
+
292
+                // If it is paid, show the gateway title.
293
+                if ( $invoice->is_paid() ) {
294
+                    $gateway = esc_html( $invoice->get_gateway_title() );
295
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
296
+
297
+                    echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
298
+                } else {
299
+                    echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
300
+                }
301
+
302
+                // If it is not paid, display the overdue and view status.
303
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
304
+
305
+                    // Invoice view status.
306
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
307
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
308
+                    } else {
309
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
310
+                    }
311
+
312
+                    // Display the overview status.
313
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
314
+                        $due_date = $invoice->get_due_date();
315
+                        $fomatted = getpaid_format_date( $due_date );
316
+
317
+                        if ( ! empty( $fomatted ) ) {
318
+                            $date = wp_sprintf( __( 'Due %s', 'invoicing' ), $fomatted );
319
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
320
+                        }
321
+                    }
322 322
 }
323 323
 
324
-				break;
324
+                break;
325 325
 
326
-			case 'recurring':
327
-				if ( $invoice->is_recurring() ) {
328
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329
-				} else {
330
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
331
-				}
332
-				break;
326
+            case 'recurring':
327
+                if ( $invoice->is_recurring() ) {
328
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
329
+                } else {
330
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
331
+                }
332
+                break;
333 333
 
334
-			case 'number':
335
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
-				$invoice_number  = esc_html( $invoice->get_number() );
337
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
334
+            case 'number':
335
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
336
+                $invoice_number  = esc_html( $invoice->get_number() );
337
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
338 338
 
339
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
339
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
340 340
 
341
-				break;
341
+                break;
342 342
 
343
-			case 'customer':
344
-				$customer_name = $invoice->get_user_full_name();
343
+            case 'customer':
344
+                $customer_name = $invoice->get_user_full_name();
345 345
 
346
-				if ( empty( $customer_name ) ) {
347
-					$customer_name = $invoice->get_email();
348
-				}
346
+                if ( empty( $customer_name ) ) {
347
+                    $customer_name = $invoice->get_email();
348
+                }
349 349
 
350
-				if ( ! empty( $customer_name ) ) {
351
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
354
-				} else {
355
-					echo '<div>&mdash;</div>';
356
-				}
350
+                if ( ! empty( $customer_name ) ) {
351
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
352
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
353
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
354
+                } else {
355
+                    echo '<div>&mdash;</div>';
356
+                }
357 357
 
358
-				break;
359
-
360
-		}
361
-
362
-	}
363
-
364
-	/**
365
-	 * Displays invoice bulk actions.
366
-	 */
367
-	public static function invoice_bulk_actions( $actions ) {
368
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
369
-		return $actions;
370
-	}
371
-
372
-	/**
373
-	 * Processes invoice bulk actions.
374
-	 */
375
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
376
-
377
-		if ( $action == 'resend-invoice' ) {
378
-			foreach ( $post_ids as $post_id ) {
379
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
380
-			}
381
-		}
382
-
383
-		return $redirect_url;
384
-
385
-	}
386
-
387
-	/**
388
-	 * Returns an array of payment forms table columns.
389
-	 */
390
-	public static function payment_form_columns( $columns ) {
391
-
392
-		$columns = array(
393
-			'cb'        => $columns['cb'],
394
-			'title'     => __( 'Name', 'invoicing' ),
395
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
396
-			'earnings'  => __( 'Revenue', 'invoicing' ),
397
-			'refunds'   => __( 'Refunded', 'invoicing' ),
398
-			'items'     => __( 'Items', 'invoicing' ),
399
-			'date'      => __( 'Date', 'invoicing' ),
400
-		);
401
-
402
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
403
-
404
-	}
405
-
406
-	/**
407
-	 * Displays payment form table columns.
408
-	 */
409
-	public static function display_payment_form_columns( $column_name, $post_id ) {
410
-
411
-		// Retrieve the payment form.
412
-		$form = new GetPaid_Payment_Form( $post_id );
413
-
414
-		switch ( $column_name ) {
415
-
416
-			case 'earnings':
417
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
418
-				break;
419
-
420
-			case 'refunds':
421
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
422
-				break;
423
-
424
-			case 'refunds':
425
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
426
-				break;
427
-
428
-			case 'shortcode':
429
-				if ( $form->is_default() ) {
430
-					echo '&mdash;';
431
-				} else {
432
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
433
-				}
434
-
435
-				break;
358
+                break;
436 359
 
437
-			case 'items':
438
-				$items = $form->get_items();
439
-
440
-				if ( $form->is_default() || empty( $items ) ) {
441
-					echo '&mdash;';
442
-					return;
443
-				}
444
-
445
-				$_items = array();
446
-
447
-				foreach ( $items as $item ) {
448
-					$url = $item->get_edit_url();
449
-
450
-					if ( empty( $url ) ) {
451
-						$_items[] = esc_html( $item->get_name() );
452
-					} else {
453
-						$_items[] = sprintf(
454
-							'<a href="%s">%s</a>',
455
-							esc_url( $url ),
456
-							esc_html( $item->get_name() )
457
-						);
458
-					}
360
+        }
361
+
362
+    }
363
+
364
+    /**
365
+     * Displays invoice bulk actions.
366
+     */
367
+    public static function invoice_bulk_actions( $actions ) {
368
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
369
+        return $actions;
370
+    }
371
+
372
+    /**
373
+     * Processes invoice bulk actions.
374
+     */
375
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
376
+
377
+        if ( $action == 'resend-invoice' ) {
378
+            foreach ( $post_ids as $post_id ) {
379
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
380
+            }
381
+        }
382
+
383
+        return $redirect_url;
384
+
385
+    }
386
+
387
+    /**
388
+     * Returns an array of payment forms table columns.
389
+     */
390
+    public static function payment_form_columns( $columns ) {
391
+
392
+        $columns = array(
393
+            'cb'        => $columns['cb'],
394
+            'title'     => __( 'Name', 'invoicing' ),
395
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
396
+            'earnings'  => __( 'Revenue', 'invoicing' ),
397
+            'refunds'   => __( 'Refunded', 'invoicing' ),
398
+            'items'     => __( 'Items', 'invoicing' ),
399
+            'date'      => __( 'Date', 'invoicing' ),
400
+        );
401
+
402
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
403
+
404
+    }
405
+
406
+    /**
407
+     * Displays payment form table columns.
408
+     */
409
+    public static function display_payment_form_columns( $column_name, $post_id ) {
410
+
411
+        // Retrieve the payment form.
412
+        $form = new GetPaid_Payment_Form( $post_id );
413
+
414
+        switch ( $column_name ) {
415
+
416
+            case 'earnings':
417
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
418
+                break;
419
+
420
+            case 'refunds':
421
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
422
+                break;
423
+
424
+            case 'refunds':
425
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
426
+                break;
427
+
428
+            case 'shortcode':
429
+                if ( $form->is_default() ) {
430
+                    echo '&mdash;';
431
+                } else {
432
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
433
+                }
434
+
435
+                break;
436
+
437
+            case 'items':
438
+                $items = $form->get_items();
439
+
440
+                if ( $form->is_default() || empty( $items ) ) {
441
+                    echo '&mdash;';
442
+                    return;
443
+                }
444
+
445
+                $_items = array();
446
+
447
+                foreach ( $items as $item ) {
448
+                    $url = $item->get_edit_url();
449
+
450
+                    if ( empty( $url ) ) {
451
+                        $_items[] = esc_html( $item->get_name() );
452
+                    } else {
453
+                        $_items[] = sprintf(
454
+                            '<a href="%s">%s</a>',
455
+                            esc_url( $url ),
456
+                            esc_html( $item->get_name() )
457
+                        );
458
+                    }
459 459
 }
460 460
 
461
-				echo wp_kses_post( implode( '<br>', $_items ) );
461
+                echo wp_kses_post( implode( '<br>', $_items ) );
462 462
 
463
-				break;
463
+                break;
464 464
 
465
-		}
465
+        }
466 466
 
467
-	}
467
+    }
468 468
 
469
-	/**
470
-	 * Filters post states.
471
-	 */
472
-	public static function filter_payment_form_state( $post_states, $post ) {
469
+    /**
470
+     * Filters post states.
471
+     */
472
+    public static function filter_payment_form_state( $post_states, $post ) {
473 473
 
474
-		if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
476
-		}
474
+        if ( 'wpi_payment_form' == $post->post_type && wpinv_get_default_payment_form() == $post->ID ) {
475
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
476
+        }
477 477
 
478
-		return $post_states;
478
+        return $post_states;
479 479
 
480
-	}
480
+    }
481 481
 
482
-	/**
483
-	 * Returns an array of coupon table columns.
484
-	 */
485
-	public static function discount_columns( $columns ) {
482
+    /**
483
+     * Returns an array of coupon table columns.
484
+     */
485
+    public static function discount_columns( $columns ) {
486
+
487
+        $columns = array(
488
+            'cb'          => $columns['cb'],
489
+            'title'       => __( 'Name', 'invoicing' ),
490
+            'code'        => __( 'Code', 'invoicing' ),
491
+            'amount'      => __( 'Amount', 'invoicing' ),
492
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
+            'start_date'  => __( 'Start Date', 'invoicing' ),
494
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
495
+        );
496
+
497
+        return apply_filters( 'wpi_discount_table_columns', $columns );
498
+    }
486 499
 
487
-		$columns = array(
488
-			'cb'          => $columns['cb'],
489
-			'title'       => __( 'Name', 'invoicing' ),
490
-			'code'        => __( 'Code', 'invoicing' ),
491
-			'amount'      => __( 'Amount', 'invoicing' ),
492
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
493
-			'start_date'  => __( 'Start Date', 'invoicing' ),
494
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
495
-		);
500
+    /**
501
+     * Filters post states.
502
+     */
503
+    public static function filter_discount_state( $post_states, $post ) {
496 504
 
497
-		return apply_filters( 'wpi_discount_table_columns', $columns );
498
-	}
505
+        if ( 'wpi_discount' == $post->post_type ) {
499 506
 
500
-	/**
501
-	 * Filters post states.
502
-	 */
503
-	public static function filter_discount_state( $post_states, $post ) {
507
+            $discount = new WPInv_Discount( $post );
504 508
 
505
-		if ( 'wpi_discount' == $post->post_type ) {
509
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
506 510
 
507
-			$discount = new WPInv_Discount( $post );
511
+            if ( $status != 'publish' ) {
512
+                return array(
513
+                    'discount_status' => wpinv_discount_status( $status ),
514
+                );
515
+            }
508 516
 
509
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
517
+            return array();
510 518
 
511
-			if ( $status != 'publish' ) {
512
-				return array(
513
-					'discount_status' => wpinv_discount_status( $status ),
514
-				);
515
-			}
519
+        }
516 520
 
517
-			return array();
521
+        return $post_states;
518 522
 
519
-		}
523
+    }
520 524
 
521
-		return $post_states;
525
+    /**
526
+     * Returns an array of items table columns.
527
+     */
528
+    public static function item_columns( $columns ) {
529
+
530
+        $columns = array(
531
+            'cb'        => $columns['cb'],
532
+            'title'     => __( 'Name', 'invoicing' ),
533
+            'price'     => __( 'Price', 'invoicing' ),
534
+            'vat_rule'  => __( 'VAT rule', 'invoicing' ),
535
+            'vat_class' => __( 'VAT class', 'invoicing' ),
536
+            'type'      => __( 'Type', 'invoicing' ),
537
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
538
+        );
539
+
540
+        if ( ! wpinv_use_taxes() ) {
541
+            unset( $columns['vat_rule'] );
542
+            unset( $columns['vat_class'] );
543
+        }
544
+
545
+        return apply_filters( 'wpi_item_table_columns', $columns );
546
+    }
547
+
548
+    /**
549
+     * Returns an array of sortable items table columns.
550
+     */
551
+    public static function sortable_item_columns( $columns ) {
552
+
553
+        return array_merge(
554
+            $columns,
555
+            array(
556
+                'price'     => 'price',
557
+                'vat_rule'  => 'vat_rule',
558
+                'vat_class' => 'vat_class',
559
+                'type'      => 'type',
560
+            )
561
+        );
562
+
563
+    }
564
+
565
+    /**
566
+     * Displays items table columns.
567
+     */
568
+    public static function display_item_columns( $column_name, $post_id ) {
569
+
570
+        $item = new WPInv_Item( $post_id );
571
+
572
+        switch ( $column_name ) {
573
+
574
+            case 'price':
575
+                if ( ! $item->is_recurring() ) {
576
+                    echo wp_kses_post( $item->get_the_price() );
577
+                    break;
578
+                }
579
+
580
+                $price = wp_sprintf(
581
+                    __( '%1$s / %2$s', 'invoicing' ),
582
+                    $item->get_the_price(),
583
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
584
+                );
585
+
586
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
+                    echo wp_kses_post( $price );
588
+                    break;
589
+                }
590
+
591
+                echo wp_kses_post( $item->get_the_initial_price() );
592
+
593
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
594
+                break;
595
+
596
+            case 'vat_rule':
597
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
598
+                break;
599
+
600
+            case 'vat_class':
601
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
602
+                break;
603
+
604
+            case 'shortcode':
605
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607
+                } else {
608
+                    echo '&mdash;';
609
+                }
610
+
611
+                break;
612
+
613
+            case 'type':
614
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
615
+                break;
616
+
617
+        }
618
+
619
+    }
620
+
621
+    /**
622
+     * Lets users filter items using taxes.
623
+     */
624
+    public static function add_item_filters( $post_type ) {
625
+
626
+        // Abort if we're not dealing with items.
627
+        if ( $post_type != 'wpi_item' ) {
628
+            return;
629
+        }
630
+
631
+        // Filter by vat rules.
632
+        if ( wpinv_use_taxes() ) {
633
+
634
+            // Sanitize selected vat rule.
635
+            $vat_rule   = '';
636
+            $vat_rules  = getpaid_get_tax_rules();
637
+            if ( isset( $_GET['vat_rule'] ) ) {
638
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
639
+            }
640
+
641
+            // Filter by VAT rule.
642
+            echo wpinv_html_select(
643
+                array(
644
+                    'options'          => array_merge(
645
+                        array(
646
+                            '' => __( 'All VAT rules', 'invoicing' ),
647
+                        ),
648
+                        $vat_rules
649
+                    ),
650
+                    'name'             => 'vat_rule',
651
+                    'id'               => 'vat_rule',
652
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
653
+                    'show_option_all'  => false,
654
+                    'show_option_none' => false,
655
+                )
656
+            );
657
+
658
+            // Filter by VAT class.
659
+
660
+            // Sanitize selected vat rule.
661
+            $vat_class   = '';
662
+            $vat_classes = getpaid_get_tax_classes();
663
+            if ( isset( $_GET['vat_class'] ) ) {
664
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );
665
+            }
666
+
667
+            echo wpinv_html_select(
668
+                array(
669
+                    'options'          => array_merge(
670
+                        array(
671
+                            '' => __( 'All VAT classes', 'invoicing' ),
672
+                        ),
673
+                        $vat_classes
674
+                    ),
675
+                    'name'             => 'vat_class',
676
+                    'id'               => 'vat_class',
677
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
678
+                    'show_option_all'  => false,
679
+                    'show_option_none' => false,
680
+                )
681
+            );
682
+
683
+        }
684
+
685
+        // Filter by item type.
686
+        $type   = '';
687
+        if ( isset( $_GET['type'] ) ) {
688
+            $type   = sanitize_text_field( $_GET['type'] );
689
+        }
522 690
 
523
-	}
691
+        echo wpinv_html_select(
692
+            array(
693
+                'options'          => array_merge(
694
+                    array(
695
+                        '' => __( 'All item types', 'invoicing' ),
696
+                    ),
697
+                    wpinv_get_item_types()
698
+                ),
699
+                'name'             => 'type',
700
+                'id'               => 'type',
701
+                'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
702
+                'show_option_all'  => false,
703
+                'show_option_none' => false,
704
+            )
705
+        );
524 706
 
525
-	/**
526
-	 * Returns an array of items table columns.
527
-	 */
528
-	public static function item_columns( $columns ) {
707
+    }
529 708
 
530
-		$columns = array(
531
-			'cb'        => $columns['cb'],
532
-			'title'     => __( 'Name', 'invoicing' ),
533
-			'price'     => __( 'Price', 'invoicing' ),
534
-			'vat_rule'  => __( 'VAT rule', 'invoicing' ),
535
-			'vat_class' => __( 'VAT class', 'invoicing' ),
536
-			'type'      => __( 'Type', 'invoicing' ),
537
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
538
-		);
709
+    /**
710
+     * Filters the item query.
711
+     */
712
+    public static function filter_item_query( $query ) {
539 713
 
540
-		if ( ! wpinv_use_taxes() ) {
541
-			unset( $columns['vat_rule'] );
542
-			unset( $columns['vat_class'] );
543
-		}
714
+        // modify the query only if it admin and main query.
715
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
716
+            return $query;
717
+        }
544 718
 
545
-		return apply_filters( 'wpi_item_table_columns', $columns );
546
-	}
719
+        // we want to modify the query for our items.
720
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
721
+            return $query;
722
+        }
547 723
 
548
-	/**
549
-	 * Returns an array of sortable items table columns.
550
-	 */
551
-	public static function sortable_item_columns( $columns ) {
552
-
553
-		return array_merge(
554
-			$columns,
555
-			array(
556
-				'price'     => 'price',
557
-				'vat_rule'  => 'vat_rule',
558
-				'vat_class' => 'vat_class',
559
-				'type'      => 'type',
560
-			)
561
-		);
562
-
563
-	}
564
-
565
-	/**
566
-	 * Displays items table columns.
567
-	 */
568
-	public static function display_item_columns( $column_name, $post_id ) {
569
-
570
-		$item = new WPInv_Item( $post_id );
571
-
572
-		switch ( $column_name ) {
573
-
574
-			case 'price':
575
-				if ( ! $item->is_recurring() ) {
576
-					echo wp_kses_post( $item->get_the_price() );
577
-					break;
578
-				}
579
-
580
-				$price = wp_sprintf(
581
-					__( '%1$s / %2$s', 'invoicing' ),
582
-					$item->get_the_price(),
583
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
584
-				);
585
-
586
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
587
-					echo wp_kses_post( $price );
588
-					break;
589
-				}
590
-
591
-				echo wp_kses_post( $item->get_the_initial_price() );
592
-
593
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
594
-				break;
595
-
596
-			case 'vat_rule':
597
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
598
-				break;
599
-
600
-			case 'vat_class':
601
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
602
-				break;
603
-
604
-			case 'shortcode':
605
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
606
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
607
-				} else {
608
-					echo '&mdash;';
609
-				}
610
-
611
-				break;
612
-
613
-			case 'type':
614
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
615
-				break;
616
-
617
-		}
618
-
619
-	}
620
-
621
-	/**
622
-	 * Lets users filter items using taxes.
623
-	 */
624
-	public static function add_item_filters( $post_type ) {
625
-
626
-		// Abort if we're not dealing with items.
627
-		if ( $post_type != 'wpi_item' ) {
628
-			return;
629
-		}
630
-
631
-		// Filter by vat rules.
632
-		if ( wpinv_use_taxes() ) {
633
-
634
-			// Sanitize selected vat rule.
635
-			$vat_rule   = '';
636
-			$vat_rules  = getpaid_get_tax_rules();
637
-			if ( isset( $_GET['vat_rule'] ) ) {
638
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] );
639
-			}
640
-
641
-			// Filter by VAT rule.
642
-			echo wpinv_html_select(
643
-				array(
644
-					'options'          => array_merge(
645
-						array(
646
-							'' => __( 'All VAT rules', 'invoicing' ),
647
-						),
648
-						$vat_rules
649
-					),
650
-					'name'             => 'vat_rule',
651
-					'id'               => 'vat_rule',
652
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ) ) ? $vat_rule : '',
653
-					'show_option_all'  => false,
654
-					'show_option_none' => false,
655
-				)
656
-			);
657
-
658
-			// Filter by VAT class.
659
-
660
-			// Sanitize selected vat rule.
661
-			$vat_class   = '';
662
-			$vat_classes = getpaid_get_tax_classes();
663
-			if ( isset( $_GET['vat_class'] ) ) {
664
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );
665
-			}
666
-
667
-			echo wpinv_html_select(
668
-				array(
669
-					'options'          => array_merge(
670
-						array(
671
-							'' => __( 'All VAT classes', 'invoicing' ),
672
-						),
673
-						$vat_classes
674
-					),
675
-					'name'             => 'vat_class',
676
-					'id'               => 'vat_class',
677
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ) ) ? $vat_class : '',
678
-					'show_option_all'  => false,
679
-					'show_option_none' => false,
680
-				)
681
-			);
682
-
683
-		}
684
-
685
-		// Filter by item type.
686
-		$type   = '';
687
-		if ( isset( $_GET['type'] ) ) {
688
-			$type   = sanitize_text_field( $_GET['type'] );
689
-		}
690
-
691
-		echo wpinv_html_select(
692
-			array(
693
-				'options'          => array_merge(
694
-					array(
695
-						'' => __( 'All item types', 'invoicing' ),
696
-					),
697
-					wpinv_get_item_types()
698
-				),
699
-				'name'             => 'type',
700
-				'id'               => 'type',
701
-				'selected'         => in_array( $type, wpinv_item_types() ) ? $type : '',
702
-				'show_option_all'  => false,
703
-				'show_option_none' => false,
704
-			)
705
-		);
706
-
707
-	}
708
-
709
-	/**
710
-	 * Filters the item query.
711
-	 */
712
-	public static function filter_item_query( $query ) {
713
-
714
-		// modify the query only if it admin and main query.
715
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
716
-			return $query;
717
-		}
718
-
719
-		// we want to modify the query for our items.
720
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' != $query->query['post_type'] ) {
721
-			return $query;
722
-		}
723
-
724
-		if ( empty( $query->query_vars['meta_query'] ) ) {
725
-			$query->query_vars['meta_query'] = array();
726
-		}
727
-
728
-		// Filter vat rule type
724
+        if ( empty( $query->query_vars['meta_query'] ) ) {
725
+            $query->query_vars['meta_query'] = array();
726
+        }
727
+
728
+        // Filter vat rule type
729 729
         if ( ! empty( $_GET['vat_rule'] ) ) {
730 730
             $query->query_vars['meta_query'][] = array(
731 731
                 'key'     => '_wpinv_vat_rule',
@@ -750,97 +750,97 @@  discard block
 block discarded – undo
750 750
                 'value'   => sanitize_text_field( $_GET['type'] ),
751 751
                 'compare' => '=',
752 752
             );
753
-		}
754
-
755
-	}
756
-
757
-	/**
758
-	 * Reorders items.
759
-	 */
760
-	public static function reorder_items( $vars ) {
761
-		global $typenow;
762
-
763
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
764
-			return $vars;
765
-		}
766
-
767
-		// By item type.
768
-		if ( 'type' == $vars['orderby'] ) {
769
-			return array_merge(
770
-				$vars,
771
-				array(
772
-					'meta_key' => '_wpinv_type',
773
-					'orderby'  => 'meta_value',
774
-				)
775
-			);
776
-		}
777
-
778
-		// By vat class.
779
-		if ( 'vat_class' == $vars['orderby'] ) {
780
-			return array_merge(
781
-				$vars,
782
-				array(
783
-					'meta_key' => '_wpinv_vat_class',
784
-					'orderby'  => 'meta_value',
785
-				)
786
-			);
787
-		}
788
-
789
-		// By vat rule.
790
-		if ( 'vat_rule' == $vars['orderby'] ) {
791
-			return array_merge(
792
-				$vars,
793
-				array(
794
-					'meta_key' => '_wpinv_vat_rule',
795
-					'orderby'  => 'meta_value',
796
-				)
797
-			);
798
-		}
799
-
800
-		// By price.
801
-		if ( 'price' == $vars['orderby'] ) {
802
-			return array_merge(
803
-				$vars,
804
-				array(
805
-					'meta_key' => '_wpinv_price',
806
-					'orderby'  => 'meta_value_num',
807
-				)
808
-			);
809
-		}
810
-
811
-		return $vars;
812
-
813
-	}
814
-
815
-	/**
816
-	 * Fired when deleting a post.
817
-	 */
818
-	public static function delete_post( $post_id ) {
819
-
820
-		switch ( get_post_type( $post_id ) ) {
821
-
822
-			case 'wpi_item':
823
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
824
-				break;
825
-
826
-			case 'wpi_payment_form':
827
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
828
-				break;
829
-
830
-			case 'wpi_discount':
831
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
832
-				break;
833
-
834
-			case 'wpi_invoice':
835
-				$invoice = new WPInv_Invoice( $post_id );
836
-				do_action( 'getpaid_before_delete_invoice', $invoice );
837
-				$invoice->get_data_store()->delete_items( $invoice );
838
-				$invoice->get_data_store()->delete_special_fields( $invoice );
839
-				break;
840
-		}
841
-	}
842
-
843
-	/**
753
+        }
754
+
755
+    }
756
+
757
+    /**
758
+     * Reorders items.
759
+     */
760
+    public static function reorder_items( $vars ) {
761
+        global $typenow;
762
+
763
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
764
+            return $vars;
765
+        }
766
+
767
+        // By item type.
768
+        if ( 'type' == $vars['orderby'] ) {
769
+            return array_merge(
770
+                $vars,
771
+                array(
772
+                    'meta_key' => '_wpinv_type',
773
+                    'orderby'  => 'meta_value',
774
+                )
775
+            );
776
+        }
777
+
778
+        // By vat class.
779
+        if ( 'vat_class' == $vars['orderby'] ) {
780
+            return array_merge(
781
+                $vars,
782
+                array(
783
+                    'meta_key' => '_wpinv_vat_class',
784
+                    'orderby'  => 'meta_value',
785
+                )
786
+            );
787
+        }
788
+
789
+        // By vat rule.
790
+        if ( 'vat_rule' == $vars['orderby'] ) {
791
+            return array_merge(
792
+                $vars,
793
+                array(
794
+                    'meta_key' => '_wpinv_vat_rule',
795
+                    'orderby'  => 'meta_value',
796
+                )
797
+            );
798
+        }
799
+
800
+        // By price.
801
+        if ( 'price' == $vars['orderby'] ) {
802
+            return array_merge(
803
+                $vars,
804
+                array(
805
+                    'meta_key' => '_wpinv_price',
806
+                    'orderby'  => 'meta_value_num',
807
+                )
808
+            );
809
+        }
810
+
811
+        return $vars;
812
+
813
+    }
814
+
815
+    /**
816
+     * Fired when deleting a post.
817
+     */
818
+    public static function delete_post( $post_id ) {
819
+
820
+        switch ( get_post_type( $post_id ) ) {
821
+
822
+            case 'wpi_item':
823
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
824
+                break;
825
+
826
+            case 'wpi_payment_form':
827
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
828
+                break;
829
+
830
+            case 'wpi_discount':
831
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
832
+                break;
833
+
834
+            case 'wpi_invoice':
835
+                $invoice = new WPInv_Invoice( $post_id );
836
+                do_action( 'getpaid_before_delete_invoice', $invoice );
837
+                $invoice->get_data_store()->delete_items( $invoice );
838
+                $invoice->get_data_store()->delete_special_fields( $invoice );
839
+                break;
840
+        }
841
+    }
842
+
843
+    /**
844 844
      * Add a post display state for special GetPaid pages in the page list table.
845 845
      *
846 846
      * @param array   $post_states An array of post display states.
@@ -854,21 +854,21 @@  discard block
 block discarded – undo
854 854
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
855 855
         }
856 856
 
857
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
857
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
858 858
 
859
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
-					__( 'GetPaid %s History Page', 'invoicing' ),
862
-					$label
863
-				);
864
-			}
859
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
860
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
861
+                    __( 'GetPaid %s History Page', 'invoicing' ),
862
+                    $label
863
+                );
864
+            }
865 865
 }
866 866
 
867
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
867
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
868 868
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
869 869
         }
870 870
 
871
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
871
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
872 872
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
873 873
         }
874 874
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-invoice-payment-meta.php 1 patch
Indentation   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Invoice_Payment_Meta {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the invoice.
@@ -42,163 +42,163 @@  discard block
 block discarded – undo
42 42
 
43 43
                         if ( $invoice->is_draft() ) {
44 44
 
45
-						// Set gateway.
46
-						aui()->select(
45
+                        // Set gateway.
46
+                        aui()->select(
47 47
                             array(
48
-						'id'               => 'wpinv_gateway',
49
-						'name'             => 'wpinv_gateway',
50
-						'label'            => __( 'Gateway:', 'invoicing' ),
51
-						'label_type'       => 'vertical',
52
-						'placeholder'      => __( 'Select Gateway', 'invoicing' ),
53
-						'value'            => wpinv_get_default_gateway(),
54
-						'select2'          => true,
55
-						'data-allow-clear' => 'false',
56
-						'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
48
+                        'id'               => 'wpinv_gateway',
49
+                        'name'             => 'wpinv_gateway',
50
+                        'label'            => __( 'Gateway:', 'invoicing' ),
51
+                        'label_type'       => 'vertical',
52
+                        'placeholder'      => __( 'Select Gateway', 'invoicing' ),
53
+                        'value'            => wpinv_get_default_gateway(),
54
+                        'select2'          => true,
55
+                        'data-allow-clear' => 'false',
56
+                        'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
57 57
                             ),
58 58
                             true
59 59
                         );
60 60
 
61 61
                         } else {
62
-						// Invoice key.
63
-						aui()->input(
62
+                        // Invoice key.
63
+                        aui()->input(
64 64
                             array(
65
-						'type'             => 'text',
66
-						'id'               => 'wpinv_key',
67
-						'name'             => 'wpinv_key',
68
-						'label'            => sprintf(
65
+                        'type'             => 'text',
66
+                        'id'               => 'wpinv_key',
67
+                        'name'             => 'wpinv_key',
68
+                        'label'            => sprintf(
69 69
                             __( '%s Key:', 'invoicing' ),
70 70
                             ucfirst( $invoice->get_invoice_quote_type() )
71
-						),
72
-						'label_type'       => 'vertical',
73
-						'class'            => 'form-control-sm',
74
-						'value'            => $invoice->get_key( 'edit' ),
75
-						'extra_attributes' => array(
71
+                        ),
72
+                        'label_type'       => 'vertical',
73
+                        'class'            => 'form-control-sm',
74
+                        'value'            => $invoice->get_key( 'edit' ),
75
+                        'extra_attributes' => array(
76 76
                             'onclick'  => 'this.select();',
77 77
                             'readonly' => 'true',
78
-						),
78
+                        ),
79 79
                             ),
80 80
                             true
81
-						);
81
+                        );
82 82
 
83
-						// View URL.
84
-						aui()->input(
83
+                        // View URL.
84
+                        aui()->input(
85 85
                             array(
86
-						'type'             => 'text',
87
-						'id'               => 'wpinv_view_url',
88
-						'name'             => 'wpinv_view_url',
89
-						'label'            => sprintf(
86
+                        'type'             => 'text',
87
+                        'id'               => 'wpinv_view_url',
88
+                        'name'             => 'wpinv_view_url',
89
+                        'label'            => sprintf(
90 90
                             __( '%s URL:', 'invoicing' ),
91 91
                             ucfirst( $invoice->get_invoice_quote_type() )
92
-						) . '&nbsp;<a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
93
-						'label_type'       => 'vertical',
94
-						'class'            => 'form-control-sm',
95
-						'value'            => $invoice->get_view_url(),
96
-						'extra_attributes' => array(
92
+                        ) . '&nbsp;<a href="' . esc_url_raw( $invoice->get_view_url() ) . '" title="' . __( 'View invoice', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>',
93
+                        'label_type'       => 'vertical',
94
+                        'class'            => 'form-control-sm',
95
+                        'value'            => $invoice->get_view_url(),
96
+                        'extra_attributes' => array(
97 97
                             'onclick'  => 'this.select();',
98 98
                             'readonly' => 'true',
99
-						),
99
+                        ),
100 100
                             ),
101 101
                             true
102
-						);
103
-
104
-						// If the invoice is paid...
105
-						if ( $invoice->is_paid() || $invoice->is_refunded() ) {
106
-
107
-							// Gateway.
108
-							aui()->input(
109
-								array(
110
-									'type'             => 'text',
111
-									'id'               => 'wpinv_gateway',
112
-									'name'             => '',
113
-									'label'            => __( 'Gateway:', 'invoicing' ),
114
-									'label_type'       => 'vertical',
115
-									'class'            => 'form-control-sm',
116
-									'value'            => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
117
-									'extra_attributes' => array(
118
-										'onclick'  => 'this.select();',
119
-										'readonly' => 'true',
120
-									),
121
-								),
122
-								true
123
-							);
124
-
125
-							// Transaction ID.
126
-							$transaction_url = $invoice->get_transaction_url();
127
-							aui()->input(
128
-								array(
129
-									'type'             => 'text',
130
-									'id'               => 'wpinv_transaction_id',
131
-									'name'             => 'wpinv_transaction_id',
132
-									'label'            => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? '&nbsp;<a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ),
133
-									'label_type'       => 'vertical',
134
-									'class'            => 'form-control-sm',
135
-									'value'            => $invoice->get_transaction_id( 'edit' ),
136
-									'help_text'        => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
137
-									'extra_attributes' => array(
138
-										'onclick'  => 'this.select();',
139
-										'readonly' => 'true',
140
-									),
141
-								),
142
-								true
143
-							);
144
-
145
-							// Currency.
146
-							aui()->input(
147
-								array(
148
-									'type'             => 'text',
149
-									'id'               => 'wpinv_currency',
150
-									'name'             => 'wpinv_currency',
151
-									'label'            => __( 'Currency:', 'invoicing' ),
152
-									'label_type'       => 'vertical',
153
-									'class'            => 'form-control-sm',
154
-									'value'            => $invoice->get_currency( 'edit' ),
155
-									'extra_attributes' => array(
156
-										'onclick'  => 'this.select();',
157
-										'readonly' => 'true',
158
-									),
159
-								),
160
-								true
161
-							);
162
-
163
-						} else {
164
-
165
-							if ( 'wpi_invoice' == $invoice->get_post_type() ) {
166
-
167
-								// Payment URL.
168
-								aui()->input(
169
-									array(
170
-										'type'             => 'text',
171
-										'id'               => 'wpinv_payment_url',
172
-										'name'             => 'wpinv_payment_url',
173
-										'label'            => __( 'Payment URL:', 'invoicing' ),
174
-										'label_type'       => 'vertical',
175
-										'class'            => 'form-control-sm',
176
-										'value'            => $invoice->get_checkout_payment_url(),
177
-										'extra_attributes' => array(
178
-											'onclick'  => 'this.select();',
179
-											'readonly' => 'true',
180
-										),
181
-									),
182
-									true
183
-								);
184
-
185
-								// Set gateway.
186
-								aui()->select(
187
-									array(
188
-										'id'               => 'wpinv_gateway',
189
-										'name'             => 'wpinv_gateway',
190
-										'label'            => __( 'Gateway:', 'invoicing' ),
191
-										'label_type'       => 'vertical',
192
-										'placeholder'      => __( 'Select Gateway', 'invoicing' ),
193
-										'value'            => $invoice->get_gateway( 'edit' ),
194
-										'select2'          => true,
195
-										'data-allow-clear' => 'false',
196
-										'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
197
-									),
198
-									true
199
-								);
200
-
201
-							}
102
+                        );
103
+
104
+                        // If the invoice is paid...
105
+                        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
106
+
107
+                            // Gateway.
108
+                            aui()->input(
109
+                                array(
110
+                                    'type'             => 'text',
111
+                                    'id'               => 'wpinv_gateway',
112
+                                    'name'             => '',
113
+                                    'label'            => __( 'Gateway:', 'invoicing' ),
114
+                                    'label_type'       => 'vertical',
115
+                                    'class'            => 'form-control-sm',
116
+                                    'value'            => wpinv_get_gateway_admin_label( $invoice->get_gateway( 'edit' ) ),
117
+                                    'extra_attributes' => array(
118
+                                        'onclick'  => 'this.select();',
119
+                                        'readonly' => 'true',
120
+                                    ),
121
+                                ),
122
+                                true
123
+                            );
124
+
125
+                            // Transaction ID.
126
+                            $transaction_url = $invoice->get_transaction_url();
127
+                            aui()->input(
128
+                                array(
129
+                                    'type'             => 'text',
130
+                                    'id'               => 'wpinv_transaction_id',
131
+                                    'name'             => 'wpinv_transaction_id',
132
+                                    'label'            => __( 'Transaction ID:', 'invoicing' ) . ( $transaction_url ? '&nbsp;<a href="' . esc_url( $transaction_url ) . '" title="' . __( 'View details', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-fw"></i></a>' : '' ),
133
+                                    'label_type'       => 'vertical',
134
+                                    'class'            => 'form-control-sm',
135
+                                    'value'            => $invoice->get_transaction_id( 'edit' ),
136
+                                    'help_text'        => apply_filters( 'wpinv_invoice_transaction_link_' . $invoice->get_gateway( 'edit' ), '', $invoice->get_transaction_id(), $invoice ),
137
+                                    'extra_attributes' => array(
138
+                                        'onclick'  => 'this.select();',
139
+                                        'readonly' => 'true',
140
+                                    ),
141
+                                ),
142
+                                true
143
+                            );
144
+
145
+                            // Currency.
146
+                            aui()->input(
147
+                                array(
148
+                                    'type'             => 'text',
149
+                                    'id'               => 'wpinv_currency',
150
+                                    'name'             => 'wpinv_currency',
151
+                                    'label'            => __( 'Currency:', 'invoicing' ),
152
+                                    'label_type'       => 'vertical',
153
+                                    'class'            => 'form-control-sm',
154
+                                    'value'            => $invoice->get_currency( 'edit' ),
155
+                                    'extra_attributes' => array(
156
+                                        'onclick'  => 'this.select();',
157
+                                        'readonly' => 'true',
158
+                                    ),
159
+                                ),
160
+                                true
161
+                            );
162
+
163
+                        } else {
164
+
165
+                            if ( 'wpi_invoice' == $invoice->get_post_type() ) {
166
+
167
+                                // Payment URL.
168
+                                aui()->input(
169
+                                    array(
170
+                                        'type'             => 'text',
171
+                                        'id'               => 'wpinv_payment_url',
172
+                                        'name'             => 'wpinv_payment_url',
173
+                                        'label'            => __( 'Payment URL:', 'invoicing' ),
174
+                                        'label_type'       => 'vertical',
175
+                                        'class'            => 'form-control-sm',
176
+                                        'value'            => $invoice->get_checkout_payment_url(),
177
+                                        'extra_attributes' => array(
178
+                                            'onclick'  => 'this.select();',
179
+                                            'readonly' => 'true',
180
+                                        ),
181
+                                    ),
182
+                                    true
183
+                                );
184
+
185
+                                // Set gateway.
186
+                                aui()->select(
187
+                                    array(
188
+                                        'id'               => 'wpinv_gateway',
189
+                                        'name'             => 'wpinv_gateway',
190
+                                        'label'            => __( 'Gateway:', 'invoicing' ),
191
+                                        'label_type'       => 'vertical',
192
+                                        'placeholder'      => __( 'Select Gateway', 'invoicing' ),
193
+                                        'value'            => $invoice->get_gateway( 'edit' ),
194
+                                        'select2'          => true,
195
+                                        'data-allow-clear' => 'false',
196
+                                        'options'          => wp_list_pluck( wpinv_get_enabled_payment_gateways( true ), 'admin_label' ),
197
+                                    ),
198
+                                    true
199
+                                );
200
+
201
+                            }
202 202
 }
203 203
                         }
204 204
                     ?>
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,10 +17,10 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25 25
 
26 26
         // Prepare the item.
@@ -114,23 +114,23 @@  discard block
 block discarded – undo
114 114
                                 // Dynamic pricing.
115 115
                                 if ( $item->supports_dynamic_pricing() ) {
116 116
 
117
-								do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
117
+                                do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
118 118
 
119
-								// NYP toggle.
120
-								aui()->input(
119
+                                // NYP toggle.
120
+                                aui()->input(
121 121
                                     array(
122
-								'id'      => 'wpinv_name_your_price',
123
-								'name'    => 'wpinv_name_your_price',
124
-								'type'    => 'checkbox',
125
-								'label'   => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
126
-								'value'   => '1',
127
-								'checked' => $item->user_can_set_their_price(),
128
-								'no_wrap' => true,
122
+                                'id'      => 'wpinv_name_your_price',
123
+                                'name'    => 'wpinv_name_your_price',
124
+                                'type'    => 'checkbox',
125
+                                'label'   => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
126
+                                'value'   => '1',
127
+                                'checked' => $item->user_can_set_their_price(),
128
+                                'no_wrap' => true,
129 129
                                     ),
130 130
                                     true
131 131
                                 );
132 132
 
133
-							do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
133
+                            do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
134 134
 
135 135
                                 }
136 136
 
@@ -274,35 +274,35 @@  discard block
 block discarded – undo
274 274
     }
275 275
 
276 276
     /**
277
-	 * Save meta box data.
278
-	 *
279
-	 * @param int $post_id
280
-	 */
281
-	public static function save( $post_id ) {
277
+     * Save meta box data.
278
+     *
279
+     * @param int $post_id
280
+     */
281
+    public static function save( $post_id ) {
282 282
 
283 283
         // Prepare the item.
284 284
         $item = new WPInv_Item( $post_id );
285 285
 
286 286
         // Load new data.
287 287
         $item->set_props(
288
-			array(
289
-				'price'              => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
290
-				'vat_rule'           => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
291
-				'vat_class'          => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
292
-				'type'               => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
293
-				'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ),
288
+            array(
289
+                'price'              => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
290
+                'vat_rule'           => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
291
+                'vat_class'          => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
292
+                'type'               => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
293
+                'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ),
294 294
                 'minimum_price'      => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
295
-				'is_recurring'       => ! empty( $_POST['wpinv_is_recurring'] ),
296
-				'recurring_period'   => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
297
-				'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
298
-				'recurring_limit'    => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
299
-				'is_free_trial'      => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
300
-				'trial_period'       => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
301
-				'trial_interval'     => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
302
-			)
295
+                'is_recurring'       => ! empty( $_POST['wpinv_is_recurring'] ),
296
+                'recurring_period'   => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
297
+                'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
298
+                'recurring_limit'    => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
299
+                'is_free_trial'      => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
300
+                'trial_period'       => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
301
+                'trial_interval'     => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
302
+            )
303 303
         );
304 304
 
305
-		$item->save();
306
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
307
-	}
305
+        $item->save();
306
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
307
+    }
308 308
 }
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
19
-	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
19
+    public static function init() {
20
+        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
+        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
29
-
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
29
+
30
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
+            getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
+            getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
+            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
+                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
 
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
 
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
61
+        global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -261,11 +261,11 @@  discard block
 block discarded – undo
261 261
         check_ajax_referer( 'getpaid_form_nonce' );
262 262
 
263 263
         // Is the request set up correctly?
264
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
265
-			aui()->alert(
266
-				array(
267
-					'type'    => 'warning',
268
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
264
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) && empty( $_GET['invoice'] ) ) {
265
+            aui()->alert(
266
+                array(
267
+                    'type'    => 'warning',
268
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
269 269
                 ),
270 270
                 true
271 271
             );
@@ -273,7 +273,7 @@  discard block
 block discarded – undo
273 273
         }
274 274
 
275 275
         // Payment form or button?
276
-		if ( ! empty( $_GET['form'] ) ) {
276
+        if ( ! empty( $_GET['form'] ) ) {
277 277
             $form = sanitize_text_field( urldecode( $_GET['form'] ) );
278 278
 
279 279
             if ( false !== strpos( $form, '|' ) ) {
@@ -326,10 +326,10 @@  discard block
 block discarded – undo
326 326
                 getpaid_display_payment_form( $form );
327 327
             }
328 328
 } elseif ( ! empty( $_GET['invoice'] ) ) {
329
-		    getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
329
+            getpaid_display_invoice_payment_form( (int) urldecode( $_GET['invoice'] ) );
330 330
         } else {
331
-			$items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
332
-		    getpaid_display_item_payment_form( $items );
331
+            $items = getpaid_convert_items_to_array( sanitize_text_field( urldecode( $_GET['item'] ) ) );
332
+            getpaid_display_item_payment_form( $items );
333 333
         }
334 334
 
335 335
         exit;
@@ -649,7 +649,7 @@  discard block
 block discarded – undo
649 649
         if ( is_wp_error( $error ) ) {
650 650
             $alert = $error->get_error_message();
651 651
             wp_send_json_success( compact( 'alert' ) );
652
-         }
652
+            }
653 653
 
654 654
         // Update totals.
655 655
         $invoice->recalculate_total();
@@ -1084,12 +1084,12 @@  discard block
 block discarded – undo
1084 1084
     }
1085 1085
 
1086 1086
     /**
1087
-	 * Handles file uploads.
1088
-	 *
1089
-	 * @since       1.0.0
1090
-	 * @return      void
1091
-	 */
1092
-	public static function file_upload() {
1087
+     * Handles file uploads.
1088
+     *
1089
+     * @since       1.0.0
1090
+     * @return      void
1091
+     */
1092
+    public static function file_upload() {
1093 1093
 
1094 1094
         // Check nonce.
1095 1095
         check_ajax_referer( 'getpaid_form_nonce' );
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 
1151 1151
         wp_send_json_success( $response );
1152 1152
 
1153
-	}
1153
+    }
1154 1154
 
1155 1155
 }
1156 1156
 
Please login to merge, or discard this patch.
includes/wpinv-template-functions.php 1 patch
Indentation   +135 added lines, -135 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
 
@@ -311,11 +311,11 @@  discard block
 block discarded – undo
311 311
 
312 312
     $output = wpinv_html_select(
313 313
         array(
314
-			'name'             => $name,
315
-			'selected'         => $selected,
316
-			'options'          => $options,
317
-			'show_option_all'  => false,
318
-			'show_option_none' => false,
314
+            'name'             => $name,
315
+            'selected'         => $selected,
316
+            'options'          => $options,
317
+            'show_option_all'  => false,
318
+            'show_option_none' => false,
319 319
         )
320 320
     );
321 321
 
@@ -344,11 +344,11 @@  discard block
 block discarded – undo
344 344
 
345 345
     $output = wpinv_html_select(
346 346
         array(
347
-			'name'             => $name,
348
-			'selected'         => $selected,
349
-			'options'          => $options,
350
-			'show_option_all'  => false,
351
-			'show_option_none' => false,
347
+            'name'             => $name,
348
+            'selected'         => $selected,
349
+            'options'          => $options,
350
+            'show_option_all'  => false,
351
+            'show_option_none' => false,
352 352
         )
353 353
     );
354 354
 
@@ -512,16 +512,16 @@  discard block
 block discarded – undo
512 512
 
513 513
     $output = wpinv_html_select(
514 514
         array(
515
-			'name'             => $args['name'],
516
-			'selected'         => $args['selected'],
517
-			'id'               => $args['id'],
518
-			'class'            => $args['class'],
519
-			'options'          => $options,
520
-			'multiple'         => $args['multiple'],
521
-			'placeholder'      => $args['placeholder'],
522
-			'show_option_all'  => $args['show_option_all'],
523
-			'show_option_none' => $args['show_option_none'],
524
-			'data'             => $args['data'],
515
+            'name'             => $args['name'],
516
+            'selected'         => $args['selected'],
517
+            'id'               => $args['id'],
518
+            'class'            => $args['class'],
519
+            'options'          => $options,
520
+            'multiple'         => $args['multiple'],
521
+            'placeholder'      => $args['placeholder'],
522
+            'show_option_all'  => $args['show_option_all'],
523
+            'show_option_none' => $args['show_option_none'],
524
+            'data'             => $args['data'],
525 525
         )
526 526
     );
527 527
 
@@ -822,21 +822,21 @@  discard block
 block discarded – undo
822 822
 
823 823
     $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format );
824 824
 
825
-	// Remove unavailable tags.
825
+    // Remove unavailable tags.
826 826
     $formatted_address = preg_replace( '/\{\{\w+\}\}/', '', $formatted_address );
827 827
 
828 828
     // Clean up white space.
829
-	$formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
829
+    $formatted_address = preg_replace( '/  +/', ' ', trim( $formatted_address ) );
830 830
     $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address );
831 831
 
832 832
     // Break newlines apart and remove empty lines/trim commas and white space.
833
-	$formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
833
+    $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) );
834 834
 
835 835
     // Add html breaks.
836
-	$formatted_address = implode( $separator, $formatted_address );
836
+    $formatted_address = implode( $separator, $formatted_address );
837 837
 
838
-	// We're done!
839
-	return $formatted_address;
838
+    // We're done!
839
+    return $formatted_address;
840 840
 
841 841
 }
842 842
 
@@ -882,7 +882,7 @@  discard block
 block discarded – undo
882 882
 function getpaid_display_invoice_subscriptions( $invoice ) {
883 883
 
884 884
     // Subscriptions.
885
-	$subscriptions = getpaid_get_invoice_subscriptions( $invoice );
885
+    $subscriptions = getpaid_get_invoice_subscriptions( $invoice );
886 886
 
887 887
     if ( empty( $subscriptions ) || ! $invoice->is_recurring() ) {
888 888
         return;
@@ -1094,7 +1094,7 @@  discard block
 block discarded – undo
1094 1094
 }
1095 1095
 
1096 1096
 function wpinv_empty_cart_message() {
1097
-	return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1097
+    return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' );
1098 1098
 }
1099 1099
 
1100 1100
 /**
@@ -1292,9 +1292,9 @@  discard block
 block discarded – undo
1292 1292
 
1293 1293
     if ( 0 == count( $form->get_items() ) ) {
1294 1294
         aui()->alert(
1295
-			array(
1296
-				'type'    => 'warning',
1297
-				'content' => __( 'No published items found', 'invoicing' ),
1295
+            array(
1296
+                'type'    => 'warning',
1297
+                'content' => __( 'No published items found', 'invoicing' ),
1298 1298
             ),
1299 1299
             true
1300 1300
         );
@@ -1317,10 +1317,10 @@  discard block
 block discarded – undo
1317 1317
     $invoice = wpinv_get_invoice( $invoice_id );
1318 1318
 
1319 1319
     if ( empty( $invoice ) ) {
1320
-		aui()->alert(
1321
-			array(
1322
-				'type'    => 'warning',
1323
-				'content' => __( 'Invoice not found', 'invoicing' ),
1320
+        aui()->alert(
1321
+            array(
1322
+                'type'    => 'warning',
1323
+                'content' => __( 'Invoice not found', 'invoicing' ),
1324 1324
             ),
1325 1325
             true
1326 1326
         );
@@ -1328,10 +1328,10 @@  discard block
 block discarded – undo
1328 1328
     }
1329 1329
 
1330 1330
     if ( $invoice->is_paid() ) {
1331
-		aui()->alert(
1332
-			array(
1333
-				'type'    => 'warning',
1334
-				'content' => __( 'Invoice has already been paid', 'invoicing' ),
1331
+        aui()->alert(
1332
+            array(
1333
+                'type'    => 'warning',
1334
+                'content' => __( 'Invoice has already been paid', 'invoicing' ),
1335 1335
             ),
1336 1336
             true
1337 1337
         );
@@ -1395,7 +1395,7 @@  discard block
 block discarded – undo
1395 1395
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-form='$form'>$label</button>";
1396 1396
     }
1397 1397
 
1398
-	if ( ! empty( $items ) ) {
1398
+    if ( ! empty( $items ) ) {
1399 1399
         $items  = esc_attr( $items );
1400 1400
         return "<button class='btn btn-primary getpaid-payment-button' type='button' data-item='$items'>$label</button>";
1401 1401
     }
@@ -1581,21 +1581,21 @@  discard block
 block discarded – undo
1581 1581
 
1582 1582
         return aui()->select(
1583 1583
             array(
1584
-				'options'          => $states,
1585
-				'name'             => esc_attr( $field_name ),
1586
-				'id'               => sanitize_html_class( $field_name ) . $uniqid,
1587
-				'value'            => sanitize_text_field( $state ),
1588
-				'placeholder'      => $placeholder,
1589
-				'required'         => $required,
1590
-				'label'            => wp_kses_post( $label ),
1591
-				'label_type'       => 'vertical',
1592
-				'help_text'        => $help_text,
1593
-				'class'            => 'getpaid-address-field wpinv_state',
1594
-				'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1595
-				'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1596
-				'extra_attributes' => array(
1597
-					'autocomplete' => 'address-level1',
1598
-				),
1584
+                'options'          => $states,
1585
+                'name'             => esc_attr( $field_name ),
1586
+                'id'               => sanitize_html_class( $field_name ) . $uniqid,
1587
+                'value'            => sanitize_text_field( $state ),
1588
+                'placeholder'      => $placeholder,
1589
+                'required'         => $required,
1590
+                'label'            => wp_kses_post( $label ),
1591
+                'label_type'       => 'vertical',
1592
+                'help_text'        => $help_text,
1593
+                'class'            => 'getpaid-address-field wpinv_state',
1594
+                'wrap_class'       => "$wrapper_class getpaid-address-field-wrapper__state",
1595
+                'label_class'      => 'getpaid-address-field-label getpaid-address-field-label__state',
1596
+                'extra_attributes' => array(
1597
+                    'autocomplete' => 'address-level1',
1598
+                ),
1599 1599
             )
1600 1600
         );
1601 1601
 
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-payment-gateway.php 1 patch
Indentation   +615 added lines, -615 removed lines patch added patch discarded remove patch
@@ -13,462 +13,462 @@  discard block
 block discarded – undo
13 13
  */
14 14
 abstract class GetPaid_Payment_Gateway {
15 15
 
16
-	/**
17
-	 * Set if the place checkout button should be renamed on selection.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	public $checkout_button_text;
22
-
23
-	/**
24
-	 * Boolean whether the method is enabled.
25
-	 *
26
-	 * @var bool
27
-	 */
28
-	public $enabled = true;
29
-
30
-	/**
31
-	 * Payment method id.
32
-	 *
33
-	 * @var string
34
-	 */
35
-	public $id;
36
-
37
-	/**
38
-	 * Payment method order.
39
-	 *
40
-	 * @var int
41
-	 */
42
-	public $order = 10;
43
-
44
-	/**
45
-	 * Payment method title for the frontend.
46
-	 *
47
-	 * @var string
48
-	 */
49
-	public $title;
50
-
51
-	/**
52
-	 * Payment method description for the frontend.
53
-	 *
54
-	 * @var string
55
-	 */
56
-	public $description;
57
-
58
-	/**
59
-	 * Gateway title.
60
-	 *
61
-	 * @var string
62
-	 */
63
-	public $method_title = '';
64
-
65
-	/**
66
-	 * Gateway description.
67
-	 *
68
-	 * @var string
69
-	 */
70
-	public $method_description = '';
71
-
72
-	/**
73
-	 * Countries this gateway is allowed for.
74
-	 *
75
-	 * @var array
76
-	 */
77
-	public $countries;
78
-
79
-	/**
80
-	 * Currencies this gateway is allowed for.
81
-	 *
82
-	 * @var array
83
-	 */
84
-	public $currencies;
85
-
86
-	/**
87
-	 * Currencies this gateway is not allowed for.
88
-	 *
89
-	 * @var array
90
-	 */
91
-	public $exclude_currencies;
92
-
93
-	/**
94
-	 * Maximum transaction amount, zero does not define a maximum.
95
-	 *
96
-	 * @var int
97
-	 */
98
-	public $max_amount = 0;
99
-
100
-	/**
101
-	 * Optional URL to view a transaction.
102
-	 *
103
-	 * @var string
104
-	 */
105
-	public $view_transaction_url = '';
106
-
107
-	/**
108
-	 * Optional URL to view a subscription.
109
-	 *
110
-	 * @var string
111
-	 */
112
-	public $view_subscription_url = '';
113
-
114
-	/**
115
-	 * Optional label to show for "new payment method" in the payment
116
-	 * method/token selection radio selection.
117
-	 *
118
-	 * @var string
119
-	 */
120
-	public $new_method_label = '';
121
-
122
-	/**
123
-	 * Contains a user's saved tokens for this gateway.
124
-	 *
125
-	 * @var array
126
-	 */
127
-	protected $tokens = array();
128
-
129
-	/**
130
-	 * An array of features that this gateway supports.
131
-	 *
132
-	 * @var array
133
-	 */
134
-	protected $supports = array();
135
-
136
-	/**
137
-	 * Class constructor.
138
-	 */
139
-	public function __construct() {
140
-
141
-		// Register gateway.
142
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
-
144
-		$this->enabled = wpinv_is_gateway_active( $this->id );
145
-
146
-		// Add support for various features.
147
-		foreach ( $this->supports as $feature ) {
148
-			add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' );
149
-			add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' );
150
-			add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' );
151
-		}
152
-
153
-		// Invoice addons.
154
-		if ( $this->supports( 'addons' ) ) {
155
-			add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 );
156
-		}
157
-
158
-		// Gateway settings.
159
-		add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
160
-
161
-		// Gateway checkout fiellds.
162
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
163
-
164
-		// Process payment.
165
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
166
-
167
-		// Change the checkout button text.
168
-		if ( ! empty( $this->checkout_button_text ) ) {
169
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
170
-		}
171
-
172
-		// Check if a gateway is valid for a given currency.
173
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
174
-
175
-		// Generate the transaction url.
176
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
177
-
178
-		// Generate the subscription url.
179
-		add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 );
180
-
181
-		// Confirm payments.
182
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
183
-
184
-		// Verify IPNs.
185
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
186
-
187
-	}
188
-
189
-	/**
190
-	 * Checks if this gateway is a given gateway.
191
-	 *
192
-	 * @since 1.0.19
193
-	 * @return bool
194
-	 */
195
-	public function is( $gateway ) {
196
-		return $gateway == $this->id;
197
-	}
198
-
199
-	/**
200
-	 * Returns a users saved tokens for this gateway.
201
-	 *
202
-	 * @since 1.0.19
203
-	 * @return array
204
-	 */
205
-	public function get_tokens( $sandbox = null ) {
206
-
207
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
208
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
209
-
210
-			if ( is_array( $tokens ) ) {
211
-				$this->tokens = $tokens;
212
-			}
16
+    /**
17
+     * Set if the place checkout button should be renamed on selection.
18
+     *
19
+     * @var string
20
+     */
21
+    public $checkout_button_text;
22
+
23
+    /**
24
+     * Boolean whether the method is enabled.
25
+     *
26
+     * @var bool
27
+     */
28
+    public $enabled = true;
29
+
30
+    /**
31
+     * Payment method id.
32
+     *
33
+     * @var string
34
+     */
35
+    public $id;
36
+
37
+    /**
38
+     * Payment method order.
39
+     *
40
+     * @var int
41
+     */
42
+    public $order = 10;
43
+
44
+    /**
45
+     * Payment method title for the frontend.
46
+     *
47
+     * @var string
48
+     */
49
+    public $title;
50
+
51
+    /**
52
+     * Payment method description for the frontend.
53
+     *
54
+     * @var string
55
+     */
56
+    public $description;
57
+
58
+    /**
59
+     * Gateway title.
60
+     *
61
+     * @var string
62
+     */
63
+    public $method_title = '';
64
+
65
+    /**
66
+     * Gateway description.
67
+     *
68
+     * @var string
69
+     */
70
+    public $method_description = '';
71
+
72
+    /**
73
+     * Countries this gateway is allowed for.
74
+     *
75
+     * @var array
76
+     */
77
+    public $countries;
78
+
79
+    /**
80
+     * Currencies this gateway is allowed for.
81
+     *
82
+     * @var array
83
+     */
84
+    public $currencies;
85
+
86
+    /**
87
+     * Currencies this gateway is not allowed for.
88
+     *
89
+     * @var array
90
+     */
91
+    public $exclude_currencies;
92
+
93
+    /**
94
+     * Maximum transaction amount, zero does not define a maximum.
95
+     *
96
+     * @var int
97
+     */
98
+    public $max_amount = 0;
99
+
100
+    /**
101
+     * Optional URL to view a transaction.
102
+     *
103
+     * @var string
104
+     */
105
+    public $view_transaction_url = '';
106
+
107
+    /**
108
+     * Optional URL to view a subscription.
109
+     *
110
+     * @var string
111
+     */
112
+    public $view_subscription_url = '';
113
+
114
+    /**
115
+     * Optional label to show for "new payment method" in the payment
116
+     * method/token selection radio selection.
117
+     *
118
+     * @var string
119
+     */
120
+    public $new_method_label = '';
121
+
122
+    /**
123
+     * Contains a user's saved tokens for this gateway.
124
+     *
125
+     * @var array
126
+     */
127
+    protected $tokens = array();
128
+
129
+    /**
130
+     * An array of features that this gateway supports.
131
+     *
132
+     * @var array
133
+     */
134
+    protected $supports = array();
135
+
136
+    /**
137
+     * Class constructor.
138
+     */
139
+    public function __construct() {
140
+
141
+        // Register gateway.
142
+        add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
143
+
144
+        $this->enabled = wpinv_is_gateway_active( $this->id );
145
+
146
+        // Add support for various features.
147
+        foreach ( $this->supports as $feature ) {
148
+            add_filter( "wpinv_{$this->id}_support_{$feature}", '__return_true' );
149
+            add_filter( "getpaid_{$this->id}_support_{$feature}", '__return_true' );
150
+            add_filter( "getpaid_{$this->id}_supports_{$feature}", '__return_true' );
151
+        }
152
+
153
+        // Invoice addons.
154
+        if ( $this->supports( 'addons' ) ) {
155
+            add_action( "getpaid_process_{$this->id}_invoice_addons", array( $this, 'process_addons' ), 10, 2 );
156
+        }
157
+
158
+        // Gateway settings.
159
+        add_filter( "wpinv_gateway_settings_{$this->id}", array( $this, 'admin_settings' ) );
160
+
161
+        // Gateway checkout fiellds.
162
+        add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
163
+
164
+        // Process payment.
165
+        add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
166
+
167
+        // Change the checkout button text.
168
+        if ( ! empty( $this->checkout_button_text ) ) {
169
+            add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
170
+        }
171
+
172
+        // Check if a gateway is valid for a given currency.
173
+        add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
174
+
175
+        // Generate the transaction url.
176
+        add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
177
+
178
+        // Generate the subscription url.
179
+        add_filter( 'getpaid_remote_subscription_profile_url', array( $this, 'generate_subscription_url' ), 10, 2 );
180
+
181
+        // Confirm payments.
182
+        add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
183
+
184
+        // Verify IPNs.
185
+        add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
186
+
187
+    }
188
+
189
+    /**
190
+     * Checks if this gateway is a given gateway.
191
+     *
192
+     * @since 1.0.19
193
+     * @return bool
194
+     */
195
+    public function is( $gateway ) {
196
+        return $gateway == $this->id;
197
+    }
198
+
199
+    /**
200
+     * Returns a users saved tokens for this gateway.
201
+     *
202
+     * @since 1.0.19
203
+     * @return array
204
+     */
205
+    public function get_tokens( $sandbox = null ) {
206
+
207
+        if ( is_user_logged_in() && $this->supports( 'tokens' ) && 0 == count( $this->tokens ) ) {
208
+            $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
209
+
210
+            if ( is_array( $tokens ) ) {
211
+                $this->tokens = $tokens;
212
+            }
213 213
 }
214 214
 
215
-		if ( ! is_bool( $sandbox ) ) {
216
-			return $this->tokens;
217
-		}
218
-
219
-		// Filter tokens.
220
-		$args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
221
-		return wp_list_filter( $this->tokens, $args );
222
-
223
-	}
224
-
225
-	/**
226
-	 * Saves a token for this gateway.
227
-	 *
228
-	 * @since 1.0.19
229
-	 */
230
-	public function save_token( $token ) {
231
-
232
-		$tokens   = $this->get_tokens();
233
-		$tokens[] = $token;
234
-
235
-		update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
236
-
237
-		$this->tokens = $tokens;
238
-
239
-	}
240
-
241
-	/**
242
-	 * Return the title for admin screens.
243
-	 *
244
-	 * @return string
245
-	 */
246
-	public function get_method_title() {
247
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
248
-	}
249
-
250
-	/**
251
-	 * Return the description for admin screens.
252
-	 *
253
-	 * @return string
254
-	 */
255
-	public function get_method_description() {
256
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
257
-	}
258
-
259
-	/**
260
-	 * Get the success url.
261
-	 *
262
-	 * @param WPInv_Invoice $invoice Invoice object.
263
-	 * @return string
264
-	 */
265
-	public function get_return_url( $invoice ) {
266
-
267
-		// Payment success url
268
-		$return_url = add_query_arg(
269
-			array(
270
-				'payment-confirm' => $this->id,
271
-				'invoice_key'     => $invoice->get_key(),
272
-				'utm_nooverride'  => 1,
273
-			),
274
-			wpinv_get_success_page_uri()
275
-		);
276
-
277
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
278
-	}
279
-
280
-	/**
281
-	 * Confirms payments when rendering the success page.
282
-	 *
283
-	 * @param string $content Success page content.
284
-	 * @return string
285
-	 */
286
-	public function confirm_payment( $content ) {
287
-
288
-		// Retrieve the invoice.
289
-		$invoice_id = getpaid_get_current_invoice_id();
290
-		$invoice    = wpinv_get_invoice( $invoice_id );
291
-
292
-		// Ensure that it exists and that it is pending payment.
293
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
294
-			return $content;
295
-		}
296
-
297
-		// Can the user view this invoice??
298
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
299
-			return $content;
300
-		}
301
-
302
-		// Show payment processing indicator.
303
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
304
-	}
305
-
306
-	/**
307
-	 * Processes ipns and marks payments as complete.
308
-	 *
309
-	 * @return void
310
-	 */
311
-	public function verify_ipn() {}
312
-
313
-	/**
314
-	 * Processes invoice addons.
315
-	 *
316
-	 * @param WPInv_Invoice $invoice
317
-	 * @param GetPaid_Form_Item[] $items
318
-	 * @return WPInv_Invoice
319
-	 */
320
-	public function process_addons( $invoice, $items ) {
321
-
322
-	}
323
-
324
-	/**
325
-	 * Get a link to the transaction on the 3rd party gateway site (if applicable).
326
-	 *
327
-	 * @param string $transaction_url transaction url.
328
-	 * @param WPInv_Invoice $invoice Invoice object.
329
-	 * @return string transaction URL, or empty string.
330
-	 */
331
-	public function filter_transaction_url( $transaction_url, $invoice ) {
332
-
333
-		$transaction_id  = $invoice->get_transaction_id();
334
-
335
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
336
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
337
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
338
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
339
-		}
340
-
341
-		return $transaction_url;
342
-	}
343
-
344
-	/**
345
-	 * Get a link to the subscription on the 3rd party gateway site (if applicable).
346
-	 *
347
-	 * @param string $subscription_url transaction url.
348
-	 * @param WPInv_Subscription $subscription Subscription objectt.
349
-	 * @return string subscription URL, or empty string.
350
-	 */
351
-	public function generate_subscription_url( $subscription_url, $subscription ) {
352
-
353
-		$profile_id      = $subscription->get_profile_id();
354
-
355
-		if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
356
-
357
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
358
-			$replace          = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : '';
359
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
360
-
361
-		}
362
-
363
-		return $subscription_url;
364
-	}
365
-
366
-	/**
367
-	 * Check if the gateway is available for use.
368
-	 *
369
-	 * @return bool
370
-	 */
371
-	public function is_available() {
372
-		return ! empty( $this->enabled );
373
-	}
374
-
375
-	/**
376
-	 * Return the gateway's title.
377
-	 *
378
-	 * @return string
379
-	 */
380
-	public function get_title() {
381
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
382
-	}
383
-
384
-	/**
385
-	 * Return the gateway's description.
386
-	 *
387
-	 * @return string
388
-	 */
389
-	public function get_description() {
390
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
391
-	}
392
-
393
-	/**
394
-	 * Process Payment.
395
-	 *
396
-	 *
397
-	 * @param WPInv_Invoice $invoice Invoice.
398
-	 * @param array $submission_data Posted checkout fields.
399
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
400
-	 * @return void
401
-	 */
402
-	public function process_payment( $invoice, $submission_data, $submission ) {
403
-		// Process the payment then either redirect to the success page or the gateway.
404
-		do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
405
-	}
406
-
407
-	/**
408
-	 * Process refund.
409
-	 *
410
-	 * If the gateway declares 'refunds' support, this will allow it to refund.
411
-	 * a passed in amount.
412
-	 *
413
-	 * @param WPInv_Invoice $invoice Invoice.
414
-	 * @param  float  $amount Refund amount.
415
-	 * @param  string $reason Refund reason.
416
-	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
417
-	 */
418
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
419
-		return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
420
-	}
421
-
422
-	/**
423
-	 * Displays the payment fields, credit cards etc.
424
-	 *
425
-	 * @param int $invoice_id 0 or invoice id.
426
-	 * @param GetPaid_Payment_Form $form Current payment form.
427
-	 */
428
-	public function payment_fields( $invoice_id, $form ) {
429
-		do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
430
-	}
431
-
432
-	/**
433
-	 * Filters the gateway settings.
434
-	 *
435
-	 * @param array $admin_settings
436
-	 */
437
-	public function admin_settings( $admin_settings ) {
438
-		return $admin_settings;
439
-	}
440
-
441
-	/**
442
-	 * Retrieves the value of a gateway setting.
443
-	 *
444
-	 * @param string $option
445
-	 */
446
-	public function get_option( $option, $default = false ) {
447
-		return wpinv_get_option( $this->id . '_' . $option, $default );
448
-	}
449
-
450
-	/**
451
-	 * Check if a gateway supports a given feature.
452
-	 *
453
-	 * Gateways should override this to declare support (or lack of support) for a feature.
454
-	 * For backward compatibility, gateways support 'products' by default, but nothing else.
455
-	 *
456
-	 * @param string $feature string The name of a feature to test support for.
457
-	 * @return bool True if the gateway supports the feature, false otherwise.
458
-	 * @since 1.0.19
459
-	 */
460
-	public function supports( $feature ) {
461
-		return getpaid_payment_gateway_supports( $this->id, $feature );
462
-	}
463
-
464
-	/**
465
-	 * Returns the credit card form html.
466
-	 *
467
-	 * @param bool $save whether or not to display the save button.
468
-	 */
215
+        if ( ! is_bool( $sandbox ) ) {
216
+            return $this->tokens;
217
+        }
218
+
219
+        // Filter tokens.
220
+        $args = array( 'type' => $sandbox ? 'sandbox' : 'live' );
221
+        return wp_list_filter( $this->tokens, $args );
222
+
223
+    }
224
+
225
+    /**
226
+     * Saves a token for this gateway.
227
+     *
228
+     * @since 1.0.19
229
+     */
230
+    public function save_token( $token ) {
231
+
232
+        $tokens   = $this->get_tokens();
233
+        $tokens[] = $token;
234
+
235
+        update_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", $tokens );
236
+
237
+        $this->tokens = $tokens;
238
+
239
+    }
240
+
241
+    /**
242
+     * Return the title for admin screens.
243
+     *
244
+     * @return string
245
+     */
246
+    public function get_method_title() {
247
+        return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
248
+    }
249
+
250
+    /**
251
+     * Return the description for admin screens.
252
+     *
253
+     * @return string
254
+     */
255
+    public function get_method_description() {
256
+        return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
257
+    }
258
+
259
+    /**
260
+     * Get the success url.
261
+     *
262
+     * @param WPInv_Invoice $invoice Invoice object.
263
+     * @return string
264
+     */
265
+    public function get_return_url( $invoice ) {
266
+
267
+        // Payment success url
268
+        $return_url = add_query_arg(
269
+            array(
270
+                'payment-confirm' => $this->id,
271
+                'invoice_key'     => $invoice->get_key(),
272
+                'utm_nooverride'  => 1,
273
+            ),
274
+            wpinv_get_success_page_uri()
275
+        );
276
+
277
+        return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
278
+    }
279
+
280
+    /**
281
+     * Confirms payments when rendering the success page.
282
+     *
283
+     * @param string $content Success page content.
284
+     * @return string
285
+     */
286
+    public function confirm_payment( $content ) {
287
+
288
+        // Retrieve the invoice.
289
+        $invoice_id = getpaid_get_current_invoice_id();
290
+        $invoice    = wpinv_get_invoice( $invoice_id );
291
+
292
+        // Ensure that it exists and that it is pending payment.
293
+        if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
294
+            return $content;
295
+        }
296
+
297
+        // Can the user view this invoice??
298
+        if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
299
+            return $content;
300
+        }
301
+
302
+        // Show payment processing indicator.
303
+        return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
304
+    }
305
+
306
+    /**
307
+     * Processes ipns and marks payments as complete.
308
+     *
309
+     * @return void
310
+     */
311
+    public function verify_ipn() {}
312
+
313
+    /**
314
+     * Processes invoice addons.
315
+     *
316
+     * @param WPInv_Invoice $invoice
317
+     * @param GetPaid_Form_Item[] $items
318
+     * @return WPInv_Invoice
319
+     */
320
+    public function process_addons( $invoice, $items ) {
321
+
322
+    }
323
+
324
+    /**
325
+     * Get a link to the transaction on the 3rd party gateway site (if applicable).
326
+     *
327
+     * @param string $transaction_url transaction url.
328
+     * @param WPInv_Invoice $invoice Invoice object.
329
+     * @return string transaction URL, or empty string.
330
+     */
331
+    public function filter_transaction_url( $transaction_url, $invoice ) {
332
+
333
+        $transaction_id  = $invoice->get_transaction_id();
334
+
335
+        if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
336
+            $transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
337
+            $replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
338
+            $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
339
+        }
340
+
341
+        return $transaction_url;
342
+    }
343
+
344
+    /**
345
+     * Get a link to the subscription on the 3rd party gateway site (if applicable).
346
+     *
347
+     * @param string $subscription_url transaction url.
348
+     * @param WPInv_Subscription $subscription Subscription objectt.
349
+     * @return string subscription URL, or empty string.
350
+     */
351
+    public function generate_subscription_url( $subscription_url, $subscription ) {
352
+
353
+        $profile_id      = $subscription->get_profile_id();
354
+
355
+        if ( $this->id == $subscription->get_gateway() && ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
356
+
357
+            $subscription_url = sprintf( $this->view_subscription_url, $profile_id );
358
+            $replace          = $this->is_sandbox( $subscription->get_parent_invoice() ) ? 'sandbox' : '';
359
+            $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
360
+
361
+        }
362
+
363
+        return $subscription_url;
364
+    }
365
+
366
+    /**
367
+     * Check if the gateway is available for use.
368
+     *
369
+     * @return bool
370
+     */
371
+    public function is_available() {
372
+        return ! empty( $this->enabled );
373
+    }
374
+
375
+    /**
376
+     * Return the gateway's title.
377
+     *
378
+     * @return string
379
+     */
380
+    public function get_title() {
381
+        return apply_filters( 'getpaid_gateway_title', $this->title, $this );
382
+    }
383
+
384
+    /**
385
+     * Return the gateway's description.
386
+     *
387
+     * @return string
388
+     */
389
+    public function get_description() {
390
+        return apply_filters( 'getpaid_gateway_description', $this->description, $this );
391
+    }
392
+
393
+    /**
394
+     * Process Payment.
395
+     *
396
+     *
397
+     * @param WPInv_Invoice $invoice Invoice.
398
+     * @param array $submission_data Posted checkout fields.
399
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
400
+     * @return void
401
+     */
402
+    public function process_payment( $invoice, $submission_data, $submission ) {
403
+        // Process the payment then either redirect to the success page or the gateway.
404
+        do_action( 'getpaid_process_invoice_payment_' . $this->id, $invoice, $submission_data, $submission );
405
+    }
406
+
407
+    /**
408
+     * Process refund.
409
+     *
410
+     * If the gateway declares 'refunds' support, this will allow it to refund.
411
+     * a passed in amount.
412
+     *
413
+     * @param WPInv_Invoice $invoice Invoice.
414
+     * @param  float  $amount Refund amount.
415
+     * @param  string $reason Refund reason.
416
+     * @return WP_Error|bool True or false based on success, or a WP_Error object.
417
+     */
418
+    public function process_refund( $invoice, $amount = null, $reason = '' ) {
419
+        return apply_filters( 'getpaid_process_invoice_refund_' . $this->id, false, $invoice, $amount, $reason );
420
+    }
421
+
422
+    /**
423
+     * Displays the payment fields, credit cards etc.
424
+     *
425
+     * @param int $invoice_id 0 or invoice id.
426
+     * @param GetPaid_Payment_Form $form Current payment form.
427
+     */
428
+    public function payment_fields( $invoice_id, $form ) {
429
+        do_action( 'getpaid_getpaid_gateway_payment_fields_' . $this->id, $invoice_id, $form );
430
+    }
431
+
432
+    /**
433
+     * Filters the gateway settings.
434
+     *
435
+     * @param array $admin_settings
436
+     */
437
+    public function admin_settings( $admin_settings ) {
438
+        return $admin_settings;
439
+    }
440
+
441
+    /**
442
+     * Retrieves the value of a gateway setting.
443
+     *
444
+     * @param string $option
445
+     */
446
+    public function get_option( $option, $default = false ) {
447
+        return wpinv_get_option( $this->id . '_' . $option, $default );
448
+    }
449
+
450
+    /**
451
+     * Check if a gateway supports a given feature.
452
+     *
453
+     * Gateways should override this to declare support (or lack of support) for a feature.
454
+     * For backward compatibility, gateways support 'products' by default, but nothing else.
455
+     *
456
+     * @param string $feature string The name of a feature to test support for.
457
+     * @return bool True if the gateway supports the feature, false otherwise.
458
+     * @since 1.0.19
459
+     */
460
+    public function supports( $feature ) {
461
+        return getpaid_payment_gateway_supports( $this->id, $feature );
462
+    }
463
+
464
+    /**
465
+     * Returns the credit card form html.
466
+     *
467
+     * @param bool $save whether or not to display the save button.
468
+     */
469 469
     public function get_cc_form( $save = false ) {
470 470
 
471
-		ob_start();
471
+        ob_start();
472 472
 
473 473
         $id_prefix = esc_attr( uniqid( $this->id ) );
474 474
 
@@ -528,9 +528,9 @@  discard block
 block discarded – undo
528 528
 
529 529
                                             <?php
530 530
                                                 foreach ( $months as $key => $month ) {
531
-												$key   = esc_attr( $key );
532
-												$month = esc_html( $month );
533
-												echo "<option value='$key'>$month</option>" . PHP_EOL;
531
+                                                $key   = esc_attr( $key );
532
+                                                $month = esc_html( $month );
533
+                                                echo "<option value='$key'>$month</option>" . PHP_EOL;
534 534
                                                 }
535 535
                                             ?>
536 536
 
@@ -543,9 +543,9 @@  discard block
 block discarded – undo
543 543
 
544 544
                                             <?php
545 545
                                                 foreach ( $years as $key => $year ) {
546
-												$key   = esc_attr( $key );
547
-												$year  = esc_html( $year );
548
-												echo "<option value='$key'>$year</option>" . PHP_EOL;
546
+                                                $key   = esc_attr( $key );
547
+                                                $year  = esc_html( $year );
548
+                                                echo "<option value='$key'>$year</option>" . PHP_EOL;
549 549
                                                 }
550 550
                                             ?>
551 551
 
@@ -563,13 +563,13 @@  discard block
 block discarded – undo
563 563
                                         'name'             => $this->id . '[cc_cvv2]',
564 564
                                         'id'               => "$id_prefix-cc-cvv2",
565 565
                                         'label'            => __( 'CCV', 'invoicing' ),
566
-										'label_type'       => 'vertical',
567
-										'class'            => 'form-control-sm',
568
-										'extra_attributes' => array(
569
-											'autocomplete' => 'cc-csc',
570
-										),
566
+                                        'label_type'       => 'vertical',
567
+                                        'class'            => 'form-control-sm',
568
+                                        'extra_attributes' => array(
569
+                                            'autocomplete' => 'cc-csc',
570
+                                        ),
571 571
                                     ),
572
-									true
572
+                                    true
573 573
                                 );
574 574
                             ?>
575 575
                         </div>
@@ -578,192 +578,192 @@  discard block
 block discarded – undo
578 578
 					
579 579
 					<?php
580 580
 
581
-						if ( $save ) {
582
-						echo $this->save_payment_method_checkbox();
583
-						}
581
+                        if ( $save ) {
582
+                        echo $this->save_payment_method_checkbox();
583
+                        }
584 584
 
585
-					?>
585
+                    ?>
586 586
                 </div>
587 587
 
588 588
             </div>
589 589
 		<?php
590 590
 
591
-		return ob_get_clean();
591
+        return ob_get_clean();
592
+
593
+    }
594
+
595
+    /**
596
+     * Displays a new payment method entry form.
597
+     *
598
+     * @since 1.0.19
599
+     */
600
+    public function new_payment_method_entry( $form ) {
601
+        echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
602
+    }
603
+
604
+    /**
605
+     * Grab and display our saved payment methods.
606
+     *
607
+     * @since 1.0.19
608
+     */
609
+    public function saved_payment_methods() {
610
+        $html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
611
+
612
+        foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
613
+            $html .= $this->get_saved_payment_method_option_html( $token );
614
+        }
615
+
616
+        $html .= $this->get_new_payment_method_option_html();
617
+        $html .= '</ul>';
592 618
 
619
+        echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
593 620
     }
594 621
 
595
-	/**
596
-	 * Displays a new payment method entry form.
597
-	 *
598
-	 * @since 1.0.19
599
-	 */
600
-	public function new_payment_method_entry( $form ) {
601
-		echo "<div class='getpaid-new-payment-method-form' style='display:none;'>$form</div>";
602
-	}
603
-
604
-	/**
605
-	 * Grab and display our saved payment methods.
606
-	 *
607
-	 * @since 1.0.19
608
-	 */
609
-	public function saved_payment_methods() {
610
-		$html = '<ul class="getpaid-saved-payment-methods list-unstyled m-0 mt-2" data-count="' . esc_attr( count( $this->get_tokens( $this->is_sandbox() ) ) ) . '">';
611
-
612
-		foreach ( $this->get_tokens( $this->is_sandbox() ) as $token ) {
613
-			$html .= $this->get_saved_payment_method_option_html( $token );
614
-		}
615
-
616
-		$html .= $this->get_new_payment_method_option_html();
617
-		$html .= '</ul>';
618
-
619
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
620
-	}
621
-
622
-	/**
623
-	 * Gets saved payment method HTML from a token.
624
-	 *
625
-	 * @since 1.0.19
626
-	 * @param  array $token Payment Token.
627
-	 * @return string Generated payment method HTML
628
-	 */
629
-	public function get_saved_payment_method_option_html( $token ) {
630
-
631
-		return sprintf(
632
-			'<li class="getpaid-payment-method form-group">
622
+    /**
623
+     * Gets saved payment method HTML from a token.
624
+     *
625
+     * @since 1.0.19
626
+     * @param  array $token Payment Token.
627
+     * @return string Generated payment method HTML
628
+     */
629
+    public function get_saved_payment_method_option_html( $token ) {
630
+
631
+        return sprintf(
632
+            '<li class="getpaid-payment-method form-group">
633 633
 				<label>
634 634
 					<input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" data-currency="%5$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s />
635 635
 					<span>%3$s</span>
636 636
 				</label>
637 637
 			</li>',
638
-			esc_attr( $this->id ),
639
-			esc_attr( $token['id'] ),
640
-			esc_html( $token['name'] ),
641
-			checked( empty( $token['default'] ), false, false ),
642
-			empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] )
643
-		);
644
-
645
-	}
646
-
647
-	/**
648
-	 * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
649
-	 *
650
-	 * @since 1.0.19
651
-	 */
652
-	public function get_new_payment_method_option_html() {
653
-
654
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
655
-
656
-		return sprintf(
657
-			'<li class="getpaid-new-payment-method">
638
+            esc_attr( $this->id ),
639
+            esc_attr( $token['id'] ),
640
+            esc_html( $token['name'] ),
641
+            checked( empty( $token['default'] ), false, false ),
642
+            empty( $token['currency'] ) ? 'none' : esc_attr( $token['currency'] )
643
+        );
644
+
645
+    }
646
+
647
+    /**
648
+     * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
649
+     *
650
+     * @since 1.0.19
651
+     */
652
+    public function get_new_payment_method_option_html() {
653
+
654
+        $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
655
+
656
+        return sprintf(
657
+            '<li class="getpaid-new-payment-method">
658 658
 				<label>
659 659
 					<input name="getpaid-%1$s-payment-method" type="radio" data-currency="none" value="new" style="width:auto;" />
660 660
 					<span>%2$s</span>
661 661
 				</label>
662 662
 			</li>',
663
-			esc_attr( $this->id ),
664
-			esc_html( $label )
665
-		);
666
-
667
-	}
668
-
669
-	/**
670
-	 * Outputs a checkbox for saving a new payment method to the database.
671
-	 *
672
-	 * @since 1.0.19
673
-	 */
674
-	public function save_payment_method_checkbox() {
675
-
676
-		return aui()->input(
677
-			array(
678
-				'type'       => 'checkbox',
679
-				'name'       => esc_attr( "getpaid-$this->id-new-payment-method" ),
680
-				'id'         => esc_attr( uniqid( $this->id ) ),
681
-				'required'   => false,
682
-				'label'      => esc_html__( 'Save payment method', 'invoicing' ),
683
-				'value'      => 'true',
684
-				'checked'    => true,
685
-				'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1',
686
-			)
687
-		);
688
-
689
-	}
690
-
691
-	/**
692
-	 * Registers the gateway.
693
-	 *
694
-	 * @return array
695
-	 */
696
-	public function register_gateway( $gateways ) {
697
-
698
-		$gateways[ $this->id ] = array(
699
-
700
-			'admin_label'    => $this->method_title,
663
+            esc_attr( $this->id ),
664
+            esc_html( $label )
665
+        );
666
+
667
+    }
668
+
669
+    /**
670
+     * Outputs a checkbox for saving a new payment method to the database.
671
+     *
672
+     * @since 1.0.19
673
+     */
674
+    public function save_payment_method_checkbox() {
675
+
676
+        return aui()->input(
677
+            array(
678
+                'type'       => 'checkbox',
679
+                'name'       => esc_attr( "getpaid-$this->id-new-payment-method" ),
680
+                'id'         => esc_attr( uniqid( $this->id ) ),
681
+                'required'   => false,
682
+                'label'      => esc_html__( 'Save payment method', 'invoicing' ),
683
+                'value'      => 'true',
684
+                'checked'    => true,
685
+                'wrap_class' => 'getpaid-save-payment-method pt-1 pb-1',
686
+            )
687
+        );
688
+
689
+    }
690
+
691
+    /**
692
+     * Registers the gateway.
693
+     *
694
+     * @return array
695
+     */
696
+    public function register_gateway( $gateways ) {
697
+
698
+        $gateways[ $this->id ] = array(
699
+
700
+            'admin_label'    => $this->method_title,
701 701
             'checkout_label' => $this->title,
702
-			'ordering'       => $this->order,
702
+            'ordering'       => $this->order,
703 703
 
704
-		);
704
+        );
705 705
 
706
-		return $gateways;
706
+        return $gateways;
707 707
 
708
-	}
708
+    }
709 709
 
710
-	/**
711
-	 * Checks whether or not this is a sandbox request.
712
-	 *
713
-	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
714
-	 * @return bool
715
-	 */
716
-	public function is_sandbox( $invoice = null ) {
710
+    /**
711
+     * Checks whether or not this is a sandbox request.
712
+     *
713
+     * @param  WPInv_Invoice|null $invoice Invoice object or null.
714
+     * @return bool
715
+     */
716
+    public function is_sandbox( $invoice = null ) {
717 717
 
718
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
719
-			return $invoice->get_mode() == 'test';
720
-		}
718
+        if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
719
+            return $invoice->get_mode() == 'test';
720
+        }
721 721
 
722
-		return wpinv_is_test_mode( $this->id );
722
+        return wpinv_is_test_mode( $this->id );
723 723
 
724
-	}
724
+    }
725 725
 
726
-	/**
727
-	 * Renames the checkout button
728
-	 *
729
-	 * @return string
730
-	 */
731
-	public function rename_checkout_button() {
732
-		return $this->checkout_button_text;
733
-	}
726
+    /**
727
+     * Renames the checkout button
728
+     *
729
+     * @return string
730
+     */
731
+    public function rename_checkout_button() {
732
+        return $this->checkout_button_text;
733
+    }
734 734
 
735
-	/**
736
-	 * Validate gateway currency
737
-	 *
738
-	 * @return bool
739
-	 */
740
-	public function validate_currency( $validation, $currency ) {
735
+    /**
736
+     * Validate gateway currency
737
+     *
738
+     * @return bool
739
+     */
740
+    public function validate_currency( $validation, $currency ) {
741 741
 
742
-		// Required currencies.
743
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
744
-			return false;
745
-		}
742
+        // Required currencies.
743
+        if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
744
+            return false;
745
+        }
746 746
 
747
-		// Excluded currencies.
748
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
749
-			return false;
750
-		}
747
+        // Excluded currencies.
748
+        if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
749
+            return false;
750
+        }
751 751
 
752
-		return $validation;
753
-	}
752
+        return $validation;
753
+    }
754 754
 
755
-	/**
756
-	 * Displays an error
757
-	 *
758
-	 */
759
-	public function show_error( $code, $message, $type ) {
755
+    /**
756
+     * Displays an error
757
+     *
758
+     */
759
+    public function show_error( $code, $message, $type ) {
760 760
 
761
-		if ( is_admin() ) {
762
-			getpaid_admin()->{"show_$type"}( $message );
763
-		}
761
+        if ( is_admin() ) {
762
+            getpaid_admin()->{"show_$type"}( $message );
763
+        }
764 764
 
765
-		wpinv_set_error( $code, $message, $type );
765
+        wpinv_set_error( $code, $message, $type );
766 766
 
767
-	}
767
+    }
768 768
 
769 769
 }
Please login to merge, or discard this patch.