Passed
Push — master ( 20e351...0d8bd8 )
by Brian
04:12
created
templates/payment-forms-admin/edit/heading.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -8,23 +8,23 @@
 block discarded – undo
8 8
  */
9 9
 
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 ?>
14 14
 
15 15
 <div class='form-group'>
16
-    <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e( 'Heading', 'invoicing' ) ?></label>
16
+    <label :for="active_form_element.id + '_edit_heading'"><?php esc_html_e('Heading', 'invoicing') ?></label>
17 17
     <input :id="active_form_element.id + '_edit_heading'" v-model='active_form_element.text' class='form-control' type='text' />
18 18
 </div>
19 19
 
20 20
 <div class='form-group'>
21
-    <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e( 'Select Heading Level', 'invoicing' ) ?></label>
21
+    <label :for="active_form_element.id + '_edit_level'"><?php esc_html_e('Select Heading Level', 'invoicing') ?></label>
22 22
     <select class='form-control custom-select' :id="active_form_element.id + '_edit_level'" v-model='active_form_element.level'>
23
-        <option value='h1'><?php esc_html_e( 'H1', 'invoicing' ); ?></option>
24
-        <option value='h2'><?php esc_html_e( 'H2', 'invoicing' ); ?></option>
25
-        <option value='h3'><?php esc_html_e( 'H3', 'invoicing' ); ?></option>
26
-        <option value='h4'><?php esc_html_e( 'H4', 'invoicing' ); ?></option>
27
-        <option value='h5'><?php esc_html_e( 'H5', 'invoicing' ); ?></option>
28
-        <option value='h6'><?php esc_html_e( 'H6', 'invoicing' ); ?></option>
23
+        <option value='h1'><?php esc_html_e('H1', 'invoicing'); ?></option>
24
+        <option value='h2'><?php esc_html_e('H2', 'invoicing'); ?></option>
25
+        <option value='h3'><?php esc_html_e('H3', 'invoicing'); ?></option>
26
+        <option value='h4'><?php esc_html_e('H4', 'invoicing'); ?></option>
27
+        <option value='h5'><?php esc_html_e('H5', 'invoicing'); ?></option>
28
+        <option value='h6'><?php esc_html_e('H6', 'invoicing'); ?></option>
29 29
     </select>
30 30
 </div>
Please login to merge, or discard this patch.
includes/api/class-wpinv-rest-invoice-controller.php 1 patch
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  * @version 1.0.19
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * REST API invoices controller class.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 
53 53
 
