Passed
Push — master ( bad3c1...1d1d3a )
by Kiran
12:03 queued 05:36
created
includes/admin/class-getpaid-admin-profile.php 3 patches
Braces   +5 added lines, -2 removed lines patch added patch discarded remove patch
@@ -138,8 +138,11 @@
 block discarded – undo
138 138
 									</select>
139 139
 								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
140 140
 									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) $value, 1, true ); ?> />
141
-								<?php else : ?>
142
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
141
+								<?php else {
142
+    : ?>
143
+									<input type="text" name="<?php echo esc_attr( $key );
144
+}
145
+?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
143 146
 								<?php endif; ?>
144 147
 								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
145 148
 							</td>
Please login to merge, or discard this patch.
Indentation   +185 added lines, -185 removed lines patch added patch discarded remove patch
@@ -5,129 +5,129 @@  discard block
 block discarded – undo
5 5
  */
6 6
 
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit; // Exit if accessed directly
8
+    exit; // Exit if accessed directly
9 9
 }
10 10
 
11 11
 if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
12 12
 
13
-	/**
14
-	 * GetPaid_Admin_Profile Class.
15
-	 */
16
-	class GetPaid_Admin_Profile {
17
-
18
-		/**
19
-		 * Hook in tabs.
20
-		 */
21
-		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
24
-
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
27
-		}
28
-
29
-		/**
30
-		 * Get Address Fields for the edit user pages.
31
-		 *
32
-		 * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned
33
-		 */
34
-		public function get_customer_meta_fields() {
35
-
36
-			$show_fields = apply_filters(
37
-				'getpaid_customer_meta_fields',
38
-				array(
39
-					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
41
-						'fields' => array(
42
-							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
44
-								'description' => '',
45
-							),
46
-							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
48
-								'description' => '',
49
-							),
50
-							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
52
-								'description' => '',
53
-							),
54
-							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
56
-								'description' => '',
57
-							),
58
-							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
60
-								'description' => '',
61
-							),
62
-							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
64
-								'description' => '',
65
-							),
66
-							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
68
-								'description' => '',
69
-							),
70
-							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
72
-								'description' => '',
73
-								'class'       => 'getpaid_js_field-country',
74
-								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
76
-							),
77
-							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
80
-								'class'       => 'getpaid_js_field-state regular-text',
81
-							),
82
-							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
84
-								'description' => '',
85
-							),
86
-							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
88
-								'description' => '',
89
-							),
90
-						),
91
-					),
92
-				)
93
-			);
94
-			return $show_fields;
95
-		}
96
-
97
-		/**
98
-		 * Show Address Fields on edit user pages.
99
-		 *
100
-		 * @param WP_User $user
101
-		 */
102
-		public function add_customer_meta_fields( $user ) {
103
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
-				return;
105
-			}
106
-
107
-			$show_fields = $this->get_customer_meta_fields();
108
-
109
-			$customer = getpaid_get_customer_by_user_id( (int) $user->ID );
110
-
111
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
112
-				if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) {
113
-					unset( $fieldset['fields']['_wpinv_vat_number'] );
114
-				}
115
-				?>
13
+    /**
14
+     * GetPaid_Admin_Profile Class.
15
+     */
16
+    class GetPaid_Admin_Profile {
17
+
18
+        /**
19
+         * Hook in tabs.
20
+         */
21
+        public function __construct() {
22
+            add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
+            add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
24
+
25
+            add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
+            add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
27
+        }
28
+
29
+        /**
30
+         * Get Address Fields for the edit user pages.
31
+         *
32
+         * @return array Fields to display which are filtered through invoicing_customer_meta_fields before being returned
33
+         */
34
+        public function get_customer_meta_fields() {
35
+
36
+            $show_fields = apply_filters(
37
+                'getpaid_customer_meta_fields',
38
+                array(
39
+                    'billing' => array(
40
+                        'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
41
+                        'fields' => array(
42
+                            '_wpinv_first_name' => array(
43
+                                'label'       => __( 'First name', 'invoicing' ),
44
+                                'description' => '',
45
+                            ),
46
+                            '_wpinv_last_name'  => array(
47
+                                'label'       => __( 'Last name', 'invoicing' ),
48
+                                'description' => '',
49
+                            ),
50
+                            '_wpinv_company'    => array(
51
+                                'label'       => __( 'Company', 'invoicing' ),
52
+                                'description' => '',
53
+                            ),
54
+                            '_wpinv_company_id' => array(
55
+                                'label'       => __( 'Company ID', 'invoicing' ),
56
+                                'description' => '',
57
+                            ),
58
+                            '_wpinv_address'    => array(
59
+                                'label'       => __( 'Address', 'invoicing' ),
60
+                                'description' => '',
61
+                            ),
62
+                            '_wpinv_city'       => array(
63
+                                'label'       => __( 'City', 'invoicing' ),
64
+                                'description' => '',
65
+                            ),
66
+                            '_wpinv_zip'        => array(
67
+                                'label'       => __( 'Postcode / ZIP', 'invoicing' ),
68
+                                'description' => '',
69
+                            ),
70
+                            '_wpinv_country'    => array(
71
+                                'label'       => __( 'Country / Region', 'invoicing' ),
72
+                                'description' => '',
73
+                                'class'       => 'getpaid_js_field-country',
74
+                                'type'        => 'select',
75
+                                'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
76
+                            ),
77
+                            '_wpinv_state'      => array(
78
+                                'label'       => __( 'State / County', 'invoicing' ),
79
+                                'description' => __( 'State / County or state code', 'invoicing' ),
80
+                                'class'       => 'getpaid_js_field-state regular-text',
81
+                            ),
82
+                            '_wpinv_phone'      => array(
83
+                                'label'       => __( 'Phone', 'invoicing' ),
84
+                                'description' => '',
85
+                            ),
86
+                            '_wpinv_vat_number' => array(
87
+                                'label'       => __( 'VAT Number', 'invoicing' ),
88
+                                'description' => '',
89
+                            ),
90
+                        ),
91
+                    ),
92
+                )
93
+            );
94
+            return $show_fields;
95
+        }
96
+
97
+        /**
98
+         * Show Address Fields on edit user pages.
99
+         *
100
+         * @param WP_User $user
101
+         */
102
+        public function add_customer_meta_fields( $user ) {
103
+            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
104
+                return;
105
+            }
106
+
107
+            $show_fields = $this->get_customer_meta_fields();
108
+
109
+            $customer = getpaid_get_customer_by_user_id( (int) $user->ID );
110
+
111
+            foreach ( $show_fields as $fieldset_key => $fieldset ) :
112
+                if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) {
113
+                    unset( $fieldset['fields']['_wpinv_vat_number'] );
114
+                }
115
+                ?>
116 116
 				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
117 117
 				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
118 118
 					<?php foreach ( $fieldset['fields'] as $key => $field ) :
119
-						if ( ! empty( $customer ) ) {
120
-							if ( strpos( $key, '_wpinv_' ) === 0 ) {
121
-								$save_key = substr( $key , 7 );
122
-							} else {
123
-								$save_key = $key;
124
-							}
125
-
126
-							$value = $customer->get( $save_key );
127
-						} else {
128
-							$value = $this->get_user_meta( $user->ID, $key );
129
-						}
130
-						?>
119
+                        if ( ! empty( $customer ) ) {
120
+                            if ( strpos( $key, '_wpinv_' ) === 0 ) {
121
+                                $save_key = substr( $key , 7 );
122
+                            } else {
123
+                                $save_key = $key;
124
+                            }
125
+
126
+                            $value = $customer->get( $save_key );
127
+                        } else {
128
+                            $value = $this->get_user_meta( $user->ID, $key );
129
+                        }
130
+                        ?>
131 131
 						<tr>
132 132
 							<th>
133 133
 								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
@@ -150,75 +150,75 @@  discard block
 block discarded – undo
150 150
 					<?php endforeach; ?>
151 151
 				</table>
152 152
 				<?php
153
-			endforeach;
154
-		}
155
-
156
-		/**
157
-		 * Save Address Fields on edit user pages.
158
-		 *
159
-		 * @param int $user_id User ID of the user being saved
160
-		 */
161
-		public function save_customer_meta_fields( $user_id ) {
162
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
163
-				return;
164
-			}
165
-
166
-			$save_fields = $this->get_customer_meta_fields();
167
-			$save_data = array();
168
-
169
-			foreach ( $save_fields as $fieldset ) {
170
-				foreach ( $fieldset['fields'] as $key => $field ) {
171
-					if ( strpos( $key, '_wpinv_' ) === 0 ) {
172
-						$save_key = substr( $key , 7 );
173
-					} else {
174
-						$save_key = $key;
175
-					}
176
-
177
-					if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
178
-						$save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false;
179
-					} else if ( $save_key && isset( $_POST[ $key ] ) ) {
180
-						$save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] );
181
-					}
182
-				}
183
-			}
184
-
185
-			if ( empty( $save_data ) ) {
186
-				return;
187
-			}
188
-
189
-			$customer = getpaid_get_customer_by_user_id( (int) $user_id );
190
-
191
-			if ( empty( $customer ) ) {
192
-				$customer = new GetPaid_Customer( 0 );
193
-				$customer->clone_user( (int) $user_id );
194
-			}
195
-
196
-			foreach ( $save_data as $key => $value ) {
197
-				$customer->set( $key, $value );
198
-			}
199
-
200
-			$customer->save();
201
-		}
202
-
203
-		/**
204
-		 * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
205
-		 *
206
-		 * @since 3.1.0
207
-		 * @param int    $user_id User ID of the user being edited
208
-		 * @param string $key     Key for user meta field
209
-		 * @return string
210
-		 */
211
-		protected function get_user_meta( $user_id, $key ) {
212
-			$value           = get_user_meta( $user_id, $key, true );
213
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
214
-
215
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
216
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
217
-			}
218
-
219
-			return $value;
220
-		}
221
-	}
153
+            endforeach;
154
+        }
155
+
156
+        /**
157
+         * Save Address Fields on edit user pages.
158
+         *
159
+         * @param int $user_id User ID of the user being saved
160
+         */
161
+        public function save_customer_meta_fields( $user_id ) {
162
+            if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
163
+                return;
164
+            }
165
+
166
+            $save_fields = $this->get_customer_meta_fields();
167
+            $save_data = array();
168
+
169
+            foreach ( $save_fields as $fieldset ) {
170
+                foreach ( $fieldset['fields'] as $key => $field ) {
171
+                    if ( strpos( $key, '_wpinv_' ) === 0 ) {
172
+                        $save_key = substr( $key , 7 );
173
+                    } else {
174
+                        $save_key = $key;
175
+                    }
176
+
177
+                    if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
178
+                        $save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false;
179
+                    } else if ( $save_key && isset( $_POST[ $key ] ) ) {
180
+                        $save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] );
181
+                    }
182
+                }
183
+            }
184
+
185
+            if ( empty( $save_data ) ) {
186
+                return;
187
+            }
188
+
189
+            $customer = getpaid_get_customer_by_user_id( (int) $user_id );
190
+
191
+            if ( empty( $customer ) ) {
192
+                $customer = new GetPaid_Customer( 0 );
193
+                $customer->clone_user( (int) $user_id );
194
+            }
195
+
196
+            foreach ( $save_data as $key => $value ) {
197
+                $customer->set( $key, $value );
198
+            }
199
+
200
+            $customer->save();
201
+        }
202
+
203
+        /**
204
+         * Get user meta for a given key, with fallbacks to core user info for pre-existing fields.
205
+         *
206
+         * @since 3.1.0
207
+         * @param int    $user_id User ID of the user being edited
208
+         * @param string $key     Key for user meta field
209
+         * @return string
210
+         */
211
+        protected function get_user_meta( $user_id, $key ) {
212
+            $value           = get_user_meta( $user_id, $key, true );
213
+            $existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
214
+
215
+            if ( ! $value && in_array( $key, $existing_fields ) ) {
216
+                $value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
217
+            }
218
+
219
+            return $value;
220
+        }
221
+    }
222 222
 
223 223
 endif;
224 224
 
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -4,11 +4,11 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit; // Exit if accessed directly
9 9
 }
10 10
 
11
-if ( ! class_exists( 'GetPaid_Admin_Profile', false ) ) :
11
+if (!class_exists('GetPaid_Admin_Profile', false)) :
12 12
 
13 13
 	/**
14 14
 	 * GetPaid_Admin_Profile Class.
@@ -19,11 +19,11 @@  discard block
 block discarded – undo
19 19
 		 * Hook in tabs.
20 20
 		 */
21 21
 		public function __construct() {
22
-			add_action( 'show_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
23
-			add_action( 'edit_user_profile', array( $this, 'add_customer_meta_fields' ), 100 );
22
+			add_action('show_user_profile', array($this, 'add_customer_meta_fields'), 100);
23
+			add_action('edit_user_profile', array($this, 'add_customer_meta_fields'), 100);
24 24
 
25
-			add_action( 'personal_options_update', array( $this, 'save_customer_meta_fields' ) );
26
-			add_action( 'edit_user_profile_update', array( $this, 'save_customer_meta_fields' ) );
25
+			add_action('personal_options_update', array($this, 'save_customer_meta_fields'));
26
+			add_action('edit_user_profile_update', array($this, 'save_customer_meta_fields'));
27 27
 		}
28 28
 
29 29
 		/**
@@ -37,54 +37,54 @@  discard block
 block discarded – undo
37 37
 				'getpaid_customer_meta_fields',
38 38
 				array(
39 39
 					'billing' => array(
40
-						'title'  => __( 'Billing Details (GetPaid)', 'invoicing' ),
40
+						'title'  => __('Billing Details (GetPaid)', 'invoicing'),
41 41
 						'fields' => array(
42 42
 							'_wpinv_first_name' => array(
43
-								'label'       => __( 'First name', 'invoicing' ),
43
+								'label'       => __('First name', 'invoicing'),
44 44
 								'description' => '',
45 45
 							),
46 46
 							'_wpinv_last_name'  => array(
47
-								'label'       => __( 'Last name', 'invoicing' ),
47
+								'label'       => __('Last name', 'invoicing'),
48 48
 								'description' => '',
49 49
 							),
50 50
 							'_wpinv_company'    => array(
51
-								'label'       => __( 'Company', 'invoicing' ),
51
+								'label'       => __('Company', 'invoicing'),
52 52
 								'description' => '',
53 53
 							),
54 54
 							'_wpinv_company_id' => array(
55
-								'label'       => __( 'Company ID', 'invoicing' ),
55
+								'label'       => __('Company ID', 'invoicing'),
56 56
 								'description' => '',
57 57
 							),
58 58
 							'_wpinv_address'    => array(
59
-								'label'       => __( 'Address', 'invoicing' ),
59
+								'label'       => __('Address', 'invoicing'),
60 60
 								'description' => '',
61 61
 							),
62 62
 							'_wpinv_city'       => array(
63
-								'label'       => __( 'City', 'invoicing' ),
63
+								'label'       => __('City', 'invoicing'),
64 64
 								'description' => '',
65 65
 							),
66 66
 							'_wpinv_zip'        => array(
67
-								'label'       => __( 'Postcode / ZIP', 'invoicing' ),
67
+								'label'       => __('Postcode / ZIP', 'invoicing'),
68 68
 								'description' => '',
69 69
 							),
70 70
 							'_wpinv_country'    => array(
71
-								'label'       => __( 'Country / Region', 'invoicing' ),
71
+								'label'       => __('Country / Region', 'invoicing'),
72 72
 								'description' => '',
73 73
 								'class'       => 'getpaid_js_field-country',
74 74
 								'type'        => 'select',
75
-								'options'     => array( '' => __( 'Select a country / region&hellip;', 'invoicing' ) ) + wpinv_get_country_list(),
75
+								'options'     => array('' => __('Select a country / region&hellip;', 'invoicing')) + wpinv_get_country_list(),
76 76
 							),
77 77
 							'_wpinv_state'      => array(
78
-								'label'       => __( 'State / County', 'invoicing' ),
79
-								'description' => __( 'State / County or state code', 'invoicing' ),
78
+								'label'       => __('State / County', 'invoicing'),
79
+								'description' => __('State / County or state code', 'invoicing'),
80 80
 								'class'       => 'getpaid_js_field-state regular-text',
81 81
 							),
82 82
 							'_wpinv_phone'      => array(
83
-								'label'       => __( 'Phone', 'invoicing' ),
83
+								'label'       => __('Phone', 'invoicing'),
84 84
 								'description' => '',
85 85
 							),
86 86
 							'_wpinv_vat_number' => array(
87
-								'label'       => __( 'VAT Number', 'invoicing' ),
87
+								'label'       => __('VAT Number', 'invoicing'),
88 88
 								'description' => '',
89 89
 							),
90 90
 						),
@@ -99,52 +99,52 @@  discard block
 block discarded – undo
99 99
 		 *
100 100
 		 * @param WP_User $user
101 101
 		 */
102
-		public function add_customer_meta_fields( $user ) {
103
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user->ID ) ) {
102
+		public function add_customer_meta_fields($user) {
103
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user->ID)) {
104 104
 				return;
105 105
 			}
106 106
 
107 107
 			$show_fields = $this->get_customer_meta_fields();
108 108
 
109
-			$customer = getpaid_get_customer_by_user_id( (int) $user->ID );
109
+			$customer = getpaid_get_customer_by_user_id((int) $user->ID);
110 110
 
