Passed
Pull Request — master (#792)
by Kiran
06:26
created
includes/admin/class-getpaid-admin-profile.php 1 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…', 'invoicing' ) ) + wpinv_get_country_list(),
75
+								'options'     => array('' => __('Select a country / region…', '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.
templates/invoice/billing-address.php 1 patch
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,10 +7,10 @@  discard block
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12
-$invoice     = new WPInv_Invoice( $invoice );
13
-$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() );
12
+$invoice     = new WPInv_Invoice($invoice);
13
+$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info());
14 14
 $phone       = $invoice->get_phone();
15 15
 $email       = $invoice->get_email();
16 16
 $vat_number  = $invoice->get_vat_number();
@@ -22,47 +22,47 @@  discard block
 block discarded – undo
22 22
 
23 23
 
24 24
             <div class="invoice-billing-address-label col-2">
25
-                <strong><?php esc_html_e( 'To:', 'invoicing' ); ?></strong>
25
+                <strong><?php esc_html_e('To:', 'invoicing'); ?></strong>
26 26
             </div>
27 27
 
28 28
 
29 29
             <div class="invoice-billing-address-value col-10">
30 30
 
31
-                <?php do_action( 'getpaid_billing_address_top' ); ?>
31
+                <?php do_action('getpaid_billing_address_top'); ?>
32 32
 
33
-                <?php if ( ! empty( $address_row ) ) : ?>
33
+                <?php if (!empty($address_row)) : ?>
34 34
                     <div class="billing-address">
35
-                        <?php echo wp_kses_post( $address_row ); ?>
35
+                        <?php echo wp_kses_post($address_row); ?>
36 36
                     </div>
37 37
                 <?php endif; ?>
38 38
 
39 39
 
40
-                <?php if ( ! empty( $phone ) ) : ?>
40
+                <?php if (!empty($phone)) : ?>
41 41
                     <div class="billing-phone">
42
-                        <?php echo wp_sprintf( esc_html__( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?>
42
+                        <?php echo wp_sprintf(esc_html__('Phone: %s', 'invoicing'), esc_html($phone)); ?>
43 43
                     </div>
44 44
                 <?php endif; ?>
45 45
 
46 46
 
47
-                <?php if ( ! empty( $email ) ) : ?>
47
+                <?php if (!empty($email)) : ?>
48 48
                     <div class="billing-email">
49
-                        <?php echo wp_sprintf( esc_html__( 'Email: %s', 'invoicing' ), esc_html( $email ) ); ?>
49
+                        <?php echo wp_sprintf(esc_html__('Email: %s', 'invoicing'), esc_html($email)); ?>
50 50
                     </div>
51 51
                 <?php endif; ?>
52 52
 
53
-                <?php if ( ! empty( $vat_number ) && wpinv_use_taxes() ) : ?>
53
+                <?php if (!empty($vat_number) && wpinv_use_taxes()) : ?>
54 54
                     <div class="vat-number">
55
-                        <?php echo wp_sprintf( esc_html__( 'Vat Number: %s', 'invoicing' ), esc_html( $vat_number ) ); ?>
55
+                        <?php echo wp_sprintf(esc_html__('Vat Number: %s', 'invoicing'), esc_html($vat_number)); ?>
56 56
                     </div>
57 57
                 <?php endif; ?>
58 58
 
59
-                <?php if ( ! empty( $company_id ) ) : ?>
59
+                <?php if (!empty($company_id)) : ?>
60 60
                     <div class="company-id">
61
-                        <?php echo wp_sprintf( esc_html__( 'Company ID: %s', 'invoicing' ), esc_html( $company_id ) ); ?>
61
+                        <?php echo wp_sprintf(esc_html__('Company ID: %s', 'invoicing'), esc_html($company_id)); ?>
62 62
                     </div>
63 63
                 <?php endif; ?>
64 64
 
65
-                <?php do_action( 'getpaid_billing_address_bottom' ); ?>
65
+                <?php do_action('getpaid_billing_address_bottom'); ?>
66 66
 
67 67
             </div>
68 68
 
Please login to merge, or discard this patch.