54 54
 				'customers' => array(
55
-					'description'       => __( 'Limit result set to invoices for specific user ids.', 'invoicing' ),
55
+					'description'       => __('Limit result set to invoices for specific user ids.', 'invoicing'),
56 56
 					'type'              => 'array',
57 57
 					'items'             => array(
58 58
 						'type'          => 'integer',
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
 				),
63 63
 
64 64
 				'exclude_customers'  	=> array(
65
-					'description' 		=> __( 'Exclude invoices to specific users.', 'invoicing' ),
65
+					'description' 		=> __('Exclude invoices to specific users.', 'invoicing'),
66 66
 					'type'        		=> 'array',
67 67
 					'items'       		=> array(
68 68
 						'type'          => 'integer',
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 				),
73 73
 
74 74
 				'parent'  	            => array(
75
-					'description'       => __( 'Limit result set to those of particular parent IDs.', 'invoicing' ),
75
+					'description'       => __('Limit result set to those of particular parent IDs.', 'invoicing'),
76 76
 					'type'              => 'array',
77 77
 					'items'             => array(
78 78
 						'type'          => 'integer',
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
 				),
83 83
 
84 84
 				'parent_exclude'  	    => array(
85
-					'description'       => __( 'Limit result set to all items except those of a particular parent ID.', 'invoicing' ),
85
+					'description'       => __('Limit result set to all items except those of a particular parent ID.', 'invoicing'),
86 86
 					'type'              => 'array',
87 87
 					'items'             => array(
88 88
 						'type'          => 'integer',
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
 		);
97 97
 
98 98
 		// Filter collection parameters for the invoices controller.
99
-		return apply_filters( 'getpaid_rest_invoices_collection_params', $params, $this );
99
+		return apply_filters('getpaid_rest_invoices_collection_params', $params, $this);
100 100
 	}
101 101
 
102 102
 	/**
@@ -107,21 +107,21 @@  discard block
 block discarded – undo
107 107
 	 * @param WP_REST_Request $request Request object.
108 108
 	 * @return array          $query_args
109 109
 	 */
110
-	protected function prepare_items_query( $prepared_args = array(), $request = null ) {
110
+	protected function prepare_items_query($prepared_args = array(), $request = null) {
111 111
 
112
-		$query_args = parent::prepare_items_query( $prepared_args );
112
+		$query_args = parent::prepare_items_query($prepared_args);
113 113
 
114 114
 		// Retrieve invoices for specific customers.
115
-		if ( ! empty( $request['customers'] ) ) {
115
+		if (!empty($request['customers'])) {
116 116
 			$query_args['author__in'] = $request['customers'];
117 117
 		}
118 118
 
119 119
 		// Skip invoices for specific customers.
120
-		if ( ! empty( $request['exclude_customers'] ) ) {
120
+		if (!empty($request['exclude_customers'])) {
121 121
 			$query_args['author__not_in'] = $request['exclude_customers'];
122 122
 		}
123 123
 
124
-		return apply_filters( 'getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this );
124
+		return apply_filters('getpaid_rest_invoices_prepare_items_query', $query_args, $request, $this);
125 125
 
126 126
 	}
127 127
 
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return array A list of registered item statuses.
134 134
 	 */
135 135
 	public function get_post_statuses() {
136
-		return array_keys( wpinv_get_invoice_statuses( true, false, $this->post_type ) );
136
+		return array_keys(wpinv_get_invoice_statuses(true, false, $this->post_type));
137 137
 	}
138 138
 
139 139
 	/**
@@ -142,9 +142,9 @@  discard block
 block discarded – undo
142 142
 	 * @param WPInv_Invoice $invoice Invoice to save.
143 143
 	 * @return WP_Error|WPInv_Invoice
144 144
 	 */
145
-	protected function save_object( $invoice ) {
145
+	protected function save_object($invoice) {
146 146
 		$invoice->recalculate_total();
147
-		return parent::save_object( $invoice );
147
+		return parent::save_object($invoice);
148 148
 	}
149 149
 
150 150
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-invoice-data-store.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Invoice_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -108,61 +108,61 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @param WPInv_Invoice $invoice Invoice object.
110 110
 	 */
111
-	public function create( &$invoice ) {
112
-		$invoice->set_version( WPINV_VERSION );
113
-		$invoice->set_date_created( current_time('mysql') );
111
+	public function create(&$invoice) {
112
+		$invoice->set_version(WPINV_VERSION);
113
+		$invoice->set_date_created(current_time('mysql'));
114 114
 
115 115
 		// Create a new post.
116 116
 		$id = wp_insert_post(
117 117
 			apply_filters(
118 118
 				'getpaid_new_invoice_data',
119 119
 				array(
120
-					'post_date'     => $invoice->get_date_created( 'edit' ),
121
-					'post_type'     => $invoice->get_post_type( 'edit' ),
122
-					'post_status'   => $this->get_post_status( $invoice ),
120
+					'post_date'     => $invoice->get_date_created('edit'),
121
+					'post_type'     => $invoice->get_post_type('edit'),
122
+					'post_status'   => $this->get_post_status($invoice),
123 123
 					'ping_status'   => 'closed',
124
-					'post_author'   => $invoice->get_user_id( 'edit' ),
125
-					'post_title'    => $invoice->get_title( 'edit' ),
126
-					'post_excerpt'  => $invoice->get_description( 'edit' ),
127
-					'post_parent'   => $invoice->get_parent_id( 'edit' ),
124
+					'post_author'   => $invoice->get_user_id('edit'),
125
+					'post_title'    => $invoice->get_title('edit'),
126
+					'post_excerpt'  => $invoice->get_description('edit'),
127
+					'post_parent'   => $invoice->get_parent_id('edit'),
128 128
 				)
129 129
 			),
130 130
 			true
131 131
 		);
132 132
 
133
-		if ( $id && ! is_wp_error( $id ) ) {
133
+		if ($id && !is_wp_error($id)) {
134 134
 
135 135
 			// Update the new id and regenerate a title.
136
-			$invoice->set_id( $id );
136
+			$invoice->set_id($id);
137 137
 
138 138
 			$invoice->maybe_set_number();
139 139
 
140 140
 			wp_update_post(
141 141
 				array(
142 142
 					'ID'         => $invoice->get_id(),
143
-					'post_title' => $invoice->get_number( 'edit' ),
144
-					'post_name'  => $invoice->get_path( 'edit' )
143
+					'post_title' => $invoice->get_number('edit'),
144
+					'post_name'  => $invoice->get_path('edit')
145 145
 				)
146 146
 			);
147 147
 
148 148
 			// Save special fields and items.
149
-			$this->save_special_fields( $invoice );
150
-			$this->save_items( $invoice );
149
+			$this->save_special_fields($invoice);
150
+			$this->save_items($invoice);
151 151
 
152 152
 			// Update meta data.
153
-			$this->update_post_meta( $invoice );
153
+			$this->update_post_meta($invoice);
154 154
 			$invoice->save_meta_data();
155 155
 
156 156
 			// Apply changes.
157 157
 			$invoice->apply_changes();
158
-			$this->clear_caches( $invoice );
158
+			$this->clear_caches($invoice);
159 159
 
160 160
 			// Fires after a new invoice is created.
161
-			do_action( 'getpaid_new_invoice', $invoice );
161
+			do_action('getpaid_new_invoice', $invoice);
162 162
 			return true;
163 163
 		}
164 164
 
165
-		if ( is_wp_error( $id ) ) {
165
+		if (is_wp_error($id)) {
166 166
 			$invoice->last_error = $id->get_error_message();
167 167
 		}
168 168
 
@@ -175,14 +175,14 @@  discard block
 block discarded – undo
175 175
 	 * @param WPInv_Invoice $invoice Invoice object.
176 176
 	 *
177 177
 	 */
178
-	public function read( &$invoice ) {
178
+	public function read(&$invoice) {
179 179
 
180 180
 		$invoice->set_defaults();
181
-		$invoice_object = get_post( $invoice->get_id() );
181
+		$invoice_object = get_post($invoice->get_id());
182 182
 
183
-		if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) {
184
-			$invoice->last_error = __( 'Invalid invoice.', 'invoicing' );
185
-			$invoice->set_id( 0 );
183
+		if (!$invoice->get_id() || !$invoice_object || !getpaid_is_invoice_post_type($invoice_object->post_type)) {
184
+			$invoice->last_error = __('Invalid invoice.', 'invoicing');
185
+			$invoice->set_id(0);
186 186
 			return false;
187 187
 		}
188 188
 
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
 			)
201 201
 		);
202 202
 
203
-		$invoice->set_type( $invoice_object->post_type );
203
+		$invoice->set_type($invoice_object->post_type);
204 204
 
205
-		$this->read_object_data( $invoice, $invoice_object );
206
-		$this->add_special_fields( $invoice );
207
-		$this->add_items( $invoice );
205
+		$this->read_object_data($invoice, $invoice_object);
206
+		$this->add_special_fields($invoice);
207
+		$this->add_items($invoice);
208 208
 		$invoice->read_meta_data();
209
-		$invoice->set_object_read( true );
210
-		do_action( 'getpaid_read_invoice', $invoice );
209
+		$invoice->set_object_read(true);
210
+		do_action('getpaid_read_invoice', $invoice);
211 211
 
212 212
 	}
213 213
 
@@ -216,35 +216,35 @@  discard block
 block discarded – undo
216 216
 	 *
217 217
 	 * @param WPInv_Invoice $invoice Invoice object.
218 218
 	 */
219
-	public function update( &$invoice ) {
219
+	public function update(&$invoice) {
220 220
 		$invoice->save_meta_data();
221
-		$invoice->set_version( WPINV_VERSION );
221
+		$invoice->set_version(WPINV_VERSION);
222 222
 
223
-		if ( null === $invoice->get_date_created( 'edit' ) ) {
224
-			$invoice->set_date_created(  current_time('mysql') );
223
+		if (null === $invoice->get_date_created('edit')) {
224
+			$invoice->set_date_created(current_time('mysql'));
225 225
 		}
226 226
 
227 227
 		// Ensure both the key and number are set.
228 228
 		$invoice->get_path();
229 229
 
230 230
 		// Grab the current status so we can compare.
231
-		$previous_status = get_post_status( $invoice->get_id() );
231
+		$previous_status = get_post_status($invoice->get_id());
232 232
 
233 233
 		$changes = $invoice->get_changes();
234 234
 
235 235
 		// Only update the post when the post data changes.
236
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) {
236
+		if (array_intersect(array('date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path'), array_keys($changes))) {
237 237
 			$post_data = array(
238
-				'post_date'         => $invoice->get_date_created( 'edit' ),
239
-				'post_date_gmt'     => $invoice->get_date_created_gmt( 'edit' ),
240
-				'post_status'       => $invoice->get_status( 'edit' ),
241
-				'post_title'        => $invoice->get_name( 'edit' ),
242
-				'post_author'       => $invoice->get_user_id( 'edit' ),
243
-				'post_modified'     => $invoice->get_date_modified( 'edit' ),
244
-				'post_excerpt'      => $invoice->get_description( 'edit' ),
245
-				'post_parent'       => $invoice->get_parent_id( 'edit' ),
246
-				'post_name'         => $invoice->get_path( 'edit' ),
247
-				'post_type'         => $invoice->get_post_type( 'edit' ),
238
+				'post_date'         => $invoice->get_date_created('edit'),
239
+				'post_date_gmt'     => $invoice->get_date_created_gmt('edit'),
240
+				'post_status'       => $invoice->get_status('edit'),
241
+				'post_title'        => $invoice->get_name('edit'),
242
+				'post_author'       => $invoice->get_user_id('edit'),
243
+				'post_modified'     => $invoice->get_date_modified('edit'),
244
+				'post_excerpt'      => $invoice->get_description('edit'),
245
+				'post_parent'       => $invoice->get_parent_id('edit'),
246
+				'post_name'         => $invoice->get_path('edit'),
247
+				'post_type'         => $invoice->get_post_type('edit'),
248 248
 			);
249 249
 
250 250
 			/**
@@ -255,35 +255,35 @@  discard block
 block discarded – undo
255 255
 			 * This ensures hooks are fired by either WP itself (admin screen save),
256 256
 			 * or an update purely from CRUD.
257 257
 			 */
258
-			if ( doing_action( 'save_post' ) ) {
259
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) );
260
-				clean_post_cache( $invoice->get_id() );
258
+			if (doing_action('save_post')) {
259
+				$GLOBALS['wpdb']->update($GLOBALS['wpdb']->posts, $post_data, array('ID' => $invoice->get_id()));
260
+				clean_post_cache($invoice->get_id());
261 261
 			} else {
262
-				wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) );
262
+				wp_update_post(array_merge(array('ID' => $invoice->get_id()), $post_data));
263 263
 			}
264
-			$invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
264
+			$invoice->read_meta_data(true); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
265 265
 		}
266 266
 
267 267
 		// Update meta data.
268
-		$this->update_post_meta( $invoice );
268
+		$this->update_post_meta($invoice);
269 269
 
270 270
 		// Save special fields and items.
271
-		$this->save_special_fields( $invoice );
272
-		$this->save_items( $invoice );
271
+		$this->save_special_fields($invoice);
272
+		$this->save_items($invoice);
273 273
 
274 274
 		// Apply the changes.
275 275
 		$invoice->apply_changes();
276 276
 
277 277
 		// Clear caches.
278
-		$this->clear_caches( $invoice );
278
+		$this->clear_caches($invoice);
279 279
 
280 280
 		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
281
-		$new_status = $invoice->get_status( 'edit' );
281
+		$new_status = $invoice->get_status('edit');
282 282
 
283
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
284
-			do_action( 'getpaid_new_invoice', $invoice );
283
+		if ($new_status !== $previous_status && in_array($previous_status, array('new', 'auto-draft', 'draft'), true)) {
284
+			do_action('getpaid_new_invoice', $invoice);
285 285
 		} else {
286
-			do_action( 'getpaid_update_invoice', $invoice );
286
+			do_action('getpaid_update_invoice', $invoice);
287 287
 		}
288 288
 
289 289
 	}
@@ -299,45 +299,45 @@  discard block
 block discarded – undo
299 299
 	 *
300 300
 	 * @param WPInv_Invoice $invoice Invoice object.
301 301
      */
302
-    public function add_special_fields( &$invoice ) {
302
+    public function add_special_fields(&$invoice) {
303 303
 		global $wpdb;
304 304
 
305 305
 		// Maybe retrieve from the cache.
306
-		$data   = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' );
306
+		$data = wp_cache_get($invoice->get_id(), 'getpaid_invoice_special_fields');
307 307
 
308 308
 		// If not found, retrieve from the db.
309
-		if ( false === $data ) {
310
-			$table =  $wpdb->prefix . 'getpaid_invoices';
309
+		if (false === $data) {
310
+			$table = $wpdb->prefix . 'getpaid_invoices';
311 311
 
312 312
 			$data  = $wpdb->get_row(
313
-				$wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ),
313
+				$wpdb->prepare("SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id()),
314 314
 				ARRAY_A
315 315
 			);
316 316
 
317 317
 			// Update the cache with our data
318
-			wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' );
318
+			wp_cache_set($invoice->get_id(), $data, 'getpaid_invoice_special_fields');
319 319
 
320 320
 		}
321 321
 
322 322
 		// Abort if the data does not exist.
323
-		if ( empty( $data ) ) {
324
-			$invoice->set_object_read( true );
325
-			$invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) );
323
+		if (empty($data)) {
324
+			$invoice->set_object_read(true);
325
+			$invoice->set_props(wpinv_get_user_address($invoice->get_user_id()));
326 326
 			return;
327 327
 		}
328 328
 
329 329
 		$props = array();
330 330
 
331
-		foreach ( $this->database_fields_to_props as $db_field => $prop ) {
331
+		foreach ($this->database_fields_to_props as $db_field => $prop) {
332 332
 			
333
-			if ( $db_field == 'post_id' ) {
333
+			if ($db_field == 'post_id') {
334 334
 				continue;
335 335
 			}
336 336
 
337
-			$props[ $prop ] = $data[ $db_field ];
337
+			$props[$prop] = $data[$db_field];
338 338
 		}
339 339
 
340
-		$invoice->set_props( $props );
340
+		$invoice->set_props($props);
341 341
 
342 342
 	}
343 343
 
@@ -348,14 +348,14 @@  discard block
 block discarded – undo
348 348
 	 * @param  WPInv_Invoice $invoice       The Invoice object.
349 349
 	 * @return array                        A mapping of field keys => prop names, filtered by ones that should be updated.
350 350
 	 */
351
-	protected function get_special_fields_to_update( $invoice ) {
351
+	protected function get_special_fields_to_update($invoice) {
352 352
 		$fields_to_update = array();
353
-		$changed_props   = $invoice->get_changes();
353
+		$changed_props = $invoice->get_changes();
354 354
 
355 355
 		// Props should be updated if they are a part of the $changed array or don't exist yet.
356
-		foreach ( $this->database_fields_to_props as $database_field => $prop ) {
357
-			if ( array_key_exists( $prop, $changed_props ) ) {
358
-				$fields_to_update[ $database_field ] = $prop;
356
+		foreach ($this->database_fields_to_props as $database_field => $prop) {
357
+			if (array_key_exists($prop, $changed_props)) {
358
+				$fields_to_update[$database_field] = $prop;
359 359
 			}
360 360
 		}
361 361
 
@@ -368,25 +368,25 @@  discard block
 block discarded – undo
368 368
 	 * @param WPInv_Invoice $invoice WPInv_Invoice object.
369 369
 	 * @since 1.0.19
370 370
 	 */
371
-	protected function update_special_fields( &$invoice ) {
371
+	protected function update_special_fields(&$invoice) {
372 372
 		global $wpdb;
373 373
 
374 374
 		$updated_props    = array();
375
-		$fields_to_update = $this->get_special_fields_to_update( $invoice );
375
+		$fields_to_update = $this->get_special_fields_to_update($invoice);
376 376
 
377
-		foreach ( $fields_to_update as $database_field => $prop ) {
378
-			$value = $invoice->{"get_$prop"}( 'edit' );
379
-			$value = is_string( $value ) ? wp_slash( $value ) : $value;
380
-			$value = is_bool( $value ) ? ( int ) $value : $value;
381
-			$updated_props[ $database_field ] = maybe_serialize( $value );
377
+		foreach ($fields_to_update as $database_field => $prop) {
378
+			$value = $invoice->{"get_$prop"}('edit');
379
+			$value = is_string($value) ? wp_slash($value) : $value;
380
+			$value = is_bool($value) ? (int) $value : $value;
381
+			$updated_props[$database_field] = maybe_serialize($value);
382 382
 		}
383 383
 
384
-		if ( ! empty( $updated_props ) ) {
384
+		if (!empty($updated_props)) {
385 385
 
386 386
 			$table = $wpdb->prefix . 'getpaid_invoices';
387
-			$wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) );
388
-			wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
389
-			do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props );
387
+			$wpdb->update($table, $updated_props, array('post_id' => $invoice->get_id()));
388
+			wp_cache_delete($invoice->get_id(), 'getpaid_invoice_special_fields');
389
+			do_action("getpaid_invoice_update_database_fields", $invoice, $updated_props);
390 390
 
391 391
 		}
392 392
 
@@ -398,22 +398,22 @@  discard block
 block discarded – undo
398 398
 	 * @param WPInv_Invoice $invoice WPInv_Invoice object.
399 399
 	 * @since 1.0.19
400 400
 	 */
401
-	protected function insert_special_fields( &$invoice ) {
401
+	protected function insert_special_fields(&$invoice) {
402 402
 		global $wpdb;
403 403
 
404
-		$updated_props   = array();
404
+		$updated_props = array();
405 405
 
406
-		foreach ( $this->database_fields_to_props as $database_field => $prop ) {
407
-			$value = $invoice->{"get_$prop"}( 'edit' );
408
-			$value = is_string( $value ) ? wp_slash( $value ) : $value;
409
-			$value = is_bool( $value ) ? ( int ) $value : $value;
410
-			$updated_props[ $database_field ] = maybe_serialize( $value );
406
+		foreach ($this->database_fields_to_props as $database_field => $prop) {
407
+			$value = $invoice->{"get_$prop"}('edit');
408
+			$value = is_string($value) ? wp_slash($value) : $value;
409
+			$value = is_bool($value) ? (int) $value : $value;
410
+			$updated_props[$database_field] = maybe_serialize($value);
411 411
 		}
412 412
 
413 413
 		$table = $wpdb->prefix . 'getpaid_invoices';
414
-		$wpdb->insert( $table, $updated_props );
415
-		wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
416
-		do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props );
414
+		$wpdb->insert($table, $updated_props);
415
+		wp_cache_delete($invoice->get_id(), 'getpaid_invoice_special_fields');
416
+		do_action("getpaid_invoice_insert_database_fields", $invoice, $updated_props);
417 417
 
418 418
 	}
419 419
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 *
423 423
 	 * @param WPInv_Invoice $invoice Invoice object.
424 424
      */
425
-    public function save_special_fields( & $invoice ) {
425
+    public function save_special_fields(& $invoice) {
426 426
 		global $wpdb;
427 427
 
428 428
 		// The invoices table.
@@ -430,13 +430,13 @@  discard block
 block discarded – undo
430 430
 		$id    = (int) $invoice->get_id();
431 431
 		$invoice->maybe_set_key();
432 432
 
433
-		if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) {
433
+		if ($wpdb->get_var("SELECT `post_id` FROM $table WHERE `post_id`= $id")) {
434 434
 
435
-			$this->update_special_fields( $invoice );
435
+			$this->update_special_fields($invoice);
436 436
 
437 437
 		} else {
438 438
 
439
-			$this->insert_special_fields( $invoice );
439
+			$this->insert_special_fields($invoice);
440 440
 
441 441
 		}
442 442
 
@@ -447,43 +447,43 @@  discard block
 block discarded – undo
447 447
 	 *
448 448
 	 * @param WPInv_Invoice $invoice Invoice object.
449 449
      */
450
-    public function add_items( &$invoice ) {
450
+    public function add_items(&$invoice) {
451 451
 		global $wpdb;
452 452
 
453 453
 		// Maybe retrieve from the cache.
454
-		$items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' );
454
+		$items = wp_cache_get($invoice->get_id(), 'getpaid_invoice_cart_details');
455 455
 
456 456
 		// If not found, retrieve from the db.
457
-		if ( false === $items ) {
458
-			$table =  $wpdb->prefix . 'getpaid_invoice_items';
457
+		if (false === $items) {
458
+			$table = $wpdb->prefix . 'getpaid_invoice_items';
459 459
 
460 460
 			$items = $wpdb->get_results(
461
-				$wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() )
461
+				$wpdb->prepare("SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id())
462 462
 			);
463 463
 
464 464
 			// Update the cache with our data
465
-			wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' );
465
+			wp_cache_set($invoice->get_id(), $items, 'getpaid_invoice_cart_details');
466 466
 
467 467
 		}
468 468
 
469 469
 		// Abort if no items found.
470
-        if ( empty( $items ) ) {
470
+        if (empty($items)) {
471 471
             return;
472 472
 		}
473 473
 
474
-		foreach ( $items as $item_data ) {
475
-			$item = new GetPaid_Form_Item( $item_data->item_id );
474
+		foreach ($items as $item_data) {
475
+			$item = new GetPaid_Form_Item($item_data->item_id);
476 476
 
477 477
 			// Set item data.
478
-			$item->item_tax      = wpinv_sanitize_amount( $item_data->tax );
479
-			$item->item_discount = wpinv_sanitize_amount( $item_data->discount );
480
-			$item->set_name( $item_data->item_name );
481
-			$item->set_description( $item_data->item_description );
482
-			$item->set_price( $item_data->item_price );
483
-			$item->set_quantity( $item_data->quantity );
484
-			$item->set_item_meta( $item_data->meta );
485
-
486
-			$invoice->add_item( $item );
478
+			$item->item_tax      = wpinv_sanitize_amount($item_data->tax);
479
+			$item->item_discount = wpinv_sanitize_amount($item_data->discount);
480
+			$item->set_name($item_data->item_name);
481
+			$item->set_description($item_data->item_description);
482
+			$item->set_price($item_data->item_price);
483
+			$item->set_quantity($item_data->quantity);
484
+			$item->set_item_meta($item_data->meta);
485
+
486
+			$invoice->add_item($item);
487 487
 		}
488 488
 
489 489
 	}
@@ -493,20 +493,20 @@  discard block
 block discarded – undo
493 493
 	 *
494 494
 	 * @param WPInv_Invoice $invoice Invoice object.
495 495
      */
496
-    public function save_items( $invoice ) {
496
+    public function save_items($invoice) {
497 497
 
498 498
 		// Delete previously existing items.
499
-		$this->delete_items( $invoice );
499
+		$this->delete_items($invoice);
500 500
 
501
-		$table   =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
501
+		$table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
502 502
 
503
-		foreach ( $invoice->get_cart_details() as $item_data ) {
504
-			$item_data = array_map( 'maybe_serialize', $item_data );
505
-			$GLOBALS['wpdb']->insert( $table, $item_data );
503
+		foreach ($invoice->get_cart_details() as $item_data) {
504
+			$item_data = array_map('maybe_serialize', $item_data);
505
+			$GLOBALS['wpdb']->insert($table, $item_data);
506 506
 		}
507 507
 
508
-		wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' );
509
-		do_action( "getpaid_invoice_save_items", $invoice );
508
+		wp_cache_delete($invoice->get_id(), 'getpaid_invoice_cart_details');
509
+		do_action("getpaid_invoice_save_items", $invoice);
510 510
 
511 511
 	}
512 512
 
@@ -515,9 +515,9 @@  discard block
 block discarded – undo
515 515
 	 *
516 516
 	 * @param WPInv_Invoice $invoice Invoice object.
517 517
      */
518
-    public function delete_items( $invoice ) {
519
-		$table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
520
-		return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
518
+    public function delete_items($invoice) {
519
+		$table = $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
520
+		return $GLOBALS['wpdb']->delete($table, array('post_id' => $invoice->get_id()));
521 521
 	}
522 522
 
523 523
 	/**
@@ -525,9 +525,9 @@  discard block
 block discarded – undo
525 525
 	 *
526 526
 	 * @param WPInv_Invoice $invoice Invoice object.
527 527
      */
528
-    public function delete_special_fields( $invoice ) {
529
-		$table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoices';
530
-		return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
528
+    public function delete_special_fields($invoice) {
529
+		$table = $GLOBALS['wpdb']->prefix . 'getpaid_invoices';
530
+		return $GLOBALS['wpdb']->delete($table, array('post_id' => $invoice->get_id()));
531 531
 	}
532 532
 	
533 533
 	/**
@@ -538,10 +538,10 @@  discard block
 block discarded – undo
538 538
 	 * @param  WPInv_Invoice $object GetPaid_Data object.
539 539
 	 * @return string
540 540
 	 */
541
-	protected function get_post_status( $object ) {
542
-		$object_status = $object->get_status( 'edit' );
541
+	protected function get_post_status($object) {
542
+		$object_status = $object->get_status('edit');
543 543
 
544
-		if ( ! $object_status ) {
544
+		if (!$object_status) {
545 545
 			$object_status = $object->get_default_status();
546 546
 		}
547 547
 
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-input.php 1 patch
Spacing   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 *
19 19
 	 * @return string The rendered component.
20 20
 	 */
21
-	public static function input($args = array()){
21
+	public static function input($args = array()) {
22 22
 		$defaults = array(
23 23
 			'type'       => 'text',
24 24
 			'name'       => '',
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
 		/**
53 53
 		 * Parse incoming $args into an array and merge it with $defaults
54 54
 		 */
55
-		$args   = wp_parse_args( $args, $defaults );
55
+		$args   = wp_parse_args($args, $defaults);
56 56
 		$output = '';
57
-		if ( ! empty( $args['type'] ) ) {
57
+		if (!empty($args['type'])) {
58 58
 			// hidden label option needs to be empty
59 59
 			$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
60 60
 
61
-			$type = sanitize_html_class( $args['type'] );
61
+			$type = sanitize_html_class($args['type']);
62 62
 
63 63
 			$help_text = '';
64 64
 			$label = '';
@@ -66,24 +66,24 @@  discard block
 block discarded – undo
66 66
 			$label_args = array(
67 67
 				'title'=> $args['label'],
68 68
 				'for'=> $args['id'],
69
-				'class' => $args['label_class']." ",
69
+				'class' => $args['label_class'] . " ",
70 70
 				'label_type' => $args['label_type']
71 71
 			);
72 72
 
73 73
 			// floating labels need label after
74
-			if( $args['label_type'] == 'floating' && $type != 'checkbox' ){
74
+			if ($args['label_type'] == 'floating' && $type != 'checkbox') {
75 75
 				$label_after = true;
76 76
 				$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
77 77
 			}
78 78
 
79 79
 			// Some special sauce for files
80
-			if($type=='file' ){
80
+			if ($type == 'file') {
81 81
 				$label_after = true; // if type file we need the label after
82 82
 				$args['class'] .= ' custom-file-input ';
83
-			}elseif($type=='checkbox'){
83
+			}elseif ($type == 'checkbox') {
84 84
 				$label_after = true; // if type file we need the label after
85 85
 				$args['class'] .= ' custom-control-input ';
86
-			}elseif($type=='datepicker' || $type=='timepicker'){
86
+			}elseif ($type == 'datepicker' || $type == 'timepicker') {
87 87
 				$type = 'text';
88 88
 				//$args['class'] .= ' aui-flatpickr bg-initial ';
89 89
 				$args['class'] .= ' bg-initial ';
@@ -99,65 +99,65 @@  discard block
 block discarded – undo
99 99
 			$output .= '<input type="' . $type . '" ';
100 100
 
101 101
 			// name
102
-			if(!empty($args['name'])){
103
-				$output .= ' name="'.esc_attr($args['name']).'" ';
102
+			if (!empty($args['name'])) {
103
+				$output .= ' name="' . esc_attr($args['name']) . '" ';
104 104
 			}
105 105
 
106 106
 			// id
107
-			if(!empty($args['id'])){
108
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
107
+			if (!empty($args['id'])) {
108
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
109 109
 			}
110 110
 
111 111
 			// placeholder
112
-			if(isset($args['placeholder']) && '' != $args['placeholder'] ){
113
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
112
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
113
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
114 114
 			}
115 115
 
116 116
 			// title
117
-			if(!empty($args['title'])){
118
-				$output .= ' title="'.esc_attr($args['title']).'" ';
117
+			if (!empty($args['title'])) {
118
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
119 119
 			}
120 120
 
121 121
 			// value
122
-			if(!empty($args['value'])){
123
-				$output .= ' value="'.sanitize_text_field($args['value']).'" ';
122
+			if (!empty($args['value'])) {
123
+				$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
124 124
 			}
125 125
 
126 126
 			// checked, for radio and checkboxes
127
-			if( ( $type == 'checkbox' || $type == 'radio' ) && $args['checked'] ){
127
+			if (($type == 'checkbox' || $type == 'radio') && $args['checked']) {
128 128
 				$output .= ' checked ';
129 129
 			}
130 130
 
131 131
 			// validation text
132
-			if(!empty($args['validation_text'])){
133
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
132
+			if (!empty($args['validation_text'])) {
133
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
134 134
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
135 135
 			}
136 136
 
137 137
 			// validation_pattern
138
-			if(!empty($args['validation_pattern'])){
139
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
138
+			if (!empty($args['validation_pattern'])) {
139
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
140 140
 			}
141 141
 
142 142
 			// step (for numbers)
143
-			if(!empty($args['step'])){
144
-				$output .= ' step="'.$args['step'].'" ';
143
+			if (!empty($args['step'])) {
144
+				$output .= ' step="' . $args['step'] . '" ';
145 145
 			}
146 146
 
147 147
 			// required
148
-			if(!empty($args['required'])){
148
+			if (!empty($args['required'])) {
149 149
 				$output .= ' required ';
150 150
 			}
151 151
 
152 152
 			// class
153
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
154
-			$output .= ' class="form-control '.$class.'" ';
153
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
154
+			$output .= ' class="form-control ' . $class . '" ';
155 155
 
156 156
 			// data-attributes
157 157
 			$output .= AUI_Component_Helper::data_attributes($args);
158 158
 
159 159
 			// extra attributes
160
-			if(!empty($args['extra_attributes'])){
160
+			if (!empty($args['extra_attributes'])) {
161 161
 				$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
162 162
 			}
163 163
 
@@ -166,40 +166,40 @@  discard block
 block discarded – undo
166 166
 
167 167
 
168 168
 			// label
169
-			if(!empty($args['label'])){
170
-				if($type == 'file'){$label_args['class'] .= 'custom-file-label';}
171
-				elseif($type == 'checkbox'){$label_args['class'] .= 'custom-control-label';}
172
-				$label = self::label( $label_args, $type );
169
+			if (!empty($args['label'])) {
170
+				if ($type == 'file') {$label_args['class'] .= 'custom-file-label'; }
171
+				elseif ($type == 'checkbox') {$label_args['class'] .= 'custom-control-label'; }
172
+				$label = self::label($label_args, $type);
173 173
 			}
174 174
 
175 175
 			// help text
176
-			if(!empty($args['help_text'])){
176
+			if (!empty($args['help_text'])) {
177 177
 				$help_text = AUI_Component_Helper::help_text($args['help_text']);
178 178
 			}
179 179
 
180 180
 
181 181
 			// set help text in the correct possition
182
-			if($label_after){
182
+			if ($label_after) {
183 183
 				$output .= $label . $help_text;
184 184
 			}
185 185
 
186 186
 			// some input types need a separate wrap
187
-			if($type == 'file') {
188
-				$output = self::wrap( array(
187
+			if ($type == 'file') {
188
+				$output = self::wrap(array(
189 189
 					'content' => $output,
190 190
 					'class'   => 'form-group custom-file'
191
-				) );
192
-			}elseif($type == 'checkbox'){
191
+				));
192
+			}elseif ($type == 'checkbox') {
193 193
 				$wrap_class = $args['switch'] ? 'custom-switch' : 'custom-checkbox';
194
-				$output = self::wrap( array(
194
+				$output = self::wrap(array(
195 195
 					'content' => $output,
196
-					'class'   => 'custom-control '.$wrap_class
197
-				) );
196
+					'class'   => 'custom-control ' . $wrap_class
197
+				));
198 198
 
199
-				if($args['label_type']=='horizontal'){
199
+				if ($args['label_type'] == 'horizontal') {
200 200
 					$output = '<div class="col-sm-2 col-form-label"></div><div class="col-sm-10">' . $output . '</div>';
201 201
 				}
202
-			}elseif($type == 'password' && $args['password_toggle'] && !$args['input_group_right']){
202
+			}elseif ($type == 'password' && $args['password_toggle'] && !$args['input_group_right']) {
203 203
 
204 204
 
205 205
 				// allow password field to toggle view
@@ -213,49 +213,49 @@  discard block
 block discarded – undo
213 213
 			}
214 214
 
215 215
 			// input group wraps
216
-			if($args['input_group_left'] || $args['input_group_right']){
216
+			if ($args['input_group_left'] || $args['input_group_right']) {
217 217
 				$w100 = strpos($args['class'], 'w-100') !== false ? ' w-100' : '';
218
-				if($args['input_group_left']){
219
-					$output = self::wrap( array(
218
+				if ($args['input_group_left']) {
219
+					$output = self::wrap(array(
220 220
 						'content' => $output,
221
-						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative'.$w100  : 'input-group',
221
+						'class'   => $args['input_group_left_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
222 222
 						'input_group_left' => $args['input_group_left'],
223 223
 						'input_group_left_inside'    => $args['input_group_left_inside']
224
-					) );
224
+					));
225 225
 				}
226
-				if($args['input_group_right']){
227
-					$output = self::wrap( array(
226
+				if ($args['input_group_right']) {
227
+					$output = self::wrap(array(
228 228
 						'content' => $output,
229
-						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative'.$w100 : 'input-group',
229
+						'class'   => $args['input_group_right_inside'] ? 'input-group-inside position-relative' . $w100 : 'input-group',
230 230
 						'input_group_right' => $args['input_group_right'],
231 231
 						'input_group_right_inside'    => $args['input_group_right_inside']
232
-					) );
232
+					));
233 233
 				}
234 234
 
235 235
 			}
236 236
 
237
-			if(!$label_after){
237
+			if (!$label_after) {
238 238
 				$output .= $help_text;
239 239
 			}
240 240
 
241 241
 
242
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
243
-				$output = self::wrap( array(
242
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
243
+				$output = self::wrap(array(
244 244
 					'content' => $output,
245 245
 					'class'   => 'col-sm-10',
246
-				) );
246
+				));
247 247
 			}
248 248
 
249
-			if(!$label_after){
249
+			if (!$label_after) {
250 250
 				$output = $label . $output;
251 251
 			}
252 252
 
253 253
 			// wrap
254
-			if(!$args['no_wrap']){
254
+			if (!$args['no_wrap']) {
255 255
 
256
-				$form_group_class = $args['label_type']=='floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
-				$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
258
-				$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
256
+				$form_group_class = $args['label_type'] == 'floating' && $type != 'checkbox' ? 'form-label-group' : 'form-group';
257
+				$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
258
+				$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
259 259
 				$output = self::wrap(array(
260 260
 					'content' => $output,
261 261
 					'class'   => $wrap_class,
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 *
279 279
 	 * @return string The rendered component.
280 280
 	 */
281
-	public static function textarea($args = array()){
281
+	public static function textarea($args = array()) {
282 282
 		$defaults = array(
283 283
 			'name'       => '',
284 284
 			'class'      => '',
@@ -304,43 +304,43 @@  discard block
 block discarded – undo
304 304
 		/**
305 305
 		 * Parse incoming $args into an array and merge it with $defaults
306 306
 		 */
307
-		$args   = wp_parse_args( $args, $defaults );
307
+		$args   = wp_parse_args($args, $defaults);
308 308
 		$output = '';
309 309
 
310 310
 		// hidden label option needs to be empty
311 311
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
312 312
 
313 313
 		// floating labels don't work with wysiwyg so set it as top
314
-		if($args['label_type'] == 'floating' && !empty($args['wysiwyg'])){
314
+		if ($args['label_type'] == 'floating' && !empty($args['wysiwyg'])) {
315 315
 			$args['label_type'] = 'top';
316 316
 		}
317 317
 
318 318
 		$label_after = $args['label_after'];
319 319
 
320 320
 		// floating labels need label after
321
-		if( $args['label_type'] == 'floating' && empty($args['wysiwyg']) ){
321
+		if ($args['label_type'] == 'floating' && empty($args['wysiwyg'])) {
322 322
 			$label_after = true;
323 323
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
324 324
 		}
325 325
 
326 326
 		// label
327
-		if(!empty($args['label']) && is_array($args['label'])){
328
-		}elseif(!empty($args['label']) && !$label_after){
327
+		if (!empty($args['label']) && is_array($args['label'])) {
328
+		}elseif (!empty($args['label']) && !$label_after) {
329 329
 			$label_args = array(
330 330
 				'title'=> $args['label'],
331 331
 				'for'=> $args['id'],
332
-				'class' => $args['label_class']." ",
332
+				'class' => $args['label_class'] . " ",
333 333
 				'label_type' => $args['label_type']
334 334
 			);
335
-			$output .= self::label( $label_args );
335
+			$output .= self::label($label_args);
336 336
 		}
337 337
 
338 338
 		// maybe horizontal label
339
-		if($args['label_type']=='horizontal'){
339
+		if ($args['label_type'] == 'horizontal') {
340 340
 			$output .= '<div class="col-sm-10">';
341 341
 		}
342 342
 
343
-		if(!empty($args['wysiwyg'])){
343
+		if (!empty($args['wysiwyg'])) {
344 344
 			ob_start();
345 345
 			$content = $args['value'];
346 346
 			$editor_id = !empty($args['id']) ? sanitize_html_class($args['id']) : 'wp_editor';
@@ -354,69 +354,69 @@  discard block
 block discarded – undo
354 354
 			);
355 355
 
356 356
 			// maybe set settings if array
357
-			if(is_array($args['wysiwyg'])){
358
-				$settings  = wp_parse_args( $args['wysiwyg'], $settings );
357
+			if (is_array($args['wysiwyg'])) {
358
+				$settings = wp_parse_args($args['wysiwyg'], $settings);
359 359
 			}
360 360
 
361
-			wp_editor( $content, $editor_id, $settings );
361
+			wp_editor($content, $editor_id, $settings);
362 362
 			$output .= ob_get_clean();
363
-		}else{
363
+		} else {
364 364
 
365 365
 			// open
366 366
 			$output .= '<textarea ';
367 367
 
368 368
 			// name
369
-			if(!empty($args['name'])){
370
-				$output .= ' name="'.sanitize_html_class($args['name']).'" ';
369
+			if (!empty($args['name'])) {
370
+				$output .= ' name="' . sanitize_html_class($args['name']) . '" ';
371 371
 			}
372 372
 
373 373
 			// id
374
-			if(!empty($args['id'])){
375
-				$output .= ' id="'.sanitize_html_class($args['id']).'" ';
374
+			if (!empty($args['id'])) {
375
+				$output .= ' id="' . sanitize_html_class($args['id']) . '" ';
376 376
 			}
377 377
 
378 378
 			// placeholder
379
-			if(isset($args['placeholder']) && '' != $args['placeholder']){
380
-				$output .= ' placeholder="'.esc_attr($args['placeholder']).'" ';
379
+			if (isset($args['placeholder']) && '' != $args['placeholder']) {
380
+				$output .= ' placeholder="' . esc_attr($args['placeholder']) . '" ';
381 381
 			}
382 382
 
383 383
 			// title
384
-			if(!empty($args['title'])){
385
-				$output .= ' title="'.esc_attr($args['title']).'" ';
384
+			if (!empty($args['title'])) {
385
+				$output .= ' title="' . esc_attr($args['title']) . '" ';
386 386
 			}
387 387
 
388 388
 			// validation text
389
-			if(!empty($args['validation_text'])){
390
-				$output .= ' oninvalid="setCustomValidity(\''.esc_attr($args['validation_text']).'\')" ';
389
+			if (!empty($args['validation_text'])) {
390
+				$output .= ' oninvalid="setCustomValidity(\'' . esc_attr($args['validation_text']) . '\')" ';
391 391
 				$output .= ' onchange="try{setCustomValidity(\'\')}catch(e){}" ';
392 392
 			}
393 393
 
394 394
 			// validation_pattern
395
-			if(!empty($args['validation_pattern'])){
396
-				$output .= ' pattern="'.$args['validation_pattern'].'" ';
395
+			if (!empty($args['validation_pattern'])) {
396
+				$output .= ' pattern="' . $args['validation_pattern'] . '" ';
397 397
 			}
398 398
 
399 399
 			// required
400
-			if(!empty($args['required'])){
400
+			if (!empty($args['required'])) {
401 401
 				$output .= ' required ';
402 402
 			}
403 403
 
404 404
 			// rows
405
-			if(!empty($args['rows'])){
406
-				$output .= ' rows="'.absint($args['rows']).'" ';
405
+			if (!empty($args['rows'])) {
406
+				$output .= ' rows="' . absint($args['rows']) . '" ';
407 407
 			}
408 408
 
409 409
 
410 410
 			// class
411 411
 			$class = !empty($args['class']) ? $args['class'] : '';
412
-			$output .= ' class="form-control '.$class.'" ';
412
+			$output .= ' class="form-control ' . $class . '" ';
413 413
 
414 414
 
415 415
 			// close tag
416 416
 			$output .= ' >';
417 417
 
418 418
 			// value
419
-			if(!empty($args['value'])){
419
+			if (!empty($args['value'])) {
420 420
 				$output .= sanitize_textarea_field($args['value']);
421 421
 			}
422 422
 
@@ -425,32 +425,32 @@  discard block
 block discarded – undo
425 425
 
426 426
 		}
427 427
 
428
-		if(!empty($args['label']) && $label_after){
428
+		if (!empty($args['label']) && $label_after) {
429 429
 			$label_args = array(
430 430
 				'title'=> $args['label'],
431 431
 				'for'=> $args['id'],
432
-				'class' => $args['label_class']." ",
432
+				'class' => $args['label_class'] . " ",
433 433
 				'label_type' => $args['label_type']
434 434
 			);
435
-			$output .= self::label( $label_args );
435
+			$output .= self::label($label_args);
436 436
 		}
437 437
 
438 438
 		// help text
439
-		if(!empty($args['help_text'])){
439
+		if (!empty($args['help_text'])) {
440 440
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
441 441
 		}
442 442
 
443 443
 		// maybe horizontal label
444
-		if($args['label_type']=='horizontal'){
444
+		if ($args['label_type'] == 'horizontal') {
445 445
 			$output .= '</div>';
446 446
 		}
447 447
 
448 448
 
449 449
 		// wrap
450
-		if(!$args['no_wrap']){
451
-			$form_group_class = $args['label_type']=='floating' ? 'form-label-group' : 'form-group';
452
-			$wrap_class = $args['label_type']=='horizontal' ? $form_group_class . ' row' : $form_group_class;
453
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
450
+		if (!$args['no_wrap']) {
451
+			$form_group_class = $args['label_type'] == 'floating' ? 'form-label-group' : 'form-group';
452
+			$wrap_class = $args['label_type'] == 'horizontal' ? $form_group_class . ' row' : $form_group_class;
453
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
454 454
 			$output = self::wrap(array(
455 455
 				'content' => $output,
456 456
 				'class'   => $wrap_class,
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 		return $output;
464 464
 	}
465 465
 
466
-	public static function label($args = array(), $type = ''){
466
+	public static function label($args = array(), $type = '') {
467 467
 		//<label for="exampleInputEmail1">Email address</label>
468 468
 		$defaults = array(
469 469
 			'title'       => 'div',
@@ -475,20 +475,20 @@  discard block
 block discarded – undo
475 475
 		/**
476 476
 		 * Parse incoming $args into an array and merge it with $defaults
477 477
 		 */
478
-		$args   = wp_parse_args( $args, $defaults );
478
+		$args   = wp_parse_args($args, $defaults);
479 479
 		$output = '';
480 480
 
481
-		if($args['title']){
481
+		if ($args['title']) {
482 482
 
483 483
 			// maybe hide labels //@todo set a global option for visibility class
484
-			if($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type']) ){
484
+			if ($type == 'file' || $type == 'checkbox' || $type == 'radio' || !empty($args['label_type'])) {
485 485
 				$class = $args['class'];
486
-			}else{
487
-				$class = 'sr-only '.$args['class'];
486
+			} else {
487
+				$class = 'sr-only ' . $args['class'];
488 488
 			}
489 489
 
490 490
 			// maybe horizontal
491
-			if($args['label_type']=='horizontal' && $type != 'checkbox'){
491
+			if ($args['label_type'] == 'horizontal' && $type != 'checkbox') {
492 492
 				$class .= ' col-sm-2 col-form-label';
493 493
 			}
494 494
 
@@ -496,20 +496,20 @@  discard block
 block discarded – undo
496 496
 			$output .= '<label ';
497 497
 
498 498
 			// for
499
-			if(!empty($args['for'])){
500
-				$output .= ' for="'.sanitize_text_field($args['for']).'" ';
499
+			if (!empty($args['for'])) {
500
+				$output .= ' for="' . sanitize_text_field($args['for']) . '" ';
501 501
 			}
502 502
 
503 503
 			// class
504
-			$class = $class ? AUI_Component_Helper::esc_classes( $class ) : '';
505
-			$output .= ' class="'.$class.'" ';
504
+			$class = $class ? AUI_Component_Helper::esc_classes($class) : '';
505
+			$output .= ' class="' . $class . '" ';
506 506
 
507 507
 			// close
508 508
 			$output .= '>';
509 509
 
510 510
 
511 511
 			// title, don't escape fully as can contain html
512
-			if(!empty($args['title'])){
512
+			if (!empty($args['title'])) {
513 513
 				$output .= wp_kses_post($args['title']);
514 514
 			}
515 515
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 	 *
531 531
 	 * @return string
532 532
 	 */
533
-	public static function wrap($args = array()){
533
+	public static function wrap($args = array()) {
534 534
 		$defaults = array(
535 535
 			'type'       => 'div',
536 536
 			'class'      => 'form-group',
@@ -546,55 +546,55 @@  discard block
 block discarded – undo
546 546
 		/**
547 547
 		 * Parse incoming $args into an array and merge it with $defaults
548 548
 		 */
549
-		$args   = wp_parse_args( $args, $defaults );
549
+		$args   = wp_parse_args($args, $defaults);
550 550
 		$output = '';
551
-		if($args['type']){
551
+		if ($args['type']) {
552 552
 
553 553
 			// open
554
-			$output .= '<'.sanitize_html_class($args['type']);
554
+			$output .= '<' . sanitize_html_class($args['type']);
555 555
 
556 556
 			// element require
557
-			if(!empty($args['element_require'])){
557
+			if (!empty($args['element_require'])) {
558 558
 				$output .= AUI_Component_Helper::element_require($args['element_require']);
559 559
 				$args['class'] .= " aui-conditional-field";
560 560
 			}
561 561
 
562 562
 			// argument_id
563
-			if( !empty($args['argument_id']) ){
564
-				$output .= ' data-argument="'.esc_attr($args['argument_id']).'"';
563
+			if (!empty($args['argument_id'])) {
564
+				$output .= ' data-argument="' . esc_attr($args['argument_id']) . '"';
565 565
 			}
566 566
 
567 567
 			// class
568
-			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes( $args['class'] ) : '';
569
-			$output .= ' class="'.$class.'" ';
568
+			$class = !empty($args['class']) ? AUI_Component_Helper::esc_classes($args['class']) : '';
569
+			$output .= ' class="' . $class . '" ';
570 570
 
571 571
 			// close wrap
572 572
 			$output .= ' >';
573 573
 
574 574
 
575 575
 			// Input group left
576
-			if(!empty($args['input_group_left'])){
576
+			if (!empty($args['input_group_left'])) {
577 577
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
578
-				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">'.$args['input_group_left'].'</span>';
579
-				$output .= '<div class="input-group-prepend '.$position_class.'">'.$input_group_left.'</div>';
578
+				$input_group_left = strpos($args['input_group_left'], '<') !== false ? $args['input_group_left'] : '<span class="input-group-text">' . $args['input_group_left'] . '</span>';
579
+				$output .= '<div class="input-group-prepend ' . $position_class . '">' . $input_group_left . '</div>';
580 580
 			}
581 581
 
582 582
 			// content
583 583
 			$output .= $args['content'];
584 584
 
585 585
 			// Input group right
586
-			if(!empty($args['input_group_right'])){
586
+			if (!empty($args['input_group_right'])) {
587 587
 				$position_class = !empty($args['input_group_left_inside']) ? 'position-absolute h-100' : '';
588
-				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">'.$args['input_group_right'].'</span>';
589
-				$output .= '<div class="input-group-append '.$position_class.'">'.$input_group_right.'</div>';
588
+				$input_group_right = strpos($args['input_group_right'], '<') !== false ? $args['input_group_right'] : '<span class="input-group-text">' . $args['input_group_right'] . '</span>';
589
+				$output .= '<div class="input-group-append ' . $position_class . '">' . $input_group_right . '</div>';
590 590
 			}
591 591
 
592 592
 
593 593
 			// close wrap
594
-			$output .= '</'.sanitize_html_class($args['type']).'>';
594
+			$output .= '</' . sanitize_html_class($args['type']) . '>';
595 595
 
596 596
 
597
-		}else{
597
+		} else {
598 598
 			$output = $args['content'];
599 599
 		}
600 600
 
@@ -608,7 +608,7 @@  discard block
 block discarded – undo
608 608
 	 *
609 609
 	 * @return string The rendered component.
610 610
 	 */
611
-	public static function select($args = array()){
611
+	public static function select($args = array()) {
612 612
 		$defaults = array(
613 613
 			'class'      => '',
614 614
 			'wrap_class' => '',
@@ -634,11 +634,11 @@  discard block
 block discarded – undo
634 634
 		/**
635 635
 		 * Parse incoming $args into an array and merge it with $defaults
636 636
 		 */
637
-		$args   = wp_parse_args( $args, $defaults );
637
+		$args   = wp_parse_args($args, $defaults);
638 638
 		$output = '';
639 639
 
640 640
 		// for now lets hide floating labels
641
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'hidden';}
641
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'hidden'; }
642 642
 
643 643
 		// hidden label option needs to be empty
644 644
 		$args['label_type'] = $args['label_type'] == 'hidden' ? '' : $args['label_type'];
@@ -647,47 +647,47 @@  discard block
 block discarded – undo
647 647
 		$label_after = $args['label_after'];
648 648
 
649 649
 		// floating labels need label after
650
-		if( $args['label_type'] == 'floating' ){
650
+		if ($args['label_type'] == 'floating') {
651 651
 			$label_after = true;
652 652
 			$args['placeholder'] = ' '; // set the placeholder not empty so the floating label works.
653 653
 		}
654 654
 
655 655
 		// Maybe setup select2
656 656
 		$is_select2 = false;
657
-		if(!empty($args['select2'])){
657
+		if (!empty($args['select2'])) {
658 658
 			$args['class'] .= ' aui-select2';
659 659
 			$is_select2 = true;
660
-		}elseif( strpos($args['class'], 'aui-select2') !== false){
660
+		}elseif (strpos($args['class'], 'aui-select2') !== false) {
661 661
 			$is_select2 = true;
662 662
 		}
663 663
 
664 664
 		// select2 tags
665
-		if( !empty($args['select2']) && $args['select2'] === 'tags'){ // triple equals needed here for some reason
665
+		if (!empty($args['select2']) && $args['select2'] === 'tags') { // triple equals needed here for some reason
666 666
 			$args['data-tags'] = 'true';
667 667
 			$args['data-token-separators'] = "[',']";
668 668
 			$args['multiple'] = true;
669 669
 		}
670 670
 
671 671
 		// select2 placeholder
672
-		if($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])){
672
+		if ($is_select2 && isset($args['placeholder']) && '' != $args['placeholder'] && empty($args['data-placeholder'])) {
673 673
 			$args['data-placeholder'] = esc_attr($args['placeholder']);
674 674
 			$args['data-allow-clear'] = isset($args['data-allow-clear']) ? (bool) $args['data-allow-clear'] : true;
675 675
 		}
676 676
 
677 677
 		// label
678
-		if(!empty($args['label']) && is_array($args['label'])){
679
-		}elseif(!empty($args['label']) && !$label_after){
678
+		if (!empty($args['label']) && is_array($args['label'])) {
679
+		}elseif (!empty($args['label']) && !$label_after) {
680 680
 			$label_args = array(
681 681
 				'title'=> $args['label'],
682 682
 				'for'=> $args['id'],
683
-				'class' => $args['label_class']." ",
683
+				'class' => $args['label_class'] . " ",
684 684
 				'label_type' => $args['label_type']
685 685
 			);
686 686
 			$output .= self::label($label_args);
687 687
 		}
688 688
 
689 689
 		// maybe horizontal label
690
-		if($args['label_type']=='horizontal'){
690
+		if ($args['label_type'] == 'horizontal') {
691 691
 			$output .= '<div class="col-sm-10">';
692 692
 		}
693 693
 
@@ -695,32 +695,32 @@  discard block
 block discarded – undo
695 695
 		$output .= '<select ';
696 696
 
697 697
 		// style
698
-		if($is_select2){
698
+		if ($is_select2) {
699 699
 			$output .= " style='width:100%;' ";
700 700
 		}
701 701
 
702 702
 		// element require
703
-		if(!empty($args['element_require'])){
703
+		if (!empty($args['element_require'])) {
704 704
 			$output .= AUI_Component_Helper::element_require($args['element_require']);
705 705
 			$args['class'] .= " aui-conditional-field";
706 706
 		}
707 707
 
708 708
 		// class
709 709
 		$class = !empty($args['class']) ? $args['class'] : '';
710
-		$output .= AUI_Component_Helper::class_attr('custom-select '.$class);
710
+		$output .= AUI_Component_Helper::class_attr('custom-select ' . $class);
711 711
 
712 712
 		// name
713
-		if(!empty($args['name'])){
714
-			$output .= AUI_Component_Helper::name($args['name'],$args['multiple']);
713
+		if (!empty($args['name'])) {
714
+			$output .= AUI_Component_Helper::name($args['name'], $args['multiple']);
715 715
 		}
716 716
 
717 717
 		// id
718
-		if(!empty($args['id'])){
718
+		if (!empty($args['id'])) {
719 719
 			$output .= AUI_Component_Helper::id($args['id']);
720 720
 		}
721 721
 
722 722
 		// title
723
-		if(!empty($args['title'])){
723
+		if (!empty($args['title'])) {
724 724
 			$output .= AUI_Component_Helper::title($args['title']);
725 725
 		}
726 726
 
@@ -731,17 +731,17 @@  discard block
 block discarded – undo
731 731
 		$output .= AUI_Component_Helper::aria_attributes($args);
732 732
 
733 733
 		// extra attributes
734
-		if(!empty($args['extra_attributes'])){
734
+		if (!empty($args['extra_attributes'])) {
735 735
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
736 736
 		}
737 737
 
738 738
 		// required
739
-		if(!empty($args['required'])){
739
+		if (!empty($args['required'])) {
740 740
 			$output .= ' required ';
741 741
 		}
742 742
 
743 743
 		// multiple
744
-		if(!empty($args['multiple'])){
744
+		if (!empty($args['multiple'])) {
745 745
 			$output .= ' multiple ';
746 746
 		}
747 747
 
@@ -749,21 +749,21 @@  discard block
 block discarded – undo
749 749
 		$output .= ' >';
750 750
 
751 751
 		// placeholder
752
-		if(isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2){
753
-			$output .= '<option value="" disabled selected hidden>'.esc_attr($args['placeholder']).'</option>';
754
-		}elseif($is_select2 && !empty($args['placeholder'])){
752
+		if (isset($args['placeholder']) && '' != $args['placeholder'] && !$is_select2) {
753
+			$output .= '<option value="" disabled selected hidden>' . esc_attr($args['placeholder']) . '</option>';
754
+		}elseif ($is_select2 && !empty($args['placeholder'])) {
755 755
 			$output .= "<option></option>"; // select2 needs an empty select to fill the placeholder
756 756
 		}
757 757
 
758 758
 		// Options
759
-		if(!empty($args['options'])){
759
+		if (!empty($args['options'])) {
760 760
 
761
-			if(!is_array($args['options'])){
761
+			if (!is_array($args['options'])) {
762 762
 				$output .= $args['options']; // not the preferred way but an option
763
-			}else{
764
-				foreach($args['options'] as $val => $name){
763
+			} else {
764
+				foreach ($args['options'] as $val => $name) {
765 765
 					$selected = '';
766
-					if(is_array($name)){
766
+					if (is_array($name)) {
767 767
 						if (isset($name['optgroup']) && ($name['optgroup'] == 'start' || $name['optgroup'] == 'end')) {
768 768
 							$option_label = isset($name['label']) ? $name['label'] : '';
769 769
 
@@ -771,23 +771,23 @@  discard block
 block discarded – undo
771 771
 						} else {
772 772
 							$option_label = isset($name['label']) ? $name['label'] : '';
773 773
 							$option_value = isset($name['value']) ? $name['value'] : '';
774
-							if(!empty($args['multiple']) && !empty($args['value']) && is_array($args['value']) ){
774
+							if (!empty($args['multiple']) && !empty($args['value']) && is_array($args['value'])) {
775 775
 								$selected = in_array($option_value, stripslashes_deep($args['value'])) ? "selected" : "";
776
-							} elseif(!empty($args['value'])) {
777
-								$selected = selected($option_value,stripslashes_deep($args['value']), false);
776
+							} elseif (!empty($args['value'])) {
777
+								$selected = selected($option_value, stripslashes_deep($args['value']), false);
778 778
 							}
779 779
 
780 780
 							$output .= '<option value="' . esc_attr($option_value) . '" ' . $selected . '>' . $option_label . '</option>';
781 781
 						}
782
-					}else{
783
-						if(!empty($args['value'])){
784
-							if(is_array($args['value'])){
785
-								$selected = in_array($val,$args['value']) ? 'selected="selected"' : '';
786
-							} elseif(!empty($args['value'])) {
787
-								$selected = selected( $args['value'], $val, false);
782
+					} else {
783
+						if (!empty($args['value'])) {
784
+							if (is_array($args['value'])) {
785
+								$selected = in_array($val, $args['value']) ? 'selected="selected"' : '';
786
+							} elseif (!empty($args['value'])) {
787
+								$selected = selected($args['value'], $val, false);
788 788
 							}
789 789
 						}
790
-						$output .= '<option value="'.esc_attr($val).'" '.$selected.'>'.esc_attr($name).'</option>';
790
+						$output .= '<option value="' . esc_attr($val) . '" ' . $selected . '>' . esc_attr($name) . '</option>';
791 791
 					}
792 792
 				}
793 793
 			}
@@ -797,31 +797,31 @@  discard block
 block discarded – undo
797 797
 		// closing tag
798 798
 		$output .= '</select>';
799 799
 
800
-		if(!empty($args['label']) && $label_after){
800
+		if (!empty($args['label']) && $label_after) {
801 801
 			$label_args = array(
802 802
 				'title'=> $args['label'],
803 803
 				'for'=> $args['id'],
804
-				'class' => $args['label_class']." ",
804
+				'class' => $args['label_class'] . " ",
805 805
 				'label_type' => $args['label_type']
806 806
 			);
807 807
 			$output .= self::label($label_args);
808 808
 		}
809 809
 
810 810
 		// help text
811
-		if(!empty($args['help_text'])){
811
+		if (!empty($args['help_text'])) {
812 812
 			$output .= AUI_Component_Helper::help_text($args['help_text']);
813 813
 		}
814 814
 
815 815
 		// maybe horizontal label
816
-		if($args['label_type']=='horizontal'){
816
+		if ($args['label_type'] == 'horizontal') {
817 817
 			$output .= '</div>';
818 818
 		}
819 819
 
820 820
 
821 821
 		// wrap
822
-		if(!$args['no_wrap']){
823
-			$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
824
-			$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
822
+		if (!$args['no_wrap']) {
823
+			$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
824
+			$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
825 825
 			$output = self::wrap(array(
826 826
 				'content' => $output,
827 827
 				'class'   => $wrap_class,
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 *
842 842
 	 * @return string The rendered component.
843 843
 	 */
844
-	public static function radio($args = array()){
844
+	public static function radio($args = array()) {
845 845
 		$defaults = array(
846 846
 			'class'      => '',
847 847
 			'wrap_class' => '',
@@ -864,14 +864,14 @@  discard block
 block discarded – undo
864 864
 		/**
865 865
 		 * Parse incoming $args into an array and merge it with $defaults
866 866
 		 */
867
-		$args   = wp_parse_args( $args, $defaults );
867
+		$args = wp_parse_args($args, $defaults);
868 868
 
869 869
 		// for now lets use horizontal for floating
870
-		if( $args['label_type'] == 'floating' ){$args['label_type'] = 'horizontal';}
870
+		if ($args['label_type'] == 'floating') {$args['label_type'] = 'horizontal'; }
871 871
 
872 872
 		$label_args = array(
873 873
 			'title'=> $args['label'],
874
-			'class' => $args['label_class']." pt-0 ",
874
+			'class' => $args['label_class'] . " pt-0 ",
875 875
 			'label_type' => $args['label_type']
876 876
 		);
877 877
 
@@ -880,36 +880,36 @@  discard block
 block discarded – undo
880 880
 
881 881
 
882 882
 		// label before
883
-		if(!empty($args['label'])){
884
-			$output .= self::label( $label_args, 'radio' );
883
+		if (!empty($args['label'])) {
884
+			$output .= self::label($label_args, 'radio');
885 885
 		}
886 886
 
887 887
 		// maybe horizontal label
888
-		if($args['label_type']=='horizontal'){
888
+		if ($args['label_type'] == 'horizontal') {
889 889
 			$output .= '<div class="col-sm-10">';
890 890
 		}
891 891
 
892
-		if(!empty($args['options'])){
892
+		if (!empty($args['options'])) {
893 893
 			$count = 0;
894
-			foreach($args['options'] as $value => $label){
894
+			foreach ($args['options'] as $value => $label) {
895 895
 				$option_args = $args;
896 896
 				$option_args['value'] = $value;
897 897
 				$option_args['label'] = $label;
898 898
 				$option_args['checked'] = $value == $args['value'] ? true : false;
899
-				$output .= self::radio_option($option_args,$count);
899
+				$output .= self::radio_option($option_args, $count);
900 900
 				$count++;
901 901
 			}
902 902
 		}
903 903
 
904 904
 		// maybe horizontal label
905
-		if($args['label_type']=='horizontal'){
905
+		if ($args['label_type'] == 'horizontal') {
906 906
 			$output .= '</div>';
907 907
 		}
908 908
 
909 909
 
910 910
 		// wrap
911
-		$wrap_class = $args['label_type']=='horizontal' ? 'form-group row' : 'form-group';
912
-		$wrap_class = !empty($args['wrap_class']) ? $wrap_class." ".$args['wrap_class'] : $wrap_class;
911
+		$wrap_class = $args['label_type'] == 'horizontal' ? 'form-group row' : 'form-group';
912
+		$wrap_class = !empty($args['wrap_class']) ? $wrap_class . " " . $args['wrap_class'] : $wrap_class;
913 913
 		$output = self::wrap(array(
914 914
 			'content' => $output,
915 915
 			'class'   => $wrap_class,
@@ -928,7 +928,7 @@  discard block
 block discarded – undo
928 928
 	 *
929 929
 	 * @return string The rendered component.
930 930
 	 */
931
-	public static function radio_option($args = array(),$count = ''){
931
+	public static function radio_option($args = array(), $count = '') {
932 932
 		$defaults = array(
933 933
 			'class'      => '',
934 934
 			'id'         => '',
@@ -946,7 +946,7 @@  discard block
 block discarded – undo
946 946
 		/**
947 947
 		 * Parse incoming $args into an array and merge it with $defaults
948 948
 		 */
949
-		$args   = wp_parse_args( $args, $defaults );
949
+		$args   = wp_parse_args($args, $defaults);
950 950
 
951 951
 		$output = '';
952 952
 
@@ -957,27 +957,27 @@  discard block
 block discarded – undo
957 957
 		$output .= ' class="form-check-input" ';
958 958
 
959 959
 		// name
960
-		if(!empty($args['name'])){
960
+		if (!empty($args['name'])) {
961 961
 			$output .= AUI_Component_Helper::name($args['name']);
962 962
 		}
963 963
 
964 964
 		// id
965
-		if(!empty($args['id'])){
966
-			$output .= AUI_Component_Helper::id($args['id'].$count);
965
+		if (!empty($args['id'])) {
966
+			$output .= AUI_Component_Helper::id($args['id'] . $count);
967 967
 		}
968 968
 
969 969
 		// title
970
-		if(!empty($args['title'])){
970
+		if (!empty($args['title'])) {
971 971
 			$output .= AUI_Component_Helper::title($args['title']);
972 972
 		}
973 973
 
974 974
 		// value
975
-		if(isset($args['value'])){
976
-			$output .= ' value="'.sanitize_text_field($args['value']).'" ';
975
+		if (isset($args['value'])) {
976
+			$output .= ' value="' . sanitize_text_field($args['value']) . '" ';
977 977
 		}
978 978
 
979 979
 		// checked, for radio and checkboxes
980
-		if( $args['checked'] ){
980
+		if ($args['checked']) {
981 981
 			$output .= ' checked ';
982 982
 		}
983 983
 
@@ -988,12 +988,12 @@  discard block
 block discarded – undo
988 988
 		$output .= AUI_Component_Helper::aria_attributes($args);
989 989
 
990 990
 		// extra attributes
991
-		if(!empty($args['extra_attributes'])){
991
+		if (!empty($args['extra_attributes'])) {
992 992
 			$output .= AUI_Component_Helper::extra_attributes($args['extra_attributes']);
993 993
 		}
994 994
 
995 995
 		// required
996
-		if(!empty($args['required'])){
996
+		if (!empty($args['required'])) {
997 997
 			$output .= ' required ';
998 998
 		}
999 999
 
@@ -1001,13 +1001,13 @@  discard block
 block discarded – undo
1001 1001
 		$output .= ' >';
1002 1002
 
1003 1003
 		// label
1004
-		if(!empty($args['label']) && is_array($args['label'])){
1005
-		}elseif(!empty($args['label'])){
1006
-			$output .= self::label(array('title'=>$args['label'],'for'=>$args['id'].$count,'class'=>'form-check-label'),'radio');
1004
+		if (!empty($args['label']) && is_array($args['label'])) {
1005
+		}elseif (!empty($args['label'])) {
1006
+			$output .= self::label(array('title'=>$args['label'], 'for'=>$args['id'] . $count, 'class'=>'form-check-label'), 'radio');
1007 1007
 		}
1008 1008
 
1009 1009
 		// wrap
1010
-		if(!$args['no_wrap']){
1010
+		if (!$args['no_wrap']) {
1011 1011
 			$wrap_class = $args['inline'] ? 'form-check form-check-inline' : 'form-check';
1012 1012
 			$output = self::wrap(array(
1013 1013
 				'content' => $output,
Please login to merge, or discard this patch.
ayecode/wp-ayecode-ui/includes/components/class-aui-component-helper.php 1 patch
Spacing   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if ( ! defined( 'ABSPATH' ) ) {
3
+if (!defined('ABSPATH')) {
4 4
 	exit; // Exit if accessed directly
5 5
 }
6 6
 
@@ -19,12 +19,12 @@  discard block
 block discarded – undo
19 19
 	 *
20 20
 	 * @return string
21 21
 	 */
22
-	public static function name($text,$multiple = false){
22
+	public static function name($text, $multiple = false) {
23 23
 		$output = '';
24 24
 
25
-		if($text){
26
-			$is_multiple = strpos($text, '[') === false && $multiple  ? '[]' : '';
27
-			$output = ' name="'.esc_attr($text).$is_multiple.'" ';
25
+		if ($text) {
26
+			$is_multiple = strpos($text, '[') === false && $multiple ? '[]' : '';
27
+			$output = ' name="' . esc_attr($text) . $is_multiple . '" ';
28 28
 		}
29 29
 
30 30
 		return $output;
@@ -37,11 +37,11 @@  discard block
 block discarded – undo
37 37
 	 *
38 38
 	 * @return string The sanitized item.
39 39
 	 */
40
-	public static function id($text){
40
+	public static function id($text) {
41 41
 		$output = '';
42 42
 
43
-		if($text){
44
-			$output = ' id="'.sanitize_html_class($text).'" ';
43
+		if ($text) {
44
+			$output = ' id="' . sanitize_html_class($text) . '" ';
45 45
 		}
46 46
 
47 47
 		return $output;
@@ -54,11 +54,11 @@  discard block
 block discarded – undo
54 54
 	 *
55 55
 	 * @return string The sanitized item.
56 56
 	 */
57
-	public static function title($text){
57
+	public static function title($text) {
58 58
 		$output = '';
59 59
 
60
-		if($text){
61
-			$output = ' title="'.esc_attr($text).'" ';
60
+		if ($text) {
61
+			$output = ' title="' . esc_attr($text) . '" ';
62 62
 		}
63 63
 
64 64
 		return $output;
@@ -71,11 +71,11 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @return string The sanitized item.
73 73
 	 */
74
-	public static function value($text){
74
+	public static function value($text) {
75 75
 		$output = '';
76 76
 
77
-		if($text){
78
-			$output = ' value="'.sanitize_text_field($text).'" ';
77
+		if ($text) {
78
+			$output = ' value="' . sanitize_text_field($text) . '" ';
79 79
 		}
80 80
 
81 81
 		return $output;
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @return string The sanitized item.
90 90
 	 */
91
-	public static function class_attr($text){
91
+	public static function class_attr($text) {
92 92
 		$output = '';
93 93
 
94
-		if($text){
94
+		if ($text) {
95 95
 			$classes = self::esc_classes($text);
96
-			if(!empty($classes)){
97
-				$output = ' class="'.$classes.'" ';
96
+			if (!empty($classes)) {
97
+				$output = ' class="' . $classes . '" ';
98 98
 			}
99 99
 		}
100 100
 
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 	 *
109 109
 	 * @return string
110 110
 	 */
111
-	public static function esc_classes($text){
111
+	public static function esc_classes($text) {
112 112
 		$output = '';
113 113
 
114
-		if($text){
115
-			$classes = explode(" ",$text);
116
-			$classes = array_map("trim",$classes);
117
-			$classes = array_map("sanitize_html_class",$classes);
118
-			if(!empty($classes)){
119
-				$output = implode(" ",$classes);
114
+		if ($text) {
115
+			$classes = explode(" ", $text);
116
+			$classes = array_map("trim", $classes);
117
+			$classes = array_map("sanitize_html_class", $classes);
118
+			if (!empty($classes)) {
119
+				$output = implode(" ", $classes);
120 120
 			}
121 121
 		}
122 122
 
@@ -129,14 +129,14 @@  discard block
 block discarded – undo
129 129
 	 *
130 130
 	 * @return string
131 131
 	 */
132
-	public static function data_attributes($args){
132
+	public static function data_attributes($args) {
133 133
 		$output = '';
134 134
 
135
-		if(!empty($args)){
135
+		if (!empty($args)) {
136 136
 
137
-			foreach($args as $key => $val){
138
-				if(substr( $key, 0, 5 ) === "data-"){
139
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
137
+			foreach ($args as $key => $val) {
138
+				if (substr($key, 0, 5) === "data-") {
139
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
140 140
 				}
141 141
 			}
142 142
 		}
@@ -149,14 +149,14 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @return string
151 151
 	 */
152
-	public static function aria_attributes($args){
152
+	public static function aria_attributes($args) {
153 153
 		$output = '';
154 154
 
155
-		if(!empty($args)){
155
+		if (!empty($args)) {
156 156
 
157
-			foreach($args as $key => $val){
158
-				if(substr( $key, 0, 5 ) === "aria-"){
159
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
157
+			foreach ($args as $key => $val) {
158
+				if (substr($key, 0, 5) === "aria-") {
159
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
160 160
 				}
161 161
 			}
162 162
 		}
@@ -173,19 +173,19 @@  discard block
 block discarded – undo
173 173
 	 *
174 174
 	 * @return string
175 175
 	 */
176
-	public static function icon($class,$space_after = false, $extra_attributes = array()){
176
+	public static function icon($class, $space_after = false, $extra_attributes = array()) {
177 177
 		$output = '';
178 178
 
179
-		if($class){
179
+		if ($class) {
180 180
 			$classes = self::esc_classes($class);
181
-			if(!empty($classes)){
182
-				$output = '<i class="'.$classes.'" ';
181
+			if (!empty($classes)) {
182
+				$output = '<i class="' . $classes . '" ';
183 183
 				// extra attributes
184
-				if(!empty($extra_attributes)){
184
+				if (!empty($extra_attributes)) {
185 185
 					$output .= AUI_Component_Helper::extra_attributes($extra_attributes);
186 186
 				}
187 187
 				$output .= '></i>';
188
-				if($space_after){
188
+				if ($space_after) {
189 189
 					$output .= " ";
190 190
 				}
191 191
 			}
@@ -199,17 +199,17 @@  discard block
 block discarded – undo
199 199
 	 *
200 200
 	 * @return string
201 201
 	 */
202
-	public static function extra_attributes($args){
202
+	public static function extra_attributes($args) {
203 203
 		$output = '';
204 204
 
205
-		if(!empty($args)){
205
+		if (!empty($args)) {
206 206
 
207
-			if( is_array($args) ){
208
-				foreach($args as $key => $val){
209
-					$output .= ' '.sanitize_html_class($key).'="'.esc_attr($val).'" ';
207
+			if (is_array($args)) {
208
+				foreach ($args as $key => $val) {
209
+					$output .= ' ' . sanitize_html_class($key) . '="' . esc_attr($val) . '" ';
210 210
 				}
211
-			}else{
212
-				$output .= ' '.$args.' ';
211
+			} else {
212
+				$output .= ' ' . $args . ' ';
213 213
 			}
214 214
 
215 215
 		}
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	 *
223 223
 	 * @return string
224 224
 	 */
225
-	public static function help_text($text){
225
+	public static function help_text($text) {
226 226
 		$output = '';
227 227
 
228
-		if($text){
229
-			$output .= '<small class="form-text text-muted">'.wp_kses_post($text).'</small>';
228
+		if ($text) {
229
+			$output .= '<small class="form-text text-muted">' . wp_kses_post($text) . '</small>';
230 230
 		}
231 231
 
232 232
 
@@ -240,18 +240,18 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @return string|void
242 242
 	 */
243
-	public static function element_require( $input ) {
243
+	public static function element_require($input) {
244 244
 
245
-		$input = str_replace( "'", '"', $input );// we only want double quotes
245
+		$input = str_replace("'", '"', $input); // we only want double quotes
246 246
 
247
-		$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
247
+		$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
248 248
 			"jQuery(form).find('[data-argument=\"",
249 249
 			"\"]').find('input,select,textarea').val()",
250 250
 			"\"]').find('input:checked').val()",
251
-		), $input ) );
251
+		), $input));
252 252
 
253
-		if($output){
254
-			$output = ' data-element-require="'.$output.'" ';
253
+		if ($output) {
254
+			$output = ' data-element-require="' . $output . '" ';
255 255
 		}
256 256
 
257 257
 		return $output;
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-payment-form.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,14 +20,14 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-    public static function output( $post ) {
23
+    public static function output($post) {
24 24
         ?>
25 25
         <div id="wpinv-form-builder" class="bsui">
26 26
             <div class="row">
27 27
                 <div class="col-sm-4">
28 28
 
29 29
                     <!-- Builder tabs -->
30
-                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e( 'Go Back', 'invoicing' ); ?></button>
30
+                    <button class="button button-primary" v-if="active_tab!='new_item'" @click.prevent="active_tab='new_item'"><?php _e('Go Back', 'invoicing'); ?></button>
31 31
 
32 32
                     <!-- Builder tab content -->
33 33
                     <div class="mt-4">
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
                         <!-- Available builder elements -->
36 36
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='new_item'">
37 37
                             <div class="wpinv-form-builder-add-field-types">
38
-                                <small class='form-text text-muted'><?php _e( 'Add an element by dragging it to the payment form.', 'invoicing' ); ?></small>
38
+                                <small class='form-text text-muted'><?php _e('Add an element by dragging it to the payment form.', 'invoicing'); ?></small>
39 39
                                 <draggable class="section mt-2" style="display: flex; flex-flow: wrap; justify-content: space-between;" v-model="elements" :group="{ name: 'fields', pull: 'clone', put: false }" :sort="false" :clone="addDraggedField" tag="ul" filter=".wpinv-undraggable">
40 40
                                     <li v-for="element in elements" class= "wpinv-payment-form-left-fields-field" @click.prevent="addField(element)" :class="{ 'd-none': element.defaults.premade }">
41 41
                                         <button class="button btn">
@@ -50,18 +50,18 @@  discard block
 block discarded – undo
50 50
                         <!-- Edit an element -->
51 51
                         <div class="wpinv-form-builder-tab-pane" v-if="active_tab=='edit_item'" style="font-size: 14px;">
52 52
                             <div class="wpinv-form-builder-edit-field-wrapper">
53
-                                <?php do_action( 'wpinv_payment_form_edit_element_template', 'active_form_element', $post ); ?>
54
-                                <?php do_action( 'getpaid_payment_form_edit_element_template', $post ); ?>
53
+                                <?php do_action('wpinv_payment_form_edit_element_template', 'active_form_element', $post); ?>
54
+                                <?php do_action('getpaid_payment_form_edit_element_template', $post); ?>
55 55
                                 <div class='form-group'>
56
-                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e( 'Width', 'invoicing' ) ?></label>
56
+                                    <label :for="active_form_element.id + '_grid_width'"><?php esc_html_e('Width', 'invoicing') ?></label>
57 57
                                     <select class='form-control custom-select' :id="active_form_element.id + '_grid_width'" v-model='gridWidth'>
58
-                                        <option value='full'><?php esc_html_e( 'Full Width', 'invoicing' ); ?></option>
59
-                                        <option value='half'><?php esc_html_e( 'Half Width', 'invoicing' ); ?></option>
60
-                                        <option value='third'><?php esc_html_e( '1/3 Width', 'invoicing' ); ?></option>
58
+                                        <option value='full'><?php esc_html_e('Full Width', 'invoicing'); ?></option>
59
+                                        <option value='half'><?php esc_html_e('Half Width', 'invoicing'); ?></option>
60
+                                        <option value='third'><?php esc_html_e('1/3 Width', 'invoicing'); ?></option>
61 61
                                     </select>
62 62
                                 </div>
63 63
                                 <div>
64
-                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e( 'Delete Element', 'invoicing' ); ?></button>
64
+                                    <button type="button" class="button button-link button-link-delete" @click.prevent="removeField(active_form_element)" v-show="! active_form_element.premade"><?php _e('Delete Element', 'invoicing'); ?></button>
65 65
                                 </div>
66 66
                             </div>
67 67
                         </div>
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
 
71 71
                 </div>
72 72
                 <div class="col-sm-8 border-left">
73
-                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e( 'Click on any element to edit or delete it.', 'invoicing' ); ?></small>
74
-                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e( 'This form is empty. Add new elements by dragging them from the right.', 'invoicing' ); ?></p>
73
+                    <small class='form-text text-muted' v-if='form_elements.length'><?php _e('Click on any element to edit or delete it.', 'invoicing'); ?></small>
74
+                    <p class='form-text text-muted' v-if='! form_elements.length'><?php _e('This form is empty. Add new elements by dragging them from the right.', 'invoicing'); ?></p>
75 75
 
76 76
                     <div class="container-fluid">
77 77
                         <draggable class="section row" v-model="form_elements" @add="highlightLastDroppedField" group="fields" tag="div" style="min-height: 100%; font-size: 14px;">
78 78
                             <div v-for="form_element in form_elements" class="wpinv-form-builder-element-preview" :class="[{ active: active_form_element==form_element &&  active_tab=='edit_item' }, form_element.type, grid_class( form_element ) ]" @click="active_tab = 'edit_item'; active_form_element = form_element">
79 79
                                 <div class="wpinv-form-builder-element-preview-inner">
80 80
                                     <div class="wpinv-payment-form-field-preview-overlay"></div>
81
-                                    <?php do_action( 'wpinv_payment_form_render_element_template', 'form_element', $post ); ?>
81
+                                    <?php do_action('wpinv_payment_form_render_element_template', 'form_element', $post); ?>
82 82
                                 </div>
83 83
                             </div>
84 84
                         </draggable>
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
         </div>
93 93
         <?php
94 94
 
95
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
95
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
96 96
     }
97 97
 
98 98
     /**
@@ -100,33 +100,33 @@  discard block
 block discarded – undo
100 100
 	 *
101 101
 	 * @param int $post_id
102 102
 	 */
103
-	public static function save( $post_id ) {
103
+	public static function save($post_id) {
104 104
 
105 105
         // Prepare the form.
106
-        $form = new GetPaid_Payment_Form( $post_id );
106
+        $form = new GetPaid_Payment_Form($post_id);
107 107
 
108 108
         // Fetch form items.
109
-        $form_items = json_decode( wp_unslash( $_POST['wpinv_form_items'] ), true );
109
+        $form_items = json_decode(wp_unslash($_POST['wpinv_form_items']), true);
110 110
 
111 111
         // Ensure that we have an array...
112
-        if ( empty( $form_items ) ) {
112
+        if (empty($form_items)) {
113 113
             $form_items = array();
114 114
         }
115 115
 
116 116
         // Add it to the form.
117
-        $form->set_items( self::item_to_objects( $form_items ) );
117
+        $form->set_items(self::item_to_objects($form_items));
118 118
 
119 119
         // Save form elements.
120
-        $form_elements = json_decode( wp_unslash( $_POST['wpinv_form_elements'] ), true );
121
-        if ( empty( $form_elements ) ) {
120
+        $form_elements = json_decode(wp_unslash($_POST['wpinv_form_elements']), true);
121
+        if (empty($form_elements)) {
122 122
             $form_elements = array();
123 123
         }
124 124
 
125
-        $form->set_elements( $form_elements );
125
+        $form->set_elements($form_elements);
126 126
 
127 127
         // Persist data to the datastore.
128 128
         $form->save();
129
-        do_action( 'getpaid_payment_form_metabox_save', $post_id, $form );
129
+        do_action('getpaid_payment_form_metabox_save', $post_id, $form);
130 130
 
131 131
     }
132 132
 
@@ -135,14 +135,14 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $items
137 137
 	 */
138
-	public static function item_to_objects( $items ) {
138
+	public static function item_to_objects($items) {
139 139
 
140 140
         $objects = array();
141 141
 
142
-        foreach ( $items as $item ) {
143
-            $_item = new GetPaid_Form_Item( $item['id'] );
144
-            $_item->set_allow_quantities( (bool) $item['allow_quantities'] );
145
-            $_item->set_is_required( (bool) $item['required'] );
142
+        foreach ($items as $item) {
143
+            $_item = new GetPaid_Form_Item($item['id']);
144
+            $_item->set_allow_quantities((bool) $item['allow_quantities']);
145
+            $_item->set_is_required((bool) $item['required']);
146 146
             $objects[] = $_item;
147 147
         }
148 148
 
Please login to merge, or discard this patch.
templates/payment-forms/form.php 1 patch
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@  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 12
 // Make sure that the form is active.
13
-if ( ! $form->is_active() ) {
13
+if (!$form->is_active()) {
14 14
     echo aui()->alert(
15 15
         array(
16 16
             'type'    => 'warning',
17
-            'content' => __( 'This payment form is no longer active', 'invoicing' ),
17
+            'content' => __('This payment form is no longer active', 'invoicing'),
18 18
         )
19 19
     );
20 20
     return;
21 21
 }
22 22
 
23 23
 // Fires before displaying a payment form.
24
-do_action( 'getpaid_before_payment_form', $form );
24
+do_action('getpaid_before_payment_form', $form);
25 25
 ?>
26 26
 
27
-<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint( $form->get_id() ); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'>
27
+<form class='getpaid-payment-form getpaid-payment-form-<?php echo absint($form->get_id()); ?> bsui' method='POST' data-key='<?php echo uniqid('gpf'); ?>'>
28 28
 
29 29
 
30 30
     <?php 
31 31
     
32 32
         // Fires when printing the top of a payment form.
33
-        do_action( 'getpaid_payment_form_top', $form );
33
+        do_action('getpaid_payment_form_top', $form);
34 34
 
35 35
         // And the optional invoice id.
36
-        if ( ! empty( $form->invoice ) ) {
37
-            echo getpaid_hidden_field( 'invoice_id', $form->invoice->get_id() );
36
+        if (!empty($form->invoice)) {
37
+            echo getpaid_hidden_field('invoice_id', $form->invoice->get_id());
38 38
         }
39 39
 
40 40
         // We also want to include the form id.
41
-        echo getpaid_hidden_field( 'form_id', $form->get_id() );
41
+        echo getpaid_hidden_field('form_id', $form->get_id());
42 42
 
43 43
         // And an indication that this is a payment form submission.
44
-        echo getpaid_hidden_field( 'getpaid_payment_form_submission', '1' );
44
+        echo getpaid_hidden_field('getpaid_payment_form_submission', '1');
45 45
 
46 46
         // Fires before displaying payment form elements.
47
-        do_action( 'getpaid_payment_form_before_elements', $form );
47
+        do_action('getpaid_payment_form_before_elements', $form);
48 48
 
49 49
         // Display the elements.
50 50
         ?>
@@ -52,13 +52,13 @@  discard block
 block discarded – undo
52 52
             <div class="row">
53 53
                 <?php
54 54
 
55
-                    foreach ( $form->get_elements() as $element ) {
55
+                    foreach ($form->get_elements() as $element) {
56 56
 
57
-                        if ( isset( $element['type'] ) ) {
58
-                            $grid_class = esc_attr( getpaid_get_form_element_grid_class( $element ) );
57
+                        if (isset($element['type'])) {
58
+                            $grid_class = esc_attr(getpaid_get_form_element_grid_class($element));
59 59
                             echo "<div class='$grid_class'>";
60
-                            do_action( 'getpaid_payment_form_element', $element, $form );
61
-                            do_action( "getpaid_payment_form_element_{$element['type']}_template", $element, $form );
60
+                            do_action('getpaid_payment_form_element', $element, $form);
61
+                            do_action("getpaid_payment_form_element_{$element['type']}_template", $element, $form);
62 62
                             echo "</div>";
63 63
                         }
64 64
 
@@ -70,16 +70,16 @@  discard block
 block discarded – undo
70 70
 
71 71
         <?php
72 72
         // Fires after displaying payment form elements.
73
-        do_action( 'getpaid_payment_form_after_elements', $form );
73
+        do_action('getpaid_payment_form_after_elements', $form);
74 74
 
75 75
         echo "<div class='getpaid-payment-form-errors alert alert-danger d-none'></div>";
76 76
 
77
-        if ( wpinv_current_user_can_manage_invoicing() ) {
77
+        if (wpinv_current_user_can_manage_invoicing()) {
78 78
 
79 79
             edit_post_link(
80
-                __( 'Edit this form.', 'invoicing' ),
80
+                __('Edit this form.', 'invoicing'),
81 81
                 '<small class="form-text text-muted">',
82
-                '&nbsp;' . __( 'This is only visible to website administators.', 'invoicing' ) . '</small>',
82
+                '&nbsp;' . __('This is only visible to website administators.', 'invoicing') . '</small>',
83 83
                 $form->get_id(),
84 84
                 'text-danger'
85 85
             );
@@ -94,4 +94,4 @@  discard block
 block discarded – undo
94 94
 <?php
95 95
 
96 96
 // Fires after displaying a payment form.
97
-do_action( 'getpaid_after_payment_form', $form );
97
+do_action('getpaid_after_payment_form', $form);
Please login to merge, or discard this patch.
templates/payment-forms-admin/edit/pay_button.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -7,44 +7,44 @@
 block discarded – undo
7 7
  * @version 1.0.19
8 8
  */
9 9
 
10
-defined( 'ABSPATH' ) || exit;
10
+defined('ABSPATH') || exit;
11 11
 
12 12
 ?>
13 13
 
14 14
 <div class='form-group'>
15 15
     <label class="d-block">
16
-        <span><?php esc_html_e( 'Button Text', 'invoicing' ); ?></span>
16
+        <span><?php esc_html_e('Button Text', 'invoicing'); ?></span>
17 17
         <input v-model='active_form_element.label' class='form-control' type="text"/>
18
-        <small class="form-text text-muted"><?php _e( '%price% will be replaced by the total payable amount', 'invoicing' ); ?></small>
18
+        <small class="form-text text-muted"><?php _e('%price% will be replaced by the total payable amount', 'invoicing'); ?></small>
19 19
     </label>
20 20
 </div>
21 21
 
22 22
 <div class='form-group'>
23 23
     <label class="d-block">
24
-        <span><?php esc_html_e( 'Free Checkout Text', 'invoicing' ); ?></span>
24
+        <span><?php esc_html_e('Free Checkout Text', 'invoicing'); ?></span>
25 25
         <input v-model='active_form_element.free' class='form-control' type="text"/>
26
-        <small class="form-text text-muted"><?php _e( 'The text to display if the total payable amount is zero', 'invoicing' ); ?></small>
26
+        <small class="form-text text-muted"><?php _e('The text to display if the total payable amount is zero', 'invoicing'); ?></small>
27 27
     </label>
28 28
 </div>
29 29
 
30 30
 <div class='form-group'>
31 31
     <label class="d-block">
32
-        <span><?php esc_html_e( 'Help Text', 'invoicing' ); ?></span>
33
-        <textarea placeholder='<?php esc_attr_e( 'Add some help text for this field', 'invoicing' ); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
32
+        <span><?php esc_html_e('Help Text', 'invoicing'); ?></span>
33
+        <textarea placeholder='<?php esc_attr_e('Add some help text for this field', 'invoicing'); ?>' v-model='active_form_element.description' class='form-control' rows='3'></textarea>
34 34
     </label>
35 35
 </div>
36 36
 
37 37
 <div class='form-group'>
38
-    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e( 'Button Type', 'invoicing' ) ?></label>
38
+    <label :for="active_form_element.id + '_edit_type'"><?php esc_html_e('Button Type', 'invoicing') ?></label>
39 39
     <select class='form-control custom-select' :id="active_form_element.id + '_edit_type'" v-model='active_form_element.class'>
40
-        <option value='btn-primary'><?php esc_html_e( 'Primary', 'invoicing' ); ?></option>
41
-        <option value='btn-secondary'><?php esc_html_e( 'Secondary', 'invoicing' ); ?></option>
42
-        <option value='btn-success'><?php esc_html_e( 'Success', 'invoicing' ); ?></option>
43
-        <option value='btn-danger'><?php esc_html_e( 'Danger', 'invoicing' ); ?></option>
44
-        <option value='btn-warning'><?php esc_html_e( 'Warning', 'invoicing' ); ?></option>
45
-        <option value='btn-info'><?php esc_html_e( 'Info', 'invoicing' ); ?></option>
46
-        <option value='btn-light'><?php esc_html_e( 'Light', 'invoicing' ); ?></option>
47
-        <option value='btn-dark'><?php esc_html_e( 'Dark', 'invoicing' ); ?></option>
48
-        <option value='btn-link'><?php esc_html_e( 'Link', 'invoicing' ); ?></option>
40
+        <option value='btn-primary'><?php esc_html_e('Primary', 'invoicing'); ?></option>
41
+        <option value='btn-secondary'><?php esc_html_e('Secondary', 'invoicing'); ?></option>
42
+        <option value='btn-success'><?php esc_html_e('Success', 'invoicing'); ?></option>
43
+        <option value='btn-danger'><?php esc_html_e('Danger', 'invoicing'); ?></option>
44
+        <option value='btn-warning'><?php esc_html_e('Warning', 'invoicing'); ?></option>
45
+        <option value='btn-info'><?php esc_html_e('Info', 'invoicing'); ?></option>
46
+        <option value='btn-light'><?php esc_html_e('Light', 'invoicing'); ?></option>
47
+        <option value='btn-dark'><?php esc_html_e('Dark', 'invoicing'); ?></option>
48
+        <option value='btn-link'><?php esc_html_e('Link', 'invoicing'); ?></option>
49 49
     </select>
50 50
 </div>
Please login to merge, or discard this patch.
includes/wpinv-discount-functions.php 1 patch
Spacing   +33 added lines, -33 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
  * Returns an array of discount type.
@@ -17,8 +17,8 @@  discard block
 block discarded – undo
17 17
     return apply_filters(
18 18
         'wpinv_discount_types',
19 19
         array(
20
-            'percent'   => __( 'Percentage', 'invoicing' ),
21
-            'flat'     => __( 'Flat Amount', 'invoicing' ),
20
+            'percent'   => __('Percentage', 'invoicing'),
21
+            'flat'     => __('Flat Amount', 'invoicing'),
22 22
         )
23 23
     );
24 24
 }
@@ -28,46 +28,46 @@  discard block
 block discarded – undo
28 28
  * 
29 29
  * @return string
30 30
  */
31
-function wpinv_get_discount_type_name( $type = '' ) {
31
+function wpinv_get_discount_type_name($type = '') {
32 32
     $types = wpinv_get_discount_types();
33
-    return isset( $types[ $type ] ) ? $types[ $type ] : $type;
33
+    return isset($types[$type]) ? $types[$type] : $type;
34 34
 }
35 35
 
36 36
 /**
37 37
  * Deletes a discount via the admin page.
38 38
  * 
39 39
  */
40
-function wpinv_delete_discount( $data ) {
40
+function wpinv_delete_discount($data) {
41 41
 
42
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
43
-    $discount->delete( true );
42
+    $discount = new WPInv_Discount(absint($data['discount']));
43
+    $discount->delete(true);
44 44
 
45 45
 }
46
-add_action( 'getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount' );
46
+add_action('getpaid_authenticated_admin_action_delete_discount', 'wpinv_delete_discount');
47 47
 
48 48
 /**
49 49
  * Deactivates a discount via the admin page.
50 50
  */
51
-function wpinv_activate_discount( $data ) {
51
+function wpinv_activate_discount($data) {
52 52
 
53
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
54
-    $discount->set_status( 'publish' );
53
+    $discount = new WPInv_Discount(absint($data['discount']));
54
+    $discount->set_status('publish');
55 55
     $discount->save();
56 56
 
57 57
 }
58
-add_action( 'getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount' );
58
+add_action('getpaid_authenticated_admin_action_activate_discount', 'wpinv_activate_discount');
59 59
 
60 60
 /**
61 61
  * Activates a discount via the admin page.
62 62
  */
63
-function wpinv_deactivate_discount( $data ) {
63
+function wpinv_deactivate_discount($data) {
64 64
 
65
-    $discount = new WPInv_Discount( absint( $data['discount'] ) );
66
-    $discount->set_status( 'pending' );
65
+    $discount = new WPInv_Discount(absint($data['discount']));
66
+    $discount->set_status('pending');
67 67
     $discount->save();
68 68
 
69 69
 }
70
-add_action( 'getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount' );
70
+add_action('getpaid_authenticated_admin_action_deactivate_discount', 'wpinv_deactivate_discount');
71 71
 
72 72
 /**
73 73
  * Fetches a discount object.
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
  * @since 1.0.15
77 77
  * @return WPInv_Discount
78 78
  */
79
-function wpinv_get_discount( $discount ) {
80
-    return new WPInv_Discount( $discount );
79
+function wpinv_get_discount($discount) {
80
+    return new WPInv_Discount($discount);
81 81
 }
82 82
 
83 83
 /**
@@ -87,8 +87,8 @@  discard block
 block discarded – undo
87 87
  * @since 1.0.15
88 88
  * @return WPInv_Discount
89 89
  */
90
-function wpinv_get_discount_obj( $discount = 0 ) {
91
-    return new WPInv_Discount( $discount );
90
+function wpinv_get_discount_obj($discount = 0) {
91
+    return new WPInv_Discount($discount);
92 92
 }
93 93
 
94 94
 /**
@@ -98,10 +98,10 @@  discard block
 block discarded – undo
98 98
  * @param string|int $value The field value
99 99
  * @return bool|WPInv_Discount
100 100
  */
101
-function wpinv_get_discount_by( $deprecated = null, $value = '' ) {
102
-    $discount = new WPInv_Discount( $value );
101
+function wpinv_get_discount_by($deprecated = null, $value = '') {
102
+    $discount = new WPInv_Discount($value);
103 103
 
104
-    if ( $discount->get_id() != 0 ) {
104
+    if ($discount->get_id() != 0) {
105 105
         return $discount;
106 106
     }
107 107
 
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
 function wpinv_get_discount_statuses() {
117 117
 
118 118
     return array(
119
-        'expired'  => __( 'Expired', 'invoicing' ),
120
-        'publish'  => __( 'Active', 'invoicing' ),
121
-        'inactive' => __( 'Inactive', 'invoicing' ),
119
+        'expired'  => __('Expired', 'invoicing'),
120
+        'publish'  => __('Active', 'invoicing'),
121
+        'inactive' => __('Inactive', 'invoicing'),
122 122
     );
123 123
 
124 124
 }
@@ -126,9 +126,9 @@  discard block
 block discarded – undo
126 126
 /**
127 127
  * Retrieves an invoice status label.
128 128
  */
129
-function wpinv_discount_status( $status ) {
129
+function wpinv_discount_status($status) {
130 130
     $statuses = wpinv_get_discount_statuses();
131
-    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : __( 'Inactive', 'invoicing' );
131
+    return isset($statuses[$status]) ? $statuses[$status] : __('Inactive', 'invoicing');
132 132
 }
133 133
 
134 134
 /**
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
  * @param int|array|string|WPInv_Discount $code discount data, object, ID or code.
139 139
  * @return bool
140 140
  */
141
-function wpinv_discount_is_recurring( $discount = 0, $code = 0 ) {
141
+function wpinv_discount_is_recurring($discount = 0, $code = 0) {
142 142
 
143
-    if( ! empty( $discount ) ) {
144
-        $discount    = wpinv_get_discount_obj( $discount );
143
+    if (!empty($discount)) {
144
+        $discount    = wpinv_get_discount_obj($discount);
145 145
     } else {
146
-        $discount    = wpinv_get_discount_obj( $code );
146
+        $discount    = wpinv_get_discount_obj($code);
147 147
     }
148 148
 
149 149
     return $discount->get_is_recurring();
Please login to merge, or discard this patch.