111
-			foreach ( $show_fields as $fieldset_key => $fieldset ) :
112
-				if ( ! wpinv_use_taxes() && isset( $fieldset['fields']['_wpinv_vat_number'] ) ) {
113
-					unset( $fieldset['fields']['_wpinv_vat_number'] );
111
+			foreach ($show_fields as $fieldset_key => $fieldset) :
112
+				if (!wpinv_use_taxes() && isset($fieldset['fields']['_wpinv_vat_number'])) {
113
+					unset($fieldset['fields']['_wpinv_vat_number']);
114 114
 				}
115 115
 				?>
116
-				<h2><?php echo esc_html( $fieldset['title'] ); ?></h2>
117
-				<table class="form-table" id="<?php echo esc_attr( 'getpaid-fieldset-' . $fieldset_key ); ?>">
118
-					<?php foreach ( $fieldset['fields'] as $key => $field ) :
119
-						if ( ! empty( $customer ) ) {
120
-							if ( strpos( $key, '_wpinv_' ) === 0 ) {
121
-								$save_key = substr( $key , 7 );
116
+				<h2><?php echo esc_html($fieldset['title']); ?></h2>
117
+				<table class="form-table" id="<?php echo esc_attr('getpaid-fieldset-' . $fieldset_key); ?>">
118
+					<?php foreach ($fieldset['fields'] as $key => $field) :
119
+						if (!empty($customer)) {
120
+							if (strpos($key, '_wpinv_') === 0) {
121
+								$save_key = substr($key, 7);
122 122
 							} else {
123 123
 								$save_key = $key;
124 124
 							}
125 125
 
126
-							$value = $customer->get( $save_key );
126
+							$value = $customer->get($save_key);
127 127
 						} else {
128
-							$value = $this->get_user_meta( $user->ID, $key );
128
+							$value = $this->get_user_meta($user->ID, $key);
129 129
 						}
130 130
 						?>
131 131
 						<tr>
132 132
 							<th>
133
-								<label for="<?php echo esc_attr( $key ); ?>"><?php echo esc_html( $field['label'] ); ?></label>
133
+								<label for="<?php echo esc_attr($key); ?>"><?php echo esc_html($field['label']); ?></label>
134 134
 							</th>
135 135
 							<td>
136
-								<?php if ( ! empty( $field['type'] ) && 'select' === $field['type'] ) : ?>
137
-									<select name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" class="<?php echo esc_attr( $field['class'] ); ?> wpi_select2" style="width: 25em;">
138
-										<?php foreach ( $field['options'] as $option_key => $option_value ) : ?>
139
-											<option value="<?php echo esc_attr( $option_key ); ?>" <?php selected( $value, $option_key, true ); ?>><?php echo esc_html( $option_value ); ?></option>
136
+								<?php if (!empty($field['type']) && 'select' === $field['type']) : ?>
137
+									<select name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" class="<?php echo esc_attr($field['class']); ?> wpi_select2" style="width: 25em;">
138
+										<?php foreach ($field['options'] as $option_key => $option_value) : ?>
139
+											<option value="<?php echo esc_attr($option_key); ?>" <?php selected($value, $option_key, true); ?>><?php echo esc_html($option_value); ?></option>
140 140
 										<?php endforeach; ?>
141 141
 									</select>
142
-								<?php elseif ( ! empty( $field['type'] ) && 'checkbox' === $field['type'] ) : ?>
143
-									<input type="checkbox" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="1" class="<?php echo esc_attr( $field['class'] ); ?>" <?php checked( (int) $value, 1, true ); ?> />
142
+								<?php elseif (!empty($field['type']) && 'checkbox' === $field['type']) : ?>
143
+									<input type="checkbox" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="1" class="<?php echo esc_attr($field['class']); ?>" <?php checked((int) $value, 1, true); ?> />
144 144
 								<?php else : ?>
145
-									<input type="text" name="<?php echo esc_attr( $key ); ?>" id="<?php echo esc_attr( $key ); ?>" value="<?php echo esc_attr( $value ); ?>" class="<?php echo ( ! empty( $field['class'] ) ? esc_attr( $field['class'] ) : 'regular-text' ); ?>" />
145
+									<input type="text" name="<?php echo esc_attr($key); ?>" id="<?php echo esc_attr($key); ?>" value="<?php echo esc_attr($value); ?>" class="<?php echo (!empty($field['class']) ? esc_attr($field['class']) : 'regular-text'); ?>" />
146 146
 								<?php endif; ?>
147
-								<p class="description"><?php echo wp_kses_post( $field['description'] ); ?></p>
147
+								<p class="description"><?php echo wp_kses_post($field['description']); ?></p>
148 148
 							</td>
149 149
 						</tr>
150 150
 					<?php endforeach; ?>
@@ -158,43 +158,43 @@  discard block
 block discarded – undo
158 158
 		 *
159 159
 		 * @param int $user_id User ID of the user being saved
160 160
 		 */
161
-		public function save_customer_meta_fields( $user_id ) {
162
-			if ( ! apply_filters( 'getpaid_current_user_can_edit_customer_meta_fields', current_user_can( 'manage_options' ), $user_id ) ) {
161
+		public function save_customer_meta_fields($user_id) {
162
+			if (!apply_filters('getpaid_current_user_can_edit_customer_meta_fields', current_user_can('manage_options'), $user_id)) {
163 163
 				return;
164 164
 			}
165 165
 
166 166
 			$save_fields = $this->get_customer_meta_fields();
167 167
 			$save_data = array();
168 168
 
169
-			foreach ( $save_fields as $fieldset ) {
170
-				foreach ( $fieldset['fields'] as $key => $field ) {
171
-					if ( strpos( $key, '_wpinv_' ) === 0 ) {
172
-						$save_key = substr( $key , 7 );
169
+			foreach ($save_fields as $fieldset) {
170
+				foreach ($fieldset['fields'] as $key => $field) {
171
+					if (strpos($key, '_wpinv_') === 0) {
172
+						$save_key = substr($key, 7);
173 173
 					} else {
174 174
 						$save_key = $key;
175 175
 					}
176 176
 
177
-					if ( $save_key && isset( $field['type'] ) && 'checkbox' === $field['type'] ) {
178
-						$save_data[ $save_key ] = ! empty( $_POST[ $key ] ) ? true : false;
179
-					} else if ( $save_key && isset( $_POST[ $key ] ) ) {
180
-						$save_data[ $save_key ] = wpinv_clean( $_POST[ $key ] );
177
+					if ($save_key && isset($field['type']) && 'checkbox' === $field['type']) {
178
+						$save_data[$save_key] = !empty($_POST[$key]) ? true : false;
179
+					} else if ($save_key && isset($_POST[$key])) {
180
+						$save_data[$save_key] = wpinv_clean($_POST[$key]);
181 181
 					}
182 182
 				}
183 183
 			}
184 184
 
185
-			if ( empty( $save_data ) ) {
185
+			if (empty($save_data)) {
186 186
 				return;
187 187
 			}
188 188
 
189
-			$customer = getpaid_get_customer_by_user_id( (int) $user_id );
189
+			$customer = getpaid_get_customer_by_user_id((int) $user_id);
190 190
 
191
-			if ( empty( $customer ) ) {
192
-				$customer = new GetPaid_Customer( 0 );
193
-				$customer->clone_user( (int) $user_id );
191
+			if (empty($customer)) {
192
+				$customer = new GetPaid_Customer(0);
193
+				$customer->clone_user((int) $user_id);
194 194
 			}
195 195
 
196
-			foreach ( $save_data as $key => $value ) {
197
-				$customer->set( $key, $value );
196
+			foreach ($save_data as $key => $value) {
197
+				$customer->set($key, $value);
198 198
 			}
199 199
 
200 200
 			$customer->save();
@@ -208,12 +208,12 @@  discard block
 block discarded – undo
208 208
 		 * @param string $key     Key for user meta field
209 209
 		 * @return string
210 210
 		 */
211
-		protected function get_user_meta( $user_id, $key ) {
212
-			$value           = get_user_meta( $user_id, $key, true );
213
-			$existing_fields = array( '_wpinv_first_name', '_wpinv_last_name' );
211
+		protected function get_user_meta($user_id, $key) {
212
+			$value           = get_user_meta($user_id, $key, true);
213
+			$existing_fields = array('_wpinv_first_name', '_wpinv_last_name');
214 214
 
215
-			if ( ! $value && in_array( $key, $existing_fields ) ) {
216
-				$value = get_user_meta( $user_id, str_replace( '_wpinv_', '', $key ), true );
215
+			if (!$value && in_array($key, $existing_fields)) {
216
+				$value = get_user_meta($user_id, str_replace('_wpinv_', '', $key), true);
217 217
 			}
218 218
 
219 219
 			return $value;
Please login to merge, or discard this patch.
includes/user-functions.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -19,28 +19,28 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function getpaid_get_customers( $args = array(), $return = 'results' ) {
21 21
 
22
-	// Do not retrieve all fields if we just want the count.
23
-	if ( 'count' === $return ) {
24
-		$args['fields'] = 'id';
25
-		$args['number'] = 1;
26
-	}
22
+    // Do not retrieve all fields if we just want the count.
23
+    if ( 'count' === $return ) {
24
+        $args['fields'] = 'id';
25
+        $args['number'] = 1;
26
+    }
27 27
 
28
-	// Do not count all matches if we just want the results.
29
-	if ( 'results' === $return ) {
30
-		$args['count_total'] = false;
31
-	}
28
+    // Do not count all matches if we just want the results.
29
+    if ( 'results' === $return ) {
30
+        $args['count_total'] = false;
31
+    }
32 32
 
33
-	$query = new GetPaid_Customers_Query( $args );
33
+    $query = new GetPaid_Customers_Query( $args );
34 34
 
35
-	if ( 'results' === $return ) {
36
-		return $query->get_results();
37
-	}
35
+    if ( 'results' === $return ) {
36
+        return $query->get_results();
37
+    }
38 38
 
39
-	if ( 'count' === $return ) {
40
-		return $query->get_total();
41
-	}
39
+    if ( 'count' === $return ) {
40
+        return $query->get_total();
41
+    }
42 42
 
43
-	return $query;
43
+    return $query;
44 44
 }
45 45
 
46 46
 /**
@@ -106,11 +106,11 @@  discard block
 block discarded – undo
106 106
  */
107 107
 function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
108 108
 
109
-	if ( current_user_can( 'manage_options' ) ) {
110
-		return 'manage_options';
111
-	};
109
+    if ( current_user_can( 'manage_options' ) ) {
110
+        return 'manage_options';
111
+    };
112 112
 
113
-	return $capalibilty;
113
+    return $capalibilty;
114 114
 }
115 115
 
116 116
 /**
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
  * @return bool Whether the current user has the given capability.
134 134
  */
135 135
 function wpinv_current_user_can( $capability, $args = array() ) {
136
-	$can = wpinv_current_user_can_manage_invoicing();
136
+    $can = wpinv_current_user_can_manage_invoicing();
137 137
 
138
-	return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
138
+    return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
139 139
 }
140 140
 
141 141
 /**
@@ -149,10 +149,10 @@  discard block
 block discarded – undo
149 149
     // Prepare user values.
150 150
     $prefix = preg_replace( '/\s+/', '', $prefix );
151 151
     $prefix = empty( $prefix ) ? $email : $prefix;
152
-	$args   = array(
153
-		'user_login' => wpinv_generate_user_name( $prefix ),
154
-		'user_pass'  => wp_generate_password(),
155
-		'user_email' => $email,
152
+    $args   = array(
153
+        'user_login' => wpinv_generate_user_name( $prefix ),
154
+        'user_pass'  => wp_generate_password(),
155
+        'user_email' => $email,
156 156
         'role'       => 'subscriber',
157 157
     );
158 158
 
@@ -169,16 +169,16 @@  discard block
 block discarded – undo
169 169
 function wpinv_generate_user_name( $prefix = '' ) {
170 170
 
171 171
     // If prefix is an email, retrieve the part before the email.
172
-	$prefix = strtok( $prefix, '@' );
172
+    $prefix = strtok( $prefix, '@' );
173 173
     $prefix = trim( $prefix, '.' );
174 174
 
175
-	// Sanitize the username.
176
-	$prefix = sanitize_user( $prefix, true );
175
+    // Sanitize the username.
176
+    $prefix = sanitize_user( $prefix, true );
177 177
 
178
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
179
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
180
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
181
-	}
178
+    $illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
179
+    if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
180
+        $prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
181
+    }
182 182
 
183 183
     $username = $prefix;
184 184
     $postfix  = 2;
@@ -317,43 +317,43 @@  discard block
 block discarded – undo
317 317
 
318 318
                         $value = $customer->get( $key );
319 319
 
320
-					// Display the country.
321
-					if ( 'country' == $key ) {
322
-
323
-						aui()->select(
324
-							array(
325
-								'options'     => wpinv_get_country_list(),
326
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
327
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
328
-								'value'       => sanitize_text_field( $value ),
329
-								'placeholder' => $label,
330
-								'label'       => wp_kses_post( $label ),
331
-								'label_type'  => 'vertical',
332
-								'class'       => 'getpaid-address-field',
320
+                    // Display the country.
321
+                    if ( 'country' == $key ) {
322
+
323
+                        aui()->select(
324
+                            array(
325
+                                'options'     => wpinv_get_country_list(),
326
+                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
327
+                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
328
+                                'value'       => sanitize_text_field( $value ),
329
+                                'placeholder' => $label,
330
+                                'label'       => wp_kses_post( $label ),
331
+                                'label_type'  => 'vertical',
332
+                                'class'       => 'getpaid-address-field',
333 333
                             ),
334 334
                             true
335
-						);
335
+                        );
336 336
 
337
-					}
337
+                    }
338 338
 
339
-					// Display the state.
340
-					elseif ( 'state' == $key ) {
339
+                    // Display the state.
340
+                    elseif ( 'state' == $key ) {
341 341
 
342
-						getpaid_get_states_select_markup(
342
+                        getpaid_get_states_select_markup(
343 343
                             $customer->get( 'country' ),
344
-							$value,
345
-							$label,
346
-							$label,
347
-							'',
348
-							false,
349
-							'',
350
-							'getpaid_address[' . esc_attr( $key ) . ']',
344
+                            $value,
345
+                            $label,
346
+                            $label,
347
+                            '',
348
+                            false,
349
+                            '',
350
+                            'getpaid_address[' . esc_attr( $key ) . ']',
351 351
                             true
352
-						);
352
+                        );
353 353
 
354 354
                         } else {
355 355
 
356
-						aui()->input(
356
+                        aui()->input(
357 357
                             array(
358 358
                                 'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
359 359
                                 'id'          => 'wpinv-' . sanitize_html_class( $key ),
@@ -365,7 +365,7 @@  discard block
 block discarded – undo
365 365
                                 'class'       => 'getpaid-address-field',
366 366
                             ),
367 367
                             true
368
-						);
368
+                        );
369 369
 
370 370
                         }
371 371
                     }
@@ -509,7 +509,7 @@  discard block
 block discarded – undo
509 509
 function getpaid_allowed_html() {
510 510
     $allowed_html = wp_kses_allowed_html( 'post' );
511 511
 
512
-	// form fields
512
+    // form fields
513 513
     $allowed_html['form'] = array(
514 514
         'action'         => true,
515 515
         'accept'         => true,
@@ -521,12 +521,12 @@  discard block
 block discarded – undo
521 521
     );
522 522
 
523 523
     // - input
524
-	$allowed_html['input'] = array(
525
-		'class'        => array(),
526
-		'id'           => array(),
527
-		'name'         => array(),
528
-		'value'        => array(),
529
-		'type'         => array(),
524
+    $allowed_html['input'] = array(
525
+        'class'        => array(),
526
+        'id'           => array(),
527
+        'name'         => array(),
528
+        'value'        => array(),
529
+        'type'         => array(),
530 530
         'placeholder'  => array(),
531 531
         'autocomplete' => array(),
532 532
         'autofocus'    => array(),
@@ -540,33 +540,33 @@  discard block
 block discarded – undo
540 540
         'max'          => array(),
541 541
         'step'         => array(),
542 542
         'size'         => array(),
543
-	);
543
+    );
544 544
 
545 545
     // - input
546
-	$allowed_html['textarea'] = array(
547
-		'class' => array(),
548
-		'id'    => array(),
549
-		'name'  => array(),
550
-		'value' => array(),
551
-	);
552
-
553
-	// select
554
-	$allowed_html['select'] = array(
555
-		'class'        => array(),
556
-		'id'           => array(),
557
-		'name'         => array(),
546
+    $allowed_html['textarea'] = array(
547
+        'class' => array(),
548
+        'id'    => array(),
549
+        'name'  => array(),
550
+        'value' => array(),
551
+    );
552
+
553
+    // select
554
+    $allowed_html['select'] = array(
555
+        'class'        => array(),
556
+        'id'           => array(),
557
+        'name'         => array(),
558 558
         'autocomplete' => array(),
559 559
         'multiple'     => array(),
560
-	);
560
+    );
561 561
 
562
-	// select options
563
-	$allowed_html['option'] = array(
564
-		'selected' => array(),
562
+    // select options
563
+    $allowed_html['option'] = array(
564
+        'selected' => array(),
565 565
         'disabled' => array(),
566 566
         'value'    => array(),
567
-	);
567
+    );
568 568
 
569
-	return $allowed_html;
569
+    return $allowed_html;
570 570
 
571 571
 }
572 572
 
@@ -870,14 +870,14 @@  discard block
 block discarded – undo
870 870
  * @param WP_User  $user     WP_User object of the user to delete.
871 871
  */
872 872
 function getpaid_delete_user_data( $user_id, $reassign, $user ) {
873
-	global $wpdb;
874
-
875
-	// Delete customer data.
876
-	$wpdb->delete(
877
-		$wpdb->prefix . 'getpaid_customers',
878
-		array(
879
-			'user_id' => (int) $user_id,
880
-		)
881
-	);
873
+    global $wpdb;
874
+
875
+    // Delete customer data.
876
+    $wpdb->delete(
877
+        $wpdb->prefix . 'getpaid_customers',
878
+        array(
879
+            'user_id' => (int) $user_id,
880
+        )
881
+    );
882 882
 }
883 883
 add_action( 'delete_user', 'getpaid_delete_user_data', 10, 3 );
884 884
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +152 added lines, -152 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package GetPaid
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Queries the customers database.
@@ -17,26 +17,26 @@  discard block
 block discarded – undo
17 17
  *
18 18
  * @return int|array|GetPaid_Customer[]|GetPaid_Customers_Query
19 19
  */
20
-function getpaid_get_customers( $args = array(), $return = 'results' ) {
20
+function getpaid_get_customers($args = array(), $return = 'results') {
21 21
 
22 22
 	// Do not retrieve all fields if we just want the count.
23
-	if ( 'count' === $return ) {
23
+	if ('count' === $return) {
24 24
 		$args['fields'] = 'id';
25 25
 		$args['number'] = 1;
26 26
 	}
27 27
 
28 28
 	// Do not count all matches if we just want the results.
29
-	if ( 'results' === $return ) {
29
+	if ('results' === $return) {
30 30
 		$args['count_total'] = false;
31 31
 	}
32 32
 
33
-	$query = new GetPaid_Customers_Query( $args );
33
+	$query = new GetPaid_Customers_Query($args);
34 34
 
35
-	if ( 'results' === $return ) {
35
+	if ('results' === $return) {
36 36
 		return $query->get_results();
37 37
 	}
38 38
 
39
-	if ( 'count' === $return ) {
39
+	if ('count' === $return) {
40 40
 		return $query->get_total();
41 41
 	}
42 42
 
@@ -49,19 +49,19 @@  discard block
 block discarded – undo
49 49
  * @param int|string|object|GetPaid_Customer $customer customer id, email or object.
50 50
  * @return GetPaid_Customer|null
51 51
  */
52
-function getpaid_get_customer( $customer ) {
52
+function getpaid_get_customer($customer) {
53 53
 
54
-    if ( empty( $customer ) ) {
54
+    if (empty($customer)) {
55 55
         return null;
56 56
     }
57 57
 
58 58
     // Retrieve the customer.
59
-    if ( ! is_a( $customer, 'GetPaid_Customer' ) ) {
60
-        $customer = new GetPaid_Customer( $customer );
59
+    if (!is_a($customer, 'GetPaid_Customer')) {
60
+        $customer = new GetPaid_Customer($customer);
61 61
     }
62 62
 
63 63
     // Check if it exists.
64
-    if ( $customer->exists() ) {
64
+    if ($customer->exists()) {
65 65
         return $customer;
66 66
     }
67 67
 
@@ -74,9 +74,9 @@  discard block
 block discarded – undo
74 74
  * @return GetPaid_Customer|null
75 75
  * @since 1.0.0
76 76
  */
77
-function getpaid_get_customer_by_user_id( $user_id ) {
77
+function getpaid_get_customer_by_user_id($user_id) {
78 78
     return getpaid_get_customer(
79
-        GetPaid_Customer::get_customer_id_by( $user_id, 'user_id' )
79
+        GetPaid_Customer::get_customer_id_by($user_id, 'user_id')
80 80
     );
81 81
 }
82 82
 
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
  * @param array $args
89 89
  * @see wp_dropdown_users
90 90
  */
91
-function wpinv_dropdown_users( $args = '' ) {
91
+function wpinv_dropdown_users($args = '') {
92 92
 
93
-    if ( is_array( $args ) && ! empty( $args['show'] ) && 'display_name_with_email' == $args['show'] ) {
93
+    if (is_array($args) && !empty($args['show']) && 'display_name_with_email' == $args['show']) {
94 94
         $args['show'] = 'display_name_with_login';
95 95
     }
96 96
 
97
-    return wp_dropdown_users( $args );
97
+    return wp_dropdown_users($args);
98 98
 }
99 99
 
100 100
 /**
@@ -104,9 +104,9 @@  discard block
 block discarded – undo
104 104
  * @return string capability to check against
105 105
  * @param string $capalibilty Optional. The alternative capability to check against.
106 106
  */
107
-function wpinv_get_capability( $capalibilty = 'manage_invoicing' ) {
107
+function wpinv_get_capability($capalibilty = 'manage_invoicing') {
108 108
 
109
-	if ( current_user_can( 'manage_options' ) ) {
109
+	if (current_user_can('manage_options')) {
110 110
 		return 'manage_options';
111 111
 	};
112 112
 
@@ -120,7 +120,7 @@  discard block
 block discarded – undo
120 120
  * @return bool
121 121
  */
122 122
 function wpinv_current_user_can_manage_invoicing() {
123
-    return current_user_can( wpinv_get_capability() );
123
+    return current_user_can(wpinv_get_capability());
124 124
 }
125 125
 
126 126
 /**
@@ -132,10 +132,10 @@  discard block
 block discarded – undo
132 132
  * @param mixed  $args    Optional further parameters, typically starting with an object.
133 133
  * @return bool Whether the current user has the given capability.
134 134
  */
135
-function wpinv_current_user_can( $capability, $args = array() ) {
135
+function wpinv_current_user_can($capability, $args = array()) {
136 136
 	$can = wpinv_current_user_can_manage_invoicing();
137 137
 
138
-	return apply_filters( 'getpaid_current_user_can', $can, $capability, $args );
138
+	return apply_filters('getpaid_current_user_can', $can, $capability, $args);
139 139
 }
140 140
 
141 141
 /**
@@ -144,19 +144,19 @@  discard block
 block discarded – undo
144 144
  * @since 1.0.19
145 145
  * @return int|WP_Error
146 146
  */
147
-function wpinv_create_user( $email, $prefix = '' ) {
147
+function wpinv_create_user($email, $prefix = '') {
148 148
 
149 149
     // Prepare user values.
150
-    $prefix = preg_replace( '/\s+/', '', $prefix );
151
-    $prefix = empty( $prefix ) ? $email : $prefix;
152
-	$args   = array(
153
-		'user_login' => wpinv_generate_user_name( $prefix ),
150
+    $prefix = preg_replace('/\s+/', '', $prefix);
151
+    $prefix = empty($prefix) ? $email : $prefix;
152
+	$args = array(
153
+		'user_login' => wpinv_generate_user_name($prefix),
154 154
 		'user_pass'  => wp_generate_password(),
155 155
 		'user_email' => $email,
156 156
         'role'       => 'subscriber',
157 157
     );
158 158
 
159
-    return wp_insert_user( $args );
159
+    return wp_insert_user($args);
160 160
 
161 161
 }
162 162
 
@@ -166,26 +166,26 @@  discard block
 block discarded – undo
166 166
  * @since 1.0.19
167 167
  * @return bool|WP_User
168 168
  */
169
-function wpinv_generate_user_name( $prefix = '' ) {
169
+function wpinv_generate_user_name($prefix = '') {
170 170
 
171 171
     // If prefix is an email, retrieve the part before the email.
172
-	$prefix = strtok( $prefix, '@' );
173
-    $prefix = trim( $prefix, '.' );
172
+	$prefix = strtok($prefix, '@');
173
+    $prefix = trim($prefix, '.');
174 174
 
175 175
 	// Sanitize the username.
176
-	$prefix = sanitize_user( $prefix, true );
176
+	$prefix = sanitize_user($prefix, true);
177 177
 
178
-	$illegal_logins = (array) apply_filters( 'illegal_user_logins', array() );
179
-	if ( empty( $prefix ) || in_array( strtolower( $prefix ), array_map( 'strtolower', $illegal_logins ), true ) ) {
180
-		$prefix = 'gtp_' . zeroise( wp_rand( 0, 9999 ), 4 );
178
+	$illegal_logins = (array) apply_filters('illegal_user_logins', array());
179
+	if (empty($prefix) || in_array(strtolower($prefix), array_map('strtolower', $illegal_logins), true)) {
180
+		$prefix = 'gtp_' . zeroise(wp_rand(0, 9999), 4);
181 181
 	}
182 182
 
183 183
     $username = $prefix;
184 184
     $postfix  = 2;
185 185
 
186
-    while ( username_exists( $username ) ) {
186
+    while (username_exists($username)) {
187 187
         $username = "{$prefix}{$postfix}";
188
-        $postfix ++;
188
+        $postfix++;
189 189
     }
190 190
 
191 191
     return $username;
@@ -202,31 +202,31 @@  discard block
 block discarded – undo
202 202
     $tabs = array(
203 203
 
204 204
         'gp-invoices'      => array(
205
-            'label'   => __( 'Invoices', 'invoicing' ), // Name of the tab.
205
+            'label'   => __('Invoices', 'invoicing'), // Name of the tab.
206 206
             'content' => '[wpinv_history]', // Content of the tab. Or specify "callback" to provide a callback instead.
207 207
             'icon'    => 'fas fa-file-invoice', // Shown on some profile plugins.
208 208
         ),
209 209
 
210 210
         'gp-subscriptions' => array(
211
-            'label'   => __( 'Subscriptions', 'invoicing' ),
211
+            'label'   => __('Subscriptions', 'invoicing'),
212 212
             'content' => '[wpinv_subscriptions]',
213 213
             'icon'    => 'fas fa-redo',
214 214
         ),
215 215
 
216 216
         'gp-edit-address'  => array(
217
-            'label'    => __( 'Billing Address', 'invoicing' ),
217
+            'label'    => __('Billing Address', 'invoicing'),
218 218
             'callback' => 'getpaid_display_address_edit_tab',
219 219
             'icon'     => 'fas fa-credit-card',
220 220
         ),
221 221
 
222 222
     );
223 223
 
224
-    $tabs = apply_filters( 'getpaid_user_content_tabs', $tabs );
224
+    $tabs = apply_filters('getpaid_user_content_tabs', $tabs);
225 225
 
226 226
     // Make sure address editing is last on the list.
227
-    if ( isset( $tabs['gp-edit-address'] ) ) {
227
+    if (isset($tabs['gp-edit-address'])) {
228 228
         $address = $tabs['gp-edit-address'];
229
-        unset( $tabs['gp-edit-address'] );
229
+        unset($tabs['gp-edit-address']);
230 230
         $tabs['gp-edit-address'] = $address;
231 231
     }
232 232
 
@@ -240,19 +240,19 @@  discard block
 block discarded – undo
240 240
  * @param array $tab
241 241
  * @return array
242 242
  */
243
-function getpaid_prepare_user_content_tab( $tab ) {
243
+function getpaid_prepare_user_content_tab($tab) {
244 244
 
245
-    if ( ! empty( $tab['callback'] ) ) {
246
-        return call_user_func( $tab['callback'] );
245
+    if (!empty($tab['callback'])) {
246
+        return call_user_func($tab['callback']);
247 247
     }
248 248
 
249
-    if ( ! empty( $tab['content'] ) ) {
250
-        return convert_smilies( capital_P_dangit( wp_filter_content_tags( do_shortcode( shortcode_unautop( wpautop( wptexturize( do_blocks( $tab['content'] ) ) ) ) ) ) ) );
249
+    if (!empty($tab['content'])) {
250
+        return convert_smilies(capital_P_dangit(wp_filter_content_tags(do_shortcode(shortcode_unautop(wpautop(wptexturize(do_blocks($tab['content']))))))));
251 251
     }
252 252
 
253 253
     $notice = aui()->alert(
254 254
         array(
255
-            'content' => __( 'This tab has no content or content callback.', 'invoicing' ),
255
+            'content' => __('This tab has no content or content callback.', 'invoicing'),
256 256
             'type'    => 'error',
257 257
         )
258 258
     );
@@ -268,14 +268,14 @@  discard block
 block discarded – undo
268 268
  * @param string $default
269 269
  * @return array
270 270
  */
271
-function getpaid_get_tab_url( $tab, $default ) {
271
+function getpaid_get_tab_url($tab, $default) {
272 272
     global $getpaid_tab_url;
273 273
 
274
-    if ( empty( $getpaid_tab_url ) ) {
274
+    if (empty($getpaid_tab_url)) {
275 275
         return $default;
276 276
     }
277 277
 
278
-    return sprintf( $getpaid_tab_url, $tab );
278
+    return sprintf($getpaid_tab_url, $tab);
279 279
 
280 280
 }
281 281
 
@@ -287,21 +287,21 @@  discard block
 block discarded – undo
287 287
  */
288 288
 function getpaid_display_address_edit_tab() {
289 289
 
290
-    if ( 0 === get_current_user_id() ) {
290
+    if (0 === get_current_user_id()) {
291 291
         return '<div class="bsui">' . aui()->alert(
292 292
             array(
293 293
                 'type'        => 'error',
294
-                'content'     => __( 'Your must be logged in to view this section', 'invoicing' ),
294
+                'content'     => __('Your must be logged in to view this section', 'invoicing'),
295 295
                 'dismissible' => false,
296 296
             )
297 297
         ) . '</div>';
298 298
     }
299 299
 
300
-    $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
300
+    $customer = getpaid_get_customer_by_user_id(get_current_user_id());
301 301
 
302
-    if ( empty( $customer ) ) {
303
-        $customer = new GetPaid_Customer( 0 );
304
-        $customer->clone_user( get_current_user_id() );
302
+    if (empty($customer)) {
303
+        $customer = new GetPaid_Customer(0);
304
+        $customer->clone_user(get_current_user_id());
305 305
         $customer->save();
306 306
     }
307 307
 
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
 
314 314
                 <?php
315 315
 
316
-                    foreach ( getpaid_user_address_fields() as $key => $label ) {
316
+                    foreach (getpaid_user_address_fields() as $key => $label) {
317 317
 
318
-                        $value = $customer->get( $key );
318
+                        $value = $customer->get($key);
319 319
 
320 320
 					// Display the country.
321
-					if ( 'country' == $key ) {
321
+					if ('country' == $key) {
322 322
 
323 323
 						aui()->select(
324 324
 							array(
325 325
 								'options'     => wpinv_get_country_list(),
326
-								'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
327
-								'id'          => 'wpinv-' . sanitize_html_class( $key ),
328
-								'value'       => sanitize_text_field( $value ),
326
+								'name'        => 'getpaid_address[' . esc_attr($key) . ']',
327
+								'id'          => 'wpinv-' . sanitize_html_class($key),
328
+								'value'       => sanitize_text_field($value),
329 329
 								'placeholder' => $label,
330
-								'label'       => wp_kses_post( $label ),
330
+								'label'       => wp_kses_post($label),
331 331
 								'label_type'  => 'vertical',
332 332
 								'class'       => 'getpaid-address-field',
333 333
                             ),
@@ -337,17 +337,17 @@  discard block
 block discarded – undo
337 337
 					}
338 338
 
339 339
 					// Display the state.
340
-					elseif ( 'state' == $key ) {
340
+					elseif ('state' == $key) {
341 341
 
342 342
 						getpaid_get_states_select_markup(
343
-                            $customer->get( 'country' ),
343
+                            $customer->get('country'),
344 344
 							$value,
345 345
 							$label,
346 346
 							$label,
347 347
 							'',
348 348
 							false,
349 349
 							'',
350
-							'getpaid_address[' . esc_attr( $key ) . ']',
350
+							'getpaid_address[' . esc_attr($key) . ']',
351 351
                             true
352 352
 						);
353 353
 
@@ -355,13 +355,13 @@  discard block
 block discarded – undo
355 355
 
356 356
 						aui()->input(
357 357
                             array(
358
-                                'name'        => 'getpaid_address[' . esc_attr( $key ) . ']',
359
-                                'id'          => 'wpinv-' . sanitize_html_class( $key ),
358
+                                'name'        => 'getpaid_address[' . esc_attr($key) . ']',
359
+                                'id'          => 'wpinv-' . sanitize_html_class($key),
360 360
                                 'placeholder' => $label,
361
-                                'label'       => wp_kses_post( $label ),
361
+                                'label'       => wp_kses_post($label),
362 362
                                 'label_type'  => 'vertical',
363 363
                                 'type'        => 'text',
364
-                                'value'       => sanitize_text_field( $value ),
364
+                                'value'       => sanitize_text_field($value),
365 365
                                 'class'       => 'getpaid-address-field',
366 366
                             ),
367 367
                             true
@@ -375,32 +375,32 @@  discard block
 block discarded – undo
375 375
                             'name'        => 'getpaid_address[email_cc]',
376 376
                             'id'          => 'wpinv-email_cc',
377 377
                             'placeholder' => '[email protected], [email protected]',
378
-                            'label'       => __( 'Other email addresses', 'invoicing' ),
378
+                            'label'       => __('Other email addresses', 'invoicing'),
379 379
                             'label_type'  => 'vertical',
380 380
                             'type'        => 'text',
381
-                            'value'       => sanitize_text_field( $customer->get( 'email_cc' ) ),
381
+                            'value'       => sanitize_text_field($customer->get('email_cc')),
382 382
                             'class'       => 'getpaid-address-field',
383
-                            'help_text'   => __( 'Optionally provide other email addresses where we should send payment notifications', 'invoicing' ),
383
+                            'help_text'   => __('Optionally provide other email addresses where we should send payment notifications', 'invoicing'),
384 384
                         ),
385 385
                         true
386 386
                     );
387 387
 
388
-                    do_action( 'getpaid_display_address_edit_tab' );
388
+                    do_action('getpaid_display_address_edit_tab');
389 389
 
390 390
                     aui()->input(
391 391
                         array(
392 392
                             'name'      => 'getpaid_profile_edit_submit_button',
393 393
                             'id'        => 'getpaid_profile_edit_submit_button',
394
-                            'value'     => __( 'Save Address', 'invoicing' ),
395
-                            'help_text' => __( 'New invoices will use this address as the billing address.', 'invoicing' ),
394
+                            'value'     => __('Save Address', 'invoicing'),
395
+                            'help_text' => __('New invoices will use this address as the billing address.', 'invoicing'),
396 396
                             'type'      => 'submit',
397 397
                             'class'     => 'btn btn-primary btn-block submit-button',
398 398
                         ),
399 399
                         true
400 400
                     );
401 401
 
402
-                    wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' );
403
-                    getpaid_hidden_field( 'getpaid-action', 'edit_billing_details' );
402
+                    wp_nonce_field('getpaid-nonce', 'getpaid-nonce');
403
+                    getpaid_hidden_field('getpaid-action', 'edit_billing_details');
404 404
                 ?>
405 405
 
406 406
             </form>
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 
411 411
     return ob_get_clean();
412 412
 }
413
-add_shortcode( 'getpaid_edit_address', 'getpaid_display_address_edit_tab' );
413
+add_shortcode('getpaid_edit_address', 'getpaid_display_address_edit_tab');
414 414
 
415 415
 /**
416 416
  * Saves the billing address edit tab.
@@ -418,35 +418,35 @@  discard block
 block discarded – undo
418 418
  * @since 2.1.4
419 419
  * @param array $data
420 420
  */
421
-function getpaid_save_address_edit_tab( $data ) {
421
+function getpaid_save_address_edit_tab($data) {
422 422
 
423
-    if ( empty( $data['getpaid_address'] ) || ! is_array( $data['getpaid_address'] ) ) {
423
+    if (empty($data['getpaid_address']) || !is_array($data['getpaid_address'])) {
424 424
         return;
425 425
     }
426 426
 
427 427
     $data     = $data['getpaid_address'];
428
-    $customer = getpaid_get_customer_by_user_id( get_current_user_id() );
428
+    $customer = getpaid_get_customer_by_user_id(get_current_user_id());
429 429
 
430
-    if ( empty( $customer ) ) {
431
-        $customer = new GetPaid_Customer( 0 );
432
-        $customer->clone_user( get_current_user_id() );
430
+    if (empty($customer)) {
431
+        $customer = new GetPaid_Customer(0);
432
+        $customer->clone_user(get_current_user_id());
433 433
     }
434 434
 
435
-    foreach ( array_keys( getpaid_user_address_fields() ) as $field ) {
435
+    foreach (array_keys(getpaid_user_address_fields()) as $field) {
436 436
 
437
-        if ( isset( $data[ $field ] ) ) {
438
-            $customer->set( $field, sanitize_text_field( $data[ $field ] ) );
437
+        if (isset($data[$field])) {
438
+            $customer->set($field, sanitize_text_field($data[$field]));
439 439
         }
440 440
     }
441 441
 
442
-    if ( isset( $data['email_cc'] ) ) {
443
-        $customer->set( 'email_cc', sanitize_text_field( $data['email_cc'] ) );
442
+    if (isset($data['email_cc'])) {
443
+        $customer->set('email_cc', sanitize_text_field($data['email_cc']));
444 444
     }
445 445
 
446 446
     $customer->save();
447
-    wpinv_set_error( 'address_updated' );
447
+    wpinv_set_error('address_updated');
448 448
 }
449
-add_action( 'getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab' );
449
+add_action('getpaid_authenticated_action_edit_billing_details', 'getpaid_save_address_edit_tab');
450 450
 
451 451
 
452 452
 /*
@@ -464,27 +464,27 @@  discard block
 block discarded – undo
464 464
  * @param  array $tabs
465 465
  * @return array
466 466
  */
467
-function getpaid_filter_userswp_account_tabs( $tabs ) {
467
+function getpaid_filter_userswp_account_tabs($tabs) {
468 468
 
469 469
     // Abort if the integration is inactive.
470
-    if ( ! getpaid_is_userswp_integration_active() ) {
470
+    if (!getpaid_is_userswp_integration_active()) {
471 471
         return $tabs;
472 472
     }
473 473
 
474
-    $new_tabs   = array();
474
+    $new_tabs = array();
475 475
 
476
-    foreach ( getpaid_get_user_content_tabs() as $slug => $tab ) {
476
+    foreach (getpaid_get_user_content_tabs() as $slug => $tab) {
477 477
 
478
-        $new_tabs[ $slug ] = array(
478
+        $new_tabs[$slug] = array(
479 479
             'title' => $tab['label'],
480 480
             'icon'  => $tab['icon'],
481 481
         );
482 482
 
483 483
     }
484 484
 
485
-    return array_merge( $tabs, $new_tabs );
485
+    return array_merge($tabs, $new_tabs);
486 486
 }
487
-add_filter( 'uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs' );
487
+add_filter('uwp_account_available_tabs', 'getpaid_filter_userswp_account_tabs');
488 488
 
489 489
 /**
490 490
  * Display our UsersWP account tabs.
@@ -493,21 +493,21 @@  discard block
 block discarded – undo
493 493
  * @param  array $tabs
494 494
  * @return array
495 495
  */
496
-function getpaid_display_userswp_account_tabs( $tab ) {
496
+function getpaid_display_userswp_account_tabs($tab) {
497 497
     global $getpaid_tab_url;
498 498
 
499 499
     $our_tabs = getpaid_get_user_content_tabs();
500 500
 
501
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
502
-        $getpaid_tab_url = add_query_arg( 'type', '%s', uwp_get_account_page_url() );
503
-        echo wp_kses( getpaid_prepare_user_content_tab( $our_tabs[ $tab ] ), getpaid_allowed_html() );
501
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
502
+        $getpaid_tab_url = add_query_arg('type', '%s', uwp_get_account_page_url());
503
+        echo wp_kses(getpaid_prepare_user_content_tab($our_tabs[$tab]), getpaid_allowed_html());
504 504
     }
505 505
 
506 506
 }
507
-add_action( 'uwp_account_form_display', 'getpaid_display_userswp_account_tabs' );
507
+add_action('uwp_account_form_display', 'getpaid_display_userswp_account_tabs');
508 508
 
509 509
 function getpaid_allowed_html() {
510
-    $allowed_html = wp_kses_allowed_html( 'post' );
510
+    $allowed_html = wp_kses_allowed_html('post');
511 511
 
512 512
 	// form fields
513 513
     $allowed_html['form'] = array(
@@ -578,17 +578,17 @@  discard block
 block discarded – undo
578 578
  * @param  string $tab   Current tab.
579 579
  * @return string Title.
580 580
  */
581
-function getpaid_filter_userswp_account_title( $title, $tab ) {
581
+function getpaid_filter_userswp_account_title($title, $tab) {
582 582
 
583
-    $our_tabs   = getpaid_get_user_content_tabs();
583
+    $our_tabs = getpaid_get_user_content_tabs();
584 584
 
585
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
586
-        return $our_tabs[ $tab ]['label'];
585
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
586
+        return $our_tabs[$tab]['label'];
587 587
     }
588 588
 
589 589
     return $title;
590 590
 }
591
-add_filter( 'uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2 );
591
+add_filter('uwp_account_page_title', 'getpaid_filter_userswp_account_title', 10, 2);
592 592
 
593 593
 /**
594 594
  * Registers the UsersWP integration settings.
@@ -597,26 +597,26 @@  discard block
 block discarded – undo
597 597
  * @param  array $settings An array of integration settings.
598 598
  * @return array
599 599
  */
600
-function getpaid_register_userswp_settings( $settings ) {
600
+function getpaid_register_userswp_settings($settings) {
601 601
 
602
-    if ( defined( 'USERSWP_PLUGIN_FILE' ) ) {
602
+    if (defined('USERSWP_PLUGIN_FILE')) {
603 603
 
604 604
         $settings[] = array(
605 605
 
606 606
             'id'       => 'userswp',
607
-            'label'    => __( 'UsersWP', 'invoicing' ),
607
+            'label'    => __('UsersWP', 'invoicing'),
608 608
             'settings' => array(
609 609
 
610 610
                 'userswp_settings' => array(
611 611
                     'id'   => 'userswp_settings',
612
-                    'name' => '<h3>' . __( 'UsersWP', 'invoicing' ) . '</h3>',
612
+                    'name' => '<h3>' . __('UsersWP', 'invoicing') . '</h3>',
613 613
                     'type' => 'header',
614 614
                 ),
615 615
 
616 616
                 'enable_userswp'   => array(
617 617
                     'id'   => 'enable_userswp',
618
-                    'name' => __( 'Enable Integration', 'invoicing' ),
619
-                    'desc' => __( 'Display GetPaid items on UsersWP account page.', 'invoicing' ),
618
+                    'name' => __('Enable Integration', 'invoicing'),
619
+                    'desc' => __('Display GetPaid items on UsersWP account page.', 'invoicing'),
620 620
                     'type' => 'checkbox',
621 621
                     'std'  => 1,
622 622
                 ),
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 
630 630
     return $settings;
631 631
 }
632
-add_filter( 'getpaid_integration_settings', 'getpaid_register_userswp_settings' );
632
+add_filter('getpaid_integration_settings', 'getpaid_register_userswp_settings');
633 633
 
634 634
 /**
635 635
  * Ovewrites the invoices history page to UsersWP.
@@ -637,18 +637,18 @@  discard block
 block discarded – undo
637 637
  * @since  2.3.1
638 638
  * @return bool
639 639
  */
640
-function getpaid_userswp_overwrite_invoice_history_page( $url, $post_type ) {
640
+function getpaid_userswp_overwrite_invoice_history_page($url, $post_type) {
641 641
 
642 642
     $our_tabs = getpaid_get_user_content_tabs();
643 643
     $tab      = "gp-{$post_type}s";
644
-    if ( getpaid_is_userswp_integration_active() && isset( $our_tabs[ $tab ] ) ) {
645
-        return add_query_arg( 'type', $tab, uwp_get_account_page_url() );
644
+    if (getpaid_is_userswp_integration_active() && isset($our_tabs[$tab])) {
645
+        return add_query_arg('type', $tab, uwp_get_account_page_url());
646 646
     }
647 647
 
648 648
     return $url;
649 649
 
650 650
 }
651
-add_filter( 'wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2 );
651
+add_filter('wpinv_get_history_page_uri', 'getpaid_userswp_overwrite_invoice_history_page', 10, 2);
652 652
 
653 653
 /**
654 654
  * Checks if the integration is enabled.
@@ -657,8 +657,8 @@  discard block
 block discarded – undo
657 657
  * @return bool
658 658
  */
659 659
 function getpaid_is_userswp_integration_active() {
660
-    $enabled = wpinv_get_option( 'enable_userswp', 1 );
661
-    return defined( 'USERSWP_PLUGIN_FILE' ) && ! empty( $enabled );
660
+    $enabled = wpinv_get_option('enable_userswp', 1);
661
+    return defined('USERSWP_PLUGIN_FILE') && !empty($enabled);
662 662
 }
663 663
 
664 664
 /*
@@ -676,26 +676,26 @@  discard block
 block discarded – undo
676 676
  * @param  array $settings An array of integration settings.
677 677
  * @return array
678 678
  */
679
-function getpaid_register_buddypress_settings( $settings ) {
679
+function getpaid_register_buddypress_settings($settings) {
680 680
 
681
-    if ( class_exists( 'BuddyPress' ) ) {
681
+    if (class_exists('BuddyPress')) {
682 682
 
683 683
         $settings[] = array(
684 684
 
685 685
             'id'       => 'buddypress',
686
-            'label'    => __( 'BuddyPress', 'invoicing' ),
686
+            'label'    => __('BuddyPress', 'invoicing'),
687 687
             'settings' => array(
688 688
 
689 689
                 'buddypress_settings' => array(
690 690
                     'id'   => 'buddypress_settings',
691
-                    'name' => '<h3>' . __( 'BuddyPress', 'invoicing' ) . '</h3>',
691
+                    'name' => '<h3>' . __('BuddyPress', 'invoicing') . '</h3>',
692 692
                     'type' => 'header',
693 693
                 ),
694 694
 
695 695
                 'enable_buddypress'   => array(
696 696
                     'id'   => 'enable_buddypress',
697
-                    'name' => __( 'Enable Integration', 'invoicing' ),
698
-                    'desc' => __( 'Display GetPaid items on BuddyPress account pages.', 'invoicing' ),
697
+                    'name' => __('Enable Integration', 'invoicing'),
698
+                    'desc' => __('Display GetPaid items on BuddyPress account pages.', 'invoicing'),
699 699
                     'type' => 'checkbox',
700 700
                     'std'  => 1,
701 701
                 ),
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
 
709 709
     return $settings;
710 710
 }
711
-add_filter( 'getpaid_integration_settings', 'getpaid_register_buddypress_settings' );
711
+add_filter('getpaid_integration_settings', 'getpaid_register_buddypress_settings');
712 712
 
713 713
 /**
714 714
  * Checks if the integration is enabled.
@@ -717,8 +717,8 @@  discard block
 block discarded – undo
717 717
  * @return bool
718 718
  */
719 719
 function getpaid_is_buddypress_integration_active() {
720
-    $enabled = wpinv_get_option( 'enable_buddypress', 1 );
721
-    return class_exists( 'BuddyPress' ) && ! empty( $enabled );
720
+    $enabled = wpinv_get_option('enable_buddypress', 1);
721
+    return class_exists('BuddyPress') && !empty($enabled);
722 722
 }
723 723
 
724 724
 /**
@@ -729,13 +729,13 @@  discard block
 block discarded – undo
729 729
  */
730 730
 function getpaid_setup_buddypress_integration() {
731 731
 
732
-    if ( getpaid_is_buddypress_integration_active() ) {
732
+    if (getpaid_is_buddypress_integration_active()) {
733 733
         require_once WPINV_PLUGIN_DIR . 'includes/class-bp-getpaid-component.php';
734 734
         buddypress()->getpaid = new BP_GetPaid_Component();
735 735
     }
736 736
 
737 737
 }
738
-add_action( 'bp_setup_components', 'getpaid_setup_buddypress_integration' );
738
+add_action('bp_setup_components', 'getpaid_setup_buddypress_integration');
739 739
 
740 740
 /**
741 741
  * Checks if a given user has purchased a given item.
@@ -744,10 +744,10 @@  discard block
 block discarded – undo
744 744
  * @param int $item_id The item id.
745 745
  * @return int The IDs of users who purchased the item.
746 746
  */
747
-function getpaid_user_ids_who_purchased_item( $item_id ) {
747
+function getpaid_user_ids_who_purchased_item($item_id) {
748 748
     global $wpdb;
749 749
 
750
-    if ( empty( $item_id ) ) {
750
+    if (empty($item_id)) {
751 751
         return false;
752 752
     }
753 753
 
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
         )
761 761
     );
762 762
 
763
-    return wp_parse_id_list( $ids );
763
+    return wp_parse_id_list($ids);
764 764
 }
765 765
 
766 766
 /**
@@ -769,10 +769,10 @@  discard block
 block discarded – undo
769 769
  * @since 2.6.17
770 770
  * @param int $user_id The user id.
771 771
  */
772
-function getpaid_has_user_purchased_item( $user_id, $item_id ) {
772
+function getpaid_has_user_purchased_item($user_id, $item_id) {
773 773
     global $wpdb;
774 774
 
775
-    if ( empty( $user_id ) ) {
775
+    if (empty($user_id)) {
776 776
         return false;
777 777
     }
778 778
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
         )
788 788
     );
789 789
 
790
-    return ! empty( $count );
790
+    return !empty($count);
791 791
 }
792 792
 
793 793
 /**
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
  * @since 2.6.17
797 797
  * @param int $user_id The user id.
798 798
  */
799
-function getpaid_get_user_total_spend( $user_id ) {
799
+function getpaid_get_user_total_spend($user_id) {
800 800
     $args = array(
801 801
         'data'           => array(
802 802
 
@@ -811,17 +811,17 @@  discard block
 block discarded – undo
811 811
 
812 812
             'author' => array(
813 813
                 'type'     => 'post_data',
814
-                'value'    => absint( $user_id ),
814
+                'value'    => absint($user_id),
815 815
                 'key'      => 'posts.post_author',
816 816
                 'operator' => '=',
817 817
             ),
818 818
 
819 819
         ),
820 820
         'query_type'     => 'get_var',
821
-        'invoice_status' => array( 'wpi-renewal', 'wpi-processing', 'publish' ),
821
+        'invoice_status' => array('wpi-renewal', 'wpi-processing', 'publish'),
822 822
     );
823 823
 
824
-    return wpinv_round_amount( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
824
+    return wpinv_round_amount(GetPaid_Reports_Helper::get_invoice_report_data($args));
825 825
 }
826 826
 
827 827
 /**
@@ -830,7 +830,7 @@  discard block
 block discarded – undo
830 830
  * @since 2.6.17
831 831
  * @param int $user_id The user id.
832 832
  */
833
-function getpaid_count_user_invoices( $user_id ) {
833
+function getpaid_count_user_invoices($user_id) {
834 834
     $args = array(
835 835
         'data'           => array(
836 836
 
@@ -846,17 +846,17 @@  discard block
 block discarded – undo
846 846
 
847 847
             'author' => array(
848 848
                 'type'     => 'post_data',
849
-                'value'    => absint( $user_id ),
849
+                'value'    => absint($user_id),
850 850
                 'key'      => 'posts.post_author',
851 851
                 'operator' => '=',
852 852
             ),
853 853
 
854 854
         ),
855 855
         'query_type'     => 'get_var',
856
-        'invoice_status' => array_keys( wpinv_get_invoice_statuses() ),
856
+        'invoice_status' => array_keys(wpinv_get_invoice_statuses()),
857 857
     );
858 858
 
859
-    return absint( GetPaid_Reports_Helper::get_invoice_report_data( $args ) );
859
+    return absint(GetPaid_Reports_Helper::get_invoice_report_data($args));
860 860
 }
861 861
 
862 862
 /**
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
  *                           Default null, for no reassignment.
870 870
  * @param WP_User  $user     WP_User object of the user to delete.
871 871
  */
872
-function getpaid_delete_user_data( $user_id, $reassign, $user ) {
872
+function getpaid_delete_user_data($user_id, $reassign, $user) {
873 873
 	global $wpdb;
874 874
 
875 875
 	// Delete customer data.
@@ -880,4 +880,4 @@  discard block
 block discarded – undo
880 880
 		)
881 881
 	);
882 882
 }
883
-add_action( 'delete_user', 'getpaid_delete_user_data', 10, 3 );
884 883
\ No newline at end of file
884
+add_action('delete_user', 'getpaid_delete_user_data', 10, 3);
885 885
\ No newline at end of file
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 2 patches
Indentation   +244 added lines, -244 removed lines patch added patch discarded remove patch
@@ -12,257 +12,257 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Taxes {
14 14
 
15
-	/**
16
-	 * Submission taxes.
17
-	 * @var array
18
-	 */
19
-	public $taxes = array();
20
-
21
-	/**
22
-	 * Whether or not we should skip the taxes.
23
-	 * @var bool
24
-	 */
25
-	protected $skip_taxes = false;
15
+    /**
16
+     * Submission taxes.
17
+     * @var array
18
+     */
19
+    public $taxes = array();
20
+
21
+    /**
22
+     * Whether or not we should skip the taxes.
23
+     * @var bool
24
+     */
25
+    protected $skip_taxes = false;
26
+
27
+    /**
28
+     * Class constructor
29
+     *
30
+     * @param GetPaid_Payment_Form_Submission $submission
31
+     */
32
+    public function __construct( $submission ) {
33
+        // Validate VAT number.
34
+        $this->validate_vat( $submission );
35
+
36
+        if ( $this->skip_taxes ) {
37
+            return;
38
+        }
39
+
40
+        foreach ( $submission->get_items() as $item ) {
41
+            $this->process_item_tax( $item, $submission );
42
+        }
43
+
44
+        // Process any existing invoice taxes.
45
+        if ( $submission->has_invoice() ) {
46
+            $invoice = $submission->get_invoice();
47
+            $invoice = $this->refresh_totals( $invoice, $submission );
48
+
49
+            $this->taxes = array_replace( $invoice->get_taxes(), $this->taxes );
50
+        }
51
+    }
52
+
53
+    /**
54
+     * Maybe process tax.
55
+     *
56
+     * @since 1.0.19
57
+     * @param GetPaid_Form_Item $item
58
+     * @param GetPaid_Payment_Form_Submission $submission
59
+     */
60
+    public function process_item_tax( $item, $submission ) {
61
+
62
+        $rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
63
+        $rates    = getpaid_filter_item_tax_rates( $item, $rates );
64
+        $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
65
+        $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
66
+
67
+        foreach ( $taxes as $name => $amount ) {
68
+            $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
69
+            $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
70
+
71
+            $item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] );
72
+
73
+            if ( ! isset( $this->taxes[ $name ] ) ) {
74
+                $this->taxes[ $name ] = $tax;
75
+                continue;
76
+            }
77
+
78
+            $this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
79
+            $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
80
+
81
+        }
82
+
83
+    }
26 84
 
27 85
     /**
28
-	 * Class constructor
29
-	 *
30
-	 * @param GetPaid_Payment_Form_Submission $submission
31
-	 */
32
-	public function __construct( $submission ) {
33
-		// Validate VAT number.
34
-		$this->validate_vat( $submission );
35
-
36
-		if ( $this->skip_taxes ) {
37
-			return;
38
-		}
39
-
40
-		foreach ( $submission->get_items() as $item ) {
41
-			$this->process_item_tax( $item, $submission );
42
-		}
43
-
44
-		// Process any existing invoice taxes.
45
-		if ( $submission->has_invoice() ) {
46
-			$invoice = $submission->get_invoice();
47
-			$invoice = $this->refresh_totals( $invoice, $submission );
48
-
49
-			$this->taxes = array_replace( $invoice->get_taxes(), $this->taxes );
50
-		}
51
-	}
52
-
53
-	/**
54
-	 * Maybe process tax.
55
-	 *
56
-	 * @since 1.0.19
57
-	 * @param GetPaid_Form_Item $item
58
-	 * @param GetPaid_Payment_Form_Submission $submission
59
-	 */
60
-	public function process_item_tax( $item, $submission ) {
61
-
62
-		$rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
63
-		$rates    = getpaid_filter_item_tax_rates( $item, $rates );
64
-		$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
65
-		$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
66
-
67
-		foreach ( $taxes as $name => $amount ) {
68
-			$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
69
-			$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
70
-
71
-			$item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] );
72
-
73
-			if ( ! isset( $this->taxes[ $name ] ) ) {
74
-				$this->taxes[ $name ] = $tax;
75
-				continue;
76
-			}
77
-
78
-			$this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
79
-			$this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
80
-
81
-		}
82
-
83
-	}
84
-
85
-	/**
86
-	 * Checks if the submission has a digital item.
87
-	 *
88
-	 * @param GetPaid_Payment_Form_Submission $submission
89
-	 * @since 1.0.19
90
-	 * @return bool
91
-	 */
92
-	public function has_digital_item( $submission ) {
93
-
94
-		foreach ( $submission->get_items() as $item ) {
95
-
96
-			if ( 'digital' == $item->get_vat_rule() ) {
97
-				return true;
98
-			}
86
+     * Checks if the submission has a digital item.
87
+     *
88
+     * @param GetPaid_Payment_Form_Submission $submission
89
+     * @since 1.0.19
90
+     * @return bool
91
+     */
92
+    public function has_digital_item( $submission ) {
93
+
94
+        foreach ( $submission->get_items() as $item ) {
95
+
96
+            if ( 'digital' == $item->get_vat_rule() ) {
97
+                return true;
98
+            }
99 99
 }
100 100
 
101
-		return false;
102
-	}
103
-
104
-	/**
105
-	 * Checks if this is an eu store.
106
-	 *
107
-	 * @since 1.0.19
108
-	 * @return bool
109
-	 */
110
-	public static function is_eu_store() {
111
-		return self::is_eu_country( wpinv_get_default_country() );
112
-	}
113
-
114
-	/**
115
-	 * Checks if this is an eu country.
116
-	 *
117
-	 * @param string $country
118
-	 * @since 1.0.19
119
-	 * @return bool
120
-	 */
121
-	public static function is_eu_country( $country ) {
122
-		return getpaid_is_eu_state( $country );
123
-	}
124
-
125
-	/**
126
-	 * Checks if this is an eu purchase.
127
-	 *
128
-	 * @param string $customer_country
129
-	 * @since 1.0.19
130
-	 * @return bool
131
-	 */
132
-	public static function is_eu_transaction( $customer_country ) {
133
-		return self::is_eu_country( $customer_country ) && self::is_eu_store();
134
-	}
135
-
136
-	/**
137
-	 * Retrieves the vat number.
138
-	 *
139
-	 * @param GetPaid_Payment_Form_Submission $submission
140
-	 * @since 1.0.19
141
-	 * @return string
142
-	 */
143
-	public function get_vat_number( $submission ) {
144
-
145
-		// Retrieve from the posted number.
146
-		$vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
147
-		if ( ! is_null( $vat_number ) ) {
148
-			return wpinv_clean( $vat_number );
149
-		}
150
-
151
-		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
152
-	}
153
-
154
-	/**
155
-	 * Retrieves the company.
156
-	 *
157
-	 * @param GetPaid_Payment_Form_Submission $submission
158
-	 * @since 1.0.19
159
-	 * @return string
160
-	 */
161
-	public function get_company( $submission ) {
162
-
163
-		// Retrieve from the posted data.
164
-		$company = $submission->get_field( 'wpinv_company', 'billing' );
165
-		if ( ! empty( $company ) ) {
166
-			return wpinv_clean( $company );
167
-		}
168
-
169
-		// Retrieve from the invoice.
170
-		return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
171
-	}
172
-
173
-	/**
174
-	 * Checks if we require a VAT number.
175
-	 *
176
-	 * @param bool $ip_in_eu Whether the customer IP is from the EU
177
-	 * @param bool $country_in_eu Whether the customer country is from the EU
178
-	 * @since 1.0.19
179
-	 * @return string
180
-	 */
181
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
182
-
183
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
184
-		$prevent_b2c = ! empty( $prevent_b2c );
185
-		$is_eu       = $ip_in_eu || $country_in_eu;
186
-
187
-		return $prevent_b2c && $is_eu;
188
-	}
189
-
190
-	/**
191
-	 * Validate VAT data.
192
-	 *
193
-	 * @param GetPaid_Payment_Form_Submission $submission
194
-	 * @since 1.0.19
195
-	 */
196
-	public function validate_vat( $submission ) {
197
-
198
-		$in_eu = $this->is_eu_transaction( $submission->country );
199
-
200
-		// Abort if we are not validating vat numbers.
201
-		if ( ! $in_eu ) {
101
+        return false;
102
+    }
103
+
104
+    /**
105
+     * Checks if this is an eu store.
106
+     *
107
+     * @since 1.0.19
108
+     * @return bool
109
+     */
110
+    public static function is_eu_store() {
111
+        return self::is_eu_country( wpinv_get_default_country() );
112
+    }
113
+
114
+    /**
115
+     * Checks if this is an eu country.
116
+     *
117
+     * @param string $country
118
+     * @since 1.0.19
119
+     * @return bool
120
+     */
121
+    public static function is_eu_country( $country ) {
122
+        return getpaid_is_eu_state( $country );
123
+    }
124
+
125
+    /**
126
+     * Checks if this is an eu purchase.
127
+     *
128
+     * @param string $customer_country
129
+     * @since 1.0.19
130
+     * @return bool
131
+     */
132
+    public static function is_eu_transaction( $customer_country ) {
133
+        return self::is_eu_country( $customer_country ) && self::is_eu_store();
134
+    }
135
+
136
+    /**
137
+     * Retrieves the vat number.
138
+     *
139
+     * @param GetPaid_Payment_Form_Submission $submission
140
+     * @since 1.0.19
141
+     * @return string
142
+     */
143
+    public function get_vat_number( $submission ) {
144
+
145
+        // Retrieve from the posted number.
146
+        $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
147
+        if ( ! is_null( $vat_number ) ) {
148
+            return wpinv_clean( $vat_number );
149
+        }
150
+
151
+        return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
152
+    }
153
+
154
+    /**
155
+     * Retrieves the company.
156
+     *
157
+     * @param GetPaid_Payment_Form_Submission $submission
158
+     * @since 1.0.19
159
+     * @return string
160
+     */
161
+    public function get_company( $submission ) {
162
+
163
+        // Retrieve from the posted data.
164
+        $company = $submission->get_field( 'wpinv_company', 'billing' );
165
+        if ( ! empty( $company ) ) {
166
+            return wpinv_clean( $company );
167
+        }
168
+
169
+        // Retrieve from the invoice.
170
+        return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
171
+    }
172
+
173
+    /**
174
+     * Checks if we require a VAT number.
175
+     *
176
+     * @param bool $ip_in_eu Whether the customer IP is from the EU
177
+     * @param bool $country_in_eu Whether the customer country is from the EU
178
+     * @since 1.0.19
179
+     * @return string
180
+     */
181
+    public function requires_vat( $ip_in_eu, $country_in_eu ) {
182
+
183
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
184
+        $prevent_b2c = ! empty( $prevent_b2c );
185
+        $is_eu       = $ip_in_eu || $country_in_eu;
186
+
187
+        return $prevent_b2c && $is_eu;
188
+    }
189
+
190
+    /**
191
+     * Validate VAT data.
192
+     *
193
+     * @param GetPaid_Payment_Form_Submission $submission
194
+     * @since 1.0.19
195
+     */
196
+    public function validate_vat( $submission ) {
197
+
198
+        $in_eu = $this->is_eu_transaction( $submission->country );
199
+
200
+        // Abort if we are not validating vat numbers.
201
+        if ( ! $in_eu ) {
202 202
             return;
203
-		}
203
+        }
204 204
 
205
-		// Prepare variables.
206
-		$vat_number  = $this->get_vat_number( $submission );
207
-		$ip_country  = getpaid_get_ip_country();
205
+        // Prepare variables.
206
+        $vat_number  = $this->get_vat_number( $submission );
207
+        $ip_country  = getpaid_get_ip_country();
208 208
         $is_eu       = $this->is_eu_country( $submission->country );
209 209
         $is_ip_eu    = $this->is_eu_country( $ip_country );
210 210
 
211
-		// Maybe abort early for initial fetches.
212
-		if ( $submission->is_initial_fetch() && empty( $vat_number ) ) {
213
-			return;
214
-		}
215
-
216
-		// If we're preventing business to consumer purchases,
217
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
218
-
219
-			// Ensure that a vat number has been specified.
220
-			throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) );
221
-
222
-		}
223
-
224
-		if ( empty( $vat_number ) ) {
225
-			return;
226
-		}
227
-
228
-		if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
229
-			throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) );
230
-		}
231
-
232
-		if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
233
-			return;
234
-		}
235
-
236
-		$this->skip_taxes = true;
237
-	}
238
-
239
-	 /**
240
-	 * Refresh totals if country or region changed in payment form.
241
-	 *
242
-	 * @since 2.8.8
243
-	 *
244
-	 * @param object $invoice Invoice object.
245
-	 * @param GetPaid_Payment_Form_Submission $submission Payment form submission object.
246
-	 * @return object Invoice object.
247
-	 */
248
-	public function refresh_totals( $invoice, $submission ) {
249
-		if ( ! ( ! empty( $_POST['action'] ) && ( $_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form' ) && isset( $_POST['billing']['wpinv_country'] ) ) ) {
250
-			return $invoice;
251
-		}
252
-
253
-		if ( ! ( ! $invoice->is_paid() && ! $invoice->is_refunded() && ! $invoice->is_held() ) ) {
254
-			return $invoice;
255
-		}
256
-
257
-		// Maybe check the country, state.
258
-		if ( $submission->country != $invoice->get_country() || $submission->state != $invoice->get_state() ) {
259
-			$invoice->set_country( sanitize_text_field( $submission->country ) );
260
-			$invoice->set_state( sanitize_text_field( $submission->state ) );
261
-
262
-			// Recalculate totals.
263
-			$invoice->recalculate_total();
264
-		}
265
-
266
-		return $invoice;
267
-	}
211
+        // Maybe abort early for initial fetches.
212
+        if ( $submission->is_initial_fetch() && empty( $vat_number ) ) {
213
+            return;
214
+        }
215
+
216
+        // If we're preventing business to consumer purchases,
217
+        if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
218
+
219
+            // Ensure that a vat number has been specified.
220
+            throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) );
221
+
222
+        }
223
+
224
+        if ( empty( $vat_number ) ) {
225
+            return;
226
+        }
227
+
228
+        if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
229
+            throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) );
230
+        }
231
+
232
+        if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
233
+            return;
234
+        }
235
+
236
+        $this->skip_taxes = true;
237
+    }
238
+
239
+        /**
240
+         * Refresh totals if country or region changed in payment form.
241
+         *
242
+         * @since 2.8.8
243
+         *
244
+         * @param object $invoice Invoice object.
245
+         * @param GetPaid_Payment_Form_Submission $submission Payment form submission object.
246
+         * @return object Invoice object.
247
+         */
248
+    public function refresh_totals( $invoice, $submission ) {
249
+        if ( ! ( ! empty( $_POST['action'] ) && ( $_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form' ) && isset( $_POST['billing']['wpinv_country'] ) ) ) {
250
+            return $invoice;
251
+        }
252
+
253
+        if ( ! ( ! $invoice->is_paid() && ! $invoice->is_refunded() && ! $invoice->is_held() ) ) {
254
+            return $invoice;
255
+        }
256
+
257
+        // Maybe check the country, state.
258
+        if ( $submission->country != $invoice->get_country() || $submission->state != $invoice->get_state() ) {
259
+            $invoice->set_country( sanitize_text_field( $submission->country ) );
260
+            $invoice->set_state( sanitize_text_field( $submission->state ) );
261
+
262
+            // Recalculate totals.
263
+            $invoice->recalculate_total();
264
+        }
265
+
266
+        return $invoice;
267
+    }
268 268
 }
Please login to merge, or discard this patch.
Spacing   +60 added lines, -60 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission taxes class
@@ -29,24 +29,24 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param GetPaid_Payment_Form_Submission $submission
31 31
 	 */
32
-	public function __construct( $submission ) {
32
+	public function __construct($submission) {
33 33
 		// Validate VAT number.
34
-		$this->validate_vat( $submission );
34
+		$this->validate_vat($submission);
35 35
 
36
-		if ( $this->skip_taxes ) {
36
+		if ($this->skip_taxes) {
37 37
 			return;
38 38
 		}
39 39
 
40
-		foreach ( $submission->get_items() as $item ) {
41
-			$this->process_item_tax( $item, $submission );
40
+		foreach ($submission->get_items() as $item) {
41
+			$this->process_item_tax($item, $submission);
42 42
 		}
43 43
 
44 44
 		// Process any existing invoice taxes.
45
-		if ( $submission->has_invoice() ) {
45
+		if ($submission->has_invoice()) {
46 46
 			$invoice = $submission->get_invoice();
47
-			$invoice = $this->refresh_totals( $invoice, $submission );
47
+			$invoice = $this->refresh_totals($invoice, $submission);
48 48
 
49
-			$this->taxes = array_replace( $invoice->get_taxes(), $this->taxes );
49
+			$this->taxes = array_replace($invoice->get_taxes(), $this->taxes);
50 50
 		}
51 51
 	}
52 52
 
@@ -57,26 +57,26 @@  discard block
 block discarded – undo
57 57
 	 * @param GetPaid_Form_Item $item
58 58
 	 * @param GetPaid_Payment_Form_Submission $submission
59 59
 	 */
60
-	public function process_item_tax( $item, $submission ) {
60
+	public function process_item_tax($item, $submission) {
61 61
 
62
-		$rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
63
-		$rates    = getpaid_filter_item_tax_rates( $item, $rates );
64
-		$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
65
-		$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
62
+		$rates    = getpaid_get_item_tax_rates($item, $submission->country, $submission->state);
63
+		$rates    = getpaid_filter_item_tax_rates($item, $rates);
64
+		$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
65
+		$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
66 66
 
67
-		foreach ( $taxes as $name => $amount ) {
68
-			$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
69
-			$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
67
+		foreach ($taxes as $name => $amount) {
68
+			$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
69
+			$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
70 70
 
71
-			$item->item_tax += wpinv_sanitize_amount( $tax['initial_tax'] );
71
+			$item->item_tax += wpinv_sanitize_amount($tax['initial_tax']);
72 72
 
73
-			if ( ! isset( $this->taxes[ $name ] ) ) {
74
-				$this->taxes[ $name ] = $tax;
73
+			if (!isset($this->taxes[$name])) {
74
+				$this->taxes[$name] = $tax;
75 75
 				continue;
76 76
 			}
77 77
 
78
-			$this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
79
-			$this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
78
+			$this->taxes[$name]['initial_tax']   += $tax['initial_tax'];
79
+			$this->taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
80 80
 
81 81
 		}
82 82
 
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 	 * @since 1.0.19
90 90
 	 * @return bool
91 91
 	 */
92
-	public function has_digital_item( $submission ) {
92
+	public function has_digital_item($submission) {
93 93
 
94
-		foreach ( $submission->get_items() as $item ) {
94
+		foreach ($submission->get_items() as $item) {
95 95
 
96
-			if ( 'digital' == $item->get_vat_rule() ) {
96
+			if ('digital' == $item->get_vat_rule()) {
97 97
 				return true;
98 98
 			}
99 99
 }
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	 * @return bool
109 109
 	 */
110 110
 	public static function is_eu_store() {
111
-		return self::is_eu_country( wpinv_get_default_country() );
111
+		return self::is_eu_country(wpinv_get_default_country());
112 112
 	}
113 113
 
114 114
 	/**
@@ -118,8 +118,8 @@  discard block
 block discarded – undo
118 118
 	 * @since 1.0.19
119 119
 	 * @return bool
120 120
 	 */
121
-	public static function is_eu_country( $country ) {
122
-		return getpaid_is_eu_state( $country );
121
+	public static function is_eu_country($country) {
122
+		return getpaid_is_eu_state($country);
123 123
 	}
124 124
 
125 125
 	/**
@@ -129,8 +129,8 @@  discard block
 block discarded – undo
129 129
 	 * @since 1.0.19
130 130
 	 * @return bool
131 131
 	 */
132
-	public static function is_eu_transaction( $customer_country ) {
133
-		return self::is_eu_country( $customer_country ) && self::is_eu_store();
132
+	public static function is_eu_transaction($customer_country) {
133
+		return self::is_eu_country($customer_country) && self::is_eu_store();
134 134
 	}
135 135
 
136 136
 	/**
@@ -140,12 +140,12 @@  discard block
 block discarded – undo
140 140
 	 * @since 1.0.19
141 141
 	 * @return string
142 142
 	 */
143
-	public function get_vat_number( $submission ) {
143
+	public function get_vat_number($submission) {
144 144
 
145 145
 		// Retrieve from the posted number.
146
-		$vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
147
-		if ( ! is_null( $vat_number ) ) {
148
-			return wpinv_clean( $vat_number );
146
+		$vat_number = $submission->get_field('wpinv_vat_number', 'billing');
147
+		if (!is_null($vat_number)) {
148
+			return wpinv_clean($vat_number);
149 149
 		}
150 150
 
151 151
 		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
@@ -158,12 +158,12 @@  discard block
 block discarded – undo
158 158
 	 * @since 1.0.19
159 159
 	 * @return string
160 160
 	 */
161
-	public function get_company( $submission ) {
161
+	public function get_company($submission) {
162 162
 
163 163
 		// Retrieve from the posted data.
164
-		$company = $submission->get_field( 'wpinv_company', 'billing' );
165
-		if ( ! empty( $company ) ) {
166
-			return wpinv_clean( $company );
164
+		$company = $submission->get_field('wpinv_company', 'billing');
165
+		if (!empty($company)) {
166
+			return wpinv_clean($company);
167 167
 		}
168 168
 
169 169
 		// Retrieve from the invoice.
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 * @since 1.0.19
179 179
 	 * @return string
180 180
 	 */
181
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
181
+	public function requires_vat($ip_in_eu, $country_in_eu) {
182 182
 
183
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
184
-		$prevent_b2c = ! empty( $prevent_b2c );
183
+		$prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase');
184
+		$prevent_b2c = !empty($prevent_b2c);
185 185
 		$is_eu       = $ip_in_eu || $country_in_eu;
186 186
 
187 187
 		return $prevent_b2c && $is_eu;
@@ -193,43 +193,43 @@  discard block
 block discarded – undo
193 193
 	 * @param GetPaid_Payment_Form_Submission $submission
194 194
 	 * @since 1.0.19
195 195
 	 */
196
-	public function validate_vat( $submission ) {
196
+	public function validate_vat($submission) {
197 197
 
198
-		$in_eu = $this->is_eu_transaction( $submission->country );
198
+		$in_eu = $this->is_eu_transaction($submission->country);
199 199
 
200 200
 		// Abort if we are not validating vat numbers.
201
-		if ( ! $in_eu ) {
201
+		if (!$in_eu) {
202 202
             return;
203 203
 		}
204 204
 
205 205
 		// Prepare variables.
206
-		$vat_number  = $this->get_vat_number( $submission );
206
+		$vat_number  = $this->get_vat_number($submission);
207 207
 		$ip_country  = getpaid_get_ip_country();
208
-        $is_eu       = $this->is_eu_country( $submission->country );
209
-        $is_ip_eu    = $this->is_eu_country( $ip_country );
208
+        $is_eu       = $this->is_eu_country($submission->country);
209
+        $is_ip_eu    = $this->is_eu_country($ip_country);
210 210
 
211 211
 		// Maybe abort early for initial fetches.
212
-		if ( $submission->is_initial_fetch() && empty( $vat_number ) ) {
212
+		if ($submission->is_initial_fetch() && empty($vat_number)) {
213 213
 			return;
214 214
 		}
215 215
 
216 216
 		// If we're preventing business to consumer purchases,
217
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
217
+		if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) {
218 218
 
219 219
 			// Ensure that a vat number has been specified.
220
-			throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) );
220
+			throw new GetPaid_Payment_Exception('.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing'));
221 221
 
222 222
 		}
223 223
 
224
-		if ( empty( $vat_number ) ) {
224
+		if (empty($vat_number)) {
225 225
 			return;
226 226
 		}
227 227
 
228
-		if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
229
-			throw new GetPaid_Payment_Exception( '.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __( 'Your VAT number is invalid', 'invoicing' ) );
228
+		if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) {
229
+			throw new GetPaid_Payment_Exception('.getpaid-error-billingwpinv_vat_number.getpaid-custom-payment-form-errors', __('Your VAT number is invalid', 'invoicing'));
230 230
 		}
231 231
 
232
-		if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
232
+		if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
233 233
 			return;
234 234
 		}
235 235
 
@@ -245,19 +245,19 @@  discard block
 block discarded – undo
245 245
 	 * @param GetPaid_Payment_Form_Submission $submission Payment form submission object.
246 246
 	 * @return object Invoice object.
247 247
 	 */
248
-	public function refresh_totals( $invoice, $submission ) {
249
-		if ( ! ( ! empty( $_POST['action'] ) && ( $_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form' ) && isset( $_POST['billing']['wpinv_country'] ) ) ) {
248
+	public function refresh_totals($invoice, $submission) {
249
+		if (!(!empty($_POST['action']) && ($_POST['action'] == 'wpinv_payment_form_refresh_prices' || $_POST['action'] == 'wpinv_payment_form') && isset($_POST['billing']['wpinv_country']))) {
250 250
 			return $invoice;
251 251
 		}
252 252
 
253
-		if ( ! ( ! $invoice->is_paid() && ! $invoice->is_refunded() && ! $invoice->is_held() ) ) {
253
+		if (!(!$invoice->is_paid() && !$invoice->is_refunded() && !$invoice->is_held())) {
254 254
 			return $invoice;
255 255
 		}
256 256
 
257 257
 		// Maybe check the country, state.
258
-		if ( $submission->country != $invoice->get_country() || $submission->state != $invoice->get_state() ) {
259
-			$invoice->set_country( sanitize_text_field( $submission->country ) );
260
-			$invoice->set_state( sanitize_text_field( $submission->state ) );
258
+		if ($submission->country != $invoice->get_country() || $submission->state != $invoice->get_state()) {
259
+			$invoice->set_country(sanitize_text_field($submission->country));
260
+			$invoice->set_state(sanitize_text_field($submission->state));
261 261
 
262 262
 			// Recalculate totals.
263 263
 			$invoice->recalculate_total();
Please login to merge, or discard this patch.
includes/admin/class-getpaid-post-types-admin.php 2 patches
Indentation   +795 added lines, -795 removed lines patch added patch discarded remove patch
@@ -13,738 +13,738 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Post_Types_Admin {
14 14
 
15 15
     /**
16
-	 * Hook in methods.
17
-	 */
18
-	public static function init() {
19
-
20
-		// Init metaboxes.
21
-		GetPaid_Metaboxes::init();
22
-
23
-		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
-
26
-		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
-
30
-		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
-
36
-		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
-
44
-		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
-
49
-		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
-
53
-		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
-
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
-	}
59
-
60
-	/**
61
-	 * Post updated messages.
62
-	 */
63
-	public static function post_updated_messages( $messages ) {
64
-		global $post;
65
-
66
-		$messages['wpi_discount'] = array(
67
-			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
78
-		);
79
-
80
-		$messages['wpi_payment_form'] = array(
81
-			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
-		);
93
-
94
-		return $messages;
95
-
96
-	}
97
-
98
-	/**
99
-	 * Post row actions.
100
-	 */
101
-	public static function post_row_actions( $actions, $post ) {
102
-
103
-		$post = get_post( $post );
104
-
105
-		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
107
-
108
-			if ( wpinv_get_default_payment_form() === $post->ID ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
111
-			}
112
-
113
-			$actions['duplicate'] = sprintf(
114
-				'<a href="%1$s">%2$s</a>',
115
-				esc_url(
116
-					wp_nonce_url(
117
-						add_query_arg(
118
-							array(
119
-								'getpaid-admin-action' => 'duplicate_form',
120
-								'form_id'              => $post->ID,
121
-							)
122
-						),
123
-						'getpaid-nonce',
124
-						'getpaid-nonce'
125
-					)
126
-				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
128
-			);
129
-
130
-			$actions['reset'] = sprintf(
131
-				'<a href="%1$s" style="color: #800">%2$s</a>',
132
-				esc_url(
133
-					wp_nonce_url(
134
-						add_query_arg(
135
-							array(
136
-								'getpaid-admin-action' => 'reset_form_stats',
137
-								'form_id'              => $post->ID,
138
-							)
139
-						),
140
-						'getpaid-nonce',
141
-						'getpaid-nonce'
142
-					)
143
-				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
145
-			);
146
-		}
147
-
148
-		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-			if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
-				$actions['buy'] = sprintf(
152
-					'<a href="%1$s">%2$s</a>',
153
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
-					esc_html( __( 'Buy', 'invoicing' ) )
155
-				);
156
-			}
157
-		}
158
-
159
-		return $actions;
160
-	}
161
-
162
-	/**
16
+     * Hook in methods.
17
+     */
18
+    public static function init() {
19
+
20
+        // Init metaboxes.
21
+        GetPaid_Metaboxes::init();
22
+
23
+        // Filter the post updated messages.
24
+        add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
25
+
26
+        // Filter post actions.
27
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
+        add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
29
+
30
+        // Invoice table columns.
31
+        add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
+        add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
+        add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
+        add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
35
+
36
+        // Items table columns.
37
+        add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
+        add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
+        add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
+        add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
+        add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
+        add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
43
+
44
+        // Payment forms columns.
45
+        add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
+        add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
48
+
49
+        // Discount table columns.
50
+        add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
+        add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
52
+
53
+        // Deleting posts.
54
+        add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
+        add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
56
+
57
+        add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
58
+    }
59
+
60
+    /**
61
+     * Post updated messages.
62
+     */
63
+    public static function post_updated_messages( $messages ) {
64
+        global $post;
65
+
66
+        $messages['wpi_discount'] = array(
67
+            0  => '',
68
+            1  => __( 'Discount updated.', 'invoicing' ),
69
+            2  => __( 'Custom field updated.', 'invoicing' ),
70
+            3  => __( 'Custom field deleted.', 'invoicing' ),
71
+            4  => __( 'Discount updated.', 'invoicing' ),
72
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
+            6  => __( 'Discount updated.', 'invoicing' ),
74
+            7  => __( 'Discount saved.', 'invoicing' ),
75
+            8  => __( 'Discount submitted.', 'invoicing' ),
76
+            9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
+            10 => __( 'Discount draft updated.', 'invoicing' ),
78
+        );
79
+
80
+        $messages['wpi_payment_form'] = array(
81
+            0  => '',
82
+            1  => __( 'Payment Form updated.', 'invoicing' ),
83
+            2  => __( 'Custom field updated.', 'invoicing' ),
84
+            3  => __( 'Custom field deleted.', 'invoicing' ),
85
+            4  => __( 'Payment Form updated.', 'invoicing' ),
86
+            5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
+            6  => __( 'Payment Form updated.', 'invoicing' ),
88
+            7  => __( 'Payment Form saved.', 'invoicing' ),
89
+            8  => __( 'Payment Form submitted.', 'invoicing' ),
90
+            9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
+            10 => __( 'Payment Form draft updated.', 'invoicing' ),
92
+        );
93
+
94
+        return $messages;
95
+
96
+    }
97
+
98
+    /**
99
+     * Post row actions.
100
+     */
101
+    public static function post_row_actions( $actions, $post ) {
102
+
103
+        $post = get_post( $post );
104
+
105
+        // We do not want to edit the default payment form.
106
+        if ( 'wpi_payment_form' == $post->post_type ) {
107
+
108
+            if ( wpinv_get_default_payment_form() === $post->ID ) {
109
+                unset( $actions['trash'] );
110
+                unset( $actions['inline hide-if-no-js'] );
111
+            }
112
+
113
+            $actions['duplicate'] = sprintf(
114
+                '<a href="%1$s">%2$s</a>',
115
+                esc_url(
116
+                    wp_nonce_url(
117
+                        add_query_arg(
118
+                            array(
119
+                                'getpaid-admin-action' => 'duplicate_form',
120
+                                'form_id'              => $post->ID,
121
+                            )
122
+                        ),
123
+                        'getpaid-nonce',
124
+                        'getpaid-nonce'
125
+                    )
126
+                ),
127
+                esc_html( __( 'Duplicate', 'invoicing' ) )
128
+            );
129
+
130
+            $actions['reset'] = sprintf(
131
+                '<a href="%1$s" style="color: #800">%2$s</a>',
132
+                esc_url(
133
+                    wp_nonce_url(
134
+                        add_query_arg(
135
+                            array(
136
+                                'getpaid-admin-action' => 'reset_form_stats',
137
+                                'form_id'              => $post->ID,
138
+                            )
139
+                        ),
140
+                        'getpaid-nonce',
141
+                        'getpaid-nonce'
142
+                    )
143
+                ),
144
+                esc_html( __( 'Reset Stats', 'invoicing' ) )
145
+            );
146
+        }
147
+
148
+        // Link to item payment form.
149
+        if ( 'wpi_item' == $post->post_type ) {
150
+            if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
151
+                $actions['buy'] = sprintf(
152
+                    '<a href="%1$s">%2$s</a>',
153
+                    esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
+                    esc_html( __( 'Buy', 'invoicing' ) )
155
+                );
156
+            }
157
+        }
158
+
159
+        return $actions;
160
+    }
161
+
162
+    /**
163 163
      * Remove bulk edit option from admin side quote listing
164 164
      *
165 165
      * @since    1.0.0
166 166
      * @param array $actions post actions
167
-	 * @param WP_Post $post
167
+     * @param WP_Post $post
168 168
      * @return array $actions actions without edit option
169 169
      */
170 170
     public static function filter_invoice_row_actions( $actions, $post ) {
171 171
 
172 172
         if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
173 173
 
174
-			$actions = array();
175
-			$invoice = new WPInv_Invoice( $post );
176
-
177
-			$actions['edit'] = sprintf(
178
-				'<a href="%1$s">%2$s</a>',
179
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
-				esc_html( __( 'Edit', 'invoicing' ) )
181
-			);
182
-
183
-			if ( ! $invoice->is_draft() ) {
184
-
185
-				$actions['view'] = sprintf(
186
-					'<a href="%1$s">%2$s</a>',
187
-					esc_url( $invoice->get_view_url() ),
188
-					sprintf(
189
-						// translators: %s is the invoice type
190
-						esc_html__( 'View %s', 'invoicing' ),
191
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
-					)
193
-				);
194
-
195
-				$actions['send'] = sprintf(
196
-					'<a href="%1$s">%2$s</a>',
197
-					esc_url(
198
-						wp_nonce_url(
199
-							add_query_arg(
200
-								array(
201
-									'getpaid-admin-action' => 'send_invoice',
202
-									'invoice_id'           => $invoice->get_id(),
203
-								)
204
-							),
205
-							'getpaid-nonce',
206
-							'getpaid-nonce'
207
-						)
208
-					),
209
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
210
-				);
211
-
212
-			}
213
-
214
-			$actions['duplicate'] = sprintf(
215
-				'<a href="%1$s">%2$s</a>',
216
-				esc_url(
217
-					wp_nonce_url(
218
-						add_query_arg(
219
-							array(
220
-								'getpaid-admin-action' => 'duplicate_invoice',
221
-								'invoice_id'           => $post->ID,
222
-							)
223
-						),
224
-						'getpaid-nonce',
225
-						'getpaid-nonce'
226
-					)
227
-				),
228
-				esc_html( __( 'Duplicate', 'invoicing' ) )
229
-			);
174
+            $actions = array();
175
+            $invoice = new WPInv_Invoice( $post );
176
+
177
+            $actions['edit'] = sprintf(
178
+                '<a href="%1$s">%2$s</a>',
179
+                esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
+                esc_html( __( 'Edit', 'invoicing' ) )
181
+            );
182
+
183
+            if ( ! $invoice->is_draft() ) {
184
+
185
+                $actions['view'] = sprintf(
186
+                    '<a href="%1$s">%2$s</a>',
187
+                    esc_url( $invoice->get_view_url() ),
188
+                    sprintf(
189
+                        // translators: %s is the invoice type
190
+                        esc_html__( 'View %s', 'invoicing' ),
191
+                        getpaid_get_post_type_label( $invoice->get_post_type(), false )
192
+                    )
193
+                );
194
+
195
+                $actions['send'] = sprintf(
196
+                    '<a href="%1$s">%2$s</a>',
197
+                    esc_url(
198
+                        wp_nonce_url(
199
+                            add_query_arg(
200
+                                array(
201
+                                    'getpaid-admin-action' => 'send_invoice',
202
+                                    'invoice_id'           => $invoice->get_id(),
203
+                                )
204
+                            ),
205
+                            'getpaid-nonce',
206
+                            'getpaid-nonce'
207
+                        )
208
+                    ),
209
+                    esc_html( __( 'Send to Customer', 'invoicing' ) )
210
+                );
211
+
212
+            }
213
+
214
+            $actions['duplicate'] = sprintf(
215
+                '<a href="%1$s">%2$s</a>',
216
+                esc_url(
217
+                    wp_nonce_url(
218
+                        add_query_arg(
219
+                            array(
220
+                                'getpaid-admin-action' => 'duplicate_invoice',
221
+                                'invoice_id'           => $post->ID,
222
+                            )
223
+                        ),
224
+                        'getpaid-nonce',
225
+                        'getpaid-nonce'
226
+                    )
227
+                ),
228
+                esc_html( __( 'Duplicate', 'invoicing' ) )
229
+            );
230 230
 
231 231
         }
232 232
 
233 233
         return $actions;
234
-	}
235
-
236
-	/**
237
-	 * Returns an array of invoice table columns.
238
-	 */
239
-	public static function invoice_columns( $columns ) {
240
-
241
-		$columns = array(
242
-			'cb'           => $columns['cb'],
243
-			'number'       => __( 'Invoice', 'invoicing' ),
244
-			'customer'     => __( 'Customer', 'invoicing' ),
245
-			'invoice_date' => __( 'Created', 'invoicing' ),
246
-			'payment_date' => __( 'Completed', 'invoicing' ),
247
-			'amount'       => __( 'Amount', 'invoicing' ),
248
-			'recurring'    => __( 'Recurring', 'invoicing' ),
249
-			'status'       => __( 'Status', 'invoicing' ),
250
-		);
251
-
252
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
253
-	}
254
-
255
-	/**
256
-	 * Displays invoice table columns.
257
-	 */
258
-	public static function display_invoice_columns( $column_name, $post_id ) {
259
-
260
-		$invoice = new WPInv_Invoice( $post_id );
261
-
262
-		switch ( $column_name ) {
263
-
264
-			case 'invoice_date':
265
-				$date_time = esc_attr( $invoice->get_created_date() );
266
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
-				break;
269
-
270
-			case 'payment_date':
271
-				if ( $invoice->is_paid() ) {
272
-					$date_time = esc_attr( $invoice->get_completed_date() );
273
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
-				} else {
276
-					echo '&mdash;';
277
-				}
278
-
279
-				break;
280
-
281
-			case 'amount':
282
-				$amount = $invoice->get_total();
283
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
284
-
285
-				if ( $invoice->is_refunded() ) {
286
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
287
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
288
-				} else {
289
-
290
-					$discount = $invoice->get_total_discount();
291
-
292
-					if ( ! empty( $discount ) ) {
293
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
294
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
295
-					} else {
296
-						echo wp_kses_post( $formated_amount );
297
-					}
298
-				}
299
-
300
-				break;
301
-
302
-			case 'status':
303
-				$status       = esc_html( $invoice->get_status() );
304
-				$status_label = esc_html( $invoice->get_status_nicename() );
305
-
306
-				// If it is paid, show the gateway title.
307
-				if ( $invoice->is_paid() ) {
308
-					$gateway = esc_html( $invoice->get_gateway_title() );
309
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
310
-
311
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
312
-				} else {
313
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
314
-				}
315
-
316
-				// If it is not paid, display the overdue and view status.
317
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
318
-
319
-					// Invoice view status.
320
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
321
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
322
-					} else {
323
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
324
-					}
325
-
326
-					// Display the overview status.
327
-					if ( wpinv_get_option( 'overdue_active' ) ) {
328
-						$due_date = $invoice->get_due_date();
329
-						$fomatted = getpaid_format_date( $due_date );
330
-
331
-						if ( ! empty( $fomatted ) ) {
332
-							$date = wp_sprintf(
333
-								// translators: %s is the due date.
334
-								__( 'Due %s', 'invoicing' ),
335
-								$fomatted
336
-							);
337
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
338
-						}
339
-					}
340
-				}
341
-
342
-				break;
343
-
344
-			case 'recurring':
345
-				if ( $invoice->is_recurring() ) {
346
-					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
347
-				} else {
348
-					echo '<i class="fa fa-times" style="color:#616161;"></i>';
349
-				}
350
-				break;
351
-
352
-			case 'number':
353
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
354
-				$invoice_number  = esc_html( $invoice->get_number() );
355
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
356
-
357
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
358
-
359
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
360
-				break;
361
-
362
-			case 'customer':
363
-				$customer_name = $invoice->get_user_full_name();
364
-
365
-				if ( empty( $customer_name ) ) {
366
-					$customer_name = $invoice->get_email();
367
-				}
368
-
369
-				if ( ! empty( $customer_name ) ) {
370
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
371
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
372
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
373
-				} else {
374
-					echo '<div>&mdash;</div>';
375
-				}
376
-
377
-				break;
378
-
379
-		}
380
-
381
-	}
382
-
383
-	/**
384
-	 * Displays invoice bulk actions.
385
-	 */
386
-	public static function invoice_bulk_actions( $actions ) {
387
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
388
-		return $actions;
389
-	}
390
-
391
-	/**
392
-	 * Processes invoice bulk actions.
393
-	 */
394
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
395
-
396
-		if ( 'resend-invoice' === $action ) {
397
-			foreach ( $post_ids as $post_id ) {
398
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
399
-			}
400
-		}
401
-
402
-		return $redirect_url;
403
-
404
-	}
405
-
406
-	/**
407
-	 * Returns an array of payment forms table columns.
408
-	 */
409
-	public static function payment_form_columns( $columns ) {
410
-
411
-		$columns = array(
412
-			'cb'        => $columns['cb'],
413
-			'title'     => __( 'Name', 'invoicing' ),
414
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
415
-			'earnings'  => __( 'Revenue', 'invoicing' ),
416
-			'refunds'   => __( 'Refunded', 'invoicing' ),
417
-			'items'     => __( 'Items', 'invoicing' ),
418
-			'date'      => __( 'Date', 'invoicing' ),
419
-		);
420
-
421
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
422
-
423
-	}
424
-
425
-	/**
426
-	 * Displays payment form table columns.
427
-	 */
428
-	public static function display_payment_form_columns( $column_name, $post_id ) {
429
-
430
-		// Retrieve the payment form.
431
-		$form = new GetPaid_Payment_Form( $post_id );
432
-
433
-		switch ( $column_name ) {
434
-
435
-			case 'earnings':
436
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
437
-				break;
438
-
439
-			case 'refunds':
440
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
441
-				break;
442
-
443
-			case 'refunds':
444
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
445
-				break;
446
-
447
-			case 'shortcode':
448
-				if ( $form->is_default() ) {
449
-					echo '&mdash;';
450
-				} else {
451
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
452
-				}
453
-
454
-				break;
234
+    }
235
+
236
+    /**
237
+     * Returns an array of invoice table columns.
238
+     */
239
+    public static function invoice_columns( $columns ) {
240
+
241
+        $columns = array(
242
+            'cb'           => $columns['cb'],
243
+            'number'       => __( 'Invoice', 'invoicing' ),
244
+            'customer'     => __( 'Customer', 'invoicing' ),
245
+            'invoice_date' => __( 'Created', 'invoicing' ),
246
+            'payment_date' => __( 'Completed', 'invoicing' ),
247
+            'amount'       => __( 'Amount', 'invoicing' ),
248
+            'recurring'    => __( 'Recurring', 'invoicing' ),
249
+            'status'       => __( 'Status', 'invoicing' ),
250
+        );
251
+
252
+        return apply_filters( 'wpi_invoice_table_columns', $columns );
253
+    }
254
+
255
+    /**
256
+     * Displays invoice table columns.
257
+     */
258
+    public static function display_invoice_columns( $column_name, $post_id ) {
259
+
260
+        $invoice = new WPInv_Invoice( $post_id );
261
+
262
+        switch ( $column_name ) {
263
+
264
+            case 'invoice_date':
265
+                $date_time = esc_attr( $invoice->get_created_date() );
266
+                $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
+                echo wp_kses_post( "<span title='$date_time'>$date</span>" );
268
+                break;
269
+
270
+            case 'payment_date':
271
+                if ( $invoice->is_paid() ) {
272
+                    $date_time = esc_attr( $invoice->get_completed_date() );
273
+                    $date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
+                    echo wp_kses_post( "<span title='$date_time'>$date</span>" );
275
+                } else {
276
+                    echo '&mdash;';
277
+                }
278
+
279
+                break;
280
+
281
+            case 'amount':
282
+                $amount = $invoice->get_total();
283
+                $formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
284
+
285
+                if ( $invoice->is_refunded() ) {
286
+                    $refunded_amount = wpinv_price( 0, $invoice->get_currency() );
287
+                    echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
288
+                } else {
289
+
290
+                    $discount = $invoice->get_total_discount();
291
+
292
+                    if ( ! empty( $discount ) ) {
293
+                        $new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
294
+                        echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
295
+                    } else {
296
+                        echo wp_kses_post( $formated_amount );
297
+                    }
298
+                }
299
+
300
+                break;
301
+
302
+            case 'status':
303
+                $status       = esc_html( $invoice->get_status() );
304
+                $status_label = esc_html( $invoice->get_status_nicename() );
305
+
306
+                // If it is paid, show the gateway title.
307
+                if ( $invoice->is_paid() ) {
308
+                    $gateway = esc_html( $invoice->get_gateway_title() );
309
+                    $gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
310
+
311
+                    echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
312
+                } else {
313
+                    echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
314
+                }
315
+
316
+                // If it is not paid, display the overdue and view status.
317
+                if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
318
+
319
+                    // Invoice view status.
320
+                    if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
321
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
322
+                    } else {
323
+                        echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
324
+                    }
325
+
326
+                    // Display the overview status.
327
+                    if ( wpinv_get_option( 'overdue_active' ) ) {
328
+                        $due_date = $invoice->get_due_date();
329
+                        $fomatted = getpaid_format_date( $due_date );
330
+
331
+                        if ( ! empty( $fomatted ) ) {
332
+                            $date = wp_sprintf(
333
+                                // translators: %s is the due date.
334
+                                __( 'Due %s', 'invoicing' ),
335
+                                $fomatted
336
+                            );
337
+                            echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
338
+                        }
339
+                    }
340
+                }
341
+
342
+                break;
343
+
344
+            case 'recurring':
345
+                if ( $invoice->is_recurring() ) {
346
+                    echo '<i class="fa fa-check" style="color:#43850a;"></i>';
347
+                } else {
348
+                    echo '<i class="fa fa-times" style="color:#616161;"></i>';
349
+                }
350
+                break;
351
+
352
+            case 'number':
353
+                $edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
354
+                $invoice_number  = esc_html( $invoice->get_number() );
355
+                $invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
356
+
357
+                echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
358
+
359
+                do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
360
+                break;
361
+
362
+            case 'customer':
363
+                $customer_name = $invoice->get_user_full_name();
364
+
365
+                if ( empty( $customer_name ) ) {
366
+                    $customer_name = $invoice->get_email();
367
+                }
368
+
369
+                if ( ! empty( $customer_name ) ) {
370
+                    $customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
371
+                    $view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
372
+                    echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
373
+                } else {
374
+                    echo '<div>&mdash;</div>';
375
+                }
376
+
377
+                break;
455 378
 
456
-			case 'items':
457
-				$items = $form->get_items();
458
-
459
-				if ( $form->is_default() || empty( $items ) ) {
460
-					echo '&mdash;';
461
-					return;
462
-				}
463
-
464
-				$_items = array();
465
-
466
-				foreach ( $items as $item ) {
467
-					$url = $item->get_edit_url();
468
-
469
-					if ( empty( $url ) ) {
470
-						$_items[] = esc_html( $item->get_name() );
471
-					} else {
472
-						$_items[] = sprintf(
473
-							'<a href="%s">%s</a>',
474
-							esc_url( $url ),
475
-							esc_html( $item->get_name() )
476
-						);
477
-					}
379
+        }
380
+
381
+    }
382
+
383
+    /**
384
+     * Displays invoice bulk actions.
385
+     */
386
+    public static function invoice_bulk_actions( $actions ) {
387
+        $actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
388
+        return $actions;
389
+    }
390
+
391
+    /**
392
+     * Processes invoice bulk actions.
393
+     */
394
+    public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
395
+
396
+        if ( 'resend-invoice' === $action ) {
397
+            foreach ( $post_ids as $post_id ) {
398
+                getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
399
+            }
400
+        }
401
+
402
+        return $redirect_url;
403
+
404
+    }
405
+
406
+    /**
407
+     * Returns an array of payment forms table columns.
408
+     */
409
+    public static function payment_form_columns( $columns ) {
410
+
411
+        $columns = array(
412
+            'cb'        => $columns['cb'],
413
+            'title'     => __( 'Name', 'invoicing' ),
414
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
415
+            'earnings'  => __( 'Revenue', 'invoicing' ),
416
+            'refunds'   => __( 'Refunded', 'invoicing' ),
417
+            'items'     => __( 'Items', 'invoicing' ),
418
+            'date'      => __( 'Date', 'invoicing' ),
419
+        );
420
+
421
+        return apply_filters( 'wpi_payment_form_table_columns', $columns );
422
+
423
+    }
424
+
425
+    /**
426
+     * Displays payment form table columns.
427
+     */
428
+    public static function display_payment_form_columns( $column_name, $post_id ) {
429
+
430
+        // Retrieve the payment form.
431
+        $form = new GetPaid_Payment_Form( $post_id );
432
+
433
+        switch ( $column_name ) {
434
+
435
+            case 'earnings':
436
+                echo wp_kses_post( wpinv_price( $form->get_earned() ) );
437
+                break;
438
+
439
+            case 'refunds':
440
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
441
+                break;
442
+
443
+            case 'refunds':
444
+                echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
445
+                break;
446
+
447
+            case 'shortcode':
448
+                if ( $form->is_default() ) {
449
+                    echo '&mdash;';
450
+                } else {
451
+                    echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
452
+                }
453
+
454
+                break;
455
+
456
+            case 'items':
457
+                $items = $form->get_items();
458
+
459
+                if ( $form->is_default() || empty( $items ) ) {
460
+                    echo '&mdash;';
461
+                    return;
462
+                }
463
+
464
+                $_items = array();
465
+
466
+                foreach ( $items as $item ) {
467
+                    $url = $item->get_edit_url();
468
+
469
+                    if ( empty( $url ) ) {
470
+                        $_items[] = esc_html( $item->get_name() );
471
+                    } else {
472
+                        $_items[] = sprintf(
473
+                            '<a href="%s">%s</a>',
474
+                            esc_url( $url ),
475
+                            esc_html( $item->get_name() )
476
+                        );
477
+                    }
478 478
 }
479 479
 
480
-				echo wp_kses_post( implode( '<br>', $_items ) );
480
+                echo wp_kses_post( implode( '<br>', $_items ) );
481
+
482
+                break;
483
+
484
+        }
485
+
486
+    }
487
+
488
+    /**
489
+     * Filters post states.
490
+     */
491
+    public static function filter_payment_form_state( $post_states, $post ) {
492
+
493
+        if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
494
+            $post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
495
+        }
496
+
497
+        return $post_states;
498
+
499
+    }
500
+
501
+    /**
502
+     * Returns an array of coupon table columns.
503
+     */
504
+    public static function discount_columns( $columns ) {
505
+
506
+        $columns = array(
507
+            'cb'          => $columns['cb'],
508
+            'title'       => __( 'Name', 'invoicing' ),
509
+            'code'        => __( 'Code', 'invoicing' ),
510
+            'amount'      => __( 'Amount', 'invoicing' ),
511
+            'usage'       => __( 'Usage / Limit', 'invoicing' ),
512
+            'start_date'  => __( 'Start Date', 'invoicing' ),
513
+            'expiry_date' => __( 'Expiry Date', 'invoicing' ),
514
+        );
515
+
516
+        return apply_filters( 'wpi_discount_table_columns', $columns );
517
+    }
481 518
 
482
-				break;
519
+    /**
520
+     * Filters post states.
521
+     */
522
+    public static function filter_discount_state( $post_states, $post ) {
483 523
 
484
-		}
524
+        if ( 'wpi_discount' === $post->post_type ) {
485 525
 
486
-	}
526
+            $discount = new WPInv_Discount( $post );
487 527
 
488
-	/**
489
-	 * Filters post states.
490
-	 */
491
-	public static function filter_payment_form_state( $post_states, $post ) {
528
+            $status = $discount->is_expired() ? 'expired' : $discount->get_status();
492 529
 
493
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
494
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
495
-		}
530
+            if ( 'publish' !== $status ) {
531
+                return array(
532
+                    'discount_status' => wpinv_discount_status( $status ),
533
+                );
534
+            }
535
+
536
+            return array();
537
+
538
+        }
539
+
540
+        return $post_states;
496 541
 
497
-		return $post_states;
542
+    }
498 543
 
499
-	}
544
+    /**
545
+     * Returns an array of items table columns.
546
+     */
547
+    public static function item_columns( $columns ) {
548
+
549
+        $columns = array(
550
+            'cb'        => $columns['cb'],
551
+            'title'     => __( 'Name', 'invoicing' ),
552
+            'price'     => __( 'Price', 'invoicing' ),
553
+            'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
554
+            'vat_class' => __( 'Tax Class', 'invoicing' ),
555
+            'type'      => __( 'Type', 'invoicing' ),
556
+            'shortcode' => __( 'Shortcode', 'invoicing' ),
557
+        );
558
+
559
+        if ( ! wpinv_use_taxes() ) {
560
+            unset( $columns['vat_rule'] );
561
+            unset( $columns['vat_class'] );
562
+        }
500 563
 
501
-	/**
502
-	 * Returns an array of coupon table columns.
503
-	 */
504
-	public static function discount_columns( $columns ) {
564
+        return apply_filters( 'wpi_item_table_columns', $columns );
565
+    }
505 566
 
506
-		$columns = array(
507
-			'cb'          => $columns['cb'],
508
-			'title'       => __( 'Name', 'invoicing' ),
509
-			'code'        => __( 'Code', 'invoicing' ),
510
-			'amount'      => __( 'Amount', 'invoicing' ),
511
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
512
-			'start_date'  => __( 'Start Date', 'invoicing' ),
513
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
514
-		);
567
+    /**
568
+     * Returns an array of sortable items table columns.
569
+     */
570
+    public static function sortable_item_columns( $columns ) {
571
+
572
+        return array_merge(
573
+            $columns,
574
+            array(
575
+                'price'     => 'price',
576
+                'vat_rule'  => 'vat_rule',
577
+                'vat_class' => 'vat_class',
578
+                'type'      => 'type',
579
+            )
580
+        );
515 581
 
516
-		return apply_filters( 'wpi_discount_table_columns', $columns );
517
-	}
582
+    }
518 583
 
519
-	/**
520
-	 * Filters post states.
521
-	 */
522
-	public static function filter_discount_state( $post_states, $post ) {
584
+    /**
585
+     * Displays items table columns.
586
+     */
587
+    public static function display_item_columns( $column_name, $post_id ) {
523 588
 
524
-		if ( 'wpi_discount' === $post->post_type ) {
589
+        $item = new WPInv_Item( $post_id );
525 590
 
526
-			$discount = new WPInv_Discount( $post );
591
+        switch ( $column_name ) {
527 592
 
528
-			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
593
+            case 'price':
594
+                if ( ! $item->is_recurring() ) {
595
+                    echo wp_kses_post( $item->get_the_price() );
596
+                    break;
597
+                }
529 598
 
530
-			if ( 'publish' !== $status ) {
531
-				return array(
532
-					'discount_status' => wpinv_discount_status( $status ),
533
-				);
534
-			}
599
+                $price = wp_sprintf(
600
+                    __( '%1$s / %2$s', 'invoicing' ),
601
+                    $item->get_the_price(),
602
+                    getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
603
+                );
535 604
 
536
-			return array();
605
+                if ( $item->get_the_price() == $item->get_the_initial_price() ) {
606
+                    echo wp_kses_post( $price );
607
+                    break;
608
+                }
537 609
 
538
-		}
610
+                echo wp_kses_post( $item->get_the_initial_price() );
539 611
 
540
-		return $post_states;
612
+                echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
613
+                break;
541 614
 
542
-	}
615
+            case 'vat_rule':
616
+                echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
617
+                break;
543 618
 
544
-	/**
545
-	 * Returns an array of items table columns.
546
-	 */
547
-	public static function item_columns( $columns ) {
619
+            case 'vat_class':
620
+                echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
621
+                break;
548 622
 
549
-		$columns = array(
550
-			'cb'        => $columns['cb'],
551
-			'title'     => __( 'Name', 'invoicing' ),
552
-			'price'     => __( 'Price', 'invoicing' ),
553
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
554
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
555
-			'type'      => __( 'Type', 'invoicing' ),
556
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
557
-		);
623
+            case 'shortcode':
624
+                if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
625
+                    echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
626
+                } else {
627
+                    echo '&mdash;';
628
+                }
558 629
 
559
-		if ( ! wpinv_use_taxes() ) {
560
-			unset( $columns['vat_rule'] );
561
-			unset( $columns['vat_class'] );
562
-		}
630
+                break;
563 631
 
564
-		return apply_filters( 'wpi_item_table_columns', $columns );
565
-	}
632
+            case 'type':
633
+                echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
634
+                break;
566 635
 
567
-	/**
568
-	 * Returns an array of sortable items table columns.
569
-	 */
570
-	public static function sortable_item_columns( $columns ) {
571
-
572
-		return array_merge(
573
-			$columns,
574
-			array(
575
-				'price'     => 'price',
576
-				'vat_rule'  => 'vat_rule',
577
-				'vat_class' => 'vat_class',
578
-				'type'      => 'type',
579
-			)
580
-		);
581
-
582
-	}
583
-
584
-	/**
585
-	 * Displays items table columns.
586
-	 */
587
-	public static function display_item_columns( $column_name, $post_id ) {
588
-
589
-		$item = new WPInv_Item( $post_id );
590
-
591
-		switch ( $column_name ) {
592
-
593
-			case 'price':
594
-				if ( ! $item->is_recurring() ) {
595
-					echo wp_kses_post( $item->get_the_price() );
596
-					break;
597
-				}
598
-
599
-				$price = wp_sprintf(
600
-					__( '%1$s / %2$s', 'invoicing' ),
601
-					$item->get_the_price(),
602
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
603
-				);
604
-
605
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
606
-					echo wp_kses_post( $price );
607
-					break;
608
-				}
609
-
610
-				echo wp_kses_post( $item->get_the_initial_price() );
611
-
612
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
613
-				break;
614
-
615
-			case 'vat_rule':
616
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
617
-				break;
618
-
619
-			case 'vat_class':
620
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
621
-				break;
622
-
623
-			case 'shortcode':
624
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
625
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
626
-				} else {
627
-					echo '&mdash;';
628
-				}
629
-
630
-				break;
631
-
632
-			case 'type':
633
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
634
-				break;
635
-
636
-		}
637
-
638
-	}
639
-
640
-	/**
641
-	 * Lets users filter items using taxes.
642
-	 */
643
-	public static function add_item_filters( $post_type ) {
644
-
645
-		// Abort if we're not dealing with items.
646
-		if ( 'wpi_item' !== $post_type ) {
647
-			return;
648
-		}
649
-
650
-		// Filter by vat rules.
651
-		if ( wpinv_use_taxes() ) {
652
-
653
-			// Sanitize selected vat rule.
654
-			$vat_rule   = '';
655
-			$vat_rules  = getpaid_get_tax_rules();
656
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
657
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
658
-			}
659
-
660
-			// Filter by VAT rule.
661
-			wpinv_html_select(
662
-				array(
663
-					'options'          => array_merge(
664
-						array(
665
-							'' => __( 'All Tax Rules', 'invoicing' ),
666
-						),
667
-						$vat_rules
668
-					),
669
-					'name'             => 'vat_rule',
670
-					'id'               => 'vat_rule',
671
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
672
-					'show_option_all'  => false,
673
-					'show_option_none' => false,
674
-				)
675
-			);
676
-
677
-			// Filter by VAT class.
678
-
679
-			// Sanitize selected vat rule.
680
-			$vat_class   = '';
681
-			$vat_classes = getpaid_get_tax_classes();
682
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
683
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
684
-			}
685
-
686
-			wpinv_html_select(
687
-				array(
688
-					'options'          => array_merge(
689
-						array(
690
-							'' => __( 'All Tax Classes', 'invoicing' ),
691
-						),
692
-						$vat_classes
693
-					),
694
-					'name'             => 'vat_class',
695
-					'id'               => 'vat_class',
696
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
697
-					'show_option_all'  => false,
698
-					'show_option_none' => false,
699
-				)
700
-			);
701
-
702
-		}
703
-
704
-		// Filter by item type.
705
-		$type   = '';
706
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
707
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
708
-		}
709
-
710
-		wpinv_html_select(
711
-			array(
712
-				'options'          => array_merge(
713
-					array(
714
-						'' => __( 'All item types', 'invoicing' ),
715
-					),
716
-					wpinv_get_item_types()
717
-				),
718
-				'name'             => 'type',
719
-				'id'               => 'type',
720
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
721
-				'show_option_all'  => false,
722
-				'show_option_none' => false,
723
-			)
724
-		);
725
-
726
-	}
727
-
728
-	/**
729
-	 * Filters the item query.
730
-	 */
731
-	public static function filter_item_query( $query ) {
732
-
733
-		// modify the query only if it admin and main query.
734
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
735
-			return $query;
736
-		}
737
-
738
-		// we want to modify the query for our items.
739
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
740
-			return $query;
741
-		}
742
-
743
-		if ( empty( $query->query_vars['meta_query'] ) ) {
744
-			$query->query_vars['meta_query'] = array();
745
-		}
746
-
747
-		// Filter vat rule type
636
+        }
637
+
638
+    }
639
+
640
+    /**
641
+     * Lets users filter items using taxes.
642
+     */
643
+    public static function add_item_filters( $post_type ) {
644
+
645
+        // Abort if we're not dealing with items.
646
+        if ( 'wpi_item' !== $post_type ) {
647
+            return;
648
+        }
649
+
650
+        // Filter by vat rules.
651
+        if ( wpinv_use_taxes() ) {
652
+
653
+            // Sanitize selected vat rule.
654
+            $vat_rule   = '';
655
+            $vat_rules  = getpaid_get_tax_rules();
656
+            if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
657
+                $vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
658
+            }
659
+
660
+            // Filter by VAT rule.
661
+            wpinv_html_select(
662
+                array(
663
+                    'options'          => array_merge(
664
+                        array(
665
+                            '' => __( 'All Tax Rules', 'invoicing' ),
666
+                        ),
667
+                        $vat_rules
668
+                    ),
669
+                    'name'             => 'vat_rule',
670
+                    'id'               => 'vat_rule',
671
+                    'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
672
+                    'show_option_all'  => false,
673
+                    'show_option_none' => false,
674
+                )
675
+            );
676
+
677
+            // Filter by VAT class.
678
+
679
+            // Sanitize selected vat rule.
680
+            $vat_class   = '';
681
+            $vat_classes = getpaid_get_tax_classes();
682
+            if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
683
+                $vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
684
+            }
685
+
686
+            wpinv_html_select(
687
+                array(
688
+                    'options'          => array_merge(
689
+                        array(
690
+                            '' => __( 'All Tax Classes', 'invoicing' ),
691
+                        ),
692
+                        $vat_classes
693
+                    ),
694
+                    'name'             => 'vat_class',
695
+                    'id'               => 'vat_class',
696
+                    'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
697
+                    'show_option_all'  => false,
698
+                    'show_option_none' => false,
699
+                )
700
+            );
701
+
702
+        }
703
+
704
+        // Filter by item type.
705
+        $type   = '';
706
+        if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
707
+            $type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
708
+        }
709
+
710
+        wpinv_html_select(
711
+            array(
712
+                'options'          => array_merge(
713
+                    array(
714
+                        '' => __( 'All item types', 'invoicing' ),
715
+                    ),
716
+                    wpinv_get_item_types()
717
+                ),
718
+                'name'             => 'type',
719
+                'id'               => 'type',
720
+                'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
721
+                'show_option_all'  => false,
722
+                'show_option_none' => false,
723
+            )
724
+        );
725
+
726
+    }
727
+
728
+    /**
729
+     * Filters the item query.
730
+     */
731
+    public static function filter_item_query( $query ) {
732
+
733
+        // modify the query only if it admin and main query.
734
+        if ( ! ( is_admin() && $query->is_main_query() ) ) {
735
+            return $query;
736
+        }
737
+
738
+        // we want to modify the query for our items.
739
+        if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
740
+            return $query;
741
+        }
742
+
743
+        if ( empty( $query->query_vars['meta_query'] ) ) {
744
+            $query->query_vars['meta_query'] = array();
745
+        }
746
+
747
+        // Filter vat rule type
748 748
         if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
749 749
             $query->query_vars['meta_query'][] = array(
750 750
                 'key'     => '_wpinv_vat_rule',
@@ -769,101 +769,101 @@  discard block
 block discarded – undo
769 769
                 'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
770 770
                 'compare' => '=',
771 771
             );
772
-		}
773
-
774
-		$query->query_vars['meta_query'][] = array(
775
-			'key'     => '_wpinv_one_time',
776
-			'compare' => 'NOT EXISTS',
777
-		);
778
-	}
779
-
780
-	/**
781
-	 * Reorders items.
782
-	 */
783
-	public static function reorder_items( $vars ) {
784
-		global $typenow;
785
-
786
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
787
-			return $vars;
788
-		}
789
-
790
-		// By item type.
791
-		if ( 'type' === $vars['orderby'] ) {
792
-			return array_merge(
793
-				$vars,
794
-				array(
795
-					'meta_key' => '_wpinv_type',
796
-					'orderby'  => 'meta_value',
797
-				)
798
-			);
799
-		}
800
-
801
-		// By vat class.
802
-		if ( 'vat_class' === $vars['orderby'] ) {
803
-			return array_merge(
804
-				$vars,
805
-				array(
806
-					'meta_key' => '_wpinv_vat_class',
807
-					'orderby'  => 'meta_value',
808
-				)
809
-			);
810
-		}
811
-
812
-		// By vat rule.
813
-		if ( 'vat_rule' === $vars['orderby'] ) {
814
-			return array_merge(
815
-				$vars,
816
-				array(
817
-					'meta_key' => '_wpinv_vat_rule',
818
-					'orderby'  => 'meta_value',
819
-				)
820
-			);
821
-		}
822
-
823
-		// By price.
824
-		if ( 'price' === $vars['orderby'] ) {
825
-			return array_merge(
826
-				$vars,
827
-				array(
828
-					'meta_key' => '_wpinv_price',
829
-					'orderby'  => 'meta_value_num',
830
-				)
831
-			);
832
-		}
833
-
834
-		return $vars;
835
-
836
-	}
837
-
838
-	/**
839
-	 * Fired when deleting a post.
840
-	 */
841
-	public static function delete_post( $post_id ) {
842
-
843
-		switch ( get_post_type( $post_id ) ) {
844
-
845
-			case 'wpi_item':
846
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
847
-				break;
848
-
849
-			case 'wpi_payment_form':
850
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
851
-				break;
852
-
853
-			case 'wpi_discount':
854
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
855
-				break;
856
-
857
-			case 'wpi_invoice':
858
-				$invoice = new WPInv_Invoice( $post_id );
859
-				do_action( 'getpaid_before_delete_invoice', $invoice );
860
-				$invoice->get_data_store()->delete_items( $invoice );
861
-				$invoice->get_data_store()->delete_special_fields( $invoice );
862
-				break;
863
-		}
864
-	}
865
-
866
-	/**
772
+        }
773
+
774
+        $query->query_vars['meta_query'][] = array(
775
+            'key'     => '_wpinv_one_time',
776
+            'compare' => 'NOT EXISTS',
777
+        );
778
+    }
779
+
780
+    /**
781
+     * Reorders items.
782
+     */
783
+    public static function reorder_items( $vars ) {
784
+        global $typenow;
785
+
786
+        if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
787
+            return $vars;
788
+        }
789
+
790
+        // By item type.
791
+        if ( 'type' === $vars['orderby'] ) {
792
+            return array_merge(
793
+                $vars,
794
+                array(
795
+                    'meta_key' => '_wpinv_type',
796
+                    'orderby'  => 'meta_value',
797
+                )
798
+            );
799
+        }
800
+
801
+        // By vat class.
802
+        if ( 'vat_class' === $vars['orderby'] ) {
803
+            return array_merge(
804
+                $vars,
805
+                array(
806
+                    'meta_key' => '_wpinv_vat_class',
807
+                    'orderby'  => 'meta_value',
808
+                )
809
+            );
810
+        }
811
+
812
+        // By vat rule.
813
+        if ( 'vat_rule' === $vars['orderby'] ) {
814
+            return array_merge(
815
+                $vars,
816
+                array(
817
+                    'meta_key' => '_wpinv_vat_rule',
818
+                    'orderby'  => 'meta_value',
819
+                )
820
+            );
821
+        }
822
+
823
+        // By price.
824
+        if ( 'price' === $vars['orderby'] ) {
825
+            return array_merge(
826
+                $vars,
827
+                array(
828
+                    'meta_key' => '_wpinv_price',
829
+                    'orderby'  => 'meta_value_num',
830
+                )
831
+            );
832
+        }
833
+
834
+        return $vars;
835
+
836
+    }
837
+
838
+    /**
839
+     * Fired when deleting a post.
840
+     */
841
+    public static function delete_post( $post_id ) {
842
+
843
+        switch ( get_post_type( $post_id ) ) {
844
+
845
+            case 'wpi_item':
846
+                do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
847
+                break;
848
+
849
+            case 'wpi_payment_form':
850
+                do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
851
+                break;
852
+
853
+            case 'wpi_discount':
854
+                do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
855
+                break;
856
+
857
+            case 'wpi_invoice':
858
+                $invoice = new WPInv_Invoice( $post_id );
859
+                do_action( 'getpaid_before_delete_invoice', $invoice );
860
+                $invoice->get_data_store()->delete_items( $invoice );
861
+                $invoice->get_data_store()->delete_special_fields( $invoice );
862
+                break;
863
+        }
864
+    }
865
+
866
+    /**
867 867
      * Add a post display state for special GetPaid pages in the page list table.
868 868
      *
869 869
      * @param array   $post_states An array of post display states.
@@ -877,21 +877,21 @@  discard block
 block discarded – undo
877 877
             $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
878 878
         }
879 879
 
880
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
880
+        foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
881 881
 
882
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
883
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
884
-					__( 'GetPaid %s History Page', 'invoicing' ),
885
-					$label
886
-				);
887
-			}
882
+            if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
883
+                $post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
884
+                    __( 'GetPaid %s History Page', 'invoicing' ),
885
+                    $label
886
+                );
887
+            }
888 888
 }
889 889
 
890
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
890
+        if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
891 891
             $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
892 892
         }
893 893
 
894
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
894
+        if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
895 895
             $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
896 896
         }
897 897
 
Please login to merge, or discard this patch.
Spacing   +245 added lines, -245 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Post types Admin Class
@@ -21,74 +21,74 @@  discard block
 block discarded – undo
21 21
 		GetPaid_Metaboxes::init();
22 22
 
23 23
 		// Filter the post updated messages.
24
-		add_filter( 'post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages' );
24
+		add_filter('post_updated_messages', 'GetPaid_Post_Types_Admin::post_updated_messages');
25 25
 
26 26
 		// Filter post actions.
27
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2 );
28
-		add_filter( 'post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2 );
27
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::post_row_actions', 10, 2);
28
+		add_filter('post_row_actions', 'GetPaid_Post_Types_Admin::filter_invoice_row_actions', 90, 2);
29 29
 
30 30
 		// Invoice table columns.
31
-		add_filter( 'manage_wpi_invoice_posts_columns', array( __CLASS__, 'invoice_columns' ), 100 );
32
-		add_action( 'manage_wpi_invoice_posts_custom_column', array( __CLASS__, 'display_invoice_columns' ), 10, 2 );
33
-		add_filter( 'bulk_actions-edit-wpi_invoice', array( __CLASS__, 'invoice_bulk_actions' ) );
34
-		add_filter( 'handle_bulk_actions-edit-wpi_invoice', array( __CLASS__, 'handle_invoice_bulk_actions' ), 10, 3 );
31
+		add_filter('manage_wpi_invoice_posts_columns', array(__CLASS__, 'invoice_columns'), 100);
32
+		add_action('manage_wpi_invoice_posts_custom_column', array(__CLASS__, 'display_invoice_columns'), 10, 2);
33
+		add_filter('bulk_actions-edit-wpi_invoice', array(__CLASS__, 'invoice_bulk_actions'));
34
+		add_filter('handle_bulk_actions-edit-wpi_invoice', array(__CLASS__, 'handle_invoice_bulk_actions'), 10, 3);
35 35
 
36 36
 		// Items table columns.
37
-		add_filter( 'manage_wpi_item_posts_columns', array( __CLASS__, 'item_columns' ), 100 );
38
-		add_filter( 'manage_edit-wpi_item_sortable_columns', array( __CLASS__, 'sortable_item_columns' ), 20 );
39
-		add_action( 'manage_wpi_item_posts_custom_column', array( __CLASS__, 'display_item_columns' ), 10, 2 );
40
-		add_action( 'restrict_manage_posts', array( __CLASS__, 'add_item_filters' ), 100 );
41
-		add_action( 'parse_query', array( __CLASS__, 'filter_item_query' ), 100 );
42
-		add_action( 'request', array( __CLASS__, 'reorder_items' ), 100 );
37
+		add_filter('manage_wpi_item_posts_columns', array(__CLASS__, 'item_columns'), 100);
38
+		add_filter('manage_edit-wpi_item_sortable_columns', array(__CLASS__, 'sortable_item_columns'), 20);
39
+		add_action('manage_wpi_item_posts_custom_column', array(__CLASS__, 'display_item_columns'), 10, 2);
40
+		add_action('restrict_manage_posts', array(__CLASS__, 'add_item_filters'), 100);
41
+		add_action('parse_query', array(__CLASS__, 'filter_item_query'), 100);
42
+		add_action('request', array(__CLASS__, 'reorder_items'), 100);
43 43
 
44 44
 		// Payment forms columns.
45
-		add_filter( 'manage_wpi_payment_form_posts_columns', array( __CLASS__, 'payment_form_columns' ), 100 );
46
-		add_action( 'manage_wpi_payment_form_posts_custom_column', array( __CLASS__, 'display_payment_form_columns' ), 10, 2 );
47
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_payment_form_state' ), 10, 2 );
45
+		add_filter('manage_wpi_payment_form_posts_columns', array(__CLASS__, 'payment_form_columns'), 100);
46
+		add_action('manage_wpi_payment_form_posts_custom_column', array(__CLASS__, 'display_payment_form_columns'), 10, 2);
47
+		add_filter('display_post_states', array(__CLASS__, 'filter_payment_form_state'), 10, 2);
48 48
 
49 49
 		// Discount table columns.
50
-		add_filter( 'manage_wpi_discount_posts_columns', array( __CLASS__, 'discount_columns' ), 100 );
51
-		add_filter( 'bulk_actions-edit-wpi_discount', '__return_empty_array', 100 );
50
+		add_filter('manage_wpi_discount_posts_columns', array(__CLASS__, 'discount_columns'), 100);
51
+		add_filter('bulk_actions-edit-wpi_discount', '__return_empty_array', 100);
52 52
 
53 53
 		// Deleting posts.
54
-		add_action( 'delete_post', array( __CLASS__, 'delete_post' ) );
55
-		add_filter( 'display_post_states', array( __CLASS__, 'filter_discount_state' ), 10, 2 );
54
+		add_action('delete_post', array(__CLASS__, 'delete_post'));
55
+		add_filter('display_post_states', array(__CLASS__, 'filter_discount_state'), 10, 2);
56 56
 
57
-		add_filter( 'display_post_states', array( __CLASS__, 'add_display_post_states' ), 10, 2 );
57
+		add_filter('display_post_states', array(__CLASS__, 'add_display_post_states'), 10, 2);
58 58
 	}
59 59
 
60 60
 	/**
61 61
 	 * Post updated messages.
62 62
 	 */
63
-	public static function post_updated_messages( $messages ) {
63
+	public static function post_updated_messages($messages) {
64 64
 		global $post;
65 65
 
66 66
 		$messages['wpi_discount'] = array(
67 67
 			0  => '',
68
-			1  => __( 'Discount updated.', 'invoicing' ),
69
-			2  => __( 'Custom field updated.', 'invoicing' ),
70
-			3  => __( 'Custom field deleted.', 'invoicing' ),
71
-			4  => __( 'Discount updated.', 'invoicing' ),
72
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Discount restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
73
-			6  => __( 'Discount updated.', 'invoicing' ),
74
-			7  => __( 'Discount saved.', 'invoicing' ),
75
-			8  => __( 'Discount submitted.', 'invoicing' ),
76
-			9  => wp_sprintf( __( 'Discount scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
77
-			10 => __( 'Discount draft updated.', 'invoicing' ),
68
+			1  => __('Discount updated.', 'invoicing'),
69
+			2  => __('Custom field updated.', 'invoicing'),
70
+			3  => __('Custom field deleted.', 'invoicing'),
71
+			4  => __('Discount updated.', 'invoicing'),
72
+			5  => isset($_GET['revision']) ? wp_sprintf(__('Discount restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
73
+			6  => __('Discount updated.', 'invoicing'),
74
+			7  => __('Discount saved.', 'invoicing'),
75
+			8  => __('Discount submitted.', 'invoicing'),
76
+			9  => wp_sprintf(__('Discount scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
77
+			10 => __('Discount draft updated.', 'invoicing'),
78 78
 		);
79 79
 
80 80
 		$messages['wpi_payment_form'] = array(
81 81
 			0  => '',
82
-			1  => __( 'Payment Form updated.', 'invoicing' ),
83
-			2  => __( 'Custom field updated.', 'invoicing' ),
84
-			3  => __( 'Custom field deleted.', 'invoicing' ),
85
-			4  => __( 'Payment Form updated.', 'invoicing' ),
86
-			5  => isset( $_GET['revision'] ) ? wp_sprintf( __( 'Payment Form restored to revision from %s', 'invoicing' ), wp_post_revision_title( (int) $_GET['revision'], false ) ) : false,
87
-			6  => __( 'Payment Form updated.', 'invoicing' ),
88
-			7  => __( 'Payment Form saved.', 'invoicing' ),
89
-			8  => __( 'Payment Form submitted.', 'invoicing' ),
90
-			9  => wp_sprintf( __( 'Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing' ), date_i18n( __( 'M j, Y @ G:i', 'invoicing' ), strtotime( $post->post_date ) ) ),
91
-			10 => __( 'Payment Form draft updated.', 'invoicing' ),
82
+			1  => __('Payment Form updated.', 'invoicing'),
83
+			2  => __('Custom field updated.', 'invoicing'),
84
+			3  => __('Custom field deleted.', 'invoicing'),
85
+			4  => __('Payment Form updated.', 'invoicing'),
86
+			5  => isset($_GET['revision']) ? wp_sprintf(__('Payment Form restored to revision from %s', 'invoicing'), wp_post_revision_title((int) $_GET['revision'], false)) : false,
87
+			6  => __('Payment Form updated.', 'invoicing'),
88
+			7  => __('Payment Form saved.', 'invoicing'),
89
+			8  => __('Payment Form submitted.', 'invoicing'),
90
+			9  => wp_sprintf(__('Payment Form scheduled for: <strong>%1$s</strong>.', 'invoicing'), date_i18n(__('M j, Y @ G:i', 'invoicing'), strtotime($post->post_date))),
91
+			10 => __('Payment Form draft updated.', 'invoicing'),
92 92
 		);
93 93
 
94 94
 		return $messages;
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	/**
99 99
 	 * Post row actions.
100 100
 	 */
101
-	public static function post_row_actions( $actions, $post ) {
101
+	public static function post_row_actions($actions, $post) {
102 102
 
103
-		$post = get_post( $post );
103
+		$post = get_post($post);
104 104
 
105 105
 		// We do not want to edit the default payment form.
106
-		if ( 'wpi_payment_form' == $post->post_type ) {
106
+		if ('wpi_payment_form' == $post->post_type) {
107 107
 
108
-			if ( wpinv_get_default_payment_form() === $post->ID ) {
109
-				unset( $actions['trash'] );
110
-				unset( $actions['inline hide-if-no-js'] );
108
+			if (wpinv_get_default_payment_form() === $post->ID) {
109
+				unset($actions['trash']);
110
+				unset($actions['inline hide-if-no-js']);
111 111
 			}
112 112
 
113 113
 			$actions['duplicate'] = sprintf(
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 						'getpaid-nonce'
125 125
 					)
126 126
 				),
127
-				esc_html( __( 'Duplicate', 'invoicing' ) )
127
+				esc_html(__('Duplicate', 'invoicing'))
128 128
 			);
129 129
 
130 130
 			$actions['reset'] = sprintf(
@@ -141,17 +141,17 @@  discard block
 block discarded – undo
141 141
 						'getpaid-nonce'
142 142
 					)
143 143
 				),
144
-				esc_html( __( 'Reset Stats', 'invoicing' ) )
144
+				esc_html(__('Reset Stats', 'invoicing'))
145 145
 			);
146 146
 		}
147 147
 
148 148
 		// Link to item payment form.
149
-		if ( 'wpi_item' == $post->post_type ) {
150
-			if ( getpaid_item_type_supports( get_post_meta( $post->ID, '_wpinv_type', true ), 'buy_now' ) ) {
149
+		if ('wpi_item' == $post->post_type) {
150
+			if (getpaid_item_type_supports(get_post_meta($post->ID, '_wpinv_type', true), 'buy_now')) {
151 151
 				$actions['buy'] = sprintf(
152 152
 					'<a href="%1$s">%2$s</a>',
153
-					esc_url( getpaid_embed_url( false, $post->ID . '|0' ) ),
154
-					esc_html( __( 'Buy', 'invoicing' ) )
153
+					esc_url(getpaid_embed_url(false, $post->ID . '|0')),
154
+					esc_html(__('Buy', 'invoicing'))
155 155
 				);
156 156
 			}
157 157
 		}
@@ -167,28 +167,28 @@  discard block
 block discarded – undo
167 167
 	 * @param WP_Post $post
168 168
      * @return array $actions actions without edit option
169 169
      */
170
-    public static function filter_invoice_row_actions( $actions, $post ) {
170
+    public static function filter_invoice_row_actions($actions, $post) {
171 171
 
172
-        if ( getpaid_is_invoice_post_type( $post->post_type ) ) {
172
+        if (getpaid_is_invoice_post_type($post->post_type)) {
173 173
 
174 174
 			$actions = array();
175
-			$invoice = new WPInv_Invoice( $post );
175
+			$invoice = new WPInv_Invoice($post);
176 176
 
177 177
 			$actions['edit'] = sprintf(
178 178
 				'<a href="%1$s">%2$s</a>',
179
-				esc_url( get_edit_post_link( $invoice->get_id() ) ),
180
-				esc_html( __( 'Edit', 'invoicing' ) )
179
+				esc_url(get_edit_post_link($invoice->get_id())),
180
+				esc_html(__('Edit', 'invoicing'))
181 181
 			);
182 182
 
183
-			if ( ! $invoice->is_draft() ) {
183
+			if (!$invoice->is_draft()) {
184 184
 
185 185
 				$actions['view'] = sprintf(
186 186
 					'<a href="%1$s">%2$s</a>',
187
-					esc_url( $invoice->get_view_url() ),
187
+					esc_url($invoice->get_view_url()),
188 188
 					sprintf(
189 189
 						// translators: %s is the invoice type
190
-						esc_html__( 'View %s', 'invoicing' ),
191
-						getpaid_get_post_type_label( $invoice->get_post_type(), false )
190
+						esc_html__('View %s', 'invoicing'),
191
+						getpaid_get_post_type_label($invoice->get_post_type(), false)
192 192
 					)
193 193
 				);
194 194
 
@@ -206,7 +206,7 @@  discard block
 block discarded – undo
206 206
 							'getpaid-nonce'
207 207
 						)
208 208
 					),
209
-					esc_html( __( 'Send to Customer', 'invoicing' ) )
209
+					esc_html(__('Send to Customer', 'invoicing'))
210 210
 				);
211 211
 
212 212
 			}
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 						'getpaid-nonce'
226 226
 					)
227 227
 				),
228
-				esc_html( __( 'Duplicate', 'invoicing' ) )
228
+				esc_html(__('Duplicate', 'invoicing'))
229 229
 			);
230 230
 
231 231
         }
@@ -236,42 +236,42 @@  discard block
 block discarded – undo
236 236
 	/**
237 237
 	 * Returns an array of invoice table columns.
238 238
 	 */
239
-	public static function invoice_columns( $columns ) {
239
+	public static function invoice_columns($columns) {
240 240
 
241 241
 		$columns = array(
242 242
 			'cb'           => $columns['cb'],
243
-			'number'       => __( 'Invoice', 'invoicing' ),
244
-			'customer'     => __( 'Customer', 'invoicing' ),
245
-			'invoice_date' => __( 'Created', 'invoicing' ),
246
-			'payment_date' => __( 'Completed', 'invoicing' ),
247
-			'amount'       => __( 'Amount', 'invoicing' ),
248
-			'recurring'    => __( 'Recurring', 'invoicing' ),
249
-			'status'       => __( 'Status', 'invoicing' ),
243
+			'number'       => __('Invoice', 'invoicing'),
244
+			'customer'     => __('Customer', 'invoicing'),
245
+			'invoice_date' => __('Created', 'invoicing'),
246
+			'payment_date' => __('Completed', 'invoicing'),
247
+			'amount'       => __('Amount', 'invoicing'),
248
+			'recurring'    => __('Recurring', 'invoicing'),
249
+			'status'       => __('Status', 'invoicing'),
250 250
 		);
251 251
 
252
-		return apply_filters( 'wpi_invoice_table_columns', $columns );
252
+		return apply_filters('wpi_invoice_table_columns', $columns);
253 253
 	}
254 254
 
255 255
 	/**
256 256
 	 * Displays invoice table columns.
257 257
 	 */
258
-	public static function display_invoice_columns( $column_name, $post_id ) {
258
+	public static function display_invoice_columns($column_name, $post_id) {
259 259
 
260
-		$invoice = new WPInv_Invoice( $post_id );
260
+		$invoice = new WPInv_Invoice($post_id);
261 261
 
262
-		switch ( $column_name ) {
262
+		switch ($column_name) {
263 263
 
264 264
 			case 'invoice_date':
265
-				$date_time = esc_attr( $invoice->get_created_date() );
266
-				$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
267
-				echo wp_kses_post( "<span title='$date_time'>$date</span>" );
265
+				$date_time = esc_attr($invoice->get_created_date());
266
+				$date      = esc_html(getpaid_format_date_value($date_time, '&mdash;', true));
267
+				echo wp_kses_post("<span title='$date_time'>$date</span>");
268 268
 				break;
269 269
 
270 270
 			case 'payment_date':
271
-				if ( $invoice->is_paid() ) {
272
-					$date_time = esc_attr( $invoice->get_completed_date() );
273
-					$date      = esc_html( getpaid_format_date_value( $date_time, '&mdash;', true ) );
274
-					echo wp_kses_post( "<span title='$date_time'>$date</span>" );
271
+				if ($invoice->is_paid()) {
272
+					$date_time = esc_attr($invoice->get_completed_date());
273
+					$date      = esc_html(getpaid_format_date_value($date_time, '&mdash;', true));
274
+					echo wp_kses_post("<span title='$date_time'>$date</span>");
275 275
 				} else {
276 276
 					echo '&mdash;';
277 277
 				}
@@ -280,61 +280,61 @@  discard block
 block discarded – undo
280 280
 
281 281
 			case 'amount':
282 282
 				$amount = $invoice->get_total();
283
-				$formated_amount = wp_kses_post( wpinv_price( $amount, $invoice->get_currency() ) );
283
+				$formated_amount = wp_kses_post(wpinv_price($amount, $invoice->get_currency()));
284 284
 
285
-				if ( $invoice->is_refunded() ) {
286
-					$refunded_amount = wpinv_price( 0, $invoice->get_currency() );
287
-					echo wp_kses_post( "<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>" );
285
+				if ($invoice->is_refunded()) {
286
+					$refunded_amount = wpinv_price(0, $invoice->get_currency());
287
+					echo wp_kses_post("<del>$formated_amount</del>&nbsp;<ins>$refunded_amount</ins>");
288 288
 				} else {
289 289
 
290 290
 					$discount = $invoice->get_total_discount();
291 291
 
292
-					if ( ! empty( $discount ) ) {
293
-						$new_amount = wpinv_price( $amount + $discount, $invoice->get_currency() );
294
-						echo wp_kses_post( "<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>" );
292
+					if (!empty($discount)) {
293
+						$new_amount = wpinv_price($amount + $discount, $invoice->get_currency());
294
+						echo wp_kses_post("<del>$new_amount</del>&nbsp;<ins>$formated_amount</ins>");
295 295
 					} else {
296
-						echo wp_kses_post( $formated_amount );
296
+						echo wp_kses_post($formated_amount);
297 297
 					}
298 298
 				}
299 299
 
300 300
 				break;
301 301
 
302 302
 			case 'status':
303
-				$status       = esc_html( $invoice->get_status() );
304
-				$status_label = esc_html( $invoice->get_status_nicename() );
303
+				$status       = esc_html($invoice->get_status());
304
+				$status_label = esc_html($invoice->get_status_nicename());
305 305
 
306 306
 				// If it is paid, show the gateway title.
307
-				if ( $invoice->is_paid() ) {
308
-					$gateway = esc_html( $invoice->get_gateway_title() );
309
-					$gateway = wp_sprintf( esc_attr__( 'Paid via %s', 'invoicing' ), esc_html( $gateway ) );
307
+				if ($invoice->is_paid()) {
308
+					$gateway = esc_html($invoice->get_gateway_title());
309
+					$gateway = wp_sprintf(esc_attr__('Paid via %s', 'invoicing'), esc_html($gateway));
310 310
 
311
-					echo wp_kses_post( "<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>" );
311
+					echo wp_kses_post("<mark class='wpi-help-tip getpaid-invoice-status $status' title='$gateway'><span>$status_label</span></mark>");
312 312
 				} else {
313
-					echo wp_kses_post( "<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>" );
313
+					echo wp_kses_post("<mark class='getpaid-invoice-status $status'><span>$status_label</span></mark>");
314 314
 				}
315 315
 
316 316
 				// If it is not paid, display the overdue and view status.
317
-				if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
317
+				if (!$invoice->is_paid() && !$invoice->is_refunded()) {
318 318
 
319 319
 					// Invoice view status.
320
-					if ( wpinv_is_invoice_viewed( $invoice->get_id() ) ) {
321
-						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__( 'Viewed by Customer', 'invoicing' ) . '"></i>';
320
+					if (wpinv_is_invoice_viewed($invoice->get_id())) {
321
+						echo '&nbsp;&nbsp;<i class="fa fa-eye wpi-help-tip" title="' . esc_attr__('Viewed by Customer', 'invoicing') . '"></i>';
322 322
 					} else {
323
-						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__( 'Not Viewed by Customer', 'invoicing' ) . '"></i>';
323
+						echo '&nbsp;&nbsp;<i class="fa fa-eye-slash wpi-help-tip" title="' . esc_attr__('Not Viewed by Customer', 'invoicing') . '"></i>';
324 324
 					}
325 325
 
326 326
 					// Display the overview status.
327
-					if ( wpinv_get_option( 'overdue_active' ) ) {
327
+					if (wpinv_get_option('overdue_active')) {
328 328
 						$due_date = $invoice->get_due_date();
329
-						$fomatted = getpaid_format_date( $due_date );
329
+						$fomatted = getpaid_format_date($due_date);
330 330
 
331
-						if ( ! empty( $fomatted ) ) {
331
+						if (!empty($fomatted)) {
332 332
 							$date = wp_sprintf(
333 333
 								// translators: %s is the due date.
334
-								__( 'Due %s', 'invoicing' ),
334
+								__('Due %s', 'invoicing'),
335 335
 								$fomatted
336 336
 							);
337
-							echo wp_kses_post( "<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>" );
337
+							echo wp_kses_post("<p class='description' style='color: #888;' title='$due_date'>$fomatted</p>");
338 338
 						}
339 339
 					}
340 340
 				}
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 				break;
343 343
 
344 344
 			case 'recurring':
345
-				if ( $invoice->is_recurring() ) {
345
+				if ($invoice->is_recurring()) {
346 346
 					echo '<i class="fa fa-check" style="color:#43850a;"></i>';
347 347
 				} else {
348 348
 					echo '<i class="fa fa-times" style="color:#616161;"></i>';
@@ -350,26 +350,26 @@  discard block
 block discarded – undo
350 350
 				break;
351 351
 
352 352
 			case 'number':
353
-				$edit_link       = esc_url( get_edit_post_link( $invoice->get_id() ) );
354
-				$invoice_number  = esc_html( $invoice->get_number() );
355
-				$invoice_details = esc_attr__( 'View Invoice Details', 'invoicing' );
353
+				$edit_link       = esc_url(get_edit_post_link($invoice->get_id()));
354
+				$invoice_number  = esc_html($invoice->get_number());
355
+				$invoice_details = esc_attr__('View Invoice Details', 'invoicing');
356 356
 
357
-				echo wp_kses_post( "<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>" );
357
+				echo wp_kses_post("<a href='$edit_link' title='$invoice_details'><strong>$invoice_number</strong></a>");
358 358
 
359
-				do_action( 'getpaid_admin_table_invoice_number_column', $invoice );
359
+				do_action('getpaid_admin_table_invoice_number_column', $invoice);
360 360
 				break;
361 361
 
362 362
 			case 'customer':
363 363
 				$customer_name = $invoice->get_user_full_name();
364 364
 
365
-				if ( empty( $customer_name ) ) {
365
+				if (empty($customer_name)) {
366 366
 					$customer_name = $invoice->get_email();
367 367
 				}
368 368
 
369
-				if ( ! empty( $customer_name ) ) {
370
-					$customer_details = esc_attr__( 'View Customer Details', 'invoicing' );
371
-					$view_link        = esc_url( add_query_arg( 'user_id', $invoice->get_user_id(), admin_url( 'user-edit.php' ) ) );
372
-					echo wp_kses_post( "<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>" );
369
+				if (!empty($customer_name)) {
370
+					$customer_details = esc_attr__('View Customer Details', 'invoicing');
371
+					$view_link        = esc_url(add_query_arg('user_id', $invoice->get_user_id(), admin_url('user-edit.php')));
372
+					echo wp_kses_post("<a href='$view_link' title='$customer_details'><span>$customer_name</span></a>");
373 373
 				} else {
374 374
 					echo '<div>&mdash;</div>';
375 375
 				}
@@ -383,19 +383,19 @@  discard block
 block discarded – undo
383 383
 	/**
384 384
 	 * Displays invoice bulk actions.
385 385
 	 */
386
-	public static function invoice_bulk_actions( $actions ) {
387
-		$actions['resend-invoice'] = __( 'Send to Customer', 'invoicing' );
386
+	public static function invoice_bulk_actions($actions) {
387
+		$actions['resend-invoice'] = __('Send to Customer', 'invoicing');
388 388
 		return $actions;
389 389
 	}
390 390
 
391 391
 	/**
392 392
 	 * Processes invoice bulk actions.
393 393
 	 */
394
-	public static function handle_invoice_bulk_actions( $redirect_url, $action, $post_ids ) {
394
+	public static function handle_invoice_bulk_actions($redirect_url, $action, $post_ids) {
395 395
 
396
-		if ( 'resend-invoice' === $action ) {
397
-			foreach ( $post_ids as $post_id ) {
398
-				getpaid()->get( 'invoice_emails' )->user_invoice( new WPInv_Invoice( $post_id ), true );
396
+		if ('resend-invoice' === $action) {
397
+			foreach ($post_ids as $post_id) {
398
+				getpaid()->get('invoice_emails')->user_invoice(new WPInv_Invoice($post_id), true);
399 399
 			}
400 400
 		}
401 401
 
@@ -406,49 +406,49 @@  discard block
 block discarded – undo
406 406
 	/**
407 407
 	 * Returns an array of payment forms table columns.
408 408
 	 */
409
-	public static function payment_form_columns( $columns ) {
409
+	public static function payment_form_columns($columns) {
410 410
 
411 411
 		$columns = array(
412 412
 			'cb'        => $columns['cb'],
413
-			'title'     => __( 'Name', 'invoicing' ),
414
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
415
-			'earnings'  => __( 'Revenue', 'invoicing' ),
416
-			'refunds'   => __( 'Refunded', 'invoicing' ),
417
-			'items'     => __( 'Items', 'invoicing' ),
418
-			'date'      => __( 'Date', 'invoicing' ),
413
+			'title'     => __('Name', 'invoicing'),
414
+			'shortcode' => __('Shortcode', 'invoicing'),
415
+			'earnings'  => __('Revenue', 'invoicing'),
416
+			'refunds'   => __('Refunded', 'invoicing'),
417
+			'items'     => __('Items', 'invoicing'),
418
+			'date'      => __('Date', 'invoicing'),
419 419
 		);
420 420
 
421
-		return apply_filters( 'wpi_payment_form_table_columns', $columns );
421
+		return apply_filters('wpi_payment_form_table_columns', $columns);
422 422
 
423 423
 	}
424 424
 
425 425
 	/**
426 426
 	 * Displays payment form table columns.
427 427
 	 */
428
-	public static function display_payment_form_columns( $column_name, $post_id ) {
428
+	public static function display_payment_form_columns($column_name, $post_id) {
429 429
 
430 430
 		// Retrieve the payment form.
431
-		$form = new GetPaid_Payment_Form( $post_id );
431
+		$form = new GetPaid_Payment_Form($post_id);
432 432
 
433
-		switch ( $column_name ) {
433
+		switch ($column_name) {
434 434
 
435 435
 			case 'earnings':
436
-				echo wp_kses_post( wpinv_price( $form->get_earned() ) );
436
+				echo wp_kses_post(wpinv_price($form->get_earned()));
437 437
 				break;
438 438
 
439 439
 			case 'refunds':
440
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
440
+				echo wp_kses_post(wpinv_price($form->get_refunded()));
441 441
 				break;
442 442
 
443 443
 			case 'refunds':
444
-				echo wp_kses_post( wpinv_price( $form->get_refunded() ) );
444
+				echo wp_kses_post(wpinv_price($form->get_refunded()));
445 445
 				break;
446 446
 
447 447
 			case 'shortcode':
448
-				if ( $form->is_default() ) {
448
+				if ($form->is_default()) {
449 449
 					echo '&mdash;';
450 450
 				} else {
451
-					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr( $form->get_id() ) . ']" style="width: 100%;" readonly/>';
451
+					echo '<input onClick="this.select()" type="text" value="[getpaid form=' . esc_attr($form->get_id()) . ']" style="width: 100%;" readonly/>';
452 452
 				}
453 453
 
454 454
 				break;
@@ -456,28 +456,28 @@  discard block
 block discarded – undo
456 456
 			case 'items':
457 457
 				$items = $form->get_items();
458 458
 
459
-				if ( $form->is_default() || empty( $items ) ) {
459
+				if ($form->is_default() || empty($items)) {
460 460
 					echo '&mdash;';
461 461
 					return;
462 462
 				}
463 463
 
464 464
 				$_items = array();
465 465
 
466
-				foreach ( $items as $item ) {
466
+				foreach ($items as $item) {
467 467
 					$url = $item->get_edit_url();
468 468
 
469
-					if ( empty( $url ) ) {
470
-						$_items[] = esc_html( $item->get_name() );
469
+					if (empty($url)) {
470
+						$_items[] = esc_html($item->get_name());
471 471
 					} else {
472 472
 						$_items[] = sprintf(
473 473
 							'<a href="%s">%s</a>',
474
-							esc_url( $url ),
475
-							esc_html( $item->get_name() )
474
+							esc_url($url),
475
+							esc_html($item->get_name())
476 476
 						);
477 477
 					}
478 478
 }
479 479
 
480
-				echo wp_kses_post( implode( '<br>', $_items ) );
480
+				echo wp_kses_post(implode('<br>', $_items));
481 481
 
482 482
 				break;
483 483
 
@@ -488,10 +488,10 @@  discard block
 block discarded – undo
488 488
 	/**
489 489
 	 * Filters post states.
490 490
 	 */
491
-	public static function filter_payment_form_state( $post_states, $post ) {
491
+	public static function filter_payment_form_state($post_states, $post) {
492 492
 
493
-		if ( 'wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID ) {
494
-			$post_states['default_form'] = __( 'Default Payment Form', 'invoicing' );
493
+		if ('wpi_payment_form' === $post->post_type && wpinv_get_default_payment_form() === $post->ID) {
494
+			$post_states['default_form'] = __('Default Payment Form', 'invoicing');
495 495
 		}
496 496
 
497 497
 		return $post_states;
@@ -501,35 +501,35 @@  discard block
 block discarded – undo
501 501
 	/**
502 502
 	 * Returns an array of coupon table columns.
503 503
 	 */
504
-	public static function discount_columns( $columns ) {
504
+	public static function discount_columns($columns) {
505 505
 
506 506
 		$columns = array(
507 507
 			'cb'          => $columns['cb'],
508
-			'title'       => __( 'Name', 'invoicing' ),
509
-			'code'        => __( 'Code', 'invoicing' ),
510
-			'amount'      => __( 'Amount', 'invoicing' ),
511
-			'usage'       => __( 'Usage / Limit', 'invoicing' ),
512
-			'start_date'  => __( 'Start Date', 'invoicing' ),
513
-			'expiry_date' => __( 'Expiry Date', 'invoicing' ),
508
+			'title'       => __('Name', 'invoicing'),
509
+			'code'        => __('Code', 'invoicing'),
510
+			'amount'      => __('Amount', 'invoicing'),
511
+			'usage'       => __('Usage / Limit', 'invoicing'),
512
+			'start_date'  => __('Start Date', 'invoicing'),
513
+			'expiry_date' => __('Expiry Date', 'invoicing'),
514 514
 		);
515 515
 
516
-		return apply_filters( 'wpi_discount_table_columns', $columns );
516
+		return apply_filters('wpi_discount_table_columns', $columns);
517 517
 	}
518 518
 
519 519
 	/**
520 520
 	 * Filters post states.
521 521
 	 */
522
-	public static function filter_discount_state( $post_states, $post ) {
522
+	public static function filter_discount_state($post_states, $post) {
523 523
 
524
-		if ( 'wpi_discount' === $post->post_type ) {
524
+		if ('wpi_discount' === $post->post_type) {
525 525
 
526
-			$discount = new WPInv_Discount( $post );
526
+			$discount = new WPInv_Discount($post);
527 527
 
528 528
 			$status = $discount->is_expired() ? 'expired' : $discount->get_status();
529 529
 
530
-			if ( 'publish' !== $status ) {
530
+			if ('publish' !== $status) {
531 531
 				return array(
532
-					'discount_status' => wpinv_discount_status( $status ),
532
+					'discount_status' => wpinv_discount_status($status),
533 533
 				);
534 534
 			}
535 535
 
@@ -544,30 +544,30 @@  discard block
 block discarded – undo
544 544
 	/**
545 545
 	 * Returns an array of items table columns.
546 546
 	 */
547
-	public static function item_columns( $columns ) {
547
+	public static function item_columns($columns) {
548 548
 
549 549
 		$columns = array(
550 550
 			'cb'        => $columns['cb'],
551
-			'title'     => __( 'Name', 'invoicing' ),
552
-			'price'     => __( 'Price', 'invoicing' ),
553
-			'vat_rule'  => __( 'Tax Rule', 'invoicing' ),
554
-			'vat_class' => __( 'Tax Class', 'invoicing' ),
555
-			'type'      => __( 'Type', 'invoicing' ),
556
-			'shortcode' => __( 'Shortcode', 'invoicing' ),
551
+			'title'     => __('Name', 'invoicing'),
552
+			'price'     => __('Price', 'invoicing'),
553
+			'vat_rule'  => __('Tax Rule', 'invoicing'),
554
+			'vat_class' => __('Tax Class', 'invoicing'),
555
+			'type'      => __('Type', 'invoicing'),
556
+			'shortcode' => __('Shortcode', 'invoicing'),
557 557
 		);
558 558
 
559
-		if ( ! wpinv_use_taxes() ) {
560
-			unset( $columns['vat_rule'] );
561
-			unset( $columns['vat_class'] );
559
+		if (!wpinv_use_taxes()) {
560
+			unset($columns['vat_rule']);
561
+			unset($columns['vat_class']);
562 562
 		}
563 563
 
564
-		return apply_filters( 'wpi_item_table_columns', $columns );
564
+		return apply_filters('wpi_item_table_columns', $columns);
565 565
 	}
566 566
 
567 567
 	/**
568 568
 	 * Returns an array of sortable items table columns.
569 569
 	 */
570
-	public static function sortable_item_columns( $columns ) {
570
+	public static function sortable_item_columns($columns) {
571 571
 
572 572
 		return array_merge(
573 573
 			$columns,
@@ -584,45 +584,45 @@  discard block
 block discarded – undo
584 584
 	/**
585 585
 	 * Displays items table columns.
586 586
 	 */
587
-	public static function display_item_columns( $column_name, $post_id ) {
587
+	public static function display_item_columns($column_name, $post_id) {
588 588
 
589
-		$item = new WPInv_Item( $post_id );
589
+		$item = new WPInv_Item($post_id);
590 590
 
591
-		switch ( $column_name ) {
591
+		switch ($column_name) {
592 592
 
593 593
 			case 'price':
594
-				if ( ! $item->is_recurring() ) {
595
-					echo wp_kses_post( $item->get_the_price() );
594
+				if (!$item->is_recurring()) {
595
+					echo wp_kses_post($item->get_the_price());
596 596
 					break;
597 597
 				}
598 598
 
599 599
 				$price = wp_sprintf(
600
-					__( '%1$s / %2$s', 'invoicing' ),
600
+					__('%1$s / %2$s', 'invoicing'),
601 601
 					$item->get_the_price(),
602
-					getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' )
602
+					getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '')
603 603
 				);
604 604
 
605
-				if ( $item->get_the_price() == $item->get_the_initial_price() ) {
606
-					echo wp_kses_post( $price );
605
+				if ($item->get_the_price() == $item->get_the_initial_price()) {
606
+					echo wp_kses_post($price);
607 607
 					break;
608 608
 				}
609 609
 
610
-				echo wp_kses_post( $item->get_the_initial_price() );
610
+				echo wp_kses_post($item->get_the_initial_price());
611 611
 
612
-				echo '<span class="meta">' . wp_sprintf( esc_html__( 'then %s', 'invoicing' ), wp_kses_post( $price ) ) . '</span>';
612
+				echo '<span class="meta">' . wp_sprintf(esc_html__('then %s', 'invoicing'), wp_kses_post($price)) . '</span>';
613 613
 				break;
614 614
 
615 615
 			case 'vat_rule':
616
-				echo wp_kses_post( getpaid_get_tax_rule_label( $item->get_vat_rule() ) );
616
+				echo wp_kses_post(getpaid_get_tax_rule_label($item->get_vat_rule()));
617 617
 				break;
618 618
 
619 619
 			case 'vat_class':
620
-				echo wp_kses_post( getpaid_get_tax_class_label( $item->get_vat_class() ) );
620
+				echo wp_kses_post(getpaid_get_tax_class_label($item->get_vat_class()));
621 621
 				break;
622 622
 
623 623
 			case 'shortcode':
624
-				if ( $item->is_type( array( '', 'fee', 'custom' ) ) ) {
625
-					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr( $item->get_id() ) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
624
+				if ($item->is_type(array('', 'fee', 'custom'))) {
625
+					echo '<input onClick="this.select()" type="text" value="[getpaid item=' . esc_attr($item->get_id()) . ' button=\'Buy Now\']" style="width: 100%;" readonly/>';
626 626
 				} else {
627 627
 					echo '&mdash;';
628 628
 				}
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 				break;
631 631
 
632 632
 			case 'type':
633
-				echo wp_kses_post( wpinv_item_type( $item->get_id() ) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>' );
633
+				echo wp_kses_post(wpinv_item_type($item->get_id()) . '<span class="meta">' . $item->get_custom_singular_name() . '</span>');
634 634
 				break;
635 635
 
636 636
 		}
@@ -640,21 +640,21 @@  discard block
 block discarded – undo
640 640
 	/**
641 641
 	 * Lets users filter items using taxes.
642 642
 	 */
643
-	public static function add_item_filters( $post_type ) {
643
+	public static function add_item_filters($post_type) {
644 644
 
645 645
 		// Abort if we're not dealing with items.
646
-		if ( 'wpi_item' !== $post_type ) {
646
+		if ('wpi_item' !== $post_type) {
647 647
 			return;
648 648
 		}
649 649
 
650 650
 		// Filter by vat rules.
651
-		if ( wpinv_use_taxes() ) {
651
+		if (wpinv_use_taxes()) {
652 652
 
653 653
 			// Sanitize selected vat rule.
654 654
 			$vat_rule   = '';
655 655
 			$vat_rules  = getpaid_get_tax_rules();
656
-			if ( isset( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
657
-				$vat_rule   = sanitize_text_field( $_GET['vat_rule'] ); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
656
+			if (isset($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
657
+				$vat_rule = sanitize_text_field($_GET['vat_rule']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
658 658
 			}
659 659
 
660 660
 			// Filter by VAT rule.
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
 				array(
663 663
 					'options'          => array_merge(
664 664
 						array(
665
-							'' => __( 'All Tax Rules', 'invoicing' ),
665
+							'' => __('All Tax Rules', 'invoicing'),
666 666
 						),
667 667
 						$vat_rules
668 668
 					),
669 669
 					'name'             => 'vat_rule',
670 670
 					'id'               => 'vat_rule',
671
-					'selected'         => in_array( $vat_rule, array_keys( $vat_rules ), true ) ? $vat_rule : '',
671
+					'selected'         => in_array($vat_rule, array_keys($vat_rules), true) ? $vat_rule : '',
672 672
 					'show_option_all'  => false,
673 673
 					'show_option_none' => false,
674 674
 				)
@@ -679,21 +679,21 @@  discard block
 block discarded – undo
679 679
 			// Sanitize selected vat rule.
680 680
 			$vat_class   = '';
681 681
 			$vat_classes = getpaid_get_tax_classes();
682
-			if ( isset( $_GET['vat_class'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
683
-				$vat_class   = sanitize_text_field( $_GET['vat_class'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
682
+			if (isset($_GET['vat_class'])) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
683
+				$vat_class = sanitize_text_field($_GET['vat_class']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
684 684
 			}
685 685
 
686 686
 			wpinv_html_select(
687 687
 				array(
688 688
 					'options'          => array_merge(
689 689
 						array(
690
-							'' => __( 'All Tax Classes', 'invoicing' ),
690
+							'' => __('All Tax Classes', 'invoicing'),
691 691
 						),
692 692
 						$vat_classes
693 693
 					),
694 694
 					'name'             => 'vat_class',
695 695
 					'id'               => 'vat_class',
696
-					'selected'         => in_array( $vat_class, array_keys( $vat_classes ), true ) ? $vat_class : '',
696
+					'selected'         => in_array($vat_class, array_keys($vat_classes), true) ? $vat_class : '',
697 697
 					'show_option_all'  => false,
698 698
 					'show_option_none' => false,
699 699
 				)
@@ -702,22 +702,22 @@  discard block
 block discarded – undo
702 702
 		}
703 703
 
704 704
 		// Filter by item type.
705
-		$type   = '';
706
-		if ( isset( $_GET['type'] ) ) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
707
-			$type   = sanitize_text_field( $_GET['type'] );  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
705
+		$type = '';
706
+		if (isset($_GET['type'])) {  // phpcs:ignore WordPress.Security.NonceVerification.Recommended
707
+			$type = sanitize_text_field($_GET['type']); // phpcs:ignore WordPress.Security.NonceVerification.Recommended
708 708
 		}
709 709
 
710 710
 		wpinv_html_select(
711 711
 			array(
712 712
 				'options'          => array_merge(
713 713
 					array(
714
-						'' => __( 'All item types', 'invoicing' ),
714
+						'' => __('All item types', 'invoicing'),
715 715
 					),
716 716
 					wpinv_get_item_types()
717 717
 				),
718 718
 				'name'             => 'type',
719 719
 				'id'               => 'type',
720
-				'selected'         => in_array( $type, wpinv_item_types(), true ) ? $type : '',
720
+				'selected'         => in_array($type, wpinv_item_types(), true) ? $type : '',
721 721
 				'show_option_all'  => false,
722 722
 				'show_option_none' => false,
723 723
 			)
@@ -728,45 +728,45 @@  discard block
 block discarded – undo
728 728
 	/**
729 729
 	 * Filters the item query.
730 730
 	 */
731
-	public static function filter_item_query( $query ) {
731
+	public static function filter_item_query($query) {
732 732
 
733 733
 		// modify the query only if it admin and main query.
734
-		if ( ! ( is_admin() && $query->is_main_query() ) ) {
734
+		if (!(is_admin() && $query->is_main_query())) {
735 735
 			return $query;
736 736
 		}
737 737
 
738 738
 		// we want to modify the query for our items.
739
-		if ( empty( $query->query['post_type'] ) || 'wpi_item' !== $query->query['post_type'] ) {
739
+		if (empty($query->query['post_type']) || 'wpi_item' !== $query->query['post_type']) {
740 740
 			return $query;
741 741
 		}
742 742
 
743
-		if ( empty( $query->query_vars['meta_query'] ) ) {
743
+		if (empty($query->query_vars['meta_query'])) {
744 744
 			$query->query_vars['meta_query'] = array();
745 745
 		}
746 746
 
747 747
 		// Filter vat rule type
748
-        if ( ! empty( $_GET['vat_rule'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
748
+        if (!empty($_GET['vat_rule'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
749 749
             $query->query_vars['meta_query'][] = array(
750 750
                 'key'     => '_wpinv_vat_rule',
751
-                'value'   => sanitize_text_field( $_GET['vat_rule'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
751
+                'value'   => sanitize_text_field($_GET['vat_rule']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
752 752
                 'compare' => '=',
753 753
             );
754 754
         }
755 755
 
756 756
         // Filter vat class
757
-        if ( ! empty( $_GET['vat_class'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
757
+        if (!empty($_GET['vat_class'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
758 758
             $query->query_vars['meta_query'][] = array(
759 759
                 'key'     => '_wpinv_vat_class',
760
-                'value'   => sanitize_text_field( $_GET['vat_class'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
760
+                'value'   => sanitize_text_field($_GET['vat_class']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
761 761
                 'compare' => '=',
762 762
             );
763 763
         }
764 764
 
765 765
         // Filter item type
766
-        if ( ! empty( $_GET['type'] ) ) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
766
+        if (!empty($_GET['type'])) { // phpcs:ignore WordPress.Security.NonceVerification.Recommended
767 767
             $query->query_vars['meta_query'][] = array(
768 768
                 'key'     => '_wpinv_type',
769
-                'value'   => sanitize_text_field( $_GET['type'] ), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
769
+                'value'   => sanitize_text_field($_GET['type']), // phpcs:ignore WordPress.Security.NonceVerification.Recommended
770 770
                 'compare' => '=',
771 771
             );
772 772
 		}
@@ -780,15 +780,15 @@  discard block
 block discarded – undo
780 780
 	/**
781 781
 	 * Reorders items.
782 782
 	 */
783
-	public static function reorder_items( $vars ) {
783
+	public static function reorder_items($vars) {
784 784
 		global $typenow;
785 785
 
786
-		if ( 'wpi_item' !== $typenow || empty( $vars['orderby'] ) ) {
786
+		if ('wpi_item' !== $typenow || empty($vars['orderby'])) {
787 787
 			return $vars;
788 788
 		}
789 789
 
790 790
 		// By item type.
791
-		if ( 'type' === $vars['orderby'] ) {
791
+		if ('type' === $vars['orderby']) {
792 792
 			return array_merge(
793 793
 				$vars,
794 794
 				array(
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 		}
800 800
 
801 801
 		// By vat class.
802
-		if ( 'vat_class' === $vars['orderby'] ) {
802
+		if ('vat_class' === $vars['orderby']) {
803 803
 			return array_merge(
804 804
 				$vars,
805 805
 				array(
@@ -810,7 +810,7 @@  discard block
 block discarded – undo
810 810
 		}
811 811
 
812 812
 		// By vat rule.
813
-		if ( 'vat_rule' === $vars['orderby'] ) {
813
+		if ('vat_rule' === $vars['orderby']) {
814 814
 			return array_merge(
815 815
 				$vars,
816 816
 				array(
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 		}
822 822
 
823 823
 		// By price.
824
-		if ( 'price' === $vars['orderby'] ) {
824
+		if ('price' === $vars['orderby']) {
825 825
 			return array_merge(
826 826
 				$vars,
827 827
 				array(
@@ -838,27 +838,27 @@  discard block
 block discarded – undo
838 838
 	/**
839 839
 	 * Fired when deleting a post.
840 840
 	 */
841
-	public static function delete_post( $post_id ) {
841
+	public static function delete_post($post_id) {
842 842
 
843
-		switch ( get_post_type( $post_id ) ) {
843
+		switch (get_post_type($post_id)) {
844 844
 
845 845
 			case 'wpi_item':
846
-				do_action( 'getpaid_before_delete_item', new WPInv_Item( $post_id ) );
846
+				do_action('getpaid_before_delete_item', new WPInv_Item($post_id));
847 847
 				break;
848 848
 
849 849
 			case 'wpi_payment_form':
850
-				do_action( 'getpaid_before_delete_payment_form', new GetPaid_Payment_Form( $post_id ) );
850
+				do_action('getpaid_before_delete_payment_form', new GetPaid_Payment_Form($post_id));
851 851
 				break;
852 852
 
853 853
 			case 'wpi_discount':
854
-				do_action( 'getpaid_before_delete_discount', new WPInv_Discount( $post_id ) );
854
+				do_action('getpaid_before_delete_discount', new WPInv_Discount($post_id));
855 855
 				break;
856 856
 
857 857
 			case 'wpi_invoice':
858
-				$invoice = new WPInv_Invoice( $post_id );
859
-				do_action( 'getpaid_before_delete_invoice', $invoice );
860
-				$invoice->get_data_store()->delete_items( $invoice );
861
-				$invoice->get_data_store()->delete_special_fields( $invoice );
858
+				$invoice = new WPInv_Invoice($post_id);
859
+				do_action('getpaid_before_delete_invoice', $invoice);
860
+				$invoice->get_data_store()->delete_items($invoice);
861
+				$invoice->get_data_store()->delete_special_fields($invoice);
862 862
 				break;
863 863
 		}
864 864
 	}
@@ -871,28 +871,28 @@  discard block
 block discarded – undo
871 871
      *
872 872
      * @return mixed
873 873
      */
874
-    public static function add_display_post_states( $post_states, $post ) {
874
+    public static function add_display_post_states($post_states, $post) {
875 875
 
876
-        if ( wpinv_get_option( 'success_page', 0 ) == $post->ID ) {
877
-            $post_states['getpaid_success_page'] = __( 'GetPaid Receipt Page', 'invoicing' );
876
+        if (wpinv_get_option('success_page', 0) == $post->ID) {
877
+            $post_states['getpaid_success_page'] = __('GetPaid Receipt Page', 'invoicing');
878 878
         }
879 879
 
880
-		foreach ( getpaid_get_invoice_post_types() as $post_type => $label ) {
880
+		foreach (getpaid_get_invoice_post_types() as $post_type => $label) {
881 881
 
882
-			if ( wpinv_get_option( "{$post_type}_history_page", 0 ) == $post->ID ) {
883
-				$post_states[ "getpaid_{$post_type}_history_page" ] = sprintf(
884
-					__( 'GetPaid %s History Page', 'invoicing' ),
882
+			if (wpinv_get_option("{$post_type}_history_page", 0) == $post->ID) {
883
+				$post_states["getpaid_{$post_type}_history_page"] = sprintf(
884
+					__('GetPaid %s History Page', 'invoicing'),
885 885
 					$label
886 886
 				);
887 887
 			}
888 888
 }
889 889
 
890
-		if ( wpinv_get_option( 'invoice_subscription_page', 0 ) == $post->ID ) {
891
-            $post_states['getpaid_invoice_subscription_page'] = __( 'GetPaid Subscription Page', 'invoicing' );
890
+		if (wpinv_get_option('invoice_subscription_page', 0) == $post->ID) {
891
+            $post_states['getpaid_invoice_subscription_page'] = __('GetPaid Subscription Page', 'invoicing');
892 892
         }
893 893
 
894
-		if ( wpinv_get_option( 'checkout_page', 0 ) == $post->ID ) {
895
-            $post_states['getpaid_checkout_page'] = __( 'GetPaid Checkout Page', 'invoicing' );
894
+		if (wpinv_get_option('checkout_page', 0) == $post->ID) {
895
+            $post_states['getpaid_checkout_page'] = __('GetPaid Checkout Page', 'invoicing');
896 896
         }
897 897
 
898 898
         return $post_states;
Please login to merge, or discard this patch.
includes/wpinv-item-functions.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -57,21 +57,21 @@  discard block
 block discarded – undo
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
62
-			'page'       => 1,
63
-			'exclude'    => array(),
64
-			'orderby'    => 'date',
65
-			'order'      => 'DESC',
66
-			'type'       => wpinv_item_types(),
67
-			'meta_query' => array(
60
+            'status'     => array( 'publish' ),
61
+            'limit'      => get_option( 'posts_per_page' ),
62
+            'page'       => 1,
63
+            'exclude'    => array(),
64
+            'orderby'    => 'date',
65
+            'order'      => 'DESC',
66
+            'type'       => wpinv_item_types(),
67
+            'meta_query' => array(
68 68
                 array(
69 69
                     'key'     => '_wpinv_one_time',
70 70
                     'compare' => 'NOT EXISTS',
71 71
                 ),
72 72
             ),
73
-			'return'     => 'objects',
74
-			'paginate'   => false,
73
+            'return'     => 'objects',
74
+            'paginate'   => false,
75 75
         )
76 76
     );
77 77
 
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 
212 212
 function wpinv_get_item_types() {
213 213
     $item_types = array(
214
-		'custom' => __( 'Standard', 'invoicing' ),
215
-		'fee'    => __( 'Fee', 'invoicing' ),
216
-	);
214
+        'custom' => __( 'Standard', 'invoicing' ),
215
+        'fee'    => __( 'Fee', 'invoicing' ),
216
+    );
217 217
     return apply_filters( 'wpinv_get_item_types', $item_types );
218 218
 }
219 219
 
@@ -255,16 +255,16 @@  discard block
 block discarded – undo
255 255
     $args = array();
256 256
     if ( $post_ids ) {
257 257
         $args = array(
258
-			'fields' => 'ids',
259
-		);
258
+            'fields' => 'ids',
259
+        );
260 260
     }
261 261
 
262 262
     $args = array_merge(
263 263
         $args,
264 264
         array(
265 265
             'post_type'  => 'wpi_item',
266
-			'orderby'    => 'rand',
267
-			'post_count' => $num,
266
+            'orderby'    => 'rand',
267
+            'post_count' => $num,
268 268
             'meta_query' => array(
269 269
                 array(
270 270
                     'key'     => '_wpinv_one_time',
@@ -439,10 +439,10 @@  discard block
 block discarded – undo
439 439
     $bill_times_less = $bill_times - 1;
440 440
 
441 441
     if ( ! empty( $bill_times ) ) {
442
-		$bill_times = $item->get_recurring_interval() * $bill_times;
442
+        $bill_times = $item->get_recurring_interval() * $bill_times;
443 443
         $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
444
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
445
-	}
444
+        $bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
445
+    }
446 446
 
447 447
     if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
448 448
         $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
@@ -587,19 +587,19 @@  discard block
 block discarded – undo
587 587
  * @return bool Whether the item type supports the given feature.
588 588
  */
589 589
 function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) {
590
-	$supports = false;
590
+    $supports = false;
591 591
 
592
-	if ( ! is_scalar( $item_type ) ) {
593
-		return $supports;
594
-	}
592
+    if ( ! is_scalar( $item_type ) ) {
593
+        return $supports;
594
+    }
595 595
 
596
-	switch ( $feature ) {
597
-		case 'buy_now':
598
-			if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) {
599
-				$supports = true;
600
-			}
601
-			break;
602
-	}
596
+    switch ( $feature ) {
597
+        case 'buy_now':
598
+            if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) {
599
+                $supports = true;
600
+            }
601
+            break;
602
+    }
603 603
 
604
-	return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID );
604
+    return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID );
605 605
 }
606 606
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +136 added lines, -136 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves an item by it's ID.
@@ -14,9 +14,9 @@  discard block
 block discarded – undo
14 14
  * @param int the item ID to retrieve.
15 15
  * @return WPInv_Item|false
16 16
  */
17
-function wpinv_get_item_by_id( $id ) {
18
-    $item = wpinv_get_item( $id );
19
-    return empty( $item ) || $id != $item->get_id() ? false : $item;
17
+function wpinv_get_item_by_id($id) {
18
+    $item = wpinv_get_item($id);
19
+    return empty($item) || $id != $item->get_id() ? false : $item;
20 20
 }
21 21
 
22 22
 /**
@@ -24,14 +24,14 @@  discard block
 block discarded – undo
24 24
  *
25 25
  * @return WPInv_Item|false
26 26
  */
27
-function wpinv_get_item_by( $field = '', $value = '', $type = '' ) {
27
+function wpinv_get_item_by($field = '', $value = '', $type = '') {
28 28
 
29
-    if ( 'id' === strtolower( $field ) ) {
30
-        return wpinv_get_item_by_id( $value );
29
+    if ('id' === strtolower($field)) {
30
+        return wpinv_get_item_by_id($value);
31 31
     }
32 32
 
33
-    $id = WPInv_Item::get_item_id_by_field( $value, strtolower( $field ), $type );
34
-    return empty( $id ) ? false : wpinv_get_item( $id );
33
+    $id = WPInv_Item::get_item_id_by_field($value, strtolower($field), $type);
34
+    return empty($id) ? false : wpinv_get_item($id);
35 35
 
36 36
 }
37 37
 
@@ -41,24 +41,24 @@  discard block
 block discarded – undo
41 41
  * @param int|WPInv_Item the item to retrieve.
42 42
  * @return WPInv_Item|false
43 43
  */
44
-function wpinv_get_item( $item = 0 ) {
44
+function wpinv_get_item($item = 0) {
45 45
 
46
-    if ( empty( $item ) ) {
46
+    if (empty($item)) {
47 47
         return false;
48 48
     }
49 49
 
50
-    $item = new WPInv_Item( $item );
50
+    $item = new WPInv_Item($item);
51 51
     return $item->exists() ? $item : false;
52 52
 
53 53
 }
54 54
 
55
-function wpinv_get_all_items( $args = array() ) {
55
+function wpinv_get_all_items($args = array()) {
56 56
 
57 57
     $args = wp_parse_args(
58 58
         $args,
59 59
         array(
60
-			'status'     => array( 'publish' ),
61
-			'limit'      => get_option( 'posts_per_page' ),
60
+			'status'     => array('publish'),
61
+			'limit'      => get_option('posts_per_page'),
62 62
 			'page'       => 1,
63 63
 			'exclude'    => array(),
64 64
 			'orderby'    => 'date',
@@ -83,44 +83,44 @@  discard block
 block discarded – undo
83 83
         'fields'         => 'ids',
84 84
         'orderby'        => $args['orderby'],
85 85
         'order'          => $args['order'],
86
-        'paged'          => absint( $args['page'] ),
86
+        'paged'          => absint($args['page']),
87 87
     );
88 88
 
89
-    if ( ! empty( $args['exclude'] ) ) {
90
-        $wp_query_args['post__not_in'] = array_map( 'absint', $args['exclude'] );
89
+    if (!empty($args['exclude'])) {
90
+        $wp_query_args['post__not_in'] = array_map('absint', $args['exclude']);
91 91
     }
92 92
 
93
-    if ( ! $args['paginate'] ) {
93
+    if (!$args['paginate']) {
94 94
         $wp_query_args['no_found_rows'] = true;
95 95
     }
96 96
 
97
-    if ( ! empty( $args['search'] ) ) {
97
+    if (!empty($args['search'])) {
98 98
         $wp_query_args['s'] = $args['search'];
99 99
     }
100 100
 
101
-    if ( ! empty( $args['type'] ) && $args['type'] !== wpinv_item_types() ) {
102
-        $types = wpinv_parse_list( $args['type'] );
101
+    if (!empty($args['type']) && $args['type'] !== wpinv_item_types()) {
102
+        $types = wpinv_parse_list($args['type']);
103 103
         $wp_query_args['meta_query'][] = array(
104 104
             'key'     => '_wpinv_type',
105
-            'value'   => implode( ',', $types ),
105
+            'value'   => implode(',', $types),
106 106
             'compare' => 'IN',
107 107
         );
108 108
     }
109 109
 
110
-    $wp_query_args = apply_filters( 'wpinv_get_items_args', $wp_query_args, $args );
110
+    $wp_query_args = apply_filters('wpinv_get_items_args', $wp_query_args, $args);
111 111
 
112 112
     // Get results.
113
-    $items = new WP_Query( $wp_query_args );
113
+    $items = new WP_Query($wp_query_args);
114 114
 
115
-    if ( 'objects' === $args['return'] ) {
116
-        $return = array_map( 'wpinv_get_item_by_id', $items->posts );
117
-    } elseif ( 'self' === $args['return'] ) {
115
+    if ('objects' === $args['return']) {
116
+        $return = array_map('wpinv_get_item_by_id', $items->posts);
117
+    } elseif ('self' === $args['return']) {
118 118
         return $items;
119 119
     } else {
120 120
         $return = $items->posts;
121 121
     }
122 122
 
123
-    if ( $args['paginate'] ) {
123
+    if ($args['paginate']) {
124 124
         return (object) array(
125 125
             'items'         => $return,
126 126
             'total'         => $items->found_posts,
@@ -132,12 +132,12 @@  discard block
 block discarded – undo
132 132
 
133 133
 }
134 134
 
135
-function wpinv_is_free_item( $item_id = 0 ) {
136
-    if ( empty( $item_id ) ) {
135
+function wpinv_is_free_item($item_id = 0) {
136
+    if (empty($item_id)) {
137 137
         return false;
138 138
     }
139 139
 
140
-    $item = new WPInv_Item( $item_id );
140
+    $item = new WPInv_Item($item_id);
141 141
 
142 142
     return $item->is_free();
143 143
 }
@@ -147,21 +147,21 @@  discard block
 block discarded – undo
147 147
  *
148 148
  * @param WP_Post|WPInv_Item|Int $item The item to check for.
149 149
  */
150
-function wpinv_item_is_editable( $item = 0 ) {
150
+function wpinv_item_is_editable($item = 0) {
151 151
 
152 152
     // Fetch the item.
153
-    $item = new WPInv_Item( $item );
153
+    $item = new WPInv_Item($item);
154 154
 
155 155
     // Check if it is editable.
156 156
     return $item->is_editable();
157 157
 }
158 158
 
159
-function wpinv_get_item_price( $item_id = 0 ) {
160
-    if ( empty( $item_id ) ) {
159
+function wpinv_get_item_price($item_id = 0) {
160
+    if (empty($item_id)) {
161 161
         return false;
162 162
     }
163 163
 
164
-    $item = new WPInv_Item( $item_id );
164
+    $item = new WPInv_Item($item_id);
165 165
 
166 166
     return $item->get_price();
167 167
 }
@@ -171,89 +171,89 @@  discard block
 block discarded – undo
171 171
  *
172 172
  * @param WPInv_Item|int $item
173 173
  */
174
-function wpinv_is_recurring_item( $item = 0 ) {
175
-    $item = new WPInv_Item( $item );
174
+function wpinv_is_recurring_item($item = 0) {
175
+    $item = new WPInv_Item($item);
176 176
     return $item->is_recurring();
177 177
 }
178 178
 
179
-function wpinv_item_price( $item_id = 0 ) {
180
-    if ( empty( $item_id ) ) {
179
+function wpinv_item_price($item_id = 0) {
180
+    if (empty($item_id)) {
181 181
         return false;
182 182
     }
183 183
 
184
-    $price = wpinv_get_item_price( $item_id );
185
-    $price = wpinv_price( $price );
184
+    $price = wpinv_get_item_price($item_id);
185
+    $price = wpinv_price($price);
186 186
 
187
-    return apply_filters( 'wpinv_item_price', $price, $item_id );
187
+    return apply_filters('wpinv_item_price', $price, $item_id);
188 188
 }
189 189
 
190
-function wpinv_get_item_final_price( $item_id = 0, $amount_override = null ) {
191
-    if ( is_null( $amount_override ) ) {
192
-        $original_price = get_post_meta( $item_id, '_wpinv_price', true );
190
+function wpinv_get_item_final_price($item_id = 0, $amount_override = null) {
191
+    if (is_null($amount_override)) {
192
+        $original_price = get_post_meta($item_id, '_wpinv_price', true);
193 193
     } else {
194 194
         $original_price = $amount_override;
195 195
     }
196 196
 
197 197
     $price = $original_price;
198 198
 
199
-    return apply_filters( 'wpinv_get_item_final_price', $price, $item_id );
199
+    return apply_filters('wpinv_get_item_final_price', $price, $item_id);
200 200
 }
201 201
 
202
-function wpinv_item_custom_singular_name( $item_id ) {
203
-    if ( empty( $item_id ) ) {
202
+function wpinv_item_custom_singular_name($item_id) {
203
+    if (empty($item_id)) {
204 204
         return false;
205 205
     }
206 206
 
207
-    $item = new WPInv_Item( $item_id );
207
+    $item = new WPInv_Item($item_id);
208 208
 
209 209
     return $item->get_custom_singular_name();
210 210
 }
211 211
 
212 212
 function wpinv_get_item_types() {
213 213
     $item_types = array(
214
-		'custom' => __( 'Standard', 'invoicing' ),
215
-		'fee'    => __( 'Fee', 'invoicing' ),
214
+		'custom' => __('Standard', 'invoicing'),
215
+		'fee'    => __('Fee', 'invoicing'),
216 216
 	);
217
-    return apply_filters( 'wpinv_get_item_types', $item_types );
217
+    return apply_filters('wpinv_get_item_types', $item_types);
218 218
 }
219 219
 
220 220
 function wpinv_item_types() {
221 221
     $item_types = wpinv_get_item_types();
222 222
 
223
-    return ( ! empty( $item_types ) ? array_keys( $item_types ) : array() );
223
+    return (!empty($item_types) ? array_keys($item_types) : array());
224 224
 }
225 225
 
226
-function wpinv_get_item_type( $item_id ) {
227
-    if ( empty( $item_id ) ) {
226
+function wpinv_get_item_type($item_id) {
227
+    if (empty($item_id)) {
228 228
         return false;
229 229
     }
230 230
 
231
-    $item = new WPInv_Item( $item_id );
231
+    $item = new WPInv_Item($item_id);
232 232
 
233 233
     return $item->get_type();
234 234
 }
235 235
 
236
-function wpinv_item_type( $item_id ) {
236
+function wpinv_item_type($item_id) {
237 237
     $item_types = wpinv_get_item_types();
238 238
 
239
-    $item_type = wpinv_get_item_type( $item_id );
239
+    $item_type = wpinv_get_item_type($item_id);
240 240
 
241
-    if ( empty( $item_type ) ) {
241
+    if (empty($item_type)) {
242 242
         $item_type = '-';
243 243
     }
244 244
 
245
-    $item_type = isset( $item_types[ $item_type ] ) ? $item_types[ $item_type ] : __( $item_type, 'invoicing' );
245
+    $item_type = isset($item_types[$item_type]) ? $item_types[$item_type] : __($item_type, 'invoicing');
246 246
 
247
-    return apply_filters( 'wpinv_item_type', $item_type, $item_id );
247
+    return apply_filters('wpinv_item_type', $item_type, $item_id);
248 248
 }
249 249
 
250
-function wpinv_get_random_item( $post_ids = true ) {
251
-    wpinv_get_random_items( 1, $post_ids );
250
+function wpinv_get_random_item($post_ids = true) {
251
+    wpinv_get_random_items(1, $post_ids);
252 252
 }
253 253
 
254
-function wpinv_get_random_items( $num = 3, $post_ids = true ) {
254
+function wpinv_get_random_items($num = 3, $post_ids = true) {
255 255
     $args = array();
256
-    if ( $post_ids ) {
256
+    if ($post_ids) {
257 257
         $args = array(
258 258
 			'fields' => 'ids',
259 259
 		);
@@ -274,9 +274,9 @@  discard block
 block discarded – undo
274 274
         )
275 275
     );
276 276
 
277
-    $args  = apply_filters( 'wpinv_get_random_items', $args );
277
+    $args = apply_filters('wpinv_get_random_items', $args);
278 278
 
279
-    return get_posts( $args );
279
+    return get_posts($args);
280 280
 }
281 281
 
282 282
 /**
@@ -285,13 +285,13 @@  discard block
 block discarded – undo
285 285
  * @param WPInv_Item|int $item
286 286
  * @param bool $html
287 287
  */
288
-function wpinv_get_item_suffix( $item, $html = true ) {
288
+function wpinv_get_item_suffix($item, $html = true) {
289 289
 
290
-    $item   = new WPInv_Item( $item );
291
-    $suffix = $item->is_recurring() ? ' ' . __( '(r)', 'invoicing' ) : '';
292
-    $suffix = $html ? $suffix : wp_strip_all_tags( $suffix );
290
+    $item   = new WPInv_Item($item);
291
+    $suffix = $item->is_recurring() ? ' ' . __('(r)', 'invoicing') : '';
292
+    $suffix = $html ? $suffix : wp_strip_all_tags($suffix);
293 293
 
294
-    return apply_filters( 'wpinv_get_item_suffix', $suffix, $item, $html );
294
+    return apply_filters('wpinv_get_item_suffix', $suffix, $item, $html);
295 295
 }
296 296
 
297 297
 /**
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
  * @param WPInv_Item|int $item
301 301
  * @param bool $force_delete
302 302
  */
303
-function wpinv_remove_item( $item = 0, $force_delete = false ) {
304
-    $item = new WPInv_Item( $item );
305
-    $item->delete( $force_delete );
303
+function wpinv_remove_item($item = 0, $force_delete = false) {
304
+    $item = new WPInv_Item($item);
305
+    $item->delete($force_delete);
306 306
 }
307 307
 
308 308
 /**
@@ -341,44 +341,44 @@  discard block
 block discarded – undo
341 341
  * @param bool $wp_error whether or not to return a WP_Error on failure.
342 342
  * @return bool|WP_Error|WPInv_Item
343 343
  */
344
-function wpinv_create_item( $args = array(), $wp_error = false ) {
344
+function wpinv_create_item($args = array(), $wp_error = false) {
345 345
 
346 346
     // Prepare the item.
347
-    if ( ! empty( $args['custom_id'] ) && empty( $args['ID'] ) ) {
348
-        $type = empty( $args['type'] ) ? 'custom' : $args['type'];
349
-        $item = wpinv_get_item_by( 'custom_id', $args['custom_id'], $type );
347
+    if (!empty($args['custom_id']) && empty($args['ID'])) {
348
+        $type = empty($args['type']) ? 'custom' : $args['type'];
349
+        $item = wpinv_get_item_by('custom_id', $args['custom_id'], $type);
350 350
 
351
-        if ( ! empty( $item ) ) {
351
+        if (!empty($item)) {
352 352
             $args['ID'] = $item->get_id();
353 353
         }
354 354
     }
355 355
 
356 356
     // Do we have an item?
357
-    if ( ! empty( $args['ID'] ) ) {
358
-        $item = new WPInv_Item( $args['ID'] );
357
+    if (!empty($args['ID'])) {
358
+        $item = new WPInv_Item($args['ID']);
359 359
     } else {
360 360
         $item = new WPInv_Item();
361 361
     }
362 362
 
363 363
     // Do we have an error?
364
-    if ( ! empty( $item->last_error ) ) {
365
-        return $wp_error ? new WP_Error( 'invalid_item', $item->last_error ) : false;
364
+    if (!empty($item->last_error)) {
365
+        return $wp_error ? new WP_Error('invalid_item', $item->last_error) : false;
366 366
     }
367 367
 
368 368
     // Update item props.
369
-    $item->set_props( $args );
369
+    $item->set_props($args);
370 370
 
371 371
     // Save the item.
372 372
     $item->save();
373 373
 
374 374
     // Do we have an error?
375
-    if ( ! empty( $item->last_error ) ) {
376
-        return $wp_error ? new WP_Error( 'not_saved', $item->last_error ) : false;
375
+    if (!empty($item->last_error)) {
376
+        return $wp_error ? new WP_Error('not_saved', $item->last_error) : false;
377 377
     }
378 378
 
379 379
     // Was the item saved?
380
-    if ( ! $item->get_id() ) {
381
-        return $wp_error ? new WP_Error( 'not_saved', __( 'An error occured while saving the item', 'invoicing' ) ) : false;
380
+    if (!$item->get_id()) {
381
+        return $wp_error ? new WP_Error('not_saved', __('An error occured while saving the item', 'invoicing')) : false;
382 382
     }
383 383
 
384 384
     return $item;
@@ -390,14 +390,14 @@  discard block
 block discarded – undo
390 390
  *
391 391
  * @see wpinv_create_item()
392 392
  */
393
-function wpinv_update_item( $args = array(), $wp_error = false ) {
394
-    return wpinv_create_item( $args, $wp_error );
393
+function wpinv_update_item($args = array(), $wp_error = false) {
394
+    return wpinv_create_item($args, $wp_error);
395 395
 }
396 396
 
397 397
 /**
398 398
  * Sanitizes a recurring period
399 399
  */
400
-function getpaid_sanitize_recurring_period( $period, $full = false ) {
400
+function getpaid_sanitize_recurring_period($period, $full = false) {
401 401
 
402 402
     $periods = array(
403 403
         'D' => 'day',
@@ -406,16 +406,16 @@  discard block
 block discarded – undo
406 406
         'Y' => 'year',
407 407
     );
408 408
 
409
-    if ( ! isset( $periods[ $period ] ) ) {
409
+    if (!isset($periods[$period])) {
410 410
         $period = 'D';
411 411
     }
412 412
 
413
-    return $full ? $periods[ $period ] : $period;
413
+    return $full ? $periods[$period] : $period;
414 414
 
415 415
 }
416 416
 
417
-function wpinv_item_max_buyable_quantity( $item_id ) {
418
-    return apply_filters( 'wpinv_item_max_buyable_quantity', 5, $item_id );
417
+function wpinv_item_max_buyable_quantity($item_id) {
418
+    return apply_filters('wpinv_item_max_buyable_quantity', 5, $item_id);
419 419
 }
420 420
 
421 421
 /**
@@ -423,47 +423,47 @@  discard block
 block discarded – undo
423 423
  *
424 424
  * @param WPInv_Item|GetPaid_Form_Item $item
425 425
  */
426
-function getpaid_item_recurring_price_help_text( $item, $currency = '', $_initial_price = false, $_recurring_price = false ) {
426
+function getpaid_item_recurring_price_help_text($item, $currency = '', $_initial_price = false, $_recurring_price = false) {
427 427
 
428 428
     // Abort if it is not recurring.
429
-    if ( ! $item->is_recurring() ) {
429
+    if (!$item->is_recurring()) {
430 430
         return '';
431 431
     }
432 432
 
433
-    $initial_price   = false === $_initial_price ? wpinv_price( $item->get_initial_price(), $currency ) : $_initial_price;
434
-    $recurring_price = false === $_recurring_price ? wpinv_price( $item->get_recurring_price(), $currency ) : $_recurring_price;
435
-    $period          = getpaid_get_subscription_period_label( $item->get_recurring_period(), $item->get_recurring_interval(), '' );
433
+    $initial_price   = false === $_initial_price ? wpinv_price($item->get_initial_price(), $currency) : $_initial_price;
434
+    $recurring_price = false === $_recurring_price ? wpinv_price($item->get_recurring_price(), $currency) : $_recurring_price;
435
+    $period          = getpaid_get_subscription_period_label($item->get_recurring_period(), $item->get_recurring_interval(), '');
436 436
     $initial_class   = 'getpaid-item-initial-price';
437 437
     $recurring_class = 'getpaid-item-recurring-price';
438 438
     $bill_times      = $item->get_recurring_limit();
439 439
     $bill_times_less = $bill_times - 1;
440 440
 
441
-    if ( ! empty( $bill_times ) ) {
441
+    if (!empty($bill_times)) {
442 442
 		$bill_times = $item->get_recurring_interval() * $bill_times;
443
-        $bill_times_less = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times - $item->get_recurring_interval() );
444
-		$bill_times = getpaid_get_subscription_period_label( $item->get_recurring_period(), $bill_times );
443
+        $bill_times_less = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times - $item->get_recurring_interval());
444
+		$bill_times = getpaid_get_subscription_period_label($item->get_recurring_period(), $bill_times);
445 445
 	}
446 446
 
447
-    if ( $item instanceof GetPaid_Form_Item && false === $_initial_price ) {
448
-        $initial_price   = wpinv_price( $item->get_sub_total(), $currency );
449
-        $recurring_price = wpinv_price( $item->get_recurring_sub_total(), $currency );
447
+    if ($item instanceof GetPaid_Form_Item && false === $_initial_price) {
448
+        $initial_price   = wpinv_price($item->get_sub_total(), $currency);
449
+        $recurring_price = wpinv_price($item->get_recurring_sub_total(), $currency);
450 450
     }
451 451
 
452
-    if ( wpinv_price( 0, $currency ) == $initial_price && wpinv_price( 0, $currency ) == $recurring_price ) {
453
-        return __( 'Free forever', 'invoicing' );
452
+    if (wpinv_price(0, $currency) == $initial_price && wpinv_price(0, $currency) == $recurring_price) {
453
+        return __('Free forever', 'invoicing');
454 454
     }
455 455
 
456 456
     // For free trial items.
457
-    if ( $item->has_free_trial() ) {
458
-        $trial_period = getpaid_get_subscription_period_label( $item->get_trial_period(), $item->get_trial_interval() );
457
+    if ($item->has_free_trial()) {
458
+        $trial_period = getpaid_get_subscription_period_label($item->get_trial_period(), $item->get_trial_interval());
459 459
 
460
-        if ( wpinv_price( 0, $currency ) == $initial_price ) {
460
+        if (wpinv_price(0, $currency) == $initial_price) {
461 461
 
462
-            if ( empty( $bill_times ) ) {
462
+            if (empty($bill_times)) {
463 463
 
464 464
                 return sprintf(
465 465
                     // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period
466
-                    _x( 'Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing' ),
466
+                    _x('Free for %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year)', 'invoicing'),
467 467
                     "<span class='getpaid-item-trial-period'>$trial_period</span>",
468 468
                     "<span class='$recurring_class'>$recurring_price</span>",
469 469
                     "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
 
474 474
             return sprintf(
475 475
                 // translators: $1: is the trial period, $2: is the recurring price, $3: is the susbcription period, $4: is the bill times
476
-                _x( 'Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing' ),
476
+                _x('Free for %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Free for 1 month then $120 / year for 4 years)', 'invoicing'),
477 477
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
478 478
                 "<span class='$recurring_class'>$recurring_price</span>",
479 479
                 "<span class='getpaid-item-recurring-period'>$period</span>",
@@ -482,11 +482,11 @@  discard block
 block discarded – undo
482 482
 
483 483
         }
484 484
 
485
-        if ( empty( $bill_times ) ) {
485
+        if (empty($bill_times)) {
486 486
 
487 487
             return sprintf(
488 488
                 // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period
489
-                _x( '%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing' ),
489
+                _x('%1$s for %2$s then %3$s / %4$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year)', 'invoicing'),
490 490
                 "<span class='$initial_class'>$initial_price</span>",
491 491
                 "<span class='getpaid-item-trial-period'>$trial_period</span>",
492 492
                 "<span class='$recurring_class'>$recurring_price</span>",
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 
498 498
         return sprintf(
499 499
             // translators: $1: is the initial price, $2: is the trial period, $3: is the recurring price, $4: is the susbcription period, $4: is the susbcription bill times
500
-            _x( '%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing' ),
500
+            _x('%1$s for %2$s then %3$s / %4$s for %5$s', 'Item subscription amount. (e.g.: $7 for 1 month then $120 / year for 5 years)', 'invoicing'),
501 501
             "<span class='$initial_class'>$initial_price</span>",
502 502
             "<span class='getpaid-item-trial-period'>$trial_period</span>",
503 503
             "<span class='$recurring_class'>$recurring_price</span>",
@@ -507,13 +507,13 @@  discard block
 block discarded – undo
507 507
 
508 508
     }
509 509
 
510
-    if ( $initial_price == $recurring_price ) {
510
+    if ($initial_price == $recurring_price) {
511 511
 
512
-        if ( empty( $bill_times ) ) {
512
+        if (empty($bill_times)) {
513 513
 
514 514
             return sprintf(
515 515
                 // translators: $1: is the recurring price, $2: is the susbcription period
516
-                _x( '%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing' ),
516
+                _x('%1$s / %2$s', 'Item subscription amount. (e.g.: $120 / year)', 'invoicing'),
517 517
                 "<span class='$recurring_class'>$recurring_price</span>",
518 518
                 "<span class='getpaid-item-recurring-period'>$period</span>"
519 519
             );
@@ -522,7 +522,7 @@  discard block
 block discarded – undo
522 522
 
523 523
         return sprintf(
524 524
             // translators: $1: is the recurring price, $2: is the susbcription period, $3: is the susbcription bill times
525
-            _x( '%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
525
+            _x('%1$s / %2$s for %3$s', 'Item subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
526 526
             "<span class='$recurring_class'>$recurring_price</span>",
527 527
             "<span class='getpaid-item-recurring-period'>$period</span>",
528 528
             "<span class='getpaid-item-recurring-bill-times'>$bill_times</span>"
@@ -530,13 +530,13 @@  discard block
 block discarded – undo
530 530
 
531 531
     }
532 532
 
533
-    if ( $initial_price == wpinv_price( 0, $currency ) ) {
533
+    if ($initial_price == wpinv_price(0, $currency)) {
534 534
 
535
-        if ( empty( $bill_times ) ) {
535
+        if (empty($bill_times)) {
536 536
 
537 537
             return sprintf(
538 538
                 // translators: $1: is the recurring period, $2: is the recurring price
539
-                _x( 'Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing' ),
539
+                _x('Free for %1$s then %2$s / %1$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months)', 'invoicing'),
540 540
                 "<span class='getpaid-item-recurring-period'>$period</span>",
541 541
                 "<span class='$recurring_class'>$recurring_price</span>"
542 542
             );
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 
546 546
         return sprintf(
547 547
             // translators: $1: is the recurring period, $2: is the recurring price, $3: is the bill times
548
-            _x( 'Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing' ),
548
+            _x('Free for %1$s then %2$s / %1$s for %3$s', 'Item subscription amount. (e.g.: Free for 3 months then $7 / 3 months for 12 months)', 'invoicing'),
549 549
             "<span class='getpaid-item-recurring-period'>$period</span>",
550 550
             "<span class='$recurring_class'>$recurring_price</span>",
551 551
             "<span class='getpaid-item-recurring-bill-times'>$bill_times_less</span>"
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
 
554 554
     }
555 555
 
556
-    if ( empty( $bill_times ) ) {
556
+    if (empty($bill_times)) {
557 557
 
558 558
         return sprintf(
559 559
             // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period
560
-            _x( 'Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing' ),
560
+            _x('Initial payment of %1$s then %2$s / %3$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year)', 'invoicing'),
561 561
             "<span class='$initial_class'>$initial_price</span>",
562 562
             "<span class='$recurring_class'>$recurring_price</span>",
563 563
             "<span class='getpaid-item-recurring-period'>$period</span>"
@@ -567,7 +567,7 @@  discard block
 block discarded – undo
567 567
 
568 568
     return sprintf(
569 569
         // translators: $1: is the initial price, $2: is the recurring price, $3: is the susbcription period, $4: is the susbcription bill times
570
-        _x( 'Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing' ),
570
+        _x('Initial payment of %1$s then %2$s / %3$s for %4$s', 'Item subscription amount. (e.g.: Initial payment of $7 then $120 / year for 4 years)', 'invoicing'),
571 571
         "<span class='$initial_class'>$initial_price</span>",
572 572
         "<span class='$recurring_class'>$recurring_price</span>",
573 573
         "<span class='getpaid-item-recurring-period'>$period</span>",
@@ -586,20 +586,20 @@  discard block
 block discarded – undo
586 586
  * @param int    $item_ID   The item post ID. Optional.
587 587
  * @return bool Whether the item type supports the given feature.
588 588
  */
589
-function getpaid_item_type_supports( $item_type, $feature, $item_ID = 0 ) {
589
+function getpaid_item_type_supports($item_type, $feature, $item_ID = 0) {
590 590
 	$supports = false;
591 591
 
592
-	if ( ! is_scalar( $item_type ) ) {
592
+	if (!is_scalar($item_type)) {
593 593
 		return $supports;
594 594
 	}
595 595
 
596
-	switch ( $feature ) {
596
+	switch ($feature) {
597 597
 		case 'buy_now':
598
-			if ( '' === $item_type || 'fee' === $item_type || 'custom' === $item_type ) {
598
+			if ('' === $item_type || 'fee' === $item_type || 'custom' === $item_type) {
599 599
 				$supports = true;
600 600
 			}
601 601
 			break;
602 602
 	}
603 603
 
604
-	return apply_filters( 'getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID );
604
+	return apply_filters('getpaid_item_type_supports', $supports, $item_type, $feature, $item_ID);
605 605
 }
606 606
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/autoload.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
     if (!headers_sent()) {
7 7
         header('HTTP/1.1 500 Internal Server Error');
8 8
     }
9
-    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL;
9
+    $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running ' . PHP_VERSION . ', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.' . PHP_EOL;
10 10
     if (!ini_get('display_errors')) {
11 11
         if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') {
12 12
             fwrite(STDERR, $err);
Please login to merge, or discard this patch.
vendor/composer/InstalledVersions.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -327,11 +327,11 @@
 block discarded – undo
327 327
             foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) {
328 328
                 if (isset(self::$installedByVendor[$vendorDir])) {
329 329
                     $installed[] = self::$installedByVendor[$vendorDir];
330
-                } elseif (is_file($vendorDir.'/composer/installed.php')) {
330
+                } elseif (is_file($vendorDir . '/composer/installed.php')) {
331 331
                     /** @var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array<string, array{pretty_version?: string, version?: string, reference?: string|null, type?: string, install_path?: string, aliases?: string[], dev_requirement: bool, replaced?: string[], provided?: string[]}>} $required */
332
-                    $required = require $vendorDir.'/composer/installed.php';
332
+                    $required = require $vendorDir . '/composer/installed.php';
333 333
                     $installed[] = self::$installedByVendor[$vendorDir] = $required;
334
-                    if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
334
+                    if (null === self::$installed && strtr($vendorDir . '/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) {
335 335
                         self::$installed = $installed[count($installed) - 1];
336 336
                     }
337 337
                 }
Please login to merge, or discard this patch.
vendor/composer/autoload_real.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@
 block discarded – undo
34 34
         $loader->register(true);
35 35
 
36 36
         $filesToLoad = \Composer\Autoload\ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$files;
37
-        $requireFile = \Closure::bind(static function ($fileIdentifier, $file) {
37
+        $requireFile = \Closure::bind(static function($fileIdentifier, $file) {
38 38
             if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
39 39
                 $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true;
40 40
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-ayecode-ui/includes/inc/bs-conversion.php 3 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,10 +13,10 @@  discard block
 block discarded – undo
13 13
  *
14 14
  * @return array|mixed|string|string[]
15 15
  */
16
-function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) {
16
+function aui_bs_convert_sd_output($output, $instance = '', $args = '', $sd = '') {
17 17
 	global $aui_bs5;
18 18
 
19
-	if ( $aui_bs5 ) {
19
+	if ($aui_bs5) {
20 20
 		$convert = array(
21 21
 			'"ml-' => '"ms-',
22 22
 			'"mr-' => '"me-',
@@ -75,9 +75,9 @@  discard block
 block discarded – undo
75 75
 			'class="close"' => 'class="btn-close"',
76 76
 			'<span aria-hidden="true">&times;</span>' => '',
77 77
 		);
78
-		$output  = str_replace(
79
-			array_keys( $convert ),
80
-			array_values( $convert ),
78
+		$output = str_replace(
79
+			array_keys($convert),
80
+			array_values($convert),
81 81
 			$output
82 82
 		);
83 83
 	}
@@ -85,4 +85,4 @@  discard block
 block discarded – undo
85 85
 	return $output;
86 86
 }
87 87
 
88
-add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this
88
+add_filter('wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4); //$output, $instance, $args, $this
Please login to merge, or discard this patch.
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -14,76 +14,76 @@
 block discarded – undo
14 14
  * @return array|mixed|string|string[]
15 15
  */
16 16
 function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) {
17
-	global $aui_bs5;
17
+    global $aui_bs5;
18 18
 
19
-	if ( $aui_bs5 ) {
20
-		$convert = array(
21
-			'"ml-' => '"ms-',
22
-			'"mr-' => '"me-',
23
-			'"pl-' => '"ps-',
24
-			'"pr-' => '"pe-',
25
-			"'ml-" => "'ms-",
26
-			"'mr-" => "'me-",
27
-			"'pl-" => "'ps-",
28
-			"'pr-" => "'pe-",
29
-			' ml-' => ' ms-',
30
-			' mr-' => ' me-',
31
-			' pl-' => ' ps-',
32
-			' pr-' => ' pe-',
33
-			'.ml-' => '.ms-',
34
-			'.mr-' => '.me-',
35
-			'.pl-' => '.ps-',
36
-			'.pr-' => '.pe-',
37
-			' form-row' => ' row',
38
-			' embed-responsive-item' => '',
39
-			' embed-responsive' => ' ratio',
40
-			'-1by1'    => '-1x1',
41
-			'-4by3'    => '-4x3',
42
-			'-16by9'    => '-16x9',
43
-			'-21by9'    => '-21x9',
44
-			'geodir-lightbox-image' => 'aui-lightbox-image',
45
-			'geodir-lightbox-iframe' => 'aui-lightbox-iframe',
46
-			' badge-'   => ' text-bg-',
47
-			'form-group'   => 'mb-3',
48
-			'custom-select'   => 'form-select',
49
-			'float-left'   => 'float-start',
50
-			'float-right'   => 'float-end',
51
-			'text-left'    => 'text-start',
52
-			'text-sm-left'    => 'text-sm-start',
53
-			'text-md-left'    => 'text-md-start',
54
-			'text-lg-left'    => 'text-lg-start',
55
-			'text-right'    => 'text-end',
56
-			'text-sm-right'    => 'text-sm-end',
57
-			'text-md-right'    => 'text-md-end',
58
-			'text-lg-right'    => 'text-lg-end',
59
-			'border-right'    => 'border-end',
60
-			'border-left'    => 'border-start',
61
-			'font-weight-'  => 'fw-',
62
-			'btn-block'     => 'w-100',
63
-			'rounded-left'  => 'rounded-start',
64
-			'rounded-right'  => 'rounded-end',
65
-			'font-italic' => 'fst-italic',
19
+    if ( $aui_bs5 ) {
20
+        $convert = array(
21
+            '"ml-' => '"ms-',
22
+            '"mr-' => '"me-',
23
+            '"pl-' => '"ps-',
24
+            '"pr-' => '"pe-',
25
+            "'ml-" => "'ms-",
26
+            "'mr-" => "'me-",
27
+            "'pl-" => "'ps-",
28
+            "'pr-" => "'pe-",
29
+            ' ml-' => ' ms-',
30
+            ' mr-' => ' me-',
31
+            ' pl-' => ' ps-',
32
+            ' pr-' => ' pe-',
33
+            '.ml-' => '.ms-',
34
+            '.mr-' => '.me-',
35
+            '.pl-' => '.ps-',
36
+            '.pr-' => '.pe-',
37
+            ' form-row' => ' row',
38
+            ' embed-responsive-item' => '',
39
+            ' embed-responsive' => ' ratio',
40
+            '-1by1'    => '-1x1',
41
+            '-4by3'    => '-4x3',
42
+            '-16by9'    => '-16x9',
43
+            '-21by9'    => '-21x9',
44
+            'geodir-lightbox-image' => 'aui-lightbox-image',
45
+            'geodir-lightbox-iframe' => 'aui-lightbox-iframe',
46
+            ' badge-'   => ' text-bg-',
47
+            'form-group'   => 'mb-3',
48
+            'custom-select'   => 'form-select',
49
+            'float-left'   => 'float-start',
50
+            'float-right'   => 'float-end',
51
+            'text-left'    => 'text-start',
52
+            'text-sm-left'    => 'text-sm-start',
53
+            'text-md-left'    => 'text-md-start',
54
+            'text-lg-left'    => 'text-lg-start',
55
+            'text-right'    => 'text-end',
56
+            'text-sm-right'    => 'text-sm-end',
57
+            'text-md-right'    => 'text-md-end',
58
+            'text-lg-right'    => 'text-lg-end',
59
+            'border-right'    => 'border-end',
60
+            'border-left'    => 'border-start',
61
+            'font-weight-'  => 'fw-',
62
+            'btn-block'     => 'w-100',
63
+            'rounded-left'  => 'rounded-start',
64
+            'rounded-right'  => 'rounded-end',
65
+            'font-italic' => 'fst-italic',
66 66
 
67 67
 //			'custom-control custom-checkbox'    => 'form-check',
68
-			// data
69
-			' data-toggle=' => ' data-bs-toggle=',
70
-			'data-ride=' => 'data-bs-ride=',
71
-			'data-controlnav=' => 'data-bs-controlnav=',
72
-			'data-slide='   => 'data-bs-slide=',
73
-			'data-slide-to=' => 'data-bs-slide-to=',
74
-			'data-target='  => 'data-bs-target=',
75
-			'data-dismiss="modal"'  => 'data-bs-dismiss="modal"',
76
-			'class="close"' => 'class="btn-close"',
77
-			'<span aria-hidden="true">&times;</span>' => '',
78
-		);
79
-		$output  = str_replace(
80
-			array_keys( $convert ),
81
-			array_values( $convert ),
82
-			$output
83
-		);
84
-	}
68
+            // data
69
+            ' data-toggle=' => ' data-bs-toggle=',
70
+            'data-ride=' => 'data-bs-ride=',
71
+            'data-controlnav=' => 'data-bs-controlnav=',
72
+            'data-slide='   => 'data-bs-slide=',
73
+            'data-slide-to=' => 'data-bs-slide-to=',
74
+            'data-target='  => 'data-bs-target=',
75
+            'data-dismiss="modal"'  => 'data-bs-dismiss="modal"',
76
+            'class="close"' => 'class="btn-close"',
77
+            '<span aria-hidden="true">&times;</span>' => '',
78
+        );
79
+        $output  = str_replace(
80
+            array_keys( $convert ),
81
+            array_values( $convert ),
82
+            $output
83
+        );
84
+    }
85 85
 
86
-	return $output;
86
+    return $output;
87 87
 }
88 88
 
89 89
 add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this
Please login to merge, or discard this patch.
Switch Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php
1
+    <?php
2 2
 /**
3 3
  * Functionality to convert BS4 to BS5.
4 4
  */
@@ -13,77 +13,77 @@  discard block
 block discarded – undo
13 13
  *
14 14
  * @return array|mixed|string|string[]
15 15
  */
16
-function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) {
17
-	global $aui_bs5;
16
+    function aui_bs_convert_sd_output( $output, $instance = '', $args = '', $sd = '' ) {
17
+	    global $aui_bs5;
18 18
 
19
-	if ( $aui_bs5 ) {
20
-		$convert = array(
21
-			'"ml-' => '"ms-',
22
-			'"mr-' => '"me-',
23
-			'"pl-' => '"ps-',
24
-			'"pr-' => '"pe-',
25
-			"'ml-" => "'ms-",
26
-			"'mr-" => "'me-",
27
-			"'pl-" => "'ps-",
28
-			"'pr-" => "'pe-",
29
-			' ml-' => ' ms-',
30
-			' mr-' => ' me-',
31
-			' pl-' => ' ps-',
32
-			' pr-' => ' pe-',
33
-			'.ml-' => '.ms-',
34
-			'.mr-' => '.me-',
35
-			'.pl-' => '.ps-',
36
-			'.pr-' => '.pe-',
37
-			' form-row' => ' row',
38
-			' embed-responsive-item' => '',
39
-			' embed-responsive' => ' ratio',
40
-			'-1by1'    => '-1x1',
41
-			'-4by3'    => '-4x3',
42
-			'-16by9'    => '-16x9',
43
-			'-21by9'    => '-21x9',
44
-			'geodir-lightbox-image' => 'aui-lightbox-image',
45
-			'geodir-lightbox-iframe' => 'aui-lightbox-iframe',
46
-			' badge-'   => ' text-bg-',
47
-			'form-group'   => 'mb-3',
48
-			'custom-select'   => 'form-select',
49
-			'float-left'   => 'float-start',
50
-			'float-right'   => 'float-end',
51
-			'text-left'    => 'text-start',
52
-			'text-sm-left'    => 'text-sm-start',
53
-			'text-md-left'    => 'text-md-start',
54
-			'text-lg-left'    => 'text-lg-start',
55
-			'text-right'    => 'text-end',
56
-			'text-sm-right'    => 'text-sm-end',
57
-			'text-md-right'    => 'text-md-end',
58
-			'text-lg-right'    => 'text-lg-end',
59
-			'border-right'    => 'border-end',
60
-			'border-left'    => 'border-start',
61
-			'font-weight-'  => 'fw-',
62
-			'btn-block'     => 'w-100',
63
-			'rounded-left'  => 'rounded-start',
64
-			'rounded-right'  => 'rounded-end',
65
-			'font-italic' => 'fst-italic',
19
+	    if ( $aui_bs5 ) {
20
+		    $convert = array(
21
+			    '"ml-' => '"ms-',
22
+			    '"mr-' => '"me-',
23
+			    '"pl-' => '"ps-',
24
+			    '"pr-' => '"pe-',
25
+			    "'ml-" => "'ms-",
26
+			    "'mr-" => "'me-",
27
+			    "'pl-" => "'ps-",
28
+			    "'pr-" => "'pe-",
29
+			    ' ml-' => ' ms-',
30
+			    ' mr-' => ' me-',
31
+			    ' pl-' => ' ps-',
32
+			    ' pr-' => ' pe-',
33
+			    '.ml-' => '.ms-',
34
+			    '.mr-' => '.me-',
35
+			    '.pl-' => '.ps-',
36
+			    '.pr-' => '.pe-',
37
+			    ' form-row' => ' row',
38
+			    ' embed-responsive-item' => '',
39
+			    ' embed-responsive' => ' ratio',
40
+			    '-1by1'    => '-1x1',
41
+			    '-4by3'    => '-4x3',
42
+			    '-16by9'    => '-16x9',
43
+			    '-21by9'    => '-21x9',
44
+			    'geodir-lightbox-image' => 'aui-lightbox-image',
45
+			    'geodir-lightbox-iframe' => 'aui-lightbox-iframe',
46
+			    ' badge-'   => ' text-bg-',
47
+			    'form-group'   => 'mb-3',
48
+			    'custom-select'   => 'form-select',
49
+			    'float-left'   => 'float-start',
50
+			    'float-right'   => 'float-end',
51
+			    'text-left'    => 'text-start',
52
+			    'text-sm-left'    => 'text-sm-start',
53
+			    'text-md-left'    => 'text-md-start',
54
+			    'text-lg-left'    => 'text-lg-start',
55
+			    'text-right'    => 'text-end',
56
+			    'text-sm-right'    => 'text-sm-end',
57
+			    'text-md-right'    => 'text-md-end',
58
+			    'text-lg-right'    => 'text-lg-end',
59
+			    'border-right'    => 'border-end',
60
+			    'border-left'    => 'border-start',
61
+			    'font-weight-'  => 'fw-',
62
+			    'btn-block'     => 'w-100',
63
+			    'rounded-left'  => 'rounded-start',
64
+			    'rounded-right'  => 'rounded-end',
65
+			    'font-italic' => 'fst-italic',
66 66
 
67
-//			'custom-control custom-checkbox'    => 'form-check',
68
-			// data
69
-			' data-toggle=' => ' data-bs-toggle=',
70
-			'data-ride=' => 'data-bs-ride=',
71
-			'data-controlnav=' => 'data-bs-controlnav=',
72
-			'data-slide='   => 'data-bs-slide=',
73
-			'data-slide-to=' => 'data-bs-slide-to=',
74
-			'data-target='  => 'data-bs-target=',
75
-			'data-dismiss="modal"'  => 'data-bs-dismiss="modal"',
76
-			'class="close"' => 'class="btn-close"',
77
-			'<span aria-hidden="true">&times;</span>' => '',
78
-		);
79
-		$output  = str_replace(
80
-			array_keys( $convert ),
81
-			array_values( $convert ),
82
-			$output
83
-		);
84
-	}
67
+    //			'custom-control custom-checkbox'    => 'form-check',
68
+			    // data
69
+			    ' data-toggle=' => ' data-bs-toggle=',
70
+			    'data-ride=' => 'data-bs-ride=',
71
+			    'data-controlnav=' => 'data-bs-controlnav=',
72
+			    'data-slide='   => 'data-bs-slide=',
73
+			    'data-slide-to=' => 'data-bs-slide-to=',
74
+			    'data-target='  => 'data-bs-target=',
75
+			    'data-dismiss="modal"'  => 'data-bs-dismiss="modal"',
76
+			    'class="close"' => 'class="btn-close"',
77
+			    '<span aria-hidden="true">&times;</span>' => '',
78
+		    );
79
+		    $output  = str_replace(
80
+			    array_keys( $convert ),
81
+			    array_values( $convert ),
82
+			    $output
83
+		    );
84
+	    }
85 85
 
86
-	return $output;
86
+	    return $output;
87 87
 }
88 88
 
89
-add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this
89
+    add_filter( 'wp_super_duper_widget_output', 'aui_bs_convert_sd_output', 10, 4 ); //$output, $instance, $args, $this
Please login to merge, or discard this patch.