Passed
Push — master ( 1d60eb...03dff3 )
by Stiofan
06:44 queued 03:02
created
includes/gateways/paypal.php 2 patches
Indentation   +255 added lines, -255 removed lines patch added patch discarded remove patch
@@ -218,262 +218,262 @@  discard block
 block discarded – undo
218 218
 add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
219 219
 
220 220
 function wpinv_process_paypal_ipn() {
221
-	// Check the request method is POST
222
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
-		return;
224
-	}
225
-
226
-	// Set initial post data to empty string
227
-	$post_data = '';
228
-
229
-	// Fallback just in case post_max_size is lower than needed
230
-	if ( ini_get( 'allow_url_fopen' ) ) {
231
-		$post_data = file_get_contents( 'php://input' );
232
-	} else {
233
-		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
234
-		ini_set( 'post_max_size', '12M' );
235
-	}
236
-	// Start the encoded data collection with notification command
237
-	$encoded_data = 'cmd=_notify-validate';
238
-
239
-	// Get current arg separator
240
-	$arg_separator = wpinv_get_php_arg_separator_output();
241
-
242
-	// Verify there is a post_data
243
-	if ( $post_data || strlen( $post_data ) > 0 ) {
244
-		// Append the data
245
-		$encoded_data .= $arg_separator.$post_data;
246
-	} else {
247
-		// Check if POST is empty
248
-		if ( empty( $_POST ) ) {
249
-			// Nothing to do
250
-			return;
251
-		} else {
252
-			// Loop through each POST
253
-			foreach ( $_POST as $key => $value ) {
254
-				// Encode the value and append the data
255
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
-			}
257
-		}
258
-	}
259
-
260
-	// Convert collected post data to an array
261
-	parse_str( $encoded_data, $encoded_data_array );
262
-
263
-	foreach ( $encoded_data_array as $key => $value ) {
264
-		if ( false !== strpos( $key, 'amp;' ) ) {
265
-			$new_key = str_replace( '&', '&', $key );
266
-			$new_key = str_replace( 'amp;', '&' , $new_key );
267
-
268
-			unset( $encoded_data_array[ $key ] );
269
-			$encoded_data_array[ $new_key ] = $value;
270
-		}
271
-	}
272
-
273
-	// Get the PayPal redirect uri
274
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
275
-
276
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
-		// Validate the IPN
278
-
279
-		$remote_post_vars      = array(
280
-			'method'           => 'POST',
281
-			'timeout'          => 45,
282
-			'redirection'      => 5,
283
-			'httpversion'      => '1.1',
284
-			'blocking'         => true,
285
-			'headers'          => array(
286
-				'host'         => 'www.paypal.com',
287
-				'connection'   => 'close',
288
-				'content-type' => 'application/x-www-form-urlencoded',
289
-				'post'         => '/cgi-bin/webscr HTTP/1.1',
290
-
291
-			),
292
-			'sslverify'        => false,
293
-			'body'             => $encoded_data_array
294
-		);
295
-
296
-		// Get response
297
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
-
299
-		if ( is_wp_error( $api_response ) ) {
300
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
301
-			return; // Something went wrong
302
-		}
303
-
304
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
305
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
306
-			return; // Response not okay
307
-		}
308
-	}
309
-
310
-	// Check if $post_data_array has been populated
311
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
-		return;
313
-
314
-	$defaults = array(
315
-		'txn_type'       => '',
316
-		'payment_status' => ''
317
-	);
318
-
319
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
-
321
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
221
+    // Check the request method is POST
222
+    if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
+        return;
224
+    }
225
+
226
+    // Set initial post data to empty string
227
+    $post_data = '';
228
+
229
+    // Fallback just in case post_max_size is lower than needed
230
+    if ( ini_get( 'allow_url_fopen' ) ) {
231
+        $post_data = file_get_contents( 'php://input' );
232
+    } else {
233
+        // If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
234
+        ini_set( 'post_max_size', '12M' );
235
+    }
236
+    // Start the encoded data collection with notification command
237
+    $encoded_data = 'cmd=_notify-validate';
238
+
239
+    // Get current arg separator
240
+    $arg_separator = wpinv_get_php_arg_separator_output();
241
+
242
+    // Verify there is a post_data
243
+    if ( $post_data || strlen( $post_data ) > 0 ) {
244
+        // Append the data
245
+        $encoded_data .= $arg_separator.$post_data;
246
+    } else {
247
+        // Check if POST is empty
248
+        if ( empty( $_POST ) ) {
249
+            // Nothing to do
250
+            return;
251
+        } else {
252
+            // Loop through each POST
253
+            foreach ( $_POST as $key => $value ) {
254
+                // Encode the value and append the data
255
+                $encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
+            }
257
+        }
258
+    }
259
+
260
+    // Convert collected post data to an array
261
+    parse_str( $encoded_data, $encoded_data_array );
262
+
263
+    foreach ( $encoded_data_array as $key => $value ) {
264
+        if ( false !== strpos( $key, 'amp;' ) ) {
265
+            $new_key = str_replace( '&', '&', $key );
266
+            $new_key = str_replace( 'amp;', '&' , $new_key );
267
+
268
+            unset( $encoded_data_array[ $key ] );
269
+            $encoded_data_array[ $new_key ] = $value;
270
+        }
271
+    }
272
+
273
+    // Get the PayPal redirect uri
274
+    $paypal_redirect = wpinv_get_paypal_redirect( true );
275
+
276
+    if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
+        // Validate the IPN
278
+
279
+        $remote_post_vars      = array(
280
+            'method'           => 'POST',
281
+            'timeout'          => 45,
282
+            'redirection'      => 5,
283
+            'httpversion'      => '1.1',
284
+            'blocking'         => true,
285
+            'headers'          => array(
286
+                'host'         => 'www.paypal.com',
287
+                'connection'   => 'close',
288
+                'content-type' => 'application/x-www-form-urlencoded',
289
+                'post'         => '/cgi-bin/webscr HTTP/1.1',
290
+
291
+            ),
292
+            'sslverify'        => false,
293
+            'body'             => $encoded_data_array
294
+        );
295
+
296
+        // Get response
297
+        $api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
+
299
+        if ( is_wp_error( $api_response ) ) {
300
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
301
+            return; // Something went wrong
302
+        }
303
+
304
+        if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
305
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
306
+            return; // Response not okay
307
+        }
308
+    }
309
+
310
+    // Check if $post_data_array has been populated
311
+    if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
+        return;
313
+
314
+    $defaults = array(
315
+        'txn_type'       => '',
316
+        'payment_status' => ''
317
+    );
318
+
319
+    $encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
+
321
+    $invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
322 322
     
323
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
324
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
325
-
326
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
-		// Allow PayPal IPN types to be processed separately
328
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
-	} else {
330
-		// Fallback to web accept just in case the txn_type isn't present
331
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
-	}
333
-	exit;
323
+    wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
324
+    wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
325
+
326
+    if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
+        // Allow PayPal IPN types to be processed separately
328
+        do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
+    } else {
330
+        // Fallback to web accept just in case the txn_type isn't present
331
+        do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
+    }
333
+    exit;
334 334
 }
335 335
 add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
336 336
 
337 337
 function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
338
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
339
-		return;
340
-	}
341
-
342
-	if( empty( $invoice_id ) ) {
343
-		return;
344
-	}
345
-
346
-	// Collect payment details
347
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
-	$paypal_amount  = $data['mc_gross'];
349
-	$payment_status = strtolower( $data['payment_status'] );
350
-	$currency_code  = strtolower( $data['mc_currency'] );
351
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
352
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
353
-
354
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
-		return; // this isn't a PayPal standard IPN
356
-	}
357
-
358
-	// Verify payment recipient
359
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
360
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
361
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
362
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
363
-		return;
364
-	}
365
-
366
-	// Verify payment currency
367
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
371
-		return;
372
-	}
373
-
374
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
-		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
376
-		// No email associated with purchase, so store from PayPal
377
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
-
379
-		// Setup and store the customer's details
380
-		$user_info = array(
381
-			'user_id'    => '-1',
382
-			'email'      => sanitize_text_field( $data['payer_email'] ),
383
-			'first_name' => sanitize_text_field( $data['first_name'] ),
384
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
385
-			'discount'   => '',
386
-		);
387
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
388
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
389
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
390
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
391
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
392
-
393
-		$payment_meta['user_info'] = $user_info;
394
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
-	}
396
-
397
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
-		// Process a refund
399
-		wpinv_process_paypal_refund( $data, $invoice_id );
400
-	} else {
401
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
402
-			return; // Only paid payments once
403
-		}
404
-
405
-		// Retrieve the total purchase amount (before PayPal)
406
-		$payment_amount = wpinv_payment_total( $invoice_id );
407
-
408
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
-			// The prices don't match
410
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
411
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
412
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
413
-			return;
414
-		}
415
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
-			// Purchase keys don't match
417
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
420
-			return;
421
-		}
422
-
423
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
425
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
426
-			wpinv_update_payment_status( $invoice_id, 'publish' );
427
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
428
-			// Look for possible pending reasons, such as an echeck
429
-			$note = '';
430
-
431
-			switch( strtolower( $data['pending_reason'] ) ) {
432
-				case 'echeck' :
433
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
-					break;
338
+    if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
339
+        return;
340
+    }
341
+
342
+    if( empty( $invoice_id ) ) {
343
+        return;
344
+    }
345
+
346
+    // Collect payment details
347
+    $purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
+    $paypal_amount  = $data['mc_gross'];
349
+    $payment_status = strtolower( $data['payment_status'] );
350
+    $currency_code  = strtolower( $data['mc_currency'] );
351
+    $business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
352
+    $payment_meta   = wpinv_get_invoice_meta( $invoice_id );
353
+
354
+    if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
+        return; // this isn't a PayPal standard IPN
356
+    }
357
+
358
+    // Verify payment recipient
359
+    if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
360
+        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
361
+        wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
362
+        wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
363
+        return;
364
+    }
365
+
366
+    // Verify payment currency
367
+    if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
368
+        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
369
+        wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
370
+        wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
371
+        return;
372
+    }
373
+
374
+    if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
+        // This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
376
+        // No email associated with purchase, so store from PayPal
377
+        wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
+
379
+        // Setup and store the customer's details
380
+        $user_info = array(
381
+            'user_id'    => '-1',
382
+            'email'      => sanitize_text_field( $data['payer_email'] ),
383
+            'first_name' => sanitize_text_field( $data['first_name'] ),
384
+            'last_name'  => sanitize_text_field( $data['last_name'] ),
385
+            'discount'   => '',
386
+        );
387
+        $user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
388
+        $user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
389
+        $user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
390
+        $user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
391
+        $user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
392
+
393
+        $payment_meta['user_info'] = $user_info;
394
+        wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
+    }
396
+
397
+    if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
+        // Process a refund
399
+        wpinv_process_paypal_refund( $data, $invoice_id );
400
+    } else {
401
+        if ( get_post_status( $invoice_id ) == 'publish' ) {
402
+            return; // Only paid payments once
403
+        }
404
+
405
+        // Retrieve the total purchase amount (before PayPal)
406
+        $payment_amount = wpinv_payment_total( $invoice_id );
407
+
408
+        if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
+            // The prices don't match
410
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
411
+            wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
412
+            wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
413
+            return;
414
+        }
415
+        if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
+            // Purchase keys don't match
417
+            wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
418
+            wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
419
+            wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
420
+            return;
421
+        }
422
+
423
+        if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
424
+            wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
425
+            wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
426
+            wpinv_update_payment_status( $invoice_id, 'publish' );
427
+        } else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
428
+            // Look for possible pending reasons, such as an echeck
429
+            $note = '';
430
+
431
+            switch( strtolower( $data['pending_reason'] ) ) {
432
+                case 'echeck' :
433
+                    $note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
+                    break;
435 435
 				
436 436
                 case 'address' :
437
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
-					break;
437
+                    $note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
+                    break;
439 439
 				
440 440
                 case 'intl' :
441
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
-					break;
441
+                    $note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
+                    break;
443 443
 				
444 444
                 case 'multi-currency' :
445
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
-					break;
445
+                    $note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
+                    break;
447 447
 				
448 448
                 case 'paymentreview' :
449 449
                 case 'regulatory_review' :
450
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
-					break;
450
+                    $note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
+                    break;
452 452
 				
453 453
                 case 'unilateral' :
454
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
-					break;
454
+                    $note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
+                    break;
456 456
 				
457 457
                 case 'upgrade' :
458
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
-					break;
458
+                    $note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
+                    break;
460 460
 				
461 461
                 case 'verify' :
462
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
-					break;
464
-
465
-				case 'other' :
466
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
-					break;
468
-			}
469
-
470
-			if ( ! empty( $note ) ) {
471
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
472
-			}
473
-		} else {
474
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
-		}
476
-	}
462
+                    $note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
+                    break;
464
+
465
+                case 'other' :
466
+                    $note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
+                    break;
468
+            }
469
+
470
+            if ( ! empty( $note ) ) {
471
+                wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
472
+            }
473
+        } else {
474
+            wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
+        }
476
+    }
477 477
 }
478 478
 add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
479 479
 
@@ -661,34 +661,34 @@  discard block
 block discarded – undo
661 661
 }
662 662
 
663 663
 function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
664
-	// Collect payment details
664
+    // Collect payment details
665 665
 
666
-	if( empty( $invoice_id ) ) {
667
-		return;
668
-	}
666
+    if( empty( $invoice_id ) ) {
667
+        return;
668
+    }
669 669
 
670
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
671
-		return; // Only refund payments once
672
-	}
670
+    if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
671
+        return; // Only refund payments once
672
+    }
673 673
 
674
-	$payment_amount = wpinv_payment_total( $invoice_id );
675
-	$refund_amount  = $data['mc_gross'] * -1;
674
+    $payment_amount = wpinv_payment_total( $invoice_id );
675
+    $refund_amount  = $data['mc_gross'] * -1;
676 676
 
677
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
677
+    do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
678 678
 
679
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
680
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
679
+    if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
680
+        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
681 681
 
682
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
682
+        do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
683 683
 
684
-		return; // This is a partial refund
685
-	}
684
+        return; // This is a partial refund
685
+    }
686 686
 
687
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
688
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
689
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
687
+    wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
688
+    wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
689
+    wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
690 690
 
691
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
691
+    do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
692 692
 }
693 693
 
694 694
 function wpinv_get_paypal_redirect( $ssl_check = false ) {
Please login to merge, or discard this patch.
Spacing   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -1,13 +1,13 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 // Exit if accessed directly
3
-if ( ! defined( 'ABSPATH' ) ) exit;
3
+if (!defined('ABSPATH')) exit;
4 4
 
5
-add_action( 'wpinv_paypal_cc_form', '__return_false' );
6
-add_filter( 'wpinv_paypal_support_subscription', '__return_true' );
5
+add_action('wpinv_paypal_cc_form', '__return_false');
6
+add_filter('wpinv_paypal_support_subscription', '__return_true');
7 7
 
8
-function wpinv_process_paypal_payment( $purchase_data ) {
9
-    if( ! wp_verify_nonce( $purchase_data['gateway_nonce'], 'wpi-gateway' ) ) {
10
-        wp_die( __( 'Nonce verification has failed', 'invoicing' ), __( 'Error', 'invoicing' ), array( 'response' => 403 ) );
8
+function wpinv_process_paypal_payment($purchase_data) {
9
+    if (!wp_verify_nonce($purchase_data['gateway_nonce'], 'wpi-gateway')) {
10
+        wp_die(__('Nonce verification has failed', 'invoicing'), __('Error', 'invoicing'), array('response' => 403));
11 11
     }
12 12
 
13 13
     // Collect payment data
@@ -25,30 +25,30 @@  discard block
 block discarded – undo
25 25
     );
26 26
 
27 27
     // Record the pending payment
28
-    $invoice = wpinv_get_invoice( $purchase_data['invoice_id'] );
28
+    $invoice = wpinv_get_invoice($purchase_data['invoice_id']);
29 29
 
30 30
     // Check payment
31
-    if ( ! $invoice ) {
31
+    if (!$invoice) {
32 32
         // Record the error
33
-        wpinv_record_gateway_error( __( 'Payment Error', 'invoicing' ), sprintf( __( 'Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing' ), json_encode( $payment_data ) ), $invoice );
33
+        wpinv_record_gateway_error(__('Payment Error', 'invoicing'), sprintf(__('Payment creation failed before sending buyer to PayPal. Payment data: %s', 'invoicing'), json_encode($payment_data)), $invoice);
34 34
         // Problems? send back
35
-        wpinv_send_back_to_checkout( '?payment-mode=' . $purchase_data['post_data']['wpi-gateway'] );
35
+        wpinv_send_back_to_checkout('?payment-mode=' . $purchase_data['post_data']['wpi-gateway']);
36 36
     } else {
37 37
         // Only send to PayPal if the pending payment is created successfully
38
-        $listener_url = wpinv_get_ipn_url( 'paypal' );
38
+        $listener_url = wpinv_get_ipn_url('paypal');
39 39
 
40 40
         // Get the success url
41
-        $return_url = add_query_arg( array(
41
+        $return_url = add_query_arg(array(
42 42
                 'payment-confirm' => 'paypal',
43 43
                 'invoice-id' => $invoice->ID
44
-            ), get_permalink( wpinv_get_option( 'success_page', false ) ) );
44
+            ), get_permalink(wpinv_get_option('success_page', false)));
45 45
 
46 46
         // Get the PayPal redirect uri
47
-        $paypal_redirect = trailingslashit( wpinv_get_paypal_redirect() ) . '?';
47
+        $paypal_redirect = trailingslashit(wpinv_get_paypal_redirect()) . '?';
48 48
 
49 49
         // Setup PayPal arguments
50 50
         $paypal_args = array(
51
-            'business'      => wpinv_get_option( 'paypal_email', false ),
51
+            'business'      => wpinv_get_option('paypal_email', false),
52 52
             'email'         => $invoice->get_email(),
53 53
             'first_name'    => $invoice->get_first_name(),
54 54
             'last_name'     => $invoice->get_last_name(),
@@ -57,16 +57,16 @@  discard block
 block discarded – undo
57 57
             'shipping'      => '0',
58 58
             'no_note'       => '1',
59 59
             'currency_code' => wpinv_get_currency(),
60
-            'charset'       => get_bloginfo( 'charset' ),
60
+            'charset'       => get_bloginfo('charset'),
61 61
             'custom'        => $invoice->ID,
62 62
             'rm'            => '2',
63 63
             'return'        => $return_url,
64
-            'cancel_return' => wpinv_get_failed_transaction_uri( '?invoice-id=' . $invoice->ID ),
64
+            'cancel_return' => wpinv_get_failed_transaction_uri('?invoice-id=' . $invoice->ID),
65 65
             'notify_url'    => $listener_url,
66
-            'cbt'           => get_bloginfo( 'name' ),
66
+            'cbt'           => get_bloginfo('name'),
67 67
             'bn'            => 'WPInvoicing_SP',
68 68
             'lc'            => 'US', // this will force paypal site to english
69
-            'landing_page'  => apply_filters( 'wpinv_paypal_standard_landing_page', 'billing', $invoice ), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account.
69
+            'landing_page'  => apply_filters('wpinv_paypal_standard_landing_page', 'billing', $invoice), // 'login' or 'billing'. login - PayPal account login, billing - Non-PayPal account.
70 70
         );
71 71
 
72 72
         $paypal_args['address1'] = $invoice->get_address();
@@ -80,57 +80,57 @@  discard block
 block discarded – undo
80 80
             'upload' => '1'
81 81
         );
82 82
 
83
-        $paypal_args = array_merge( $paypal_extra_args, $paypal_args );
83
+        $paypal_args = array_merge($paypal_extra_args, $paypal_args);
84 84
 
85 85
         // Add cart items
86 86
         $i = 1;
87
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
88
-            foreach ( $purchase_data['cart_details'] as $item ) {
87
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
88
+            foreach ($purchase_data['cart_details'] as $item) {
89 89
                 $item['quantity'] = $item['quantity'] > 0 ? $item['quantity'] : 1;
90
-                $item_amount = wpinv_sanitize_amount( $item['subtotal'] / $item['quantity'], 2 );
90
+                $item_amount = wpinv_sanitize_amount($item['subtotal'] / $item['quantity'], 2);
91 91
 
92
-                if ( $item_amount <= 0 ) {
92
+                if ($item_amount <= 0) {
93 93
                     $item_amount = 0;
94 94
                 }
95 95
 
96
-                $paypal_args['item_number_' . $i ]      = $item['id'];
97
-                $paypal_args['item_name_' . $i ]        = stripslashes_deep( html_entity_decode( wpinv_get_cart_item_name( $item ), ENT_COMPAT, 'UTF-8' ) );
98
-                $paypal_args['quantity_' . $i ]         = $item['quantity'];
99
-                $paypal_args['amount_' . $i ]           = $item_amount;
100
-                $paypal_args['discount_amount_' . $i ]  = wpinv_sanitize_amount( $item['discount'], 2 );
96
+                $paypal_args['item_number_' . $i]      = $item['id'];
97
+                $paypal_args['item_name_' . $i]        = stripslashes_deep(html_entity_decode(wpinv_get_cart_item_name($item), ENT_COMPAT, 'UTF-8'));
98
+                $paypal_args['quantity_' . $i]         = $item['quantity'];
99
+                $paypal_args['amount_' . $i]           = $item_amount;
100
+                $paypal_args['discount_amount_' . $i]  = wpinv_sanitize_amount($item['discount'], 2);
101 101
 
102 102
                 $i++;
103 103
             }
104 104
         }
105 105
 
106 106
         // Add taxes to the cart
107
-        if ( wpinv_use_taxes() ) {
108
-            $paypal_args['tax_cart'] = wpinv_sanitize_amount( (float)$invoice->get_tax(), 2 );
107
+        if (wpinv_use_taxes()) {
108
+            $paypal_args['tax_cart'] = wpinv_sanitize_amount((float)$invoice->get_tax(), 2);
109 109
         }
110 110
 
111
-        $paypal_args = apply_filters( 'wpinv_paypal_args', $paypal_args, $purchase_data, $invoice );
111
+        $paypal_args = apply_filters('wpinv_paypal_args', $paypal_args, $purchase_data, $invoice);
112 112
 
113 113
         // Build query
114
-        $paypal_redirect .= http_build_query( $paypal_args );
114
+        $paypal_redirect .= http_build_query($paypal_args);
115 115
 
116 116
         // Fix for some sites that encode the entities
117
-        $paypal_redirect = str_replace( '&amp;', '&', $paypal_redirect );
117
+        $paypal_redirect = str_replace('&amp;', '&', $paypal_redirect);
118 118
 
119 119
         // Get rid of cart contents
120 120
         wpinv_empty_cart();
121 121
         
122 122
         // Redirect to PayPal
123
-        wp_redirect( $paypal_redirect );
123
+        wp_redirect($paypal_redirect);
124 124
         exit;
125 125
     }
126 126
 }
127
-add_action( 'wpinv_gateway_paypal', 'wpinv_process_paypal_payment' );
127
+add_action('wpinv_gateway_paypal', 'wpinv_process_paypal_payment');
128 128
 
129
-function wpinv_get_paypal_recurring_args( $paypal_args, $purchase_data, $invoice ) {
130
-    if ( $invoice->is_recurring() && $item_id = $invoice->get_recurring() ) {
131
-        $item   = new WPInv_Item( $item_id );
129
+function wpinv_get_paypal_recurring_args($paypal_args, $purchase_data, $invoice) {
130
+    if ($invoice->is_recurring() && $item_id = $invoice->get_recurring()) {
131
+        $item = new WPInv_Item($item_id);
132 132
         
133
-        if ( empty( $item ) ) {
133
+        if (empty($item)) {
134 134
             return $paypal_args;
135 135
         }
136 136
 
@@ -138,25 +138,25 @@  discard block
 block discarded – undo
138 138
         $interval           = $item->get_recurring_interval();
139 139
         $bill_times         = (int)$item->get_recurring_limit();
140 140
         
141
-        $initial_amount     = wpinv_sanitize_amount( $invoice->get_total(), 2 );
142
-        $recurring_amount   = wpinv_sanitize_amount( $invoice->get_recurring_details( 'total' ), 2 );
141
+        $initial_amount     = wpinv_sanitize_amount($invoice->get_total(), 2);
142
+        $recurring_amount   = wpinv_sanitize_amount($invoice->get_recurring_details('total'), 2);
143 143
         
144 144
         $paypal_args['cmd'] = '_xclick-subscriptions';
145 145
         $paypal_args['sra'] = '1';
146 146
         $paypal_args['src'] = '1';
147 147
         
148 148
         // Set item description
149
-        $item_name                  = sprintf( '[%s] %s', $invoice->get_number(), wpinv_get_cart_item_name( array( 'id' => $item->ID ) ) );
150
-        $paypal_args['item_name']   = stripslashes_deep( html_entity_decode( $item_name, ENT_COMPAT, 'UTF-8' ) );
149
+        $item_name                  = sprintf('[%s] %s', $invoice->get_number(), wpinv_get_cart_item_name(array('id' => $item->ID)));
150
+        $paypal_args['item_name']   = stripslashes_deep(html_entity_decode($item_name, ENT_COMPAT, 'UTF-8'));
151 151
         
152
-        if ( $invoice->is_free_trial() && $item->has_free_trial() ) {
152
+        if ($invoice->is_free_trial() && $item->has_free_trial()) {
153 153
             $paypal_args['a1']  = $initial_amount;
154 154
             $paypal_args['p1']  = $item->get_trial_interval();
155 155
             $paypal_args['t1']  = $item->get_trial_period();
156 156
             
157 157
             // Set the recurring amount
158 158
             $paypal_args['a3']  = $recurring_amount;
159
-        } else if ( $initial_amount != $recurring_amount && $bill_times != 1 ) {
159
+        } else if ($initial_amount != $recurring_amount && $bill_times != 1) {
160 160
             $paypal_args['a1']  = $initial_amount;
161 161
             $paypal_args['p1']  = $interval;
162 162
             $paypal_args['t1']  = $period;
@@ -164,63 +164,63 @@  discard block
 block discarded – undo
164 164
             // Set the recurring amount
165 165
             $paypal_args['a3']  = $recurring_amount;
166 166
             
167
-            if ( $bill_times > 1 ) {
167
+            if ($bill_times > 1) {
168 168
                 $bill_times--;
169 169
             }
170 170
         } else {
171
-            $paypal_args['a3']  = $initial_amount;
171
+            $paypal_args['a3'] = $initial_amount;
172 172
         }
173 173
         
174 174
         $paypal_args['p3']  = $interval;
175 175
         $paypal_args['t3']  = $period;
176 176
         
177
-        if ( $bill_times > 1 ) {
177
+        if ($bill_times > 1) {
178 178
             // Make sure it's not over the max of 52
179
-            $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
179
+            $paypal_args['srt'] = ($bill_times <= 52 ? absint($bill_times) : 52);
180 180
         }
181 181
                 
182 182
         // Remove cart items
183 183
         $i = 1;
184
-        if( is_array( $purchase_data['cart_details'] ) && ! empty( $purchase_data['cart_details'] ) ) {
185
-            foreach ( $purchase_data['cart_details'] as $item ) {                
186
-                if ( isset( $paypal_args['item_number_' . $i] ) ) {
187
-                    unset( $paypal_args['item_number_' . $i] );
184
+        if (is_array($purchase_data['cart_details']) && !empty($purchase_data['cart_details'])) {
185
+            foreach ($purchase_data['cart_details'] as $item) {                
186
+                if (isset($paypal_args['item_number_' . $i])) {
187
+                    unset($paypal_args['item_number_' . $i]);
188 188
                 }
189
-                if ( isset( $paypal_args['item_name_' . $i] ) ) {
190
-                    unset( $paypal_args['item_name_' . $i] );
189
+                if (isset($paypal_args['item_name_' . $i])) {
190
+                    unset($paypal_args['item_name_' . $i]);
191 191
                 }
192
-                if ( isset( $paypal_args['quantity_' . $i] ) ) {
193
-                    unset( $paypal_args['quantity_' . $i] );
192
+                if (isset($paypal_args['quantity_' . $i])) {
193
+                    unset($paypal_args['quantity_' . $i]);
194 194
                 }
195
-                if ( isset( $paypal_args['amount_' . $i] ) ) {
196
-                    unset( $paypal_args['amount_' . $i] );
195
+                if (isset($paypal_args['amount_' . $i])) {
196
+                    unset($paypal_args['amount_' . $i]);
197 197
                 }
198
-                if ( isset( $paypal_args['discount_amount_' . $i] ) ) {
199
-                    unset( $paypal_args['discount_amount_' . $i] );
198
+                if (isset($paypal_args['discount_amount_' . $i])) {
199
+                    unset($paypal_args['discount_amount_' . $i]);
200 200
                 }
201 201
 
202 202
                 $i++;
203 203
             }
204 204
         }
205 205
         
206
-        if ( isset( $paypal_args['tax_cart'] ) ) {
207
-            unset( $paypal_args['tax_cart'] );
206
+        if (isset($paypal_args['tax_cart'])) {
207
+            unset($paypal_args['tax_cart']);
208 208
         }
209 209
                 
210
-        if ( isset( $paypal_args['upload'] ) ) {
211
-            unset( $paypal_args['upload'] );
210
+        if (isset($paypal_args['upload'])) {
211
+            unset($paypal_args['upload']);
212 212
         }
213 213
         
214
-        $paypal_args = apply_filters( 'wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice );
214
+        $paypal_args = apply_filters('wpinv_paypal_recurring_args', $paypal_args, $purchase_data, $invoice);
215 215
     }
216 216
     
217 217
     return $paypal_args;
218 218
 }
219
-add_filter( 'wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3 );
219
+add_filter('wpinv_paypal_args', 'wpinv_get_paypal_recurring_args', 10, 3);
220 220
 
221 221
 function wpinv_process_paypal_ipn() {
222 222
 	// Check the request method is POST
223
-	if ( isset( $_SERVER['REQUEST_METHOD'] ) && $_SERVER['REQUEST_METHOD'] != 'POST' ) {
223
+	if (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] != 'POST') {
224 224
 		return;
225 225
 	}
226 226
 
@@ -228,11 +228,11 @@  discard block
 block discarded – undo
228 228
 	$post_data = '';
229 229
 
230 230
 	// Fallback just in case post_max_size is lower than needed
231
-	if ( ini_get( 'allow_url_fopen' ) ) {
232
-		$post_data = file_get_contents( 'php://input' );
231
+	if (ini_get('allow_url_fopen')) {
232
+		$post_data = file_get_contents('php://input');
233 233
 	} else {
234 234
 		// If allow_url_fopen is not enabled, then make sure that post_max_size is large enough
235
-		ini_set( 'post_max_size', '12M' );
235
+		ini_set('post_max_size', '12M');
236 236
 	}
237 237
 	// Start the encoded data collection with notification command
238 238
 	$encoded_data = 'cmd=_notify-validate';
@@ -241,43 +241,43 @@  discard block
 block discarded – undo
241 241
 	$arg_separator = wpinv_get_php_arg_separator_output();
242 242
 
243 243
 	// Verify there is a post_data
244
-	if ( $post_data || strlen( $post_data ) > 0 ) {
244
+	if ($post_data || strlen($post_data) > 0) {
245 245
 		// Append the data
246
-		$encoded_data .= $arg_separator.$post_data;
246
+		$encoded_data .= $arg_separator . $post_data;
247 247
 	} else {
248 248
 		// Check if POST is empty
249
-		if ( empty( $_POST ) ) {
249
+		if (empty($_POST)) {
250 250
 			// Nothing to do
251 251
 			return;
252 252
 		} else {
253 253
 			// Loop through each POST
254
-			foreach ( $_POST as $key => $value ) {
254
+			foreach ($_POST as $key => $value) {
255 255
 				// Encode the value and append the data
256
-				$encoded_data .= $arg_separator."$key=" . urlencode( $value );
256
+				$encoded_data .= $arg_separator . "$key=" . urlencode($value);
257 257
 			}
258 258
 		}
259 259
 	}
260 260
 
261 261
 	// Convert collected post data to an array
262
-	parse_str( $encoded_data, $encoded_data_array );
262
+	parse_str($encoded_data, $encoded_data_array);
263 263
 
264
-	foreach ( $encoded_data_array as $key => $value ) {
265
-		if ( false !== strpos( $key, 'amp;' ) ) {
266
-			$new_key = str_replace( '&amp;', '&', $key );
267
-			$new_key = str_replace( 'amp;', '&' , $new_key );
264
+	foreach ($encoded_data_array as $key => $value) {
265
+		if (false !== strpos($key, 'amp;')) {
266
+			$new_key = str_replace('&amp;', '&', $key);
267
+			$new_key = str_replace('amp;', '&', $new_key);
268 268
 
269
-			unset( $encoded_data_array[ $key ] );
270
-			$encoded_data_array[ $new_key ] = $value;
269
+			unset($encoded_data_array[$key]);
270
+			$encoded_data_array[$new_key] = $value;
271 271
 		}
272 272
 	}
273 273
 
274 274
 	// Get the PayPal redirect uri
275
-	$paypal_redirect = wpinv_get_paypal_redirect( true );
275
+	$paypal_redirect = wpinv_get_paypal_redirect(true);
276 276
 
277
-	if ( !wpinv_get_option( 'disable_paypal_verification', false ) ) {
277
+	if (!wpinv_get_option('disable_paypal_verification', false)) {
278 278
 		// Validate the IPN
279 279
 
280
-		$remote_post_vars      = array(
280
+		$remote_post_vars = array(
281 281
 			'method'           => 'POST',
282 282
 			'timeout'          => 45,
283 283
 			'redirection'      => 5,
@@ -295,21 +295,21 @@  discard block
 block discarded – undo
295 295
 		);
296 296
 
297 297
 		// Get response
298
-		$api_response = wp_remote_post( wpinv_get_paypal_redirect(), $remote_post_vars );
298
+		$api_response = wp_remote_post(wpinv_get_paypal_redirect(), $remote_post_vars);
299 299
 
300
-		if ( is_wp_error( $api_response ) ) {
301
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
300
+		if (is_wp_error($api_response)) {
301
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
302 302
 			return; // Something went wrong
303 303
 		}
304 304
 
305
-		if ( $api_response['body'] !== 'VERIFIED' && wpinv_get_option( 'disable_paypal_verification', false ) ) {
306
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid IPN verification response. IPN data: %s', 'invoicing' ), json_encode( $api_response ) ) );
305
+		if ($api_response['body'] !== 'VERIFIED' && wpinv_get_option('disable_paypal_verification', false)) {
306
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid IPN verification response. IPN data: %s', 'invoicing'), json_encode($api_response)));
307 307
 			return; // Response not okay
308 308
 		}
309 309
 	}
310 310
 
311 311
 	// Check if $post_data_array has been populated
312
-	if ( !is_array( $encoded_data_array ) && !empty( $encoded_data_array ) )
312
+	if (!is_array($encoded_data_array) && !empty($encoded_data_array))
313 313
 		return;
314 314
 
315 315
 	$defaults = array(
@@ -317,265 +317,265 @@  discard block
 block discarded – undo
317 317
 		'payment_status' => ''
318 318
 	);
319 319
 
320
-	$encoded_data_array = wp_parse_args( $encoded_data_array, $defaults );
320
+	$encoded_data_array = wp_parse_args($encoded_data_array, $defaults);
321 321
 
322
-	$invoice_id = isset( $encoded_data_array['custom'] ) ? absint( $encoded_data_array['custom'] ) : 0;
322
+	$invoice_id = isset($encoded_data_array['custom']) ? absint($encoded_data_array['custom']) : 0;
323 323
     
324
-	wpinv_error_log( $encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__ );
325
-	wpinv_error_log( $encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__ );
324
+	wpinv_error_log($encoded_data_array['txn_type'], 'PayPal txn_type', __FILE__, __LINE__);
325
+	wpinv_error_log($encoded_data_array, 'PayPal IPN response', __FILE__, __LINE__);
326 326
 
327
-	if ( has_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'] ) ) {
327
+	if (has_action('wpinv_paypal_' . $encoded_data_array['txn_type'])) {
328 328
 		// Allow PayPal IPN types to be processed separately
329
-		do_action( 'wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id );
329
+		do_action('wpinv_paypal_' . $encoded_data_array['txn_type'], $encoded_data_array, $invoice_id);
330 330
 	} else {
331 331
 		// Fallback to web accept just in case the txn_type isn't present
332
-		do_action( 'wpinv_paypal_web_accept', $encoded_data_array, $invoice_id );
332
+		do_action('wpinv_paypal_web_accept', $encoded_data_array, $invoice_id);
333 333
 	}
334 334
 	exit;
335 335
 }
336
-add_action( 'wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn' );
336
+add_action('wpinv_verify_paypal_ipn', 'wpinv_process_paypal_ipn');
337 337
 
338
-function wpinv_process_paypal_web_accept_and_cart( $data, $invoice_id ) {
339
-	if ( $data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded' ) {
338
+function wpinv_process_paypal_web_accept_and_cart($data, $invoice_id) {
339
+	if ($data['txn_type'] != 'web_accept' && $data['txn_type'] != 'cart' && $data['payment_status'] != 'Refunded') {
340 340
 		return;
341 341
 	}
342 342
 
343
-	if( empty( $invoice_id ) ) {
343
+	if (empty($invoice_id)) {
344 344
 		return;
345 345
 	}
346 346
 
347 347
 	// Collect payment details
348
-	$purchase_key   = isset( $data['invoice'] ) ? $data['invoice'] : $data['item_number'];
348
+	$purchase_key   = isset($data['invoice']) ? $data['invoice'] : $data['item_number'];
349 349
 	$paypal_amount  = $data['mc_gross'];
350
-	$payment_status = strtolower( $data['payment_status'] );
351
-	$currency_code  = strtolower( $data['mc_currency'] );
352
-	$business_email = isset( $data['business'] ) && is_email( $data['business'] ) ? trim( $data['business'] ) : trim( $data['receiver_email'] );
353
-	$payment_meta   = wpinv_get_invoice_meta( $invoice_id );
350
+	$payment_status = strtolower($data['payment_status']);
351
+	$currency_code  = strtolower($data['mc_currency']);
352
+	$business_email = isset($data['business']) && is_email($data['business']) ? trim($data['business']) : trim($data['receiver_email']);
353
+	$payment_meta   = wpinv_get_invoice_meta($invoice_id);
354 354
 
355
-	if ( wpinv_get_payment_gateway( $invoice_id ) != 'paypal' ) {
355
+	if (wpinv_get_payment_gateway($invoice_id) != 'paypal') {
356 356
 		return; // this isn't a PayPal standard IPN
357 357
 	}
358 358
 
359 359
 	// Verify payment recipient
360
-	if ( strcasecmp( $business_email, trim( wpinv_get_option( 'paypal_email', false ) ) ) != 0 ) {
361
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid business email in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
362
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
363
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid PayPal business email.', 'invoicing' ), '', '', true );
360
+	if (strcasecmp($business_email, trim(wpinv_get_option('paypal_email', false))) != 0) {
361
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid business email in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
362
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
363
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid PayPal business email.', 'invoicing'), '', '', true);
364 364
 		return;
365 365
 	}
366 366
 
367 367
 	// Verify payment currency
368
-	if ( $currency_code != strtolower( $payment_meta['currency'] ) ) {
369
-		wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
370
-		wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
371
-		wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid currency in PayPal IPN.', 'invoicing' ), '', '', true );
368
+	if ($currency_code != strtolower($payment_meta['currency'])) {
369
+		wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
370
+		wpinv_update_payment_status($invoice_id, 'wpi-failed');
371
+		wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid currency in PayPal IPN.', 'invoicing'), '', '', true);
372 372
 		return;
373 373
 	}
374 374
 
375
-	if ( !wpinv_get_payment_user_email( $invoice_id ) ) {
375
+	if (!wpinv_get_payment_user_email($invoice_id)) {
376 376
 		// This runs when a Buy Now purchase was made. It bypasses checkout so no personal info is collected until PayPal
377 377
 		// No email associated with purchase, so store from PayPal
378
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_email', $data['payer_email'] );
378
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_email', $data['payer_email']);
379 379
 
380 380
 		// Setup and store the customer's details
381 381
 		$user_info = array(
382 382
 			'user_id'    => '-1',
383
-			'email'      => sanitize_text_field( $data['payer_email'] ),
384
-			'first_name' => sanitize_text_field( $data['first_name'] ),
385
-			'last_name'  => sanitize_text_field( $data['last_name'] ),
383
+			'email'      => sanitize_text_field($data['payer_email']),
384
+			'first_name' => sanitize_text_field($data['first_name']),
385
+			'last_name'  => sanitize_text_field($data['last_name']),
386 386
 			'discount'   => '',
387 387
 		);
388
-		$user_info['address'] = ! empty( $data['address_street']       ) ? sanitize_text_field( $data['address_street'] )       : false;
389
-		$user_info['city']    = ! empty( $data['address_city']         ) ? sanitize_text_field( $data['address_city'] )         : false;
390
-		$user_info['state']   = ! empty( $data['address_state']        ) ? sanitize_text_field( $data['address_state'] )        : false;
391
-		$user_info['country'] = ! empty( $data['address_country_code'] ) ? sanitize_text_field( $data['address_country_code'] ) : false;
392
-		$user_info['zip']     = ! empty( $data['address_zip']          ) ? sanitize_text_field( $data['address_zip'] )          : false;
388
+		$user_info['address'] = !empty($data['address_street']) ? sanitize_text_field($data['address_street']) : false;
389
+		$user_info['city']    = !empty($data['address_city']) ? sanitize_text_field($data['address_city']) : false;
390
+		$user_info['state']   = !empty($data['address_state']) ? sanitize_text_field($data['address_state']) : false;
391
+		$user_info['country'] = !empty($data['address_country_code']) ? sanitize_text_field($data['address_country_code']) : false;
392
+		$user_info['zip']     = !empty($data['address_zip']) ? sanitize_text_field($data['address_zip']) : false;
393 393
 
394 394
 		$payment_meta['user_info'] = $user_info;
395
-		wpinv_update_invoice_meta( $invoice_id, '_wpinv_payment_meta', $payment_meta );
395
+		wpinv_update_invoice_meta($invoice_id, '_wpinv_payment_meta', $payment_meta);
396 396
 	}
397 397
 
398
-	if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
398
+	if ($payment_status == 'refunded' || $payment_status == 'reversed') {
399 399
 		// Process a refund
400
-		wpinv_process_paypal_refund( $data, $invoice_id );
400
+		wpinv_process_paypal_refund($data, $invoice_id);
401 401
 	} else {
402
-		if ( get_post_status( $invoice_id ) == 'publish' ) {
402
+		if (get_post_status($invoice_id) == 'publish') {
403 403
 			return; // Only paid payments once
404 404
 		}
405 405
 
406 406
 		// Retrieve the total purchase amount (before PayPal)
407
-		$payment_amount = wpinv_payment_total( $invoice_id );
407
+		$payment_amount = wpinv_payment_total($invoice_id);
408 408
 
409
-		if ( number_format( (float) $paypal_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
409
+		if (number_format((float)$paypal_amount, 2) < number_format((float)$payment_amount, 2)) {
410 410
 			// The prices don't match
411
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid payment amount in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
412
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
413
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid amount in PayPal IPN.', 'invoicing' ), '', '', true );
411
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid payment amount in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
412
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
413
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid amount in PayPal IPN.', 'invoicing'), '', '', true);
414 414
 			return;
415 415
 		}
416
-		if ( $purchase_key != wpinv_get_payment_key( $invoice_id ) ) {
416
+		if ($purchase_key != wpinv_get_payment_key($invoice_id)) {
417 417
 			// Purchase keys don't match
418
-			wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid purchase key in IPN response. IPN data: %s', 'invoicing' ), json_encode( $data ) ), $invoice_id );
419
-			wpinv_update_payment_status( $invoice_id, 'wpi-failed' );
420
-			wpinv_insert_payment_note( $invoice_id, __( 'Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing' ), '', '', true );
418
+			wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid purchase key in IPN response. IPN data: %s', 'invoicing'), json_encode($data)), $invoice_id);
419
+			wpinv_update_payment_status($invoice_id, 'wpi-failed');
420
+			wpinv_insert_payment_note($invoice_id, __('Payment failed due to invalid purchase key in PayPal IPN.', 'invoicing'), '', '', true);
421 421
 			return;
422 422
 		}
423 423
 
424
-		if ( 'complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode( 'paypal' ) ) {
425
-			wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $data['txn_id'] ), '', '', true );
426
-			wpinv_set_payment_transaction_id( $invoice_id, $data['txn_id'] );
427
-			wpinv_update_payment_status( $invoice_id, 'publish' );
428
-		} else if ( 'pending' == $payment_status && isset( $data['pending_reason'] ) ) {
424
+		if ('complete' == $payment_status || 'completed' == $payment_status || 'processed' == $payment_status || wpinv_is_test_mode('paypal')) {
425
+			wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
426
+			wpinv_set_payment_transaction_id($invoice_id, $data['txn_id']);
427
+			wpinv_update_payment_status($invoice_id, 'publish');
428
+		} else if ('pending' == $payment_status && isset($data['pending_reason'])) {
429 429
 			// Look for possible pending reasons, such as an echeck
430 430
 			$note = '';
431 431
 
432
-			switch( strtolower( $data['pending_reason'] ) ) {
432
+			switch (strtolower($data['pending_reason'])) {
433 433
 				case 'echeck' :
434
-					$note = __( 'Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing' );
434
+					$note = __('Payment made via eCheck and will clear automatically in 5-8 days', 'invoicing');
435 435
 					break;
436 436
 				
437 437
                 case 'address' :
438
-					$note = __( 'Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing' );
438
+					$note = __('Payment requires a confirmed customer address and must be accepted manually through PayPal', 'invoicing');
439 439
 					break;
440 440
 				
441 441
                 case 'intl' :
442
-					$note = __( 'Payment must be accepted manually through PayPal due to international account regulations', 'invoicing' );
442
+					$note = __('Payment must be accepted manually through PayPal due to international account regulations', 'invoicing');
443 443
 					break;
444 444
 				
445 445
                 case 'multi-currency' :
446
-					$note = __( 'Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing' );
446
+					$note = __('Payment received in non-shop currency and must be accepted manually through PayPal', 'invoicing');
447 447
 					break;
448 448
 				
449 449
                 case 'paymentreview' :
450 450
                 case 'regulatory_review' :
451
-					$note = __( 'Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing' );
451
+					$note = __('Payment is being reviewed by PayPal staff as high-risk or in possible violation of government regulations', 'invoicing');
452 452
 					break;
453 453
 				
454 454
                 case 'unilateral' :
455
-					$note = __( 'Payment was sent to non-confirmed or non-registered email address.', 'invoicing' );
455
+					$note = __('Payment was sent to non-confirmed or non-registered email address.', 'invoicing');
456 456
 					break;
457 457
 				
458 458
                 case 'upgrade' :
459
-					$note = __( 'PayPal account must be upgraded before this payment can be accepted', 'invoicing' );
459
+					$note = __('PayPal account must be upgraded before this payment can be accepted', 'invoicing');
460 460
 					break;
461 461
 				
462 462
                 case 'verify' :
463
-					$note = __( 'PayPal account is not verified. Verify account in order to accept this payment', 'invoicing' );
463
+					$note = __('PayPal account is not verified. Verify account in order to accept this payment', 'invoicing');
464 464
 					break;
465 465
 
466 466
 				case 'other' :
467
-					$note = __( 'Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing' );
467
+					$note = __('Payment is pending for unknown reasons. Contact PayPal support for assistance', 'invoicing');
468 468
 					break;
469 469
 			}
470 470
 
471
-			if ( ! empty( $note ) ) {
472
-				wpinv_insert_payment_note( $invoice_id, $note, '', '', true );
471
+			if (!empty($note)) {
472
+				wpinv_insert_payment_note($invoice_id, $note, '', '', true);
473 473
 			}
474 474
 		} else {
475
-			wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal IPN has been received with invalid payment status: %s', 'invoicing' ), $payment_status ), '', '', true );
475
+			wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal IPN has been received with invalid payment status: %s', 'invoicing'), $payment_status), '', '', true);
476 476
 		}
477 477
 	}
478 478
 }
479
-add_action( 'wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2 );
479
+add_action('wpinv_paypal_web_accept', 'wpinv_process_paypal_web_accept_and_cart', 10, 2);
480 480
 
481 481
 // Process PayPal subscription sign ups
482
-add_action( 'wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup' );
482
+add_action('wpinv_paypal_subscr_signup', 'wpinv_process_paypal_subscr_signup');
483 483
 
484 484
 // Process PayPal subscription payments
485
-add_action( 'wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment' );
485
+add_action('wpinv_paypal_subscr_payment', 'wpinv_process_paypal_subscr_payment');
486 486
 
487 487
 // Process PayPal subscription cancellations
488
-add_action( 'wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel' );
488
+add_action('wpinv_paypal_subscr_cancel', 'wpinv_process_paypal_subscr_cancel');
489 489
 
490 490
 // Process PayPal subscription end of term notices
491
-add_action( 'wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot' );
491
+add_action('wpinv_paypal_subscr_eot', 'wpinv_process_paypal_subscr_eot');
492 492
 
493 493
 // Process PayPal payment failed
494
-add_action( 'wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed' );
494
+add_action('wpinv_paypal_subscr_failed', 'wpinv_process_paypal_subscr_failed');
495 495
 
496 496
 
497 497
 /**
498 498
  * Process the subscription started IPN.
499 499
  */
500
-function wpinv_process_paypal_subscr_signup( $ipn_data ) {
501
-    $parent_invoice_id = absint( $ipn_data['custom'] );
502
-    if( empty( $parent_invoice_id ) ) {
500
+function wpinv_process_paypal_subscr_signup($ipn_data) {
501
+    $parent_invoice_id = absint($ipn_data['custom']);
502
+    if (empty($parent_invoice_id)) {
503 503
         return;
504 504
     }
505 505
 
506
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
507
-    if ( empty( $invoice ) ) {
506
+    $invoice = wpinv_get_invoice($parent_invoice_id);
507
+    if (empty($invoice)) {
508 508
         return;
509 509
     }
510 510
 
511
-    if ( $invoice->is_free_trial() && !empty( $ipn_data['invoice'] ) ) {
512
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Invoice ID: %s', 'invoicing' ) , $ipn_data['invoice'] ), '', '', true);
513
-        if ( !empty( $ipn_data['txn_id'] ) ) {
514
-            wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
511
+    if ($invoice->is_free_trial() && !empty($ipn_data['invoice'])) {
512
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Invoice ID: %s', 'invoicing'), $ipn_data['invoice']), '', '', true);
513
+        if (!empty($ipn_data['txn_id'])) {
514
+            wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
515 515
         }
516 516
     }
517 517
 
518
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
519
-    if ( false === $subscription ) {
518
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
519
+    if (false === $subscription) {
520 520
         return;
521 521
     }
522 522
     
523
-    wpinv_update_payment_status( $parent_invoice_id, 'publish' );
523
+    wpinv_update_payment_status($parent_invoice_id, 'publish');
524 524
     sleep(1);
525
-    wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
526
-    update_post_meta($parent_invoice_id,'_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
525
+    wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
526
+    update_post_meta($parent_invoice_id, '_wpinv_subscr_profile_id', $ipn_data['subscr_id']);
527 527
 
528 528
     $status     = 'trialling' == $subscription->status ? 'trialling' : 'active';
529
-    $diff_days  = absint( ( ( strtotime( $subscription->expiration ) - strtotime( $subscription->created ) ) / DAY_IN_SECONDS ) );
530
-    $created    = date_i18n( 'Y-m-d H:i:s' );
531
-    $expiration = date_i18n( 'Y-m-d 23:59:59', ( strtotime( $created ) + ( $diff_days * DAY_IN_SECONDS ) ) );
529
+    $diff_days  = absint(((strtotime($subscription->expiration) - strtotime($subscription->created)) / DAY_IN_SECONDS));
530
+    $created    = date_i18n('Y-m-d H:i:s');
531
+    $expiration = date_i18n('Y-m-d 23:59:59', (strtotime($created) + ($diff_days * DAY_IN_SECONDS)));
532 532
 
533 533
     // Retrieve pending subscription from database and update it's status to active and set proper profile ID
534
-    $subscription->update( array( 'profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration ) );
534
+    $subscription->update(array('profile_id' => $ipn_data['subscr_id'], 'status' => $status, 'created' => $created, 'expiration' => $expiration));
535 535
 }
536 536
 
537 537
 /**
538 538
  * Process the subscription payment received IPN.
539 539
  */
540
-function wpinv_process_paypal_subscr_payment( $ipn_data ) {
541
-    $parent_invoice_id = absint( $ipn_data['custom'] );
540
+function wpinv_process_paypal_subscr_payment($ipn_data) {
541
+    $parent_invoice_id = absint($ipn_data['custom']);
542 542
 
543
-    $parent_invoice = wpinv_get_invoice( $parent_invoice_id );
544
-    if ( empty( $parent_invoice ) ) {
543
+    $parent_invoice = wpinv_get_invoice($parent_invoice_id);
544
+    if (empty($parent_invoice)) {
545 545
         return;
546 546
     }
547 547
 
548
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
549
-    if ( false === $subscription ) {
548
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
549
+    if (false === $subscription) {
550 550
         return;
551 551
     }
552 552
 
553
-    $transaction_id = wpinv_get_payment_transaction_id( $parent_invoice_id );
553
+    $transaction_id = wpinv_get_payment_transaction_id($parent_invoice_id);
554 554
     $times_billed   = $subscription->get_times_billed();
555
-    $signup_date    = strtotime( $subscription->created );
556
-    $today          = date( 'Ynd', $signup_date ) == date( 'Ynd', strtotime( $ipn_data['payment_date'] ) );
555
+    $signup_date    = strtotime($subscription->created);
556
+    $today          = date('Ynd', $signup_date) == date('Ynd', strtotime($ipn_data['payment_date']));
557 557
 
558 558
     // Look to see if payment is same day as signup and we have set the transaction ID on the parent payment yet.
559
-    if ( (empty($times_billed) || $today) && ( !$transaction_id || $transaction_id == $parent_invoice_id ) ) {
560
-        wpinv_update_payment_status( $parent_invoice_id, 'publish' );
559
+    if ((empty($times_billed) || $today) && (!$transaction_id || $transaction_id == $parent_invoice_id)) {
560
+        wpinv_update_payment_status($parent_invoice_id, 'publish');
561 561
         sleep(1);
562 562
         
563 563
         // This is the very first payment
564
-        wpinv_set_payment_transaction_id( $parent_invoice_id, $ipn_data['txn_id'] );
565
-        wpinv_insert_payment_note( $parent_invoice_id, sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
564
+        wpinv_set_payment_transaction_id($parent_invoice_id, $ipn_data['txn_id']);
565
+        wpinv_insert_payment_note($parent_invoice_id, sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
566 566
         return;
567 567
     }
568 568
 
569
-    if ( wpinv_get_id_by_transaction_id( $ipn_data['txn_id'] ) ) {
569
+    if (wpinv_get_id_by_transaction_id($ipn_data['txn_id'])) {
570 570
         return; // Payment already recorded
571 571
     }
572 572
 
573
-    $currency_code = strtolower( $ipn_data['mc_currency'] );
573
+    $currency_code = strtolower($ipn_data['mc_currency']);
574 574
 
575 575
     // verify details
576
-    if ( $currency_code != strtolower( wpinv_get_currency() ) ) {
576
+    if ($currency_code != strtolower(wpinv_get_currency())) {
577 577
         // the currency code is invalid
578
-        wpinv_record_gateway_error( __( 'IPN Error', 'invoicing' ), sprintf( __( 'Invalid currency in IPN response. IPN data: ', 'invoicing' ), json_encode( $ipn_data ) ) );
578
+        wpinv_record_gateway_error(__('IPN Error', 'invoicing'), sprintf(__('Invalid currency in IPN response. IPN data: ', 'invoicing'), json_encode($ipn_data)));
579 579
         return;
580 580
     }
581 581
 
@@ -585,11 +585,11 @@  discard block
 block discarded – undo
585 585
         'gateway'        => 'paypal'
586 586
     );
587 587
     
588
-    $invoice_id = $subscription->add_payment( $args );
588
+    $invoice_id = $subscription->add_payment($args);
589 589
 
590
-    if ( $invoice_id > 0 ) {
591
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $ipn_data['txn_id'] ), '', '', true );
592
-        wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $ipn_data['subscr_id'] ), '', '', true );
590
+    if ($invoice_id > 0) {
591
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $ipn_data['txn_id']), '', '', true);
592
+        wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $ipn_data['subscr_id']), '', '', true);
593 593
 
594 594
         $subscription->renew();
595 595
     }
@@ -598,10 +598,10 @@  discard block
 block discarded – undo
598 598
 /**
599 599
  * Process the subscription canceled IPN.
600 600
  */
601
-function wpinv_process_paypal_subscr_cancel( $ipn_data ) {
602
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
601
+function wpinv_process_paypal_subscr_cancel($ipn_data) {
602
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
603 603
 
604
-    if( false === $subscription ) {
604
+    if (false === $subscription) {
605 605
         return;
606 606
     }
607 607
 
@@ -611,10 +611,10 @@  discard block
 block discarded – undo
611 611
 /**
612 612
  * Process the subscription expired IPN.
613 613
  */
614
-function wpinv_process_paypal_subscr_eot( $ipn_data ) {
615
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
614
+function wpinv_process_paypal_subscr_eot($ipn_data) {
615
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
616 616
 
617
-    if( false === $subscription ) {
617
+    if (false === $subscription) {
618 618
         return;
619 619
     }
620 620
 
@@ -624,40 +624,40 @@  discard block
 block discarded – undo
624 624
 /**
625 625
  * Process the subscription payment failed IPN.
626 626
  */
627
-function wpinv_process_paypal_subscr_failed( $ipn_data ) {
628
-    $subscription = wpinv_get_paypal_subscription( $ipn_data );
627
+function wpinv_process_paypal_subscr_failed($ipn_data) {
628
+    $subscription = wpinv_get_paypal_subscription($ipn_data);
629 629
 
630
-    if( false === $subscription ) {
630
+    if (false === $subscription) {
631 631
         return;
632 632
     }
633 633
 
634 634
     $subscription->failing();
635 635
 
636
-    do_action( 'wpinv_recurring_payment_failed', $subscription );
636
+    do_action('wpinv_recurring_payment_failed', $subscription);
637 637
 }
638 638
 
639 639
 /**
640 640
  * Retrieve the subscription this IPN notice is for.
641 641
  */
642
-function wpinv_get_paypal_subscription( $ipn_data = array() ) {
643
-    $parent_invoice_id = absint( $ipn_data['custom'] );
642
+function wpinv_get_paypal_subscription($ipn_data = array()) {
643
+    $parent_invoice_id = absint($ipn_data['custom']);
644 644
 
645
-    if( empty( $parent_invoice_id ) ) {
645
+    if (empty($parent_invoice_id)) {
646 646
         return false;
647 647
     }
648 648
 
649
-    $invoice = wpinv_get_invoice( $parent_invoice_id );
650
-    if ( empty( $invoice ) ) {
649
+    $invoice = wpinv_get_invoice($parent_invoice_id);
650
+    if (empty($invoice)) {
651 651
         return false;
652 652
     }
653 653
 
654
-    $subscription = new WPInv_Subscription( $ipn_data['subscr_id'], true );
654
+    $subscription = new WPInv_Subscription($ipn_data['subscr_id'], true);
655 655
 
656
-    if ( ! ( ! empty( $subscription ) && $subscription->id > 0 ) ) {
657
-        $subscription = wpinv_get_subscription( $parent_invoice_id );
656
+    if (!(!empty($subscription) && $subscription->id > 0)) {
657
+        $subscription = wpinv_get_subscription($parent_invoice_id);
658 658
 
659
-        if ( ! empty( $subscription ) && $subscription->id > 0 ) {
660
-            $subscription->update( array( 'profile_id' => sanitize_text_field( $ipn_data['subscr_id'] ) ) );
659
+        if (!empty($subscription) && $subscription->id > 0) {
660
+            $subscription->update(array('profile_id' => sanitize_text_field($ipn_data['subscr_id'])));
661 661
         } else {
662 662
             return false;
663 663
         }
@@ -667,46 +667,46 @@  discard block
 block discarded – undo
667 667
 
668 668
 }
669 669
 
670
-function wpinv_process_paypal_refund( $data, $invoice_id = 0 ) {
670
+function wpinv_process_paypal_refund($data, $invoice_id = 0) {
671 671
 	// Collect payment details
672 672
 
673
-	if( empty( $invoice_id ) ) {
673
+	if (empty($invoice_id)) {
674 674
 		return;
675 675
 	}
676 676
 
677
-	if ( get_post_status( $invoice_id ) == 'wpi-refunded' ) {
677
+	if (get_post_status($invoice_id) == 'wpi-refunded') {
678 678
 		return; // Only refund payments once
679 679
 	}
680 680
 
681
-	$payment_amount = wpinv_payment_total( $invoice_id );
681
+	$payment_amount = wpinv_payment_total($invoice_id);
682 682
 	$refund_amount  = $data['mc_gross'] * -1;
683 683
 
684
-	do_action( 'wpinv_paypal_refund_request', $data, $invoice_id );
684
+	do_action('wpinv_paypal_refund_request', $data, $invoice_id);
685 685
 
686
-	if ( number_format( (float) $refund_amount, 2 ) < number_format( (float) $payment_amount, 2 ) ) {
687
-		wpinv_insert_payment_note( $invoice_id, wp_sprintf( __( 'PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing' ), (float)$refund_amount . ' '. $data['mc_currency'], $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
686
+	if (number_format((float)$refund_amount, 2) < number_format((float)$payment_amount, 2)) {
687
+		wpinv_insert_payment_note($invoice_id, wp_sprintf(__('PayPal partial refund of %s processed for transaction #%s for reason: %s', 'invoicing'), (float)$refund_amount . ' ' . $data['mc_currency'], $data['parent_txn_id'], $data['reason_code']), '', '', true);
688 688
 
689
-		do_action( 'wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount );
689
+		do_action('wpinv_paypal_invoice_partially_refunded', $data, $invoice_id, $refund_amount);
690 690
 
691 691
 		return; // This is a partial refund
692 692
 	}
693 693
 
694
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Payment #%s Refunded for reason: %s', 'invoicing' ), $data['parent_txn_id'], $data['reason_code'] ), '', '', true );
695
-	wpinv_insert_payment_note( $invoice_id, sprintf( __( 'PayPal Refund Transaction ID: %s', 'invoicing' ), $data['txn_id'] ), '', '', true );
696
-	wpinv_update_payment_status( $invoice_id, 'wpi-refunded' );
694
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Payment #%s Refunded for reason: %s', 'invoicing'), $data['parent_txn_id'], $data['reason_code']), '', '', true);
695
+	wpinv_insert_payment_note($invoice_id, sprintf(__('PayPal Refund Transaction ID: %s', 'invoicing'), $data['txn_id']), '', '', true);
696
+	wpinv_update_payment_status($invoice_id, 'wpi-refunded');
697 697
 
698
-	do_action( 'wpinv_paypal_invoice_fully_refunded', $data, $invoice_id );
698
+	do_action('wpinv_paypal_invoice_fully_refunded', $data, $invoice_id);
699 699
 }
700 700
 
701
-function wpinv_get_paypal_redirect( $ssl_check = false ) {
702
-    if ( is_ssl() || ! $ssl_check ) {
701
+function wpinv_get_paypal_redirect($ssl_check = false) {
702
+    if (is_ssl() || !$ssl_check) {
703 703
         $protocol = 'https://';
704 704
     } else {
705 705
         $protocol = 'http://';
706 706
     }
707 707
 
708 708
     // Check the current payment mode
709
-    if ( wpinv_is_test_mode( 'paypal' ) ) {
709
+    if (wpinv_is_test_mode('paypal')) {
710 710
         // Test mode
711 711
         $paypal_uri = $protocol . 'www.sandbox.paypal.com/cgi-bin/webscr';
712 712
     } else {
@@ -714,120 +714,120 @@  discard block
 block discarded – undo
714 714
         $paypal_uri = $protocol . 'www.paypal.com/cgi-bin/webscr';
715 715
     }
716 716
 
717
-    return apply_filters( 'wpinv_paypal_uri', $paypal_uri );
717
+    return apply_filters('wpinv_paypal_uri', $paypal_uri);
718 718
 }
719 719
 
720
-function wpinv_paypal_success_page_content( $content ) {
720
+function wpinv_paypal_success_page_content($content) {
721 721
     global $wpi_invoice;
722 722
     
723 723
     $session = wpinv_get_checkout_session();
724 724
 
725
-    if ( empty( $_GET['invoice-id'] ) && empty( $session['invoice_key'] )  ) {
725
+    if (empty($_GET['invoice-id']) && empty($session['invoice_key'])) {
726 726
         return $content;
727 727
     }
728 728
 
729
-    $invoice_id = !empty( $_GET['invoice-id'] ) ? absint( $_GET['invoice-id'] ) : wpinv_get_invoice_id_by_key( $session['invoice_key'] );
729
+    $invoice_id = !empty($_GET['invoice-id']) ? absint($_GET['invoice-id']) : wpinv_get_invoice_id_by_key($session['invoice_key']);
730 730
 
731
-    if ( empty(  $invoice_id ) ) {
731
+    if (empty($invoice_id)) {
732 732
         return $content;
733 733
     }
734 734
 
735
-    $wpi_invoice = wpinv_get_invoice( $invoice_id );
735
+    $wpi_invoice = wpinv_get_invoice($invoice_id);
736 736
     
737
-    if ( !empty( $wpi_invoice ) && 'wpi-pending' == $wpi_invoice->status ) {
737
+    if (!empty($wpi_invoice) && 'wpi-pending' == $wpi_invoice->status) {
738 738
         // Payment is still pending so show processing indicator to fix the Race Condition, issue #
739 739
         ob_start();
740
-        wpinv_get_template_part( 'wpinv-payment-processing' );
740
+        wpinv_get_template_part('wpinv-payment-processing');
741 741
         $content = ob_get_clean();
742 742
     }
743 743
 
744 744
     return $content;
745 745
 }
746
-add_filter( 'wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content' );
746
+add_filter('wpinv_payment_confirm_paypal', 'wpinv_paypal_success_page_content');
747 747
 
748
-function wpinv_paypal_get_transaction_id( $invoice_id ) {
748
+function wpinv_paypal_get_transaction_id($invoice_id) {
749 749
     $transaction_id = '';
750
-    $notes = wpinv_get_invoice_notes( $invoice_id );
750
+    $notes = wpinv_get_invoice_notes($invoice_id);
751 751
 
752
-    foreach ( $notes as $note ) {
753
-        if ( preg_match( '/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match ) ) {
752
+    foreach ($notes as $note) {
753
+        if (preg_match('/^PayPal Transaction ID: ([^\s]+)/', $note->comment_content, $match)) {
754 754
             $transaction_id = $match[1];
755 755
             continue;
756 756
         }
757 757
     }
758 758
 
759
-    return apply_filters( 'wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id );
759
+    return apply_filters('wpinv_paypal_set_transaction_id', $transaction_id, $invoice_id);
760 760
 }
761
-add_filter( 'wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1 );
761
+add_filter('wpinv_payment_get_transaction_id-paypal', 'wpinv_paypal_get_transaction_id', 10, 1);
762 762
 
763
-function wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice ) {
764
-    if ( $transaction_id == $invoice_id ) {
763
+function wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice) {
764
+    if ($transaction_id == $invoice_id) {
765 765
         $transaction_link = $transaction_id;
766 766
     } else {
767
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
767
+        if (!empty($invoice) && !empty($invoice->mode)) {
768 768
             $mode = $invoice->mode;
769 769
         } else {
770
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
770
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
771 771
         }
772 772
 
773 773
         $sandbox = $mode == 'test' ? '.sandbox' : '';
774 774
         $transaction_url = 'https://www' . $sandbox . '.paypal.com/webscr?cmd=_history-details-from-hub&id=' . $transaction_id;
775 775
 
776
-        $transaction_link = '<a href="' . esc_url( $transaction_url ) . '" target="_blank">' . $transaction_id . '</a>';
776
+        $transaction_link = '<a href="' . esc_url($transaction_url) . '" target="_blank">' . $transaction_id . '</a>';
777 777
     }
778 778
 
779
-    return apply_filters( 'wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice );
779
+    return apply_filters('wpinv_paypal_link_payment_details_transaction_id', $transaction_link, $transaction_id, $invoice);
780 780
 }
781
-add_filter( 'wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3 );
781
+add_filter('wpinv_payment_details_transaction_id-paypal', 'wpinv_paypal_link_transaction_id', 10, 3);
782 782
 
783
-function wpinv_paypal_profile_id_link( $profile_id, $subscription ) {
783
+function wpinv_paypal_profile_id_link($profile_id, $subscription) {
784 784
     $link = $profile_id;
785 785
 
786
-    if ( ! empty( $profile_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
787
-        $invoice = wpinv_get_invoice( $invoice_id );
786
+    if (!empty($profile_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
787
+        $invoice = wpinv_get_invoice($invoice_id);
788 788
 
789
-        if ( ! empty( $invoice ) && ! empty( $invoice->mode ) ) {
789
+        if (!empty($invoice) && !empty($invoice->mode)) {
790 790
             $mode = $invoice->mode;
791 791
         } else {
792
-            $mode = wpinv_is_test_mode( 'paypal' ) ? 'test' : 'live';
792
+            $mode = wpinv_is_test_mode('paypal') ? 'test' : 'live';
793 793
         }
794 794
 
795 795
         $sandbox = $mode == 'test' ? '.sandbox' : '';
796 796
         $url = 'https://www' . $sandbox . '.paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=' . $profile_id;
797 797
 
798
-        $link = '<a href="' . esc_url( $url ) . '" target="_blank">' . $profile_id . '</a>';
798
+        $link = '<a href="' . esc_url($url) . '" target="_blank">' . $profile_id . '</a>';
799 799
     }
800 800
     
801
-    return apply_filters( 'wpinv_paypal_profile_id_link', $link, $profile_id, $subscription );
801
+    return apply_filters('wpinv_paypal_profile_id_link', $link, $profile_id, $subscription);
802 802
 }
803
-add_filter( 'wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2 );
803
+add_filter('wpinv_subscription_profile_link_paypal', 'wpinv_paypal_profile_id_link', 10, 2);
804 804
 
805
-function wpinv_paypal_transaction_id_link( $transaction_id, $subscription ) {
806
-    if ( ! empty( $transaction_id ) && ! empty( $subscription ) && ( $invoice_id = $subscription->get_original_payment_id() ) ) {
807
-        $invoice = wpinv_get_invoice( $invoice_id );
805
+function wpinv_paypal_transaction_id_link($transaction_id, $subscription) {
806
+    if (!empty($transaction_id) && !empty($subscription) && ($invoice_id = $subscription->get_original_payment_id())) {
807
+        $invoice = wpinv_get_invoice($invoice_id);
808 808
 
809
-        if ( ! empty( $invoice ) ) {
810
-            return wpinv_paypal_link_transaction_id( $transaction_id, $invoice_id, $invoice );
809
+        if (!empty($invoice)) {
810
+            return wpinv_paypal_link_transaction_id($transaction_id, $invoice_id, $invoice);
811 811
         }        
812 812
     }
813 813
     
814 814
     return $transaction_id;
815 815
 }
816
-add_filter( 'wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2 );
816
+add_filter('wpinv_subscription_transaction_link_paypal', 'wpinv_paypal_transaction_id_link', 10, 2);
817 817
 
818 818
 function wpinv_is_paypal_valid_for_use() {
819
-    return in_array( wpinv_get_currency(), apply_filters( 'wpinv_paypal_supported_currencies', array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' ) ) );
819
+    return in_array(wpinv_get_currency(), apply_filters('wpinv_paypal_supported_currencies', array('AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR')));
820 820
 }
821 821
 
822
-function wpinv_check_paypal_currency_support( $gateway_list ) {
823
-    if ( isset( $gateway_list['paypal'] ) && ! wpinv_is_paypal_valid_for_use() ) {
824
-        unset( $gateway_list['paypal'] );
822
+function wpinv_check_paypal_currency_support($gateway_list) {
823
+    if (isset($gateway_list['paypal']) && !wpinv_is_paypal_valid_for_use()) {
824
+        unset($gateway_list['paypal']);
825 825
     }
826 826
     return $gateway_list;
827 827
 }
828
-add_filter( 'wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1 );
828
+add_filter('wpinv_enabled_payment_gateways', 'wpinv_check_paypal_currency_support', 10, 1);
829 829
 
830
-function wpinv_gateway_paypal_button_label( $label ) {
831
-    return __( 'Proceed to PayPal', 'invoicing' );
830
+function wpinv_gateway_paypal_button_label($label) {
831
+    return __('Proceed to PayPal', 'invoicing');
832 832
 }
833
-add_filter( 'wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1 );
834 833
\ No newline at end of file
834
+add_filter('wpinv_gateway_paypal_button_label', 'wpinv_gateway_paypal_button_label', 10, 1);
835 835
\ No newline at end of file
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -811,7 +811,7 @@
 block discarded – undo
811 811
 		/**
812 812
 		 * Output the JS for building the dynamic Guntenberg block.
813 813
 		 *
814
-		 * @return mixed
814
+		 * @return string
815 815
 		 */
816 816
 		public function block() {
817 817
 			ob_start();
Please login to merge, or discard this patch.
Indentation   +990 added lines, -990 removed lines patch added patch discarded remove patch
@@ -1,164 +1,164 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 if ( ! class_exists( 'WP_Super_Duper' ) ) {
7 7
 
8 8
 
9
-	/**
10
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
-	 *
12
-	 * Should not be called direct but extended instead.
13
-	 *
14
-	 * Class WP_Super_Duper
15
-	 * @ver 1.0.2
16
-	 */
17
-	class WP_Super_Duper extends WP_Widget {
9
+    /**
10
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
11
+     *
12
+     * Should not be called direct but extended instead.
13
+     *
14
+     * Class WP_Super_Duper
15
+     * @ver 1.0.2
16
+     */
17
+    class WP_Super_Duper extends WP_Widget {
18 18
 
19 19
 
20
-		public $version = "1.0.2";
21
-		public $block_code;
22
-		public $options;
23
-		public $base_id;
24
-		public $arguments = array();
25
-		public $instance = array();
26
-		private $class_name;
20
+        public $version = "1.0.2";
21
+        public $block_code;
22
+        public $options;
23
+        public $base_id;
24
+        public $arguments = array();
25
+        public $instance = array();
26
+        private $class_name;
27 27
 
28
-		/**
29
-		 * Take the array options and use them to build.
30
-		 */
31
-		public function __construct( $options ) {
32
-			global $sd_widgets;
28
+        /**
29
+         * Take the array options and use them to build.
30
+         */
31
+        public function __construct( $options ) {
32
+            global $sd_widgets;
33 33
 
34 34
 
35 35
 
36
-			//print_r($options);exit;
37
-			$sd_widgets[$options['base_id']] = array('name'=> $options['name'],'class_name'=>$options['class_name']);
38
-			$this->base_id = $options['base_id'];
39
-			// lets filter the options before we do anything
40
-			$options       = apply_filters( "wp_super_duper_options", $options );
41
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
42
-			$options       = $this->add_name_from_key( $options );
43
-			$this->options = $options;
36
+            //print_r($options);exit;
37
+            $sd_widgets[$options['base_id']] = array('name'=> $options['name'],'class_name'=>$options['class_name']);
38
+            $this->base_id = $options['base_id'];
39
+            // lets filter the options before we do anything
40
+            $options       = apply_filters( "wp_super_duper_options", $options );
41
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
42
+            $options       = $this->add_name_from_key( $options );
43
+            $this->options = $options;
44 44
 
45
-			$this->base_id   = $options['base_id'];
46
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
45
+            $this->base_id   = $options['base_id'];
46
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
47 47
 
48 48
 
49
-			// init parent
50
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
49
+            // init parent
50
+            parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
51 51
 
52 52
 
53
-			if ( isset( $options['class_name'] ) ) {
54
-				// register widget
55
-				$this->class_name = $options['class_name'];
53
+            if ( isset( $options['class_name'] ) ) {
54
+                // register widget
55
+                $this->class_name = $options['class_name'];
56 56
 
57
-				// register shortcode
58
-				$this->register_shortcode();
57
+                // register shortcode
58
+                $this->register_shortcode();
59 59
 
60
-				// register block
61
-				//$this->register_block();
62
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
63
-			}
60
+                // register block
61
+                //$this->register_block();
62
+                add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
63
+            }
64 64
 
65
-			// add the CSS and JS we need ONCE
66
-			global $sd_widget_scripts;
65
+            // add the CSS and JS we need ONCE
66
+            global $sd_widget_scripts;
67 67
 
68
-			if ( ! $sd_widget_scripts ) {
69
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
70
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
71
-				wp_add_inline_style( 'widgets', $this->widget_css() );
68
+            if ( ! $sd_widget_scripts ) {
69
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
70
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
71
+                wp_add_inline_style( 'widgets', $this->widget_css() );
72 72
 
73
-				// seems ashame to add this for one icon but i love it :(
74
-				//wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), $this->version);
75
-				//wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.1/js/v4-shims.js', array(), $this->version);
73
+                // seems ashame to add this for one icon but i love it :(
74
+                //wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), $this->version);
75
+                //wp_register_script('font-awesome-shim', 'https://use.fontawesome.com/releases/v5.4.1/js/v4-shims.js', array(), $this->version);
76 76
 
77
-				//echo '###';
78
-				$sd_widget_scripts = true;
77
+                //echo '###';
78
+                $sd_widget_scripts = true;
79 79
 
80
-				// add shortcode insert button once
81
-				add_action( 'media_buttons',array( $this, 'shortcode_insert_button' ) );
82
-				//if( !wp_doing_ajax() ){
83
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
84
-				//}
80
+                // add shortcode insert button once
81
+                add_action( 'media_buttons',array( $this, 'shortcode_insert_button' ) );
82
+                //if( !wp_doing_ajax() ){
83
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
84
+                //}
85 85
 
86
-			}
86
+            }
87 87
 
88
-			do_action( 'wp_super_duper_widget_init', $options, $this );
88
+            do_action( 'wp_super_duper_widget_init', $options, $this );
89 89
 
90
-		}
90
+        }
91 91
 
92
-		/**
93
-		 * Get widget settings.
94
-		 *
95
-		 * @since 2.0.0
96
-		 */
97
-		public static function get_widget_settings(){
98
-			global $sd_widgets;
92
+        /**
93
+         * Get widget settings.
94
+         *
95
+         * @since 2.0.0
96
+         */
97
+        public static function get_widget_settings(){
98
+            global $sd_widgets;
99 99
 //			print_r($_REQUEST);
100 100
 //			echo '####';
101 101
 
102
-			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
103
-			if(!$shortcode){wp_die();}
104
-			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] :'';
105
-			if(!$widget_args){wp_die();}
106
-			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
107
-			if(!$class_name){wp_die();}
102
+            $shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
103
+            if(!$shortcode){wp_die();}
104
+            $widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] :'';
105
+            if(!$widget_args){wp_die();}
106
+            $class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
107
+            if(!$class_name){wp_die();}
108 108
 
109 109
 
110 110
 
111
-			//print_r( $sd_widgets );
111
+            //print_r( $sd_widgets );
112 112
 
113 113
 
114
-			// invoke an instance method
114
+            // invoke an instance method
115 115
 //			$instance = new Instance();
116 116
 //			call_user_func( array( $instance, 'method' ) );
117
-			$widget = new $class_name;
117
+            $widget = new $class_name;
118 118
 
119 119
 //			print_r($widget->form(array()));
120
-			ob_start();
121
-			$widget->form(array());
122
-			$form = ob_get_clean();
123
-			echo "<form id='$shortcode'>".$form."<div class=\"widget-control-save\"></div></form>";
120
+            ob_start();
121
+            $widget->form(array());
122
+            $form = ob_get_clean();
123
+            echo "<form id='$shortcode'>".$form."<div class=\"widget-control-save\"></div></form>";
124 124
 //			echo "<div id='sd-shortcode-output'></div>";
125 125
 
126
-			echo "<style>".$widget->widget_css()."</style>";
127
-			echo "<script>".$widget->widget_js()."</script>";
128
-			?>
126
+            echo "<style>".$widget->widget_css()."</style>";
127
+            echo "<script>".$widget->widget_js()."</script>";
128
+            ?>
129 129
 			<?php
130
-			wp_die();
131
-		}
132
-
133
-		/**
134
-		 * Insert button in shortcode.
135
-		 *
136
-		 * @since 2.0.0
137
-		 *
138
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
139
-		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
140
-		 */
141
-		public static function shortcode_insert_button($editor_id = '',$insert_shortcode_function=''){
142
-			global $sd_widgets,$shortcode_insert_button_once;
143
-			if($shortcode_insert_button_once){return;}
144
-			add_thickbox();
145
-			?>
130
+            wp_die();
131
+        }
132
+
133
+        /**
134
+         * Insert button in shortcode.
135
+         *
136
+         * @since 2.0.0
137
+         *
138
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
139
+         * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
140
+         */
141
+        public static function shortcode_insert_button($editor_id = '',$insert_shortcode_function=''){
142
+            global $sd_widgets,$shortcode_insert_button_once;
143
+            if($shortcode_insert_button_once){return;}
144
+            add_thickbox();
145
+            ?>
146 146
 			<div id="super-duper-content" style="display:none;">
147 147
 
148 148
 				<div class="sd-shortcode-left-wrap">
149 149
 					<?php
150
-					//print_r( $sd_widgets );
151
-					asort($sd_widgets );
152
-					if(!empty($sd_widgets)){
153
-						echo '<select onchange="sd_get_shortcode_options(this);">';
154
-						echo "<option>".__('Select shortcode')."</option>";
155
-						foreach($sd_widgets as $shortcode => $class){
156
-							echo "<option value='".esc_attr($shortcode)."'>".esc_attr($shortcode)." (".esc_attr($class['name']).")</option>";
157
-						}
158
-						echo "</select>";
159
-
160
-					}
161
-					?>
150
+                    //print_r( $sd_widgets );
151
+                    asort($sd_widgets );
152
+                    if(!empty($sd_widgets)){
153
+                        echo '<select onchange="sd_get_shortcode_options(this);">';
154
+                        echo "<option>".__('Select shortcode')."</option>";
155
+                        foreach($sd_widgets as $shortcode => $class){
156
+                            echo "<option value='".esc_attr($shortcode)."'>".esc_attr($shortcode)." (".esc_attr($class['name']).")</option>";
157
+                        }
158
+                        echo "</select>";
159
+
160
+                    }
161
+                    ?>
162 162
 					<div class="sd-shortcode-settings"></div>
163 163
 
164 164
 				</div>
@@ -196,16 +196,16 @@  discard block
 block discarded – undo
196 196
 			<script>
197 197
 
198 198
 				<?php
199
-				if(!empty($insert_shortcode_function)){
200
-					echo $insert_shortcode_function;
201
-				}else{
202
-
203
-				/**
204
-				 * Function for super duper insert shortcode.
205
-				 *
206
-				 * @since 2.0.0
207
-				 */
208
-				?>
199
+                if(!empty($insert_shortcode_function)){
200
+                    echo $insert_shortcode_function;
201
+                }else{
202
+
203
+                /**
204
+                 * Function for super duper insert shortcode.
205
+                 *
206
+                 * @since 2.0.0
207
+                 */
208
+                ?>
209 209
 				function sd_insert_shortcode(){
210 210
 					$shortcode = jQuery('#sd-shortcode-output').val();
211 211
 					if($shortcode){
@@ -345,12 +345,12 @@  discard block
 block discarded – undo
345 345
 				}
346 346
 			</script>
347 347
 			<?php
348
-			$shortcode_insert_button_once = true;
349
-		}
348
+            $shortcode_insert_button_once = true;
349
+        }
350 350
 
351
-		public function widget_css() {
352
-			ob_start();
353
-			?>
351
+        public function widget_css() {
352
+            ob_start();
353
+            ?>
354 354
 			<style>
355 355
 				/*body {display: none;}*/
356 356
 				.sd-advanced-setting {
@@ -372,21 +372,21 @@  discard block
 block discarded – undo
372 372
 				}
373 373
 			</style>
374 374
 			<?php
375
-			$output = ob_get_clean();
375
+            $output = ob_get_clean();
376 376
 
377
-			/*
377
+            /*
378 378
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
379 379
 			 */
380 380
 
381
-			return str_replace( array(
382
-				'<style>',
383
-				'</style>'
384
-			), '', $output );
385
-		}
381
+            return str_replace( array(
382
+                '<style>',
383
+                '</style>'
384
+            ), '', $output );
385
+        }
386 386
 
387
-		public function widget_js() {
388
-			ob_start();
389
-			?>
387
+        public function widget_js() {
388
+            ob_start();
389
+            ?>
390 390
 			<script>
391 391
 
392 392
 				/**
@@ -542,280 +542,280 @@  discard block
 block discarded – undo
542 542
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
543 543
 			</script>
544 544
 			<?php
545
-			$output = ob_get_clean();
545
+            $output = ob_get_clean();
546 546
 
547
-			/*
547
+            /*
548 548
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
549 549
 			 */
550 550
 
551
-			return str_replace( array(
552
-				'<script>',
553
-				'</script>'
554
-			), '', $output );
555
-		}
556
-
557
-
558
-		/**
559
-		 * Set the name from the argument key.
560
-		 *
561
-		 * @param $options
562
-		 *
563
-		 * @return mixed
564
-		 */
565
-		private function add_name_from_key( $options, $arguments = false ) {
566
-			if ( ! empty( $options['arguments'] ) ) {
567
-				foreach ( $options['arguments'] as $key => $val ) {
568
-					$options['arguments'][ $key ]['name'] = $key;
569
-				}
570
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
571
-				foreach ( $options as $key => $val ) {
572
-					$options[ $key ]['name'] = $key;
573
-				}
574
-			}
575
-
576
-			return $options;
577
-		}
578
-
579
-		/**
580
-		 * Register the parent shortcode.
581
-		 *
582
-		 * @since 2.0.0
583
-		 */
584
-		public function register_shortcode() {
585
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
586
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
587
-		}
588
-
589
-		/**
590
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
591
-		 *
592
-		 * @since 2.0.0
593
-		 */
594
-		public static function render_shortcode() {
595
-
596
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
597
-			if ( ! current_user_can( 'manage_options' ) ) {
598
-				wp_die();
599
-			}
600
-
601
-			// we might need the $post value here so lets set it.
602
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
603
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
604
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
605
-					global $post;
606
-					$post = $post_obj;
607
-				}
608
-			}
609
-
610
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
611
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
612
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
613
-				$attributes       = '';
614
-				if ( ! empty( $attributes_array ) ) {
615
-					foreach ( $attributes_array as $key => $value ) {
616
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
617
-					}
618
-				}
619
-
620
-				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
621
-
622
-				echo do_shortcode( $shortcode );
623
-
624
-			}
625
-			wp_die();
626
-		}
627
-
628
-		/**
629
-		 * Output the shortcode.
630
-		 *
631
-		 * @param array $args
632
-		 * @param string $content
633
-		 */
634
-		public function shortcode_output( $args = array(), $content = '' ) {
635
-			$args = self::argument_values( $args );
636
-
637
-			// add extra argument so we know its a output to gutenberg
638
-			//$args
639
-			$args = $this->string_to_bool( $args );
640
-
641
-
642
-			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
643
-
644
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
645
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
646
-
647
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
648
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
649
-
650
-			$shortcode_args = array();
651
-			$output = '';
652
-			$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ?  true : false;
653
-			$main_content = $this->output( $args, $shortcode_args, $content );
654
-			if($main_content && !$no_wrap){
655
-				// wrap the shortcode in a dive with the same class as the widget
656
-				$output .= '<div class="'.$calss.'" ' . $attrs . '>';
657
-				if(!empty($args['title'])){
658
-					// if its a shortcode and there is a title try to grab the title wrappers
659
-					$shortcode_args = array('before_title'=>'', 'after_title' => '');
660
-					if(empty($instance)){
661
-						global $wp_registered_sidebars;
662
-						if(!empty($wp_registered_sidebars)){
663
-							foreach($wp_registered_sidebars as $sidebar){
664
-								if(!empty($sidebar['before_title'])){
665
-									$shortcode_args['before_title'] = $sidebar['before_title'];
666
-									$shortcode_args['after_title'] = $sidebar['after_title'];
667
-									break;
668
-								}
669
-							}
670
-						}
671
-					}
672
-					$output .= $this->output_title($shortcode_args,$args);
673
-				}
674
-				$output .= $main_content;
675
-				$output .= '</div>';
676
-			}elseif($main_content && $no_wrap){
677
-				$output .= $main_content;
678
-			}
679
-
680
-			return $output;
681
-		}
682
-
683
-
684
-		/**
685
-		 * Sometimes booleans values can be turned to strings, so we fix that.
686
-		 *
687
-		 * @param $options
688
-		 *
689
-		 * @return mixed
690
-		 */
691
-		public function string_to_bool( $options ) {
692
-			// convert bool strings to booleans
693
-			foreach ( $options as $key => $val ) {
694
-				if ( $val == 'false' ) {
695
-					$options[ $key ] = false;
696
-				} elseif ( $val == 'true' ) {
697
-					$options[ $key ] = true;
698
-				}
699
-			}
700
-
701
-			return $options;
702
-		}
703
-
704
-		/**
705
-		 * Get the argument values that are also filterable.
706
-		 *
707
-		 * @param $instance
708
-		 *
709
-		 * @return array
710
-		 */
711
-		public function argument_values( $instance ) {
712
-			$argument_values = array();
713
-
714
-			// set widget instance
715
-			$this->instance = $instance;
716
-
717
-			if ( empty( $this->arguments ) ) {
718
-				$this->arguments = $this->get_arguments();
719
-			}
720
-
721
-			if ( ! empty( $this->arguments ) ) {
722
-				foreach ( $this->arguments as $key => $args ) {
723
-					// set the input name from the key
724
-					$args['name'] = $key;
725
-					//
726
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
727
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
728
-						$argument_values[ $key ] = $args['default'];
729
-					}
730
-				}
731
-			}
732
-
733
-			return $argument_values;
734
-		}
735
-
736
-		/**
737
-		 * Set arguments in super duper.
738
-		 *
739
-		 * @since 2.0.0
740
-		 *
741
-		 * @return array Set arguments.
742
-		 */
743
-		public function set_arguments() {
744
-			return $this->arguments;
745
-		}
746
-
747
-		/**
748
-		 * Get arguments in super duper.
749
-		 *
750
-		 * @since 2.0.0
751
-		 *
752
-		 * @return array Get arguments.
753
-		 */
754
-		public function get_arguments() {
755
-			if ( empty( $this->arguments ) ) {
756
-				$this->arguments =  $this->set_arguments();
757
-			}
758
-
759
-			$this->arguments = apply_filters('wp_super_duper_arguments',$this->arguments,$this->options, $this->instance);
760
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
761
-
762
-
763
-			return $this->arguments;
764
-		}
765
-
766
-		/**
767
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
768
-		 *
769
-		 * @param array $args
770
-		 * @param array $widget_args
771
-		 * @param string $content
772
-		 */
773
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
774
-
775
-		}
776
-
777
-		/**
778
-		 * Add the dyanmic block code inline when the wp-block in enqueued.
779
-		 */
780
-		public function register_block() {
781
-			wp_add_inline_script( 'wp-blocks', $this->block() );
782
-		}
783
-
784
-
785
-		/**
786
-		 * Check if we need to show advanced options.
787
-		 *
788
-		 * @return bool
789
-		 */
790
-		public function block_show_advanced() {
791
-			//$this->arguments
792
-			$show      = false;
793
-			$arguments = $this->arguments;
794
-
795
-			if(empty($arguments)){
796
-				$arguments = $this->get_arguments();
797
-			}
798
-
799
-			if ( ! empty( $arguments ) ) {
800
-				foreach ( $arguments as $argument ) {
801
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
802
-						$show = true;
803
-					}
804
-				}
805
-			}
806
-
807
-			return $show;
808
-		}
809
-
810
-
811
-		/**
812
-		 * Output the JS for building the dynamic Guntenberg block.
813
-		 *
814
-		 * @return mixed
815
-		 */
816
-		public function block() {
817
-			ob_start();
818
-			?>
551
+            return str_replace( array(
552
+                '<script>',
553
+                '</script>'
554
+            ), '', $output );
555
+        }
556
+
557
+
558
+        /**
559
+         * Set the name from the argument key.
560
+         *
561
+         * @param $options
562
+         *
563
+         * @return mixed
564
+         */
565
+        private function add_name_from_key( $options, $arguments = false ) {
566
+            if ( ! empty( $options['arguments'] ) ) {
567
+                foreach ( $options['arguments'] as $key => $val ) {
568
+                    $options['arguments'][ $key ]['name'] = $key;
569
+                }
570
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
571
+                foreach ( $options as $key => $val ) {
572
+                    $options[ $key ]['name'] = $key;
573
+                }
574
+            }
575
+
576
+            return $options;
577
+        }
578
+
579
+        /**
580
+         * Register the parent shortcode.
581
+         *
582
+         * @since 2.0.0
583
+         */
584
+        public function register_shortcode() {
585
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
586
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
587
+        }
588
+
589
+        /**
590
+         * Render the shortcode via ajax so we can return it to Gutenberg.
591
+         *
592
+         * @since 2.0.0
593
+         */
594
+        public static function render_shortcode() {
595
+
596
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
597
+            if ( ! current_user_can( 'manage_options' ) ) {
598
+                wp_die();
599
+            }
600
+
601
+            // we might need the $post value here so lets set it.
602
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
603
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
604
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
605
+                    global $post;
606
+                    $post = $post_obj;
607
+                }
608
+            }
609
+
610
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
611
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
612
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
613
+                $attributes       = '';
614
+                if ( ! empty( $attributes_array ) ) {
615
+                    foreach ( $attributes_array as $key => $value ) {
616
+                        $attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
617
+                    }
618
+                }
619
+
620
+                $shortcode = "[" . $shortcode_name . " " . $attributes . "]";
621
+
622
+                echo do_shortcode( $shortcode );
623
+
624
+            }
625
+            wp_die();
626
+        }
627
+
628
+        /**
629
+         * Output the shortcode.
630
+         *
631
+         * @param array $args
632
+         * @param string $content
633
+         */
634
+        public function shortcode_output( $args = array(), $content = '' ) {
635
+            $args = self::argument_values( $args );
636
+
637
+            // add extra argument so we know its a output to gutenberg
638
+            //$args
639
+            $args = $this->string_to_bool( $args );
640
+
641
+
642
+            $calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
643
+
644
+            $calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
645
+            $calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
646
+
647
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
648
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
649
+
650
+            $shortcode_args = array();
651
+            $output = '';
652
+            $no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ?  true : false;
653
+            $main_content = $this->output( $args, $shortcode_args, $content );
654
+            if($main_content && !$no_wrap){
655
+                // wrap the shortcode in a dive with the same class as the widget
656
+                $output .= '<div class="'.$calss.'" ' . $attrs . '>';
657
+                if(!empty($args['title'])){
658
+                    // if its a shortcode and there is a title try to grab the title wrappers
659
+                    $shortcode_args = array('before_title'=>'', 'after_title' => '');
660
+                    if(empty($instance)){
661
+                        global $wp_registered_sidebars;
662
+                        if(!empty($wp_registered_sidebars)){
663
+                            foreach($wp_registered_sidebars as $sidebar){
664
+                                if(!empty($sidebar['before_title'])){
665
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
666
+                                    $shortcode_args['after_title'] = $sidebar['after_title'];
667
+                                    break;
668
+                                }
669
+                            }
670
+                        }
671
+                    }
672
+                    $output .= $this->output_title($shortcode_args,$args);
673
+                }
674
+                $output .= $main_content;
675
+                $output .= '</div>';
676
+            }elseif($main_content && $no_wrap){
677
+                $output .= $main_content;
678
+            }
679
+
680
+            return $output;
681
+        }
682
+
683
+
684
+        /**
685
+         * Sometimes booleans values can be turned to strings, so we fix that.
686
+         *
687
+         * @param $options
688
+         *
689
+         * @return mixed
690
+         */
691
+        public function string_to_bool( $options ) {
692
+            // convert bool strings to booleans
693
+            foreach ( $options as $key => $val ) {
694
+                if ( $val == 'false' ) {
695
+                    $options[ $key ] = false;
696
+                } elseif ( $val == 'true' ) {
697
+                    $options[ $key ] = true;
698
+                }
699
+            }
700
+
701
+            return $options;
702
+        }
703
+
704
+        /**
705
+         * Get the argument values that are also filterable.
706
+         *
707
+         * @param $instance
708
+         *
709
+         * @return array
710
+         */
711
+        public function argument_values( $instance ) {
712
+            $argument_values = array();
713
+
714
+            // set widget instance
715
+            $this->instance = $instance;
716
+
717
+            if ( empty( $this->arguments ) ) {
718
+                $this->arguments = $this->get_arguments();
719
+            }
720
+
721
+            if ( ! empty( $this->arguments ) ) {
722
+                foreach ( $this->arguments as $key => $args ) {
723
+                    // set the input name from the key
724
+                    $args['name'] = $key;
725
+                    //
726
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
727
+                    if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
728
+                        $argument_values[ $key ] = $args['default'];
729
+                    }
730
+                }
731
+            }
732
+
733
+            return $argument_values;
734
+        }
735
+
736
+        /**
737
+         * Set arguments in super duper.
738
+         *
739
+         * @since 2.0.0
740
+         *
741
+         * @return array Set arguments.
742
+         */
743
+        public function set_arguments() {
744
+            return $this->arguments;
745
+        }
746
+
747
+        /**
748
+         * Get arguments in super duper.
749
+         *
750
+         * @since 2.0.0
751
+         *
752
+         * @return array Get arguments.
753
+         */
754
+        public function get_arguments() {
755
+            if ( empty( $this->arguments ) ) {
756
+                $this->arguments =  $this->set_arguments();
757
+            }
758
+
759
+            $this->arguments = apply_filters('wp_super_duper_arguments',$this->arguments,$this->options, $this->instance);
760
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
761
+
762
+
763
+            return $this->arguments;
764
+        }
765
+
766
+        /**
767
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
768
+         *
769
+         * @param array $args
770
+         * @param array $widget_args
771
+         * @param string $content
772
+         */
773
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
774
+
775
+        }
776
+
777
+        /**
778
+         * Add the dyanmic block code inline when the wp-block in enqueued.
779
+         */
780
+        public function register_block() {
781
+            wp_add_inline_script( 'wp-blocks', $this->block() );
782
+        }
783
+
784
+
785
+        /**
786
+         * Check if we need to show advanced options.
787
+         *
788
+         * @return bool
789
+         */
790
+        public function block_show_advanced() {
791
+            //$this->arguments
792
+            $show      = false;
793
+            $arguments = $this->arguments;
794
+
795
+            if(empty($arguments)){
796
+                $arguments = $this->get_arguments();
797
+            }
798
+
799
+            if ( ! empty( $arguments ) ) {
800
+                foreach ( $arguments as $argument ) {
801
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
802
+                        $show = true;
803
+                    }
804
+                }
805
+            }
806
+
807
+            return $show;
808
+        }
809
+
810
+
811
+        /**
812
+         * Output the JS for building the dynamic Guntenberg block.
813
+         *
814
+         * @return mixed
815
+         */
816
+        public function block() {
817
+            ob_start();
818
+            ?>
819 819
 			<script>
820 820
 				/**
821 821
 				 * BLOCK: Basic
@@ -854,67 +854,67 @@  discard block
 block discarded – undo
854 854
 						icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
855 855
 						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
856 856
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
857
-						echo "keywords : " . $this->options['block-keywords'] . ",";
858
-					}?>
857
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
858
+                    }?>
859 859
 
860 860
 						<?php
861 861
 
862
-						$show_advanced = $this->block_show_advanced();
863
-
864
-						$show_alignment = false;
865
-
866
-						if ( ! empty( $this->arguments ) ) {
867
-							echo "attributes : {";
868
-
869
-							if ( $show_advanced ) {
870
-								echo "show_advanced: {";
871
-								echo "	type: 'boolean',";
872
-								echo "  default: false,";
873
-								echo "},";
874
-							}
875
-
876
-							foreach ( $this->arguments as $key => $args ) {
877
-
878
-								// set if we should show alignment
879
-								if ( $key == 'alignment' ) {
880
-									$show_alignment = true;
881
-								}
882
-
883
-								$extra = '';
884
-
885
-								if ( $args['type'] == 'checkbox' ) {
886
-									$type    = 'boolean';
887
-									$default = isset( $args['default'] ) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
-								} elseif ( $args['type'] == 'number' ) {
889
-									$type    = 'number';
890
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
891
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
892
-									$type    = 'array';
893
-									if(is_array($args['default'])){
894
-										$default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
-									}else{
896
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
897
-									}
898
-								} elseif ( $args['type'] == 'multiselect' ) {
899
-									$type    = 'array';
900
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
901
-								} else {
902
-									$type    = 'string';
903
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
904
-								}
905
-								echo $key . " : {";
906
-								echo "type : '$type',";
907
-								echo "default : $default,";
908
-								echo "},";
909
-							}
910
-
911
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
912
-
913
-							echo "},";
914
-
915
-						}
916
-
917
-						?>
862
+                        $show_advanced = $this->block_show_advanced();
863
+
864
+                        $show_alignment = false;
865
+
866
+                        if ( ! empty( $this->arguments ) ) {
867
+                            echo "attributes : {";
868
+
869
+                            if ( $show_advanced ) {
870
+                                echo "show_advanced: {";
871
+                                echo "	type: 'boolean',";
872
+                                echo "  default: false,";
873
+                                echo "},";
874
+                            }
875
+
876
+                            foreach ( $this->arguments as $key => $args ) {
877
+
878
+                                // set if we should show alignment
879
+                                if ( $key == 'alignment' ) {
880
+                                    $show_alignment = true;
881
+                                }
882
+
883
+                                $extra = '';
884
+
885
+                                if ( $args['type'] == 'checkbox' ) {
886
+                                    $type    = 'boolean';
887
+                                    $default = isset( $args['default'] ) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
+                                } elseif ( $args['type'] == 'number' ) {
889
+                                    $type    = 'number';
890
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
891
+                                } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
892
+                                    $type    = 'array';
893
+                                    if(is_array($args['default'])){
894
+                                        $default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
+                                    }else{
896
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
897
+                                    }
898
+                                } elseif ( $args['type'] == 'multiselect' ) {
899
+                                    $type    = 'array';
900
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
901
+                                } else {
902
+                                    $type    = 'string';
903
+                                    $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
904
+                                }
905
+                                echo $key . " : {";
906
+                                echo "type : '$type',";
907
+                                echo "default : $default,";
908
+                                echo "},";
909
+                            }
910
+
911
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
912
+
913
+                            echo "},";
914
+
915
+                        }
916
+
917
+                        ?>
918 918
 
919 919
 						// The "edit" property must be a valid function.
920 920
 						edit: function (props) {
@@ -933,8 +933,8 @@  discard block
 block discarded – undo
933 933
 										'shortcode': '<?php echo $this->options['base_id'];?>',
934 934
 										'attributes': props.attributes,
935 935
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
936
-										echo $post->ID;
937
-									}?>,
936
+                                        echo $post->ID;
937
+                                    }?>,
938 938
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
939 939
 									};
940 940
 
@@ -976,10 +976,10 @@  discard block
 block discarded – undo
976 976
 
977 977
 									<?php
978 978
 
979
-									if(! empty( $this->arguments )){
979
+                                    if(! empty( $this->arguments )){
980 980
 
981
-									if ( $show_advanced ) {
982
-									?>
981
+                                    if ( $show_advanced ) {
982
+                                    ?>
983 983
 									el(
984 984
 										wp.components.ToggleControl,
985 985
 										{
@@ -992,65 +992,65 @@  discard block
 block discarded – undo
992 992
 									),
993 993
 									<?php
994 994
 
995
-									}
996
-
997
-									foreach($this->arguments as $key => $args){
998
-									$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
999
-									$options = '';
1000
-									$extra = '';
1001
-									$require = '';
1002
-									$onchange = "props.setAttributes({ $key: $key } )";
1003
-									$value = "props.attributes.$key";
1004
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1005
-									if ( in_array( $args['type'], $text_type ) ) {
1006
-										$type = 'TextControl';
1007
-									} elseif ( $args['type'] == 'checkbox' ) {
1008
-										$type = 'CheckboxControl';
1009
-										$extra .= "checked: props.attributes.$key,";
1010
-										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1011
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1012
-										$type = 'SelectControl';
1013
-										if ( ! empty( $args['options'] ) ) {
1014
-											$options .= "options  : [";
1015
-											foreach ( $args['options'] as $option_val => $option_label ) {
1016
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1017
-											}
1018
-											$options .= "],";
1019
-										}
1020
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1021
-											$extra .= ' multiple: true, ';
1022
-											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1023
-											//$value = "['edit', 'delete']";
1024
-										}
1025
-									} elseif ( $args['type'] == 'alignment' ) {
1026
-										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1027
-									} else {
1028
-										continue;// if we have not implemented the control then don't break the JS.
1029
-									}
1030
-
1031
-									// add show only if advanced
1032
-									if ( ! empty( $args['advanced'] ) ) {
1033
-										echo "props.attributes.show_advanced && ";
1034
-									}
1035
-									// add setting require if defined
1036
-									if ( ! empty( $args['element_require'] ) ) {
1037
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1038
-									}
1039
-									?>
995
+                                    }
996
+
997
+                                    foreach($this->arguments as $key => $args){
998
+                                    $custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
999
+                                    $options = '';
1000
+                                    $extra = '';
1001
+                                    $require = '';
1002
+                                    $onchange = "props.setAttributes({ $key: $key } )";
1003
+                                    $value = "props.attributes.$key";
1004
+                                    $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1005
+                                    if ( in_array( $args['type'], $text_type ) ) {
1006
+                                        $type = 'TextControl';
1007
+                                    } elseif ( $args['type'] == 'checkbox' ) {
1008
+                                        $type = 'CheckboxControl';
1009
+                                        $extra .= "checked: props.attributes.$key,";
1010
+                                        $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1011
+                                    } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1012
+                                        $type = 'SelectControl';
1013
+                                        if ( ! empty( $args['options'] ) ) {
1014
+                                            $options .= "options  : [";
1015
+                                            foreach ( $args['options'] as $option_val => $option_label ) {
1016
+                                                $options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1017
+                                            }
1018
+                                            $options .= "],";
1019
+                                        }
1020
+                                        if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1021
+                                            $extra .= ' multiple: true, ';
1022
+                                            //$onchange = "props.setAttributes({ $key: ['edit'] } )";
1023
+                                            //$value = "['edit', 'delete']";
1024
+                                        }
1025
+                                    } elseif ( $args['type'] == 'alignment' ) {
1026
+                                        $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1027
+                                    } else {
1028
+                                        continue;// if we have not implemented the control then don't break the JS.
1029
+                                    }
1030
+
1031
+                                    // add show only if advanced
1032
+                                    if ( ! empty( $args['advanced'] ) ) {
1033
+                                        echo "props.attributes.show_advanced && ";
1034
+                                    }
1035
+                                    // add setting require if defined
1036
+                                    if ( ! empty( $args['element_require'] ) ) {
1037
+                                        echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1038
+                                    }
1039
+                                    ?>
1040 1040
 									el(
1041 1041
 										wp.components.<?php echo esc_attr( $type );?>,
1042 1042
 										{
1043 1043
 											label: '<?php echo esc_attr( $args['title'] );?>',
1044 1044
 											help: '<?php if ( isset( $args['desc'] ) ) {
1045
-												echo esc_attr( $args['desc'] );
1046
-											}?>',
1045
+                                                echo esc_attr( $args['desc'] );
1046
+                                            }?>',
1047 1047
 											value: <?php echo $value;?>,
1048 1048
 											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1049
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1050
-										}?>
1049
+                                            echo "type: '" . esc_attr( $args['type'] ) . "',";
1050
+                                        }?>
1051 1051
 											<?php if ( ! empty( $args['placeholder'] ) ) {
1052
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1053
-										}?>
1052
+                                            echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1053
+                                        }?>
1054 1054
 											<?php echo $options;?>
1055 1055
 											<?php echo $extra;?>
1056 1056
 											<?php echo $custom_attributes;?>
@@ -1060,27 +1060,27 @@  discard block
 block discarded – undo
1060 1060
 										}
1061 1061
 									),
1062 1062
 									<?php
1063
-									}
1064
-									}
1065
-									?>
1063
+                                    }
1064
+                                    }
1065
+                                    ?>
1066 1066
 
1067 1067
 								),
1068 1068
 
1069 1069
 								<?php
1070
-								// If the user sets block-output array then build it
1071
-								if ( ! empty( $this->options['block-output'] ) ) {
1072
-								$this->block_element( $this->options['block-output'] );
1073
-							}else{
1074
-								// if no block-output is set then we try and get the shortcode html output via ajax.
1075
-								?>
1070
+                                // If the user sets block-output array then build it
1071
+                                if ( ! empty( $this->options['block-output'] ) ) {
1072
+                                $this->block_element( $this->options['block-output'] );
1073
+                            }else{
1074
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
1075
+                                ?>
1076 1076
 								el('div', {
1077 1077
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
1078 1078
 									className: props.className,
1079 1079
 									style: {'min-height': '30px'}
1080 1080
 								})
1081 1081
 								<?php
1082
-								}
1083
-								?>
1082
+                                }
1083
+                                ?>
1084 1084
 							]; // end return
1085 1085
 						},
1086 1086
 
@@ -1097,17 +1097,17 @@  discard block
 block discarded – undo
1097 1097
 							var content = "[<?php echo $this->options['base_id'];?>";
1098 1098
 							<?php
1099 1099
 
1100
-							if(! empty( $this->arguments )){
1101
-							foreach($this->arguments as $key => $args){
1102
-							?>
1100
+                            if(! empty( $this->arguments )){
1101
+                            foreach($this->arguments as $key => $args){
1102
+                            ?>
1103 1103
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1104 1104
 								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1105 1105
 							}
1106 1106
 							<?php
1107
-							}
1108
-							}
1107
+                            }
1108
+                            }
1109 1109
 
1110
-							?>
1110
+                            ?>
1111 1111
 							content += "]";
1112 1112
 
1113 1113
 
@@ -1132,367 +1132,367 @@  discard block
 block discarded – undo
1132 1132
 				})();
1133 1133
 			</script>
1134 1134
 			<?php
1135
-			$output = ob_get_clean();
1135
+            $output = ob_get_clean();
1136 1136
 
1137
-			/*
1137
+            /*
1138 1138
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1139 1139
 			 */
1140 1140
 
1141
-			return str_replace( array(
1142
-				'<script>',
1143
-				'</script>'
1144
-			), '', $output );
1145
-		}
1146
-
1147
-		/**
1148
-		 * Convert an array of attributes to block string.
1149
-		 *
1150
-		 * @todo there is prob a faster way to do this, also we could add some validation here.
1151
-		 * @param $custom_attributes
1152
-		 *
1153
-		 * @return string
1154
-		 */
1155
-		public function array_to_attributes($custom_attributes, $html = false){
1156
-			$attributes = '';
1157
-			if(!empty($custom_attributes)){
1158
-
1159
-				if($html){
1160
-					foreach($custom_attributes as $key => $val){
1161
-						$attributes .= " $key='$val' ";
1162
-					}
1163
-				}else{
1164
-					foreach($custom_attributes as $key => $val){
1165
-						$attributes .= "'$key': '$val',";
1166
-					}
1167
-				}
1168
-			}
1169
-
1170
-			return $attributes;
1171
-		}
1172
-
1173
-
1174
-		/**
1175
-		 * A self looping function to create the output for JS block elements.
1176
-		 *
1177
-		 * This is what is output in the WP Editor visual view.
1178
-		 *
1179
-		 * @param $args
1180
-		 */
1181
-		public function block_element( $args ) {
1182
-
1183
-
1184
-			if ( ! empty( $args ) ) {
1185
-				foreach ( $args as $element => $new_args ) {
1186
-
1187
-					if ( is_array( $new_args ) ) { // its an element
1188
-
1189
-
1190
-						if ( isset( $new_args['element'] ) ) {
1191
-
1192
-							//print_r($new_args);
1193
-
1194
-							if ( isset( $new_args['element_require'] ) ) {
1195
-								echo str_replace( array(
1196
-										"'+",
1197
-										"+'"
1198
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1199
-								unset( $new_args['element_require'] );
1200
-							}
1201
-
1202
-							echo "\n el( '" . $new_args['element'] . "', {";
1203
-
1204
-							// get the attributes
1205
-							foreach ( $new_args as $new_key => $new_value ) {
1206
-
1207
-
1208
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1209
-									// do nothing
1210
-								} else {
1211
-									echo $this->block_element( array( $new_key => $new_value ) );
1212
-								}
1213
-							}
1214
-
1215
-							echo "},";// end attributes
1216
-
1217
-							// get the content
1218
-							$first_item = 0;
1219
-							foreach ( $new_args as $new_key => $new_value ) {
1220
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1221
-									//echo ",".$first_item;// separate the children
1222
-
1223
-
1224
-									if ( $first_item > 0 ) {
1225
-										//echo ",";// separate the children
1226
-									} else {
1227
-										//echo '####'.$first_item;
1228
-									}
1229
-
1230
-									if ( $new_key === 'content' ) {
1231
-										//print_r($new_args);
1232
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1233
-									}
1234
-
1235
-									if ( is_array( $new_value ) ) {
1236
-
1237
-										if ( isset( $new_value['element_require'] ) ) {
1238
-											echo str_replace( array(
1239
-													"'+",
1240
-													"+'"
1241
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1242
-											unset( $new_value['element_require'] );
1243
-										}
1244
-
1245
-										if ( isset( $new_value['element_repeat'] ) ) {
1246
-											$x = 1;
1247
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1248
-												$this->block_element( array( '' => $new_value ) );
1249
-												$x ++;
1250
-											}
1251
-										} else {
1252
-											$this->block_element( array( '' => $new_value ) );
1253
-										}
1254
-										//print_r($new_value);
1255
-									}
1256
-									$first_item ++;
1257
-								}
1258
-							}
1259
-
1260
-							echo ")";// end content
1261
-
1262
-							//if($first_item>0){
1263
-							echo ", \n";
1264
-							//}
1265
-
1266
-
1267
-						}
1268
-						//$this->block_element($new_args);
1269
-					} else {
1270
-
1271
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1272
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1273
-						} elseif ( $element == 'style' ) {
1274
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1275
-						} else {
1276
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1277
-						}
1278
-
1279
-					}
1280
-
1281
-
1282
-				}
1283
-			}
1284
-		}
1285
-
1286
-		/**
1287
-		 * Replace block attributes placeholders with the proper naming.
1288
-		 *
1289
-		 * @param $string
1290
-		 *
1291
-		 * @return mixed
1292
-		 */
1293
-		public function block_props_replace( $string, $no_wrap = false ) {
1294
-
1295
-			if ( $no_wrap ) {
1296
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1297
-			} else {
1298
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1299
-			}
1300
-
1301
-			return $string;
1302
-		}
1303
-
1304
-		/**
1305
-		 * Outputs the content of the widget
1306
-		 *
1307
-		 * @param array $args
1308
-		 * @param array $instance
1309
-		 */
1310
-		public function widget( $args, $instance ) {
1311
-			// outputs the content of the widget
1312
-
1313
-			// get the filtered values
1314
-			$argument_values = $this->argument_values( $instance );
1315
-			$argument_values = $this->string_to_bool( $argument_values );
1316
-			$output = $this->output( $argument_values, $args );
1317
-
1318
-			if ( $output ) {
1319
-				// Before widget
1320
-				$before_widget = $args['before_widget'];
1321
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1322
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1323
-
1324
-				// After widget
1325
-				$after_widget = $args['after_widget'];
1326
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1327
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1328
-
1329
-				echo $before_widget;
1330
-				echo $this->output_title($args, $instance);
1331
-				echo $output;
1332
-				echo $after_widget;
1333
-			}
1334
-		}
1335
-
1336
-		/**
1337
-		 * Output the super title.
1338
-		 *
1339
-		 * @param $args
1340
-		 * @param array $instance
1341
-		 *
1342
-		 * @return string
1343
-		 */
1344
-		public function output_title($args, $instance = array()){
1345
-			$output = '';
1346
-			if ( ! empty( $instance['title'] ) ) {
1347
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
1348
-				$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
1349
-				$output = $args['before_title'] . $title . $args['after_title'];
1350
-			}
1351
-			return $output;
1352
-		}
1353
-
1354
-		/**
1355
-		 * Outputs the options form inputs for the widget.
1356
-		 *
1357
-		 * @param array $instance The widget options.
1358
-		 */
1359
-		public function form( $instance ) {
1360
-
1361
-			// set widget instance
1362
-			$this->instance = $instance;
1363
-
1364
-			// set it as a SD widget
1365
-			echo $this->widget_advanced_toggle();
1366
-
1367
-
1368
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
1369
-			$arguments = $this->get_arguments();
1141
+            return str_replace( array(
1142
+                '<script>',
1143
+                '</script>'
1144
+            ), '', $output );
1145
+        }
1146
+
1147
+        /**
1148
+         * Convert an array of attributes to block string.
1149
+         *
1150
+         * @todo there is prob a faster way to do this, also we could add some validation here.
1151
+         * @param $custom_attributes
1152
+         *
1153
+         * @return string
1154
+         */
1155
+        public function array_to_attributes($custom_attributes, $html = false){
1156
+            $attributes = '';
1157
+            if(!empty($custom_attributes)){
1158
+
1159
+                if($html){
1160
+                    foreach($custom_attributes as $key => $val){
1161
+                        $attributes .= " $key='$val' ";
1162
+                    }
1163
+                }else{
1164
+                    foreach($custom_attributes as $key => $val){
1165
+                        $attributes .= "'$key': '$val',";
1166
+                    }
1167
+                }
1168
+            }
1169
+
1170
+            return $attributes;
1171
+        }
1172
+
1173
+
1174
+        /**
1175
+         * A self looping function to create the output for JS block elements.
1176
+         *
1177
+         * This is what is output in the WP Editor visual view.
1178
+         *
1179
+         * @param $args
1180
+         */
1181
+        public function block_element( $args ) {
1182
+
1183
+
1184
+            if ( ! empty( $args ) ) {
1185
+                foreach ( $args as $element => $new_args ) {
1186
+
1187
+                    if ( is_array( $new_args ) ) { // its an element
1188
+
1189
+
1190
+                        if ( isset( $new_args['element'] ) ) {
1191
+
1192
+                            //print_r($new_args);
1193
+
1194
+                            if ( isset( $new_args['element_require'] ) ) {
1195
+                                echo str_replace( array(
1196
+                                        "'+",
1197
+                                        "+'"
1198
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1199
+                                unset( $new_args['element_require'] );
1200
+                            }
1201
+
1202
+                            echo "\n el( '" . $new_args['element'] . "', {";
1203
+
1204
+                            // get the attributes
1205
+                            foreach ( $new_args as $new_key => $new_value ) {
1206
+
1207
+
1208
+                                if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1209
+                                    // do nothing
1210
+                                } else {
1211
+                                    echo $this->block_element( array( $new_key => $new_value ) );
1212
+                                }
1213
+                            }
1214
+
1215
+                            echo "},";// end attributes
1216
+
1217
+                            // get the content
1218
+                            $first_item = 0;
1219
+                            foreach ( $new_args as $new_key => $new_value ) {
1220
+                                if ( $new_key === 'content' || is_array( $new_value ) ) {
1221
+                                    //echo ",".$first_item;// separate the children
1222
+
1223
+
1224
+                                    if ( $first_item > 0 ) {
1225
+                                        //echo ",";// separate the children
1226
+                                    } else {
1227
+                                        //echo '####'.$first_item;
1228
+                                    }
1229
+
1230
+                                    if ( $new_key === 'content' ) {
1231
+                                        //print_r($new_args);
1232
+                                        echo "'" . $this->block_props_replace( $new_value ) . "'";
1233
+                                    }
1234
+
1235
+                                    if ( is_array( $new_value ) ) {
1236
+
1237
+                                        if ( isset( $new_value['element_require'] ) ) {
1238
+                                            echo str_replace( array(
1239
+                                                    "'+",
1240
+                                                    "+'"
1241
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1242
+                                            unset( $new_value['element_require'] );
1243
+                                        }
1244
+
1245
+                                        if ( isset( $new_value['element_repeat'] ) ) {
1246
+                                            $x = 1;
1247
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
1248
+                                                $this->block_element( array( '' => $new_value ) );
1249
+                                                $x ++;
1250
+                                            }
1251
+                                        } else {
1252
+                                            $this->block_element( array( '' => $new_value ) );
1253
+                                        }
1254
+                                        //print_r($new_value);
1255
+                                    }
1256
+                                    $first_item ++;
1257
+                                }
1258
+                            }
1259
+
1260
+                            echo ")";// end content
1261
+
1262
+                            //if($first_item>0){
1263
+                            echo ", \n";
1264
+                            //}
1265
+
1266
+
1267
+                        }
1268
+                        //$this->block_element($new_args);
1269
+                    } else {
1270
+
1271
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
1272
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1273
+                        } elseif ( $element == 'style' ) {
1274
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1275
+                        } else {
1276
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1277
+                        }
1278
+
1279
+                    }
1280
+
1281
+
1282
+                }
1283
+            }
1284
+        }
1285
+
1286
+        /**
1287
+         * Replace block attributes placeholders with the proper naming.
1288
+         *
1289
+         * @param $string
1290
+         *
1291
+         * @return mixed
1292
+         */
1293
+        public function block_props_replace( $string, $no_wrap = false ) {
1294
+
1295
+            if ( $no_wrap ) {
1296
+                $string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1297
+            } else {
1298
+                $string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1299
+            }
1300
+
1301
+            return $string;
1302
+        }
1303
+
1304
+        /**
1305
+         * Outputs the content of the widget
1306
+         *
1307
+         * @param array $args
1308
+         * @param array $instance
1309
+         */
1310
+        public function widget( $args, $instance ) {
1311
+            // outputs the content of the widget
1312
+
1313
+            // get the filtered values
1314
+            $argument_values = $this->argument_values( $instance );
1315
+            $argument_values = $this->string_to_bool( $argument_values );
1316
+            $output = $this->output( $argument_values, $args );
1317
+
1318
+            if ( $output ) {
1319
+                // Before widget
1320
+                $before_widget = $args['before_widget'];
1321
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1322
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1323
+
1324
+                // After widget
1325
+                $after_widget = $args['after_widget'];
1326
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1327
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1328
+
1329
+                echo $before_widget;
1330
+                echo $this->output_title($args, $instance);
1331
+                echo $output;
1332
+                echo $after_widget;
1333
+            }
1334
+        }
1335
+
1336
+        /**
1337
+         * Output the super title.
1338
+         *
1339
+         * @param $args
1340
+         * @param array $instance
1341
+         *
1342
+         * @return string
1343
+         */
1344
+        public function output_title($args, $instance = array()){
1345
+            $output = '';
1346
+            if ( ! empty( $instance['title'] ) ) {
1347
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
1348
+                $title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
1349
+                $output = $args['before_title'] . $title . $args['after_title'];
1350
+            }
1351
+            return $output;
1352
+        }
1353
+
1354
+        /**
1355
+         * Outputs the options form inputs for the widget.
1356
+         *
1357
+         * @param array $instance The widget options.
1358
+         */
1359
+        public function form( $instance ) {
1360
+
1361
+            // set widget instance
1362
+            $this->instance = $instance;
1363
+
1364
+            // set it as a SD widget
1365
+            echo $this->widget_advanced_toggle();
1366
+
1367
+
1368
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
1369
+            $arguments = $this->get_arguments();
1370 1370
 //			print_r($instance );
1371 1371
 //			echo '###';
1372 1372
 //			print_r($arguments  );
1373 1373
 
1374
-			if ( is_array( $arguments ) ) {
1375
-				foreach ( $arguments as $key => $args ) {
1376
-					$this->widget_inputs( $args, $instance );
1377
-				}
1378
-			}
1379
-		}
1380
-
1381
-		/**
1382
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
1383
-		 *
1384
-		 * @return string
1385
-		 */
1386
-		public function widget_advanced_toggle() {
1387
-
1388
-			$output = '';
1389
-			if ( $this->block_show_advanced() ) {
1390
-				$val = 1;
1391
-			} else {
1392
-				$val = 0;
1393
-			}
1394
-			if($val){
1374
+            if ( is_array( $arguments ) ) {
1375
+                foreach ( $arguments as $key => $args ) {
1376
+                    $this->widget_inputs( $args, $instance );
1377
+                }
1378
+            }
1379
+        }
1380
+
1381
+        /**
1382
+         * Get the hidden input that when added makes the advanced button show on widget settings.
1383
+         *
1384
+         * @return string
1385
+         */
1386
+        public function widget_advanced_toggle() {
1387
+
1388
+            $output = '';
1389
+            if ( $this->block_show_advanced() ) {
1390
+                $val = 1;
1391
+            } else {
1392
+                $val = 0;
1393
+            }
1394
+            if($val){
1395 1395
 //				$output .=  '<span class="sd-advanced-button-container"><button class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button></span>';
1396
-			}
1396
+            }
1397 1397
 
1398
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
1398
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
1399 1399
 
1400 1400
 
1401 1401
 
1402 1402
 
1403
-			return $output;
1403
+            return $output;
1404 1404
 
1405
-		}
1405
+        }
1406 1406
 
1407
-		/**
1408
-		 * Convert require element.
1409
-		 *
1410
-		 * @since 2.0.0
1411
-		 *
1412
-		 * @param string $input Input element.
1413
-		 * @return string $output
1414
-		 */
1415
-		public function convert_element_require( $input ) {
1407
+        /**
1408
+         * Convert require element.
1409
+         *
1410
+         * @since 2.0.0
1411
+         *
1412
+         * @param string $input Input element.
1413
+         * @return string $output
1414
+         */
1415
+        public function convert_element_require( $input ) {
1416 1416
 
1417
-			$input = str_replace( "'", '"', $input );// we only want double quotes
1417
+            $input = str_replace( "'", '"', $input );// we only want double quotes
1418 1418
 
1419
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
1420
-				"jQuery(form).find('[data-argument=\"",
1421
-				"\"]').find('input,select').val()"
1422
-			), $input ) );
1419
+            $output = esc_attr( str_replace( array( "[%", "%]" ), array(
1420
+                "jQuery(form).find('[data-argument=\"",
1421
+                "\"]').find('input,select').val()"
1422
+            ), $input ) );
1423 1423
 
1424 1424
 
1425
-			return $output;
1426
-		}
1425
+            return $output;
1426
+        }
1427 1427
 
1428
-		/**
1429
-		 * Builds the inputs for the widget options.
1430
-		 *
1431
-		 * @param $args
1432
-		 * @param $instance
1433
-		 */
1434
-		public function widget_inputs( $args, $instance ) {
1428
+        /**
1429
+         * Builds the inputs for the widget options.
1430
+         *
1431
+         * @param $args
1432
+         * @param $instance
1433
+         */
1434
+        public function widget_inputs( $args, $instance ) {
1435 1435
 
1436 1436
 //print_r($instance );echo '###';
1437 1437
 //print_r($args );
1438
-			$class           = "";
1439
-			$element_require = "";
1440
-			$custom_attributes = "";
1441
-
1442
-			// get value
1443
-			if ( isset( $instance[ $args['name'] ] ) ) {
1444
-				$value = $instance[ $args['name'] ];
1445
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
1446
-				$value = is_array($args['default']) ? array_map("esc_html",$args['default']) : esc_html( $args['default'] );
1447
-			} else {
1448
-				$value = '';
1449
-			}
1450
-
1451
-			// get placeholder
1452
-			if ( ! empty( $args['placeholder'] ) ) {
1453
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
1454
-			} else {
1455
-				$placeholder = '';
1456
-			}
1457
-
1458
-			// get if advanced
1459
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
1460
-				$class .= " sd-advanced-setting ";
1461
-			}
1462
-
1463
-			// element_require
1464
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
1465
-				$element_require = $args['element_require'];
1466
-			}
1467
-
1468
-			// custom_attributes
1469
-			if( isset( $args['custom_attributes']) && $args['custom_attributes']){
1470
-				$custom_attributes = $this->array_to_attributes($args['custom_attributes'],true);
1471
-			}
1472
-
1473
-
1474
-
1475
-
1476
-			// before wrapper
1477
-			?>
1438
+            $class           = "";
1439
+            $element_require = "";
1440
+            $custom_attributes = "";
1441
+
1442
+            // get value
1443
+            if ( isset( $instance[ $args['name'] ] ) ) {
1444
+                $value = $instance[ $args['name'] ];
1445
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
1446
+                $value = is_array($args['default']) ? array_map("esc_html",$args['default']) : esc_html( $args['default'] );
1447
+            } else {
1448
+                $value = '';
1449
+            }
1450
+
1451
+            // get placeholder
1452
+            if ( ! empty( $args['placeholder'] ) ) {
1453
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
1454
+            } else {
1455
+                $placeholder = '';
1456
+            }
1457
+
1458
+            // get if advanced
1459
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
1460
+                $class .= " sd-advanced-setting ";
1461
+            }
1462
+
1463
+            // element_require
1464
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
1465
+                $element_require = $args['element_require'];
1466
+            }
1467
+
1468
+            // custom_attributes
1469
+            if( isset( $args['custom_attributes']) && $args['custom_attributes']){
1470
+                $custom_attributes = $this->array_to_attributes($args['custom_attributes'],true);
1471
+            }
1472
+
1473
+
1474
+
1475
+
1476
+            // before wrapper
1477
+            ?>
1478 1478
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
1479 1479
 			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
1480 1480
 			   data-element_require='<?php if ( $element_require ) {
1481
-				   echo $this->convert_element_require( $element_require );
1482
-			   } ?>'
1481
+                    echo $this->convert_element_require( $element_require );
1482
+                } ?>'
1483 1483
 			>
1484 1484
 				<?php
1485 1485
 
1486
-				switch ( $args['type'] ) {
1487
-					//array('text','password','number','email','tel','url','color')
1488
-					case "text":
1489
-					case "password":
1490
-					case "number":
1491
-					case "email":
1492
-					case "tel":
1493
-					case "url":
1494
-					case "color":
1495
-						?>
1486
+                switch ( $args['type'] ) {
1487
+                    //array('text','password','number','email','tel','url','color')
1488
+                    case "text":
1489
+                    case "password":
1490
+                    case "number":
1491
+                    case "email":
1492
+                    case "tel":
1493
+                    case "url":
1494
+                    case "color":
1495
+                        ?>
1496 1496
 						<label
1497 1497
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1498 1498
 						<input <?php echo $placeholder; ?> class="widefat"
@@ -1503,11 +1503,11 @@  discard block
 block discarded – undo
1503 1503
 							                               value="<?php echo esc_attr( $value ); ?>">
1504 1504
 						<?php
1505 1505
 
1506
-						break;
1507
-					case "select":
1508
-						$multiple = isset( $args['multiple'] ) && $args['multiple']  ? true : false;
1509
-						if($multiple){if(empty($value)){$value = array();}}
1510
-						?>
1506
+                        break;
1507
+                    case "select":
1508
+                        $multiple = isset( $args['multiple'] ) && $args['multiple']  ? true : false;
1509
+                        if($multiple){if(empty($value)){$value = array();}}
1510
+                        ?>
1511 1511
 						<label
1512 1512
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1513 1513
 						<select <?php echo $placeholder; ?> class="widefat"
@@ -1515,28 +1515,28 @@  discard block
 block discarded – undo
1515 1515
 							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1516 1516
 							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if($multiple){echo "[]";}?>"
1517 1517
 							<?php if ($multiple) {
1518
-								echo "multiple";
1519
-							} //@todo not implemented yet due to gutenberg not supporting it
1520
-							?>
1518
+                                echo "multiple";
1519
+                            } //@todo not implemented yet due to gutenberg not supporting it
1520
+                            ?>
1521 1521
 						>
1522 1522
 							<?php
1523 1523
 
1524 1524
 
1525
-							if ( ! empty( $args['options'] ) ) {
1526
-								foreach ( $args['options'] as $val => $label ) {
1525
+                            if ( ! empty( $args['options'] ) ) {
1526
+                                foreach ( $args['options'] as $val => $label ) {
1527 1527
 //									print_r($value);
1528 1528
 //									echo '@@@'.print_r($val,true),'@@@';
1529 1529
 //									echo '###'.$value.'###';
1530
-									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1531
-									echo "<option value='$val' " . $selected . ">$label</option>";
1532
-								}
1533
-							}
1534
-							?>
1530
+                                    if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1531
+                                    echo "<option value='$val' " . $selected . ">$label</option>";
1532
+                                }
1533
+                            }
1534
+                            ?>
1535 1535
 						</select>
1536 1536
 						<?php
1537
-						break;
1538
-					case "checkbox":
1539
-						?>
1537
+                        break;
1538
+                    case "checkbox":
1539
+                        ?>
1540 1540
 						<input <?php echo $placeholder; ?>
1541 1541
 							<?php checked( 1, $value, true ) ?>
1542 1542
 							<?php echo $custom_attributes;?>
@@ -1546,110 +1546,110 @@  discard block
 block discarded – undo
1546 1546
 						<label
1547 1547
 							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1548 1548
 						<?php
1549
-						break;
1550
-					case "hidden":
1551
-						?>
1549
+                        break;
1550
+                    case "hidden":
1551
+                        ?>
1552 1552
 						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1553 1553
 						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
1554 1554
 						       value="<?php echo esc_attr( $value ); ?>">
1555 1555
 						<?php
1556
-						break;
1557
-					default:
1558
-						echo "No input type found!"; // @todo we need to add more input types.
1559
-				}
1556
+                        break;
1557
+                    default:
1558
+                        echo "No input type found!"; // @todo we need to add more input types.
1559
+                }
1560 1560
 
1561
-				// after wrapper
1562
-				?>
1561
+                // after wrapper
1562
+                ?>
1563 1563
 			</p>
1564 1564
 			<?php
1565 1565
 
1566
-		}
1567
-
1568
-
1569
-		/**
1570
-		 * Get the widget input description html.
1571
-		 *
1572
-		 * @param $args
1573
-		 *
1574
-		 * @return string
1575
-		 * @todo, need to make its own tooltip script
1576
-		 */
1577
-		public function widget_field_desc( $args ) {
1578
-
1579
-			$description = '';
1580
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
1581
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
1582
-					$description = $this->desc_tip( $args['desc'] );
1583
-				} else {
1584
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
1585
-				}
1586
-			}
1587
-
1588
-			return $description;
1589
-		}
1590
-
1591
-
1592
-		/**
1593
-		 * Get the tool tip html.
1594
-		 *
1595
-		 * @param $tip
1596
-		 * @param bool $allow_html
1597
-		 *
1598
-		 * @return string
1599
-		 */
1600
-		function desc_tip( $tip, $allow_html = false ) {
1601
-			if ( $allow_html ) {
1602
-				$tip = $this->sanitize_tooltip( $tip );
1603
-			} else {
1604
-				$tip = esc_attr( $tip );
1605
-			}
1606
-
1607
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
1608
-		}
1609
-
1610
-		/**
1611
-		 * Sanitize a string destined to be a tooltip.
1612
-		 *
1613
-		 * @param string $var
1614
-		 *
1615
-		 * @return string
1616
-		 */
1617
-		public function sanitize_tooltip( $var ) {
1618
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
1619
-				'br'     => array(),
1620
-				'em'     => array(),
1621
-				'strong' => array(),
1622
-				'small'  => array(),
1623
-				'span'   => array(),
1624
-				'ul'     => array(),
1625
-				'li'     => array(),
1626
-				'ol'     => array(),
1627
-				'p'      => array(),
1628
-			) ) );
1629
-		}
1630
-
1631
-		/**
1632
-		 * Processing widget options on save
1633
-		 *
1634
-		 * @param array $new_instance The new options
1635
-		 * @param array $old_instance The previous options
1636
-		 *
1637
-		 * @return array
1638
-		 * @todo we should add some sanitation here.
1639
-		 */
1640
-		public function update( $new_instance, $old_instance ) {
1566
+        }
1567
+
1568
+
1569
+        /**
1570
+         * Get the widget input description html.
1571
+         *
1572
+         * @param $args
1573
+         *
1574
+         * @return string
1575
+         * @todo, need to make its own tooltip script
1576
+         */
1577
+        public function widget_field_desc( $args ) {
1578
+
1579
+            $description = '';
1580
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
1581
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
1582
+                    $description = $this->desc_tip( $args['desc'] );
1583
+                } else {
1584
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
1585
+                }
1586
+            }
1587
+
1588
+            return $description;
1589
+        }
1590
+
1591
+
1592
+        /**
1593
+         * Get the tool tip html.
1594
+         *
1595
+         * @param $tip
1596
+         * @param bool $allow_html
1597
+         *
1598
+         * @return string
1599
+         */
1600
+        function desc_tip( $tip, $allow_html = false ) {
1601
+            if ( $allow_html ) {
1602
+                $tip = $this->sanitize_tooltip( $tip );
1603
+            } else {
1604
+                $tip = esc_attr( $tip );
1605
+            }
1606
+
1607
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
1608
+        }
1609
+
1610
+        /**
1611
+         * Sanitize a string destined to be a tooltip.
1612
+         *
1613
+         * @param string $var
1614
+         *
1615
+         * @return string
1616
+         */
1617
+        public function sanitize_tooltip( $var ) {
1618
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
1619
+                'br'     => array(),
1620
+                'em'     => array(),
1621
+                'strong' => array(),
1622
+                'small'  => array(),
1623
+                'span'   => array(),
1624
+                'ul'     => array(),
1625
+                'li'     => array(),
1626
+                'ol'     => array(),
1627
+                'p'      => array(),
1628
+            ) ) );
1629
+        }
1630
+
1631
+        /**
1632
+         * Processing widget options on save
1633
+         *
1634
+         * @param array $new_instance The new options
1635
+         * @param array $old_instance The previous options
1636
+         *
1637
+         * @return array
1638
+         * @todo we should add some sanitation here.
1639
+         */
1640
+        public function update( $new_instance, $old_instance ) {
1641 1641
 //			print_r($new_instance);
1642 1642
 //			print_r($old_instance);
1643 1643
 //			exit;
1644
-			//save the widget
1645
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
1644
+            //save the widget
1645
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
1646 1646
 
1647
-			// set widget instance
1648
-			$this->instance = $instance;
1647
+            // set widget instance
1648
+            $this->instance = $instance;
1649 1649
 
1650
-			if(empty($this->arguments)){
1651
-				$this->get_arguments();
1652
-			}
1650
+            if(empty($this->arguments)){
1651
+                $this->get_arguments();
1652
+            }
1653 1653
 
1654 1654
 
1655 1655
 //			print_r($new_instance);
@@ -1658,18 +1658,18 @@  discard block
 block discarded – undo
1658 1658
 //			print_r($this->arguments);
1659 1659
 //			exit;
1660 1660
 
1661
-			// check for checkboxes
1662
-			if ( ! empty( $this->arguments ) ) {
1663
-				foreach ( $this->arguments as $argument ) {
1664
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
1665
-						$instance[ $argument['name'] ] = '0';
1666
-					}
1667
-				}
1668
-			}
1661
+            // check for checkboxes
1662
+            if ( ! empty( $this->arguments ) ) {
1663
+                foreach ( $this->arguments as $argument ) {
1664
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
1665
+                        $instance[ $argument['name'] ] = '0';
1666
+                    }
1667
+                }
1668
+            }
1669 1669
 
1670
-			return $instance;
1671
-		}
1670
+            return $instance;
1671
+        }
1672 1672
 
1673
-	}
1673
+    }
1674 1674
 
1675 1675
 }
Please login to merge, or discard this patch.
Spacing   +298 added lines, -298 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8 8
 
9 9
 	/**
@@ -28,29 +28,29 @@  discard block
 block discarded – undo
28 28
 		/**
29 29
 		 * Take the array options and use them to build.
30 30
 		 */
31
-		public function __construct( $options ) {
31
+		public function __construct($options) {
32 32
 			global $sd_widgets;
33 33
 
34 34
 
35 35
 
36 36
 			//print_r($options);exit;
37
-			$sd_widgets[$options['base_id']] = array('name'=> $options['name'],'class_name'=>$options['class_name']);
37
+			$sd_widgets[$options['base_id']] = array('name'=> $options['name'], 'class_name'=>$options['class_name']);
38 38
 			$this->base_id = $options['base_id'];
39 39
 			// lets filter the options before we do anything
40
-			$options       = apply_filters( "wp_super_duper_options", $options );
41
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
42
-			$options       = $this->add_name_from_key( $options );
40
+			$options       = apply_filters("wp_super_duper_options", $options);
41
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
42
+			$options       = $this->add_name_from_key($options);
43 43
 			$this->options = $options;
44 44
 
45 45
 			$this->base_id   = $options['base_id'];
46
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
46
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
47 47
 
48 48
 
49 49
 			// init parent
50
-			parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
50
+			parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
51 51
 
52 52
 
53
-			if ( isset( $options['class_name'] ) ) {
53
+			if (isset($options['class_name'])) {
54 54
 				// register widget
55 55
 				$this->class_name = $options['class_name'];
56 56
 
@@ -59,16 +59,16 @@  discard block
 block discarded – undo
59 59
 
60 60
 				// register block
61 61
 				//$this->register_block();
62
-				add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
62
+				add_action('admin_enqueue_scripts', array($this, 'register_block'));
63 63
 			}
64 64
 
65 65
 			// add the CSS and JS we need ONCE
66 66
 			global $sd_widget_scripts;
67 67
 
68
-			if ( ! $sd_widget_scripts ) {
69
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
70
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
71
-				wp_add_inline_style( 'widgets', $this->widget_css() );
68
+			if (!$sd_widget_scripts) {
69
+				wp_add_inline_script('admin-widgets', $this->widget_js());
70
+				wp_add_inline_script('customize-controls', $this->widget_js());
71
+				wp_add_inline_style('widgets', $this->widget_css());
72 72
 
73 73
 				// seems ashame to add this for one icon but i love it :(
74 74
 				//wp_register_script('font-awesome', 'https://use.fontawesome.com/releases/v5.4.1/js/all.js', array('font-awesome-shim'), $this->version);
@@ -78,14 +78,14 @@  discard block
 block discarded – undo
78 78
 				$sd_widget_scripts = true;
79 79
 
80 80
 				// add shortcode insert button once
81
-				add_action( 'media_buttons',array( $this, 'shortcode_insert_button' ) );
81
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
82 82
 				//if( !wp_doing_ajax() ){
83
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
83
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
84 84
 				//}
85 85
 
86 86
 			}
87 87
 
88
-			do_action( 'wp_super_duper_widget_init', $options, $this );
88
+			do_action('wp_super_duper_widget_init', $options, $this);
89 89
 
90 90
 		}
91 91
 
@@ -94,17 +94,17 @@  discard block
 block discarded – undo
94 94
 		 *
95 95
 		 * @since 2.0.0
96 96
 		 */
97
-		public static function get_widget_settings(){
97
+		public static function get_widget_settings() {
98 98
 			global $sd_widgets;
99 99
 //			print_r($_REQUEST);
100 100
 //			echo '####';
101 101
 
102 102
 			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
103
-			if(!$shortcode){wp_die();}
104
-			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] :'';
105
-			if(!$widget_args){wp_die();}
103
+			if (!$shortcode) {wp_die(); }
104
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
105
+			if (!$widget_args) {wp_die(); }
106 106
 			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
107
-			if(!$class_name){wp_die();}
107
+			if (!$class_name) {wp_die(); }
108 108
 
109 109
 
110 110
 
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 			ob_start();
121 121
 			$widget->form(array());
122 122
 			$form = ob_get_clean();
123
-			echo "<form id='$shortcode'>".$form."<div class=\"widget-control-save\"></div></form>";
123
+			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
124 124
 //			echo "<div id='sd-shortcode-output'></div>";
125 125
 
126
-			echo "<style>".$widget->widget_css()."</style>";
127
-			echo "<script>".$widget->widget_js()."</script>";
126
+			echo "<style>" . $widget->widget_css() . "</style>";
127
+			echo "<script>" . $widget->widget_js() . "</script>";
128 128
 			?>
129 129
 			<?php
130 130
 			wp_die();
@@ -138,9 +138,9 @@  discard block
 block discarded – undo
138 138
 		 * @param string $editor_id Optional. Shortcode editor id. Default null.
139 139
 		 * @param string $insert_shortcode_function Optional. Insert shotcode function. Default null.
140 140
 		 */
141
-		public static function shortcode_insert_button($editor_id = '',$insert_shortcode_function=''){
142
-			global $sd_widgets,$shortcode_insert_button_once;
143
-			if($shortcode_insert_button_once){return;}
141
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
142
+			global $sd_widgets, $shortcode_insert_button_once;
143
+			if ($shortcode_insert_button_once) {return; }
144 144
 			add_thickbox();
145 145
 			?>
146 146
 			<div id="super-duper-content" style="display:none;">
@@ -148,12 +148,12 @@  discard block
 block discarded – undo
148 148
 				<div class="sd-shortcode-left-wrap">
149 149
 					<?php
150 150
 					//print_r( $sd_widgets );
151
-					asort($sd_widgets );
152
-					if(!empty($sd_widgets)){
151
+					asort($sd_widgets);
152
+					if (!empty($sd_widgets)) {
153 153
 						echo '<select onchange="sd_get_shortcode_options(this);">';
154
-						echo "<option>".__('Select shortcode')."</option>";
155
-						foreach($sd_widgets as $shortcode => $class){
156
-							echo "<option value='".esc_attr($shortcode)."'>".esc_attr($shortcode)." (".esc_attr($class['name']).")</option>";
154
+						echo "<option>" . __('Select shortcode') . "</option>";
155
+						foreach ($sd_widgets as $shortcode => $class) {
156
+							echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
157 157
 						}
158 158
 						echo "</select>";
159 159
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
 				<div  class="sd-shortcode-right-wrap">
167 167
 					<textarea id='sd-shortcode-output' disabled></textarea>
168 168
 					<div id='sd-shortcode-output-actions'>
169
-						<button class="button" onclick="sd_insert_shortcode()"><?php _e('Insert shortcode');?></button>
170
-						<button class="button" onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode');?></button>
169
+						<button class="button" onclick="sd_insert_shortcode()"><?php _e('Insert shortcode'); ?></button>
170
+						<button class="button" onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
171 171
 					</div>
172 172
 				</div>
173 173
 
174 174
 			</div>
175 175
 
176 176
 
177
-			<a href="#TB_inline?width=100%&height=550&inlineId=super-duper-content" class="thickbox button super-duper-content-open" title="<?php _e('Add Shortcode');?>"><i class="fas fa-cubes" aria-hidden="true"></i></a>
177
+			<a href="#TB_inline?width=100%&height=550&inlineId=super-duper-content" class="thickbox button super-duper-content-open" title="<?php _e('Add Shortcode'); ?>"><i class="fas fa-cubes" aria-hidden="true"></i></a>
178 178
 
179 179
 			<style>
180 180
 				.sd-shortcode-left-wrap{
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 			<script>
197 197
 
198 198
 				<?php
199
-				if(!empty($insert_shortcode_function)){
199
+				if (!empty($insert_shortcode_function)) {
200 200
 					echo $insert_shortcode_function;
201
-				}else{
201
+				} else {
202 202
 
203 203
 				/**
204 204
 				 * Function for super duper insert shortcode.
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 							'shortcode': $short_code,
253 253
 							'attributes': 123,
254 254
 							'post_id': 321,
255
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
255
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
256 256
 						};
257 257
 
258 258
 						jQuery.post(ajaxurl, data, function (response) {
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
379 379
 			 */
380 380
 
381
-			return str_replace( array(
381
+			return str_replace(array(
382 382
 				'<style>',
383 383
 				'</style>'
384
-			), '', $output );
384
+			), '', $output);
385 385
 		}
386 386
 
387 387
 		public function widget_js() {
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 					});
540 540
 
541 541
 				}
542
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
542
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
543 543
 			</script>
544 544
 			<?php
545 545
 			$output = ob_get_clean();
@@ -548,10 +548,10 @@  discard block
 block discarded – undo
548 548
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
549 549
 			 */
550 550
 
551
-			return str_replace( array(
551
+			return str_replace(array(
552 552
 				'<script>',
553 553
 				'</script>'
554
-			), '', $output );
554
+			), '', $output);
555 555
 		}
556 556
 
557 557
 
@@ -562,14 +562,14 @@  discard block
 block discarded – undo
562 562
 		 *
563 563
 		 * @return mixed
564 564
 		 */
565
-		private function add_name_from_key( $options, $arguments = false ) {
566
-			if ( ! empty( $options['arguments'] ) ) {
567
-				foreach ( $options['arguments'] as $key => $val ) {
568
-					$options['arguments'][ $key ]['name'] = $key;
565
+		private function add_name_from_key($options, $arguments = false) {
566
+			if (!empty($options['arguments'])) {
567
+				foreach ($options['arguments'] as $key => $val) {
568
+					$options['arguments'][$key]['name'] = $key;
569 569
 				}
570
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
571
-				foreach ( $options as $key => $val ) {
572
-					$options[ $key ]['name'] = $key;
570
+			} elseif ($arguments && is_array($options) && !empty($options)) {
571
+				foreach ($options as $key => $val) {
572
+					$options[$key]['name'] = $key;
573 573
 				}
574 574
 			}
575 575
 
@@ -582,8 +582,8 @@  discard block
 block discarded – undo
582 582
 		 * @since 2.0.0
583 583
 		 */
584 584
 		public function register_shortcode() {
585
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
586
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( __CLASS__, 'render_shortcode' ) );
585
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
586
+			add_action('wp_ajax_super_duper_output_shortcode', array(__CLASS__, 'render_shortcode'));
587 587
 		}
588 588
 
589 589
 		/**
@@ -593,33 +593,33 @@  discard block
 block discarded – undo
593 593
 		 */
594 594
 		public static function render_shortcode() {
595 595
 
596
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
597
-			if ( ! current_user_can( 'manage_options' ) ) {
596
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
597
+			if (!current_user_can('manage_options')) {
598 598
 				wp_die();
599 599
 			}
600 600
 
601 601
 			// we might need the $post value here so lets set it.
602
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
603
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
604
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
602
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
603
+				$post_obj = get_post(absint($_POST['post_id']));
604
+				if (!empty($post_obj) && empty($post)) {
605 605
 					global $post;
606 606
 					$post = $post_obj;
607 607
 				}
608 608
 			}
609 609
 
610
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
611
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
612
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
610
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
611
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
612
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
613 613
 				$attributes       = '';
614
-				if ( ! empty( $attributes_array ) ) {
615
-					foreach ( $attributes_array as $key => $value ) {
616
-						$attributes .= " " . sanitize_title_with_dashes( $key ) . "='" . wp_slash( $value ) . "' ";
614
+				if (!empty($attributes_array)) {
615
+					foreach ($attributes_array as $key => $value) {
616
+						$attributes .= " " . sanitize_title_with_dashes($key) . "='" . wp_slash($value) . "' ";
617 617
 					}
618 618
 				}
619 619
 
620 620
 				$shortcode = "[" . $shortcode_name . " " . $attributes . "]";
621 621
 
622
-				echo do_shortcode( $shortcode );
622
+				echo do_shortcode($shortcode);
623 623
 
624 624
 			}
625 625
 			wp_die();
@@ -631,37 +631,37 @@  discard block
 block discarded – undo
631 631
 		 * @param array $args
632 632
 		 * @param string $content
633 633
 		 */
634
-		public function shortcode_output( $args = array(), $content = '' ) {
635
-			$args = self::argument_values( $args );
634
+		public function shortcode_output($args = array(), $content = '') {
635
+			$args = self::argument_values($args);
636 636
 
637 637
 			// add extra argument so we know its a output to gutenberg
638 638
 			//$args
639
-			$args = $this->string_to_bool( $args );
639
+			$args = $this->string_to_bool($args);
640 640
 
641 641
 
642 642
 			$calss = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
643 643
 
644
-			$calss = apply_filters( 'wp_super_duper_div_classname', $calss, $args, $this );
645
-			$calss = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this );
644
+			$calss = apply_filters('wp_super_duper_div_classname', $calss, $args, $this);
645
+			$calss = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $calss, $args, $this);
646 646
 
647
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
648
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
647
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
648
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
649 649
 
650 650
 			$shortcode_args = array();
651 651
 			$output = '';
652 652
 			$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ?  true : false;
653
-			$main_content = $this->output( $args, $shortcode_args, $content );
654
-			if($main_content && !$no_wrap){
653
+			$main_content = $this->output($args, $shortcode_args, $content);
654
+			if ($main_content && !$no_wrap) {
655 655
 				// wrap the shortcode in a dive with the same class as the widget
656
-				$output .= '<div class="'.$calss.'" ' . $attrs . '>';
657
-				if(!empty($args['title'])){
656
+				$output .= '<div class="' . $calss . '" ' . $attrs . '>';
657
+				if (!empty($args['title'])) {
658 658
 					// if its a shortcode and there is a title try to grab the title wrappers
659 659
 					$shortcode_args = array('before_title'=>'', 'after_title' => '');
660
-					if(empty($instance)){
660
+					if (empty($instance)) {
661 661
 						global $wp_registered_sidebars;
662
-						if(!empty($wp_registered_sidebars)){
663
-							foreach($wp_registered_sidebars as $sidebar){
664
-								if(!empty($sidebar['before_title'])){
662
+						if (!empty($wp_registered_sidebars)) {
663
+							foreach ($wp_registered_sidebars as $sidebar) {
664
+								if (!empty($sidebar['before_title'])) {
665 665
 									$shortcode_args['before_title'] = $sidebar['before_title'];
666 666
 									$shortcode_args['after_title'] = $sidebar['after_title'];
667 667
 									break;
@@ -669,11 +669,11 @@  discard block
 block discarded – undo
669 669
 							}
670 670
 						}
671 671
 					}
672
-					$output .= $this->output_title($shortcode_args,$args);
672
+					$output .= $this->output_title($shortcode_args, $args);
673 673
 				}
674 674
 				$output .= $main_content;
675 675
 				$output .= '</div>';
676
-			}elseif($main_content && $no_wrap){
676
+			}elseif ($main_content && $no_wrap) {
677 677
 				$output .= $main_content;
678 678
 			}
679 679
 
@@ -688,13 +688,13 @@  discard block
 block discarded – undo
688 688
 		 *
689 689
 		 * @return mixed
690 690
 		 */
691
-		public function string_to_bool( $options ) {
691
+		public function string_to_bool($options) {
692 692
 			// convert bool strings to booleans
693
-			foreach ( $options as $key => $val ) {
694
-				if ( $val == 'false' ) {
695
-					$options[ $key ] = false;
696
-				} elseif ( $val == 'true' ) {
697
-					$options[ $key ] = true;
693
+			foreach ($options as $key => $val) {
694
+				if ($val == 'false') {
695
+					$options[$key] = false;
696
+				} elseif ($val == 'true') {
697
+					$options[$key] = true;
698 698
 				}
699 699
 			}
700 700
 
@@ -708,24 +708,24 @@  discard block
 block discarded – undo
708 708
 		 *
709 709
 		 * @return array
710 710
 		 */
711
-		public function argument_values( $instance ) {
711
+		public function argument_values($instance) {
712 712
 			$argument_values = array();
713 713
 
714 714
 			// set widget instance
715 715
 			$this->instance = $instance;
716 716
 
717
-			if ( empty( $this->arguments ) ) {
717
+			if (empty($this->arguments)) {
718 718
 				$this->arguments = $this->get_arguments();
719 719
 			}
720 720
 
721
-			if ( ! empty( $this->arguments ) ) {
722
-				foreach ( $this->arguments as $key => $args ) {
721
+			if (!empty($this->arguments)) {
722
+				foreach ($this->arguments as $key => $args) {
723 723
 					// set the input name from the key
724 724
 					$args['name'] = $key;
725 725
 					//
726
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
727
-					if ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
728
-						$argument_values[ $key ] = $args['default'];
726
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
727
+					if ($argument_values[$key] == '' && isset($args['default'])) {
728
+						$argument_values[$key] = $args['default'];
729 729
 					}
730 730
 				}
731 731
 			}
@@ -752,12 +752,12 @@  discard block
 block discarded – undo
752 752
 		 * @return array Get arguments.
753 753
 		 */
754 754
 		public function get_arguments() {
755
-			if ( empty( $this->arguments ) ) {
756
-				$this->arguments =  $this->set_arguments();
755
+			if (empty($this->arguments)) {
756
+				$this->arguments = $this->set_arguments();
757 757
 			}
758 758
 
759
-			$this->arguments = apply_filters('wp_super_duper_arguments',$this->arguments,$this->options, $this->instance);
760
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
759
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
760
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
761 761
 
762 762
 
763 763
 			return $this->arguments;
@@ -770,7 +770,7 @@  discard block
 block discarded – undo
770 770
 		 * @param array $widget_args
771 771
 		 * @param string $content
772 772
 		 */
773
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
773
+		public function output($args = array(), $widget_args = array(), $content = '') {
774 774
 
775 775
 		}
776 776
 
@@ -778,7 +778,7 @@  discard block
 block discarded – undo
778 778
 		 * Add the dyanmic block code inline when the wp-block in enqueued.
779 779
 		 */
780 780
 		public function register_block() {
781
-			wp_add_inline_script( 'wp-blocks', $this->block() );
781
+			wp_add_inline_script('wp-blocks', $this->block());
782 782
 		}
783 783
 
784 784
 
@@ -792,13 +792,13 @@  discard block
 block discarded – undo
792 792
 			$show      = false;
793 793
 			$arguments = $this->arguments;
794 794
 
795
-			if(empty($arguments)){
795
+			if (empty($arguments)) {
796 796
 				$arguments = $this->get_arguments();
797 797
 			}
798 798
 
799
-			if ( ! empty( $arguments ) ) {
800
-				foreach ( $arguments as $argument ) {
801
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
799
+			if (!empty($arguments)) {
800
+				foreach ($arguments as $argument) {
801
+					if (isset($argument['advanced']) && $argument['advanced']) {
802 802
 						$show = true;
803 803
 					}
804 804
 				}
@@ -848,12 +848,12 @@  discard block
 block discarded – undo
848 848
 					 * @return {?WPBlock}          The block, if it has been successfully
849 849
 					 *                             registered; otherwise `undefined`.
850 850
 					 */
851
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
852
-						title: '<?php echo $this->options['name'];?>', // Block title.
853
-						description: '<?php echo esc_attr( $this->options['widget_ops']['description'] )?>', // Block title.
854
-						icon: '<?php echo isset( $this->options['block-icon'] ) ? esc_attr( $this->options['block-icon'] ) : 'shield-alt';?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
855
-						category: '<?php echo isset( $this->options['block-category'] ) ? esc_attr( $this->options['block-category'] ) : 'common';?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
856
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
851
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
852
+						title: '<?php echo $this->options['name']; ?>', // Block title.
853
+						description: '<?php echo esc_attr($this->options['widget_ops']['description'])?>', // Block title.
854
+						icon: '<?php echo isset($this->options['block-icon']) ? esc_attr($this->options['block-icon']) : 'shield-alt'; ?>', // Block icon from Dashicons → https://developer.wordpress.org/resource/dashicons/.
855
+						category: '<?php echo isset($this->options['block-category']) ? esc_attr($this->options['block-category']) : 'common'; ?>', // Block category — Group blocks together based on common traits E.g. common, formatting, layout widgets, embed.
856
+						<?php if (isset($this->options['block-keywords'])) {
857 857
 						echo "keywords : " . $this->options['block-keywords'] . ",";
858 858
 					}?>
859 859
 
@@ -863,44 +863,44 @@  discard block
 block discarded – undo
863 863
 
864 864
 						$show_alignment = false;
865 865
 
866
-						if ( ! empty( $this->arguments ) ) {
866
+						if (!empty($this->arguments)) {
867 867
 							echo "attributes : {";
868 868
 
869
-							if ( $show_advanced ) {
869
+							if ($show_advanced) {
870 870
 								echo "show_advanced: {";
871 871
 								echo "	type: 'boolean',";
872 872
 								echo "  default: false,";
873 873
 								echo "},";
874 874
 							}
875 875
 
876
-							foreach ( $this->arguments as $key => $args ) {
876
+							foreach ($this->arguments as $key => $args) {
877 877
 
878 878
 								// set if we should show alignment
879
-								if ( $key == 'alignment' ) {
879
+								if ($key == 'alignment') {
880 880
 									$show_alignment = true;
881 881
 								}
882 882
 
883 883
 								$extra = '';
884 884
 
885
-								if ( $args['type'] == 'checkbox' ) {
885
+								if ($args['type'] == 'checkbox') {
886 886
 									$type    = 'boolean';
887
-									$default = isset( $args['default'] ) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
-								} elseif ( $args['type'] == 'number' ) {
887
+									$default = isset($args['default']) && "'" . $args['default'] . "'" ? 'true' : 'false';
888
+								} elseif ($args['type'] == 'number') {
889 889
 									$type    = 'number';
890
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
891
-								} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
890
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
891
+								} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
892 892
 									$type    = 'array';
893
-									if(is_array($args['default'])){
894
-										$default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
-									}else{
896
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
893
+									if (is_array($args['default'])) {
894
+										$default = isset($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
+									} else {
896
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
897 897
 									}
898
-								} elseif ( $args['type'] == 'multiselect' ) {
898
+								} elseif ($args['type'] == 'multiselect') {
899 899
 									$type    = 'array';
900
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
900
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
901 901
 								} else {
902 902
 									$type    = 'string';
903
-									$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
903
+									$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
904 904
 								}
905 905
 								echo $key . " : {";
906 906
 								echo "type : '$type',";
@@ -930,12 +930,12 @@  discard block
 block discarded – undo
930 930
 									is_fetching = true;
931 931
 									var data = {
932 932
 										'action': 'super_duper_output_shortcode',
933
-										'shortcode': '<?php echo $this->options['base_id'];?>',
933
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
934 934
 										'attributes': props.attributes,
935
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
935
+										'post_id': <?php global $post; if (isset($post->ID)) {
936 936
 										echo $post->ID;
937 937
 									}?>,
938
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
938
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
939 939
 									};
940 940
 
941 941
 									jQuery.post(ajaxurl, data, function (response) {
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 
959 959
 								el(wp.editor.BlockControls, {key: 'controls'},
960 960
 
961
-									<?php if($show_alignment){?>
961
+									<?php if ($show_alignment) {?>
962 962
 									el(
963 963
 										wp.editor.AlignmentToolbar,
964 964
 										{
@@ -976,9 +976,9 @@  discard block
 block discarded – undo
976 976
 
977 977
 									<?php
978 978
 
979
-									if(! empty( $this->arguments )){
979
+									if (!empty($this->arguments)) {
980 980
 
981
-									if ( $show_advanced ) {
981
+									if ($show_advanced) {
982 982
 									?>
983 983
 									el(
984 984
 										wp.components.ToggleControl,
@@ -994,68 +994,68 @@  discard block
 block discarded – undo
994 994
 
995 995
 									}
996 996
 
997
-									foreach($this->arguments as $key => $args){
997
+									foreach ($this->arguments as $key => $args) {
998 998
 									$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
999 999
 									$options = '';
1000 1000
 									$extra = '';
1001 1001
 									$require = '';
1002 1002
 									$onchange = "props.setAttributes({ $key: $key } )";
1003 1003
 									$value = "props.attributes.$key";
1004
-									$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'color' );
1005
-									if ( in_array( $args['type'], $text_type ) ) {
1004
+									$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'color');
1005
+									if (in_array($args['type'], $text_type)) {
1006 1006
 										$type = 'TextControl';
1007
-									} elseif ( $args['type'] == 'checkbox' ) {
1007
+									} elseif ($args['type'] == 'checkbox') {
1008 1008
 										$type = 'CheckboxControl';
1009 1009
 										$extra .= "checked: props.attributes.$key,";
1010 1010
 										$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
1011
-									} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
1011
+									} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
1012 1012
 										$type = 'SelectControl';
1013
-										if ( ! empty( $args['options'] ) ) {
1013
+										if (!empty($args['options'])) {
1014 1014
 											$options .= "options  : [";
1015
-											foreach ( $args['options'] as $option_val => $option_label ) {
1016
-												$options .= "{ value : '" . esc_attr( $option_val ) . "',     label : '" . esc_attr( $option_label ) . "'     },";
1015
+											foreach ($args['options'] as $option_val => $option_label) {
1016
+												$options .= "{ value : '" . esc_attr($option_val) . "',     label : '" . esc_attr($option_label) . "'     },";
1017 1017
 											}
1018 1018
 											$options .= "],";
1019 1019
 										}
1020
-										if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1020
+										if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
1021 1021
 											$extra .= ' multiple: true, ';
1022 1022
 											//$onchange = "props.setAttributes({ $key: ['edit'] } )";
1023 1023
 											//$value = "['edit', 'delete']";
1024 1024
 										}
1025
-									} elseif ( $args['type'] == 'alignment' ) {
1025
+									} elseif ($args['type'] == 'alignment') {
1026 1026
 										$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
1027 1027
 									} else {
1028
-										continue;// if we have not implemented the control then don't break the JS.
1028
+										continue; // if we have not implemented the control then don't break the JS.
1029 1029
 									}
1030 1030
 
1031 1031
 									// add show only if advanced
1032
-									if ( ! empty( $args['advanced'] ) ) {
1032
+									if (!empty($args['advanced'])) {
1033 1033
 										echo "props.attributes.show_advanced && ";
1034 1034
 									}
1035 1035
 									// add setting require if defined
1036
-									if ( ! empty( $args['element_require'] ) ) {
1037
-										echo $this->block_props_replace( $args['element_require'], true ) . " && ";
1036
+									if (!empty($args['element_require'])) {
1037
+										echo $this->block_props_replace($args['element_require'], true) . " && ";
1038 1038
 									}
1039 1039
 									?>
1040 1040
 									el(
1041
-										wp.components.<?php echo esc_attr( $type );?>,
1041
+										wp.components.<?php echo esc_attr($type); ?>,
1042 1042
 										{
1043
-											label: '<?php echo esc_attr( $args['title'] );?>',
1044
-											help: '<?php if ( isset( $args['desc'] ) ) {
1045
-												echo esc_attr( $args['desc'] );
1043
+											label: '<?php echo esc_attr($args['title']); ?>',
1044
+											help: '<?php if (isset($args['desc'])) {
1045
+												echo esc_attr($args['desc']);
1046 1046
 											}?>',
1047
-											value: <?php echo $value;?>,
1048
-											<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
1049
-											echo "type: '" . esc_attr( $args['type'] ) . "',";
1047
+											value: <?php echo $value; ?>,
1048
+											<?php if ($type == 'TextControl' && $args['type'] != 'text') {
1049
+											echo "type: '" . esc_attr($args['type']) . "',";
1050 1050
 										}?>
1051
-											<?php if ( ! empty( $args['placeholder'] ) ) {
1052
-											echo "placeholder: '" . esc_attr( $args['placeholder'] ) . "',";
1051
+											<?php if (!empty($args['placeholder'])) {
1052
+											echo "placeholder: '" . esc_attr($args['placeholder']) . "',";
1053 1053
 										}?>
1054
-											<?php echo $options;?>
1055
-											<?php echo $extra;?>
1056
-											<?php echo $custom_attributes;?>
1057
-											onChange: function ( <?php echo $key;?> ) {
1058
-												<?php echo $onchange;?>
1054
+											<?php echo $options; ?>
1055
+											<?php echo $extra; ?>
1056
+											<?php echo $custom_attributes; ?>
1057
+											onChange: function ( <?php echo $key; ?> ) {
1058
+												<?php echo $onchange; ?>
1059 1059
 											}
1060 1060
 										}
1061 1061
 									),
@@ -1068,9 +1068,9 @@  discard block
 block discarded – undo
1068 1068
 
1069 1069
 								<?php
1070 1070
 								// If the user sets block-output array then build it
1071
-								if ( ! empty( $this->options['block-output'] ) ) {
1072
-								$this->block_element( $this->options['block-output'] );
1073
-							}else{
1071
+								if (!empty($this->options['block-output'])) {
1072
+								$this->block_element($this->options['block-output']);
1073
+							} else {
1074 1074
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1075 1075
 								?>
1076 1076
 								el('div', {
@@ -1094,14 +1094,14 @@  discard block
 block discarded – undo
1094 1094
 							var align = '';
1095 1095
 
1096 1096
 							// build the shortcode.
1097
-							var content = "[<?php echo $this->options['base_id'];?>";
1097
+							var content = "[<?php echo $this->options['base_id']; ?>";
1098 1098
 							<?php
1099 1099
 
1100
-							if(! empty( $this->arguments )){
1101
-							foreach($this->arguments as $key => $args){
1100
+							if (!empty($this->arguments)) {
1101
+							foreach ($this->arguments as $key => $args) {
1102 1102
 							?>
1103
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
1104
-								content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>+ "' ";
1103
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
1104
+								content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>+ "' ";
1105 1105
 							}
1106 1106
 							<?php
1107 1107
 							}
@@ -1138,10 +1138,10 @@  discard block
 block discarded – undo
1138 1138
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1139 1139
 			 */
1140 1140
 
1141
-			return str_replace( array(
1141
+			return str_replace(array(
1142 1142
 				'<script>',
1143 1143
 				'</script>'
1144
-			), '', $output );
1144
+			), '', $output);
1145 1145
 		}
1146 1146
 
1147 1147
 		/**
@@ -1152,16 +1152,16 @@  discard block
 block discarded – undo
1152 1152
 		 *
1153 1153
 		 * @return string
1154 1154
 		 */
1155
-		public function array_to_attributes($custom_attributes, $html = false){
1155
+		public function array_to_attributes($custom_attributes, $html = false) {
1156 1156
 			$attributes = '';
1157
-			if(!empty($custom_attributes)){
1157
+			if (!empty($custom_attributes)) {
1158 1158
 
1159
-				if($html){
1160
-					foreach($custom_attributes as $key => $val){
1159
+				if ($html) {
1160
+					foreach ($custom_attributes as $key => $val) {
1161 1161
 						$attributes .= " $key='$val' ";
1162 1162
 					}
1163
-				}else{
1164
-					foreach($custom_attributes as $key => $val){
1163
+				} else {
1164
+					foreach ($custom_attributes as $key => $val) {
1165 1165
 						$attributes .= "'$key': '$val',";
1166 1166
 					}
1167 1167
 				}
@@ -1178,86 +1178,86 @@  discard block
 block discarded – undo
1178 1178
 		 *
1179 1179
 		 * @param $args
1180 1180
 		 */
1181
-		public function block_element( $args ) {
1181
+		public function block_element($args) {
1182 1182
 
1183 1183
 
1184
-			if ( ! empty( $args ) ) {
1185
-				foreach ( $args as $element => $new_args ) {
1184
+			if (!empty($args)) {
1185
+				foreach ($args as $element => $new_args) {
1186 1186
 
1187
-					if ( is_array( $new_args ) ) { // its an element
1187
+					if (is_array($new_args)) { // its an element
1188 1188
 
1189 1189
 
1190
-						if ( isset( $new_args['element'] ) ) {
1190
+						if (isset($new_args['element'])) {
1191 1191
 
1192 1192
 							//print_r($new_args);
1193 1193
 
1194
-							if ( isset( $new_args['element_require'] ) ) {
1195
-								echo str_replace( array(
1194
+							if (isset($new_args['element_require'])) {
1195
+								echo str_replace(array(
1196 1196
 										"'+",
1197 1197
 										"+'"
1198
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
1199
-								unset( $new_args['element_require'] );
1198
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
1199
+								unset($new_args['element_require']);
1200 1200
 							}
1201 1201
 
1202 1202
 							echo "\n el( '" . $new_args['element'] . "', {";
1203 1203
 
1204 1204
 							// get the attributes
1205
-							foreach ( $new_args as $new_key => $new_value ) {
1205
+							foreach ($new_args as $new_key => $new_value) {
1206 1206
 
1207 1207
 
1208
-								if ( $new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
1208
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
1209 1209
 									// do nothing
1210 1210
 								} else {
1211
-									echo $this->block_element( array( $new_key => $new_value ) );
1211
+									echo $this->block_element(array($new_key => $new_value));
1212 1212
 								}
1213 1213
 							}
1214 1214
 
1215
-							echo "},";// end attributes
1215
+							echo "},"; // end attributes
1216 1216
 
1217 1217
 							// get the content
1218 1218
 							$first_item = 0;
1219
-							foreach ( $new_args as $new_key => $new_value ) {
1220
-								if ( $new_key === 'content' || is_array( $new_value ) ) {
1219
+							foreach ($new_args as $new_key => $new_value) {
1220
+								if ($new_key === 'content' || is_array($new_value)) {
1221 1221
 									//echo ",".$first_item;// separate the children
1222 1222
 
1223 1223
 
1224
-									if ( $first_item > 0 ) {
1224
+									if ($first_item > 0) {
1225 1225
 										//echo ",";// separate the children
1226 1226
 									} else {
1227 1227
 										//echo '####'.$first_item;
1228 1228
 									}
1229 1229
 
1230
-									if ( $new_key === 'content' ) {
1230
+									if ($new_key === 'content') {
1231 1231
 										//print_r($new_args);
1232
-										echo "'" . $this->block_props_replace( $new_value ) . "'";
1232
+										echo "'" . $this->block_props_replace($new_value) . "'";
1233 1233
 									}
1234 1234
 
1235
-									if ( is_array( $new_value ) ) {
1235
+									if (is_array($new_value)) {
1236 1236
 
1237
-										if ( isset( $new_value['element_require'] ) ) {
1238
-											echo str_replace( array(
1237
+										if (isset($new_value['element_require'])) {
1238
+											echo str_replace(array(
1239 1239
 													"'+",
1240 1240
 													"+'"
1241
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
1242
-											unset( $new_value['element_require'] );
1241
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
1242
+											unset($new_value['element_require']);
1243 1243
 										}
1244 1244
 
1245
-										if ( isset( $new_value['element_repeat'] ) ) {
1245
+										if (isset($new_value['element_repeat'])) {
1246 1246
 											$x = 1;
1247
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
1248
-												$this->block_element( array( '' => $new_value ) );
1249
-												$x ++;
1247
+											while ($x <= absint($new_value['element_repeat'])) {
1248
+												$this->block_element(array('' => $new_value));
1249
+												$x++;
1250 1250
 											}
1251 1251
 										} else {
1252
-											$this->block_element( array( '' => $new_value ) );
1252
+											$this->block_element(array('' => $new_value));
1253 1253
 										}
1254 1254
 										//print_r($new_value);
1255 1255
 									}
1256
-									$first_item ++;
1256
+									$first_item++;
1257 1257
 								}
1258 1258
 							}
1259 1259
 
1260
-							echo ")";// end content
1260
+							echo ")"; // end content
1261 1261
 
1262 1262
 							//if($first_item>0){
1263 1263
 							echo ", \n";
@@ -1268,12 +1268,12 @@  discard block
 block discarded – undo
1268 1268
 						//$this->block_element($new_args);
1269 1269
 					} else {
1270 1270
 
1271
-						if ( substr( $element, 0, 3 ) === "if_" ) {
1272
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
1273
-						} elseif ( $element == 'style' ) {
1274
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
1271
+						if (substr($element, 0, 3) === "if_") {
1272
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
1273
+						} elseif ($element == 'style') {
1274
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
1275 1275
 						} else {
1276
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
1276
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
1277 1277
 						}
1278 1278
 
1279 1279
 					}
@@ -1290,12 +1290,12 @@  discard block
 block discarded – undo
1290 1290
 		 *
1291 1291
 		 * @return mixed
1292 1292
 		 */
1293
-		public function block_props_replace( $string, $no_wrap = false ) {
1293
+		public function block_props_replace($string, $no_wrap = false) {
1294 1294
 
1295
-			if ( $no_wrap ) {
1296
-				$string = str_replace( array( "[%", "%]" ), array( "props.attributes.", "" ), $string );
1295
+			if ($no_wrap) {
1296
+				$string = str_replace(array("[%", "%]"), array("props.attributes.", ""), $string);
1297 1297
 			} else {
1298
-				$string = str_replace( array( "[%", "%]" ), array( "'+props.attributes.", "+'" ), $string );
1298
+				$string = str_replace(array("[%", "%]"), array("'+props.attributes.", "+'"), $string);
1299 1299
 			}
1300 1300
 
1301 1301
 			return $string;
@@ -1307,24 +1307,24 @@  discard block
 block discarded – undo
1307 1307
 		 * @param array $args
1308 1308
 		 * @param array $instance
1309 1309
 		 */
1310
-		public function widget( $args, $instance ) {
1310
+		public function widget($args, $instance) {
1311 1311
 			// outputs the content of the widget
1312 1312
 
1313 1313
 			// get the filtered values
1314
-			$argument_values = $this->argument_values( $instance );
1315
-			$argument_values = $this->string_to_bool( $argument_values );
1316
-			$output = $this->output( $argument_values, $args );
1314
+			$argument_values = $this->argument_values($instance);
1315
+			$argument_values = $this->string_to_bool($argument_values);
1316
+			$output = $this->output($argument_values, $args);
1317 1317
 
1318
-			if ( $output ) {
1318
+			if ($output) {
1319 1319
 				// Before widget
1320 1320
 				$before_widget = $args['before_widget'];
1321
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
1322
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
1321
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
1322
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
1323 1323
 
1324 1324
 				// After widget
1325 1325
 				$after_widget = $args['after_widget'];
1326
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
1327
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
1326
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
1327
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
1328 1328
 
1329 1329
 				echo $before_widget;
1330 1330
 				echo $this->output_title($args, $instance);
@@ -1341,11 +1341,11 @@  discard block
 block discarded – undo
1341 1341
 		 *
1342 1342
 		 * @return string
1343 1343
 		 */
1344
-		public function output_title($args, $instance = array()){
1344
+		public function output_title($args, $instance = array()) {
1345 1345
 			$output = '';
1346
-			if ( ! empty( $instance['title'] ) ) {
1346
+			if (!empty($instance['title'])) {
1347 1347
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
1348
-				$title = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
1348
+				$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
1349 1349
 				$output = $args['before_title'] . $title . $args['after_title'];
1350 1350
 			}
1351 1351
 			return $output;
@@ -1356,7 +1356,7 @@  discard block
 block discarded – undo
1356 1356
 		 *
1357 1357
 		 * @param array $instance The widget options.
1358 1358
 		 */
1359
-		public function form( $instance ) {
1359
+		public function form($instance) {
1360 1360
 
1361 1361
 			// set widget instance
1362 1362
 			$this->instance = $instance;
@@ -1365,15 +1365,15 @@  discard block
 block discarded – undo
1365 1365
 			echo $this->widget_advanced_toggle();
1366 1366
 
1367 1367
 
1368
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
1368
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
1369 1369
 			$arguments = $this->get_arguments();
1370 1370
 //			print_r($instance );
1371 1371
 //			echo '###';
1372 1372
 //			print_r($arguments  );
1373 1373
 
1374
-			if ( is_array( $arguments ) ) {
1375
-				foreach ( $arguments as $key => $args ) {
1376
-					$this->widget_inputs( $args, $instance );
1374
+			if (is_array($arguments)) {
1375
+				foreach ($arguments as $key => $args) {
1376
+					$this->widget_inputs($args, $instance);
1377 1377
 				}
1378 1378
 			}
1379 1379
 		}
@@ -1386,12 +1386,12 @@  discard block
 block discarded – undo
1386 1386
 		public function widget_advanced_toggle() {
1387 1387
 
1388 1388
 			$output = '';
1389
-			if ( $this->block_show_advanced() ) {
1389
+			if ($this->block_show_advanced()) {
1390 1390
 				$val = 1;
1391 1391
 			} else {
1392 1392
 				$val = 0;
1393 1393
 			}
1394
-			if($val){
1394
+			if ($val) {
1395 1395
 //				$output .=  '<span class="sd-advanced-button-container"><button class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button></span>';
1396 1396
 			}
1397 1397
 
@@ -1412,14 +1412,14 @@  discard block
 block discarded – undo
1412 1412
 		 * @param string $input Input element.
1413 1413
 		 * @return string $output
1414 1414
 		 */
1415
-		public function convert_element_require( $input ) {
1415
+		public function convert_element_require($input) {
1416 1416
 
1417
-			$input = str_replace( "'", '"', $input );// we only want double quotes
1417
+			$input = str_replace("'", '"', $input); // we only want double quotes
1418 1418
 
1419
-			$output = esc_attr( str_replace( array( "[%", "%]" ), array(
1419
+			$output = esc_attr(str_replace(array("[%", "%]"), array(
1420 1420
 				"jQuery(form).find('[data-argument=\"",
1421 1421
 				"\"]').find('input,select').val()"
1422
-			), $input ) );
1422
+			), $input));
1423 1423
 
1424 1424
 
1425 1425
 			return $output;
@@ -1431,7 +1431,7 @@  discard block
 block discarded – undo
1431 1431
 		 * @param $args
1432 1432
 		 * @param $instance
1433 1433
 		 */
1434
-		public function widget_inputs( $args, $instance ) {
1434
+		public function widget_inputs($args, $instance) {
1435 1435
 
1436 1436
 //print_r($instance );echo '###';
1437 1437
 //print_r($args );
@@ -1440,34 +1440,34 @@  discard block
 block discarded – undo
1440 1440
 			$custom_attributes = "";
1441 1441
 
1442 1442
 			// get value
1443
-			if ( isset( $instance[ $args['name'] ] ) ) {
1444
-				$value = $instance[ $args['name'] ];
1445
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
1446
-				$value = is_array($args['default']) ? array_map("esc_html",$args['default']) : esc_html( $args['default'] );
1443
+			if (isset($instance[$args['name']])) {
1444
+				$value = $instance[$args['name']];
1445
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
1446
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
1447 1447
 			} else {
1448 1448
 				$value = '';
1449 1449
 			}
1450 1450
 
1451 1451
 			// get placeholder
1452
-			if ( ! empty( $args['placeholder'] ) ) {
1453
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
1452
+			if (!empty($args['placeholder'])) {
1453
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
1454 1454
 			} else {
1455 1455
 				$placeholder = '';
1456 1456
 			}
1457 1457
 
1458 1458
 			// get if advanced
1459
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
1459
+			if (isset($args['advanced']) && $args['advanced']) {
1460 1460
 				$class .= " sd-advanced-setting ";
1461 1461
 			}
1462 1462
 
1463 1463
 			// element_require
1464
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
1464
+			if (isset($args['element_require']) && $args['element_require']) {
1465 1465
 				$element_require = $args['element_require'];
1466 1466
 			}
1467 1467
 
1468 1468
 			// custom_attributes
1469
-			if( isset( $args['custom_attributes']) && $args['custom_attributes']){
1470
-				$custom_attributes = $this->array_to_attributes($args['custom_attributes'],true);
1469
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
1470
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
1471 1471
 			}
1472 1472
 
1473 1473
 
@@ -1475,15 +1475,15 @@  discard block
 block discarded – undo
1475 1475
 
1476 1476
 			// before wrapper
1477 1477
 			?>
1478
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>"
1479
-			   data-argument='<?php echo esc_attr( $args['name'] ); ?>'
1480
-			   data-element_require='<?php if ( $element_require ) {
1481
-				   echo $this->convert_element_require( $element_require );
1478
+			<p class="sd-argument <?php echo esc_attr($class); ?>"
1479
+			   data-argument='<?php echo esc_attr($args['name']); ?>'
1480
+			   data-element_require='<?php if ($element_require) {
1481
+				   echo $this->convert_element_require($element_require);
1482 1482
 			   } ?>'
1483 1483
 			>
1484 1484
 				<?php
1485 1485
 
1486
-				switch ( $args['type'] ) {
1486
+				switch ($args['type']) {
1487 1487
 					//array('text','password','number','email','tel','url','color')
1488 1488
 					case "text":
1489 1489
 					case "password":
@@ -1494,26 +1494,26 @@  discard block
 block discarded – undo
1494 1494
 					case "color":
1495 1495
 						?>
1496 1496
 						<label
1497
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1497
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
1498 1498
 						<input <?php echo $placeholder; ?> class="widefat"
1499
-							<?php echo $custom_attributes;?>
1500
-							                               id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1501
-							                               name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"
1502
-							                               type="<?php echo esc_attr( $args['type'] ); ?>"
1503
-							                               value="<?php echo esc_attr( $value ); ?>">
1499
+							<?php echo $custom_attributes; ?>
1500
+							                               id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1501
+							                               name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"
1502
+							                               type="<?php echo esc_attr($args['type']); ?>"
1503
+							                               value="<?php echo esc_attr($value); ?>">
1504 1504
 						<?php
1505 1505
 
1506 1506
 						break;
1507 1507
 					case "select":
1508
-						$multiple = isset( $args['multiple'] ) && $args['multiple']  ? true : false;
1509
-						if($multiple){if(empty($value)){$value = array();}}
1508
+						$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
1509
+						if ($multiple) {if (empty($value)) {$value = array(); }}
1510 1510
 						?>
1511 1511
 						<label
1512
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1512
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
1513 1513
 						<select <?php echo $placeholder; ?> class="widefat"
1514
-							<?php echo $custom_attributes;?>
1515
-							                                id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1516
-							                                name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if($multiple){echo "[]";}?>"
1514
+							<?php echo $custom_attributes; ?>
1515
+							                                id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1516
+							                                name="<?php echo esc_attr($this->get_field_name($args['name'])); if ($multiple) {echo "[]"; }?>"
1517 1517
 							<?php if ($multiple) {
1518 1518
 								echo "multiple";
1519 1519
 							} //@todo not implemented yet due to gutenberg not supporting it
@@ -1522,12 +1522,12 @@  discard block
 block discarded – undo
1522 1522
 							<?php
1523 1523
 
1524 1524
 
1525
-							if ( ! empty( $args['options'] ) ) {
1526
-								foreach ( $args['options'] as $val => $label ) {
1525
+							if (!empty($args['options'])) {
1526
+								foreach ($args['options'] as $val => $label) {
1527 1527
 //									print_r($value);
1528 1528
 //									echo '@@@'.print_r($val,true),'@@@';
1529 1529
 //									echo '###'.$value.'###';
1530
-									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1530
+									if ($multiple) {$selected = in_array($val, $value) ? 'selected="selected"' : ''; } else {$selected = selected($value, $val, false); }
1531 1531
 									echo "<option value='$val' " . $selected . ">$label</option>";
1532 1532
 								}
1533 1533
 							}
@@ -1538,20 +1538,20 @@  discard block
 block discarded – undo
1538 1538
 					case "checkbox":
1539 1539
 						?>
1540 1540
 						<input <?php echo $placeholder; ?>
1541
-							<?php checked( 1, $value, true ) ?>
1542
-							<?php echo $custom_attributes;?>
1543
-							class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1544
-							name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox"
1541
+							<?php checked(1, $value, true) ?>
1542
+							<?php echo $custom_attributes; ?>
1543
+							class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1544
+							name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox"
1545 1545
 							value="1">
1546 1546
 						<label
1547
-							for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo esc_attr( $args['title'] ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
1547
+							for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo esc_attr($args['title']); ?><?php echo $this->widget_field_desc($args); ?></label>
1548 1548
 						<?php
1549 1549
 						break;
1550 1550
 					case "hidden":
1551 1551
 						?>
1552
-						<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"
1553
-						       name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden"
1554
-						       value="<?php echo esc_attr( $value ); ?>">
1552
+						<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"
1553
+						       name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden"
1554
+						       value="<?php echo esc_attr($value); ?>">
1555 1555
 						<?php
1556 1556
 						break;
1557 1557
 					default:
@@ -1574,14 +1574,14 @@  discard block
 block discarded – undo
1574 1574
 		 * @return string
1575 1575
 		 * @todo, need to make its own tooltip script
1576 1576
 		 */
1577
-		public function widget_field_desc( $args ) {
1577
+		public function widget_field_desc($args) {
1578 1578
 
1579 1579
 			$description = '';
1580
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
1581
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
1582
-					$description = $this->desc_tip( $args['desc'] );
1580
+			if (isset($args['desc']) && $args['desc']) {
1581
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
1582
+					$description = $this->desc_tip($args['desc']);
1583 1583
 				} else {
1584
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
1584
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
1585 1585
 				}
1586 1586
 			}
1587 1587
 
@@ -1597,11 +1597,11 @@  discard block
 block discarded – undo
1597 1597
 		 *
1598 1598
 		 * @return string
1599 1599
 		 */
1600
-		function desc_tip( $tip, $allow_html = false ) {
1601
-			if ( $allow_html ) {
1602
-				$tip = $this->sanitize_tooltip( $tip );
1600
+		function desc_tip($tip, $allow_html = false) {
1601
+			if ($allow_html) {
1602
+				$tip = $this->sanitize_tooltip($tip);
1603 1603
 			} else {
1604
-				$tip = esc_attr( $tip );
1604
+				$tip = esc_attr($tip);
1605 1605
 			}
1606 1606
 
1607 1607
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -1614,8 +1614,8 @@  discard block
 block discarded – undo
1614 1614
 		 *
1615 1615
 		 * @return string
1616 1616
 		 */
1617
-		public function sanitize_tooltip( $var ) {
1618
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
1617
+		public function sanitize_tooltip($var) {
1618
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
1619 1619
 				'br'     => array(),
1620 1620
 				'em'     => array(),
1621 1621
 				'strong' => array(),
@@ -1625,7 +1625,7 @@  discard block
 block discarded – undo
1625 1625
 				'li'     => array(),
1626 1626
 				'ol'     => array(),
1627 1627
 				'p'      => array(),
1628
-			) ) );
1628
+			)));
1629 1629
 		}
1630 1630
 
1631 1631
 		/**
@@ -1637,17 +1637,17 @@  discard block
 block discarded – undo
1637 1637
 		 * @return array
1638 1638
 		 * @todo we should add some sanitation here.
1639 1639
 		 */
1640
-		public function update( $new_instance, $old_instance ) {
1640
+		public function update($new_instance, $old_instance) {
1641 1641
 //			print_r($new_instance);
1642 1642
 //			print_r($old_instance);
1643 1643
 //			exit;
1644 1644
 			//save the widget
1645
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
1645
+			$instance = array_merge((array)$old_instance, (array)$new_instance);
1646 1646
 
1647 1647
 			// set widget instance
1648 1648
 			$this->instance = $instance;
1649 1649
 
1650
-			if(empty($this->arguments)){
1650
+			if (empty($this->arguments)) {
1651 1651
 				$this->get_arguments();
1652 1652
 			}
1653 1653
 
@@ -1659,10 +1659,10 @@  discard block
 block discarded – undo
1659 1659
 //			exit;
1660 1660
 
1661 1661
 			// check for checkboxes
1662
-			if ( ! empty( $this->arguments ) ) {
1663
-				foreach ( $this->arguments as $argument ) {
1664
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
1665
-						$instance[ $argument['name'] ] = '0';
1662
+			if (!empty($this->arguments)) {
1663
+				foreach ($this->arguments as $argument) {
1664
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
1665
+						$instance[$argument['name']] = '0';
1666 1666
 					}
1667 1667
 				}
1668 1668
 			}
Please login to merge, or discard this patch.
Braces   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 				<?php
199 199
 				if(!empty($insert_shortcode_function)){
200 200
 					echo $insert_shortcode_function;
201
-				}else{
201
+				} else{
202 202
 
203 203
 				/**
204 204
 				 * Function for super duper insert shortcode.
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 				}
674 674
 				$output .= $main_content;
675 675
 				$output .= '</div>';
676
-			}elseif($main_content && $no_wrap){
676
+			} elseif($main_content && $no_wrap){
677 677
 				$output .= $main_content;
678 678
 			}
679 679
 
@@ -892,7 +892,7 @@  discard block
 block discarded – undo
892 892
 									$type    = 'array';
893 893
 									if(is_array($args['default'])){
894 894
 										$default = isset( $args['default'] ) ? "['" . implode("','", $args['default']) . "']" : "[]";
895
-									}else{
895
+									} else{
896 896
 										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
897 897
 									}
898 898
 								} elseif ( $args['type'] == 'multiselect' ) {
@@ -1070,7 +1070,7 @@  discard block
 block discarded – undo
1070 1070
 								// If the user sets block-output array then build it
1071 1071
 								if ( ! empty( $this->options['block-output'] ) ) {
1072 1072
 								$this->block_element( $this->options['block-output'] );
1073
-							}else{
1073
+							} else{
1074 1074
 								// if no block-output is set then we try and get the shortcode html output via ajax.
1075 1075
 								?>
1076 1076
 								el('div', {
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 					foreach($custom_attributes as $key => $val){
1161 1161
 						$attributes .= " $key='$val' ";
1162 1162
 					}
1163
-				}else{
1163
+				} else{
1164 1164
 					foreach($custom_attributes as $key => $val){
1165 1165
 						$attributes .= "'$key': '$val',";
1166 1166
 					}
@@ -1527,7 +1527,7 @@  discard block
 block discarded – undo
1527 1527
 //									print_r($value);
1528 1528
 //									echo '@@@'.print_r($val,true),'@@@';
1529 1529
 //									echo '###'.$value.'###';
1530
-									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; }else{$selected = selected( $value, $val, false );}
1530
+									if ($multiple) {$selected = in_array($val,$value) ? 'selected="selected"' : ''; } else{$selected = selected( $value, $val, false );}
1531 1531
 									echo "<option value='$val' " . $selected . ">$label</option>";
1532 1532
 								}
1533 1533
 							}
Please login to merge, or discard this patch.
vendor/composer/autoload_static.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -28,6 +28,9 @@
 block discarded – undo
28 28
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
29 29
     );
30 30
 
31
+    /**
32
+     * @return callable
33
+     */
31 34
     public static function getInitializer(ClassLoader $loader)
32 35
     {
33 36
         return \Closure::bind(function () use ($loader) {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -6,31 +6,31 @@
 block discarded – undo
6 6
 
7 7
 class ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5
8 8
 {
9
-    public static $files = array (
9
+    public static $files = array(
10 10
         '24583d3588ebda5228dd453cfaa070da' => __DIR__ . '/..' . '/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php',
11 11
     );
12 12
 
13
-    public static $prefixLengthsPsr4 = array (
13
+    public static $prefixLengthsPsr4 = array(
14 14
         'C' => 
15
-        array (
15
+        array(
16 16
             'Composer\\Installers\\' => 20,
17 17
         ),
18 18
     );
19 19
 
20
-    public static $prefixDirsPsr4 = array (
20
+    public static $prefixDirsPsr4 = array(
21 21
         'Composer\\Installers\\' => 
22
-        array (
22
+        array(
23 23
             0 => __DIR__ . '/..' . '/composer/installers/src/Composer/Installers',
24 24
         ),
25 25
     );
26 26
 
27
-    public static $classMap = array (
27
+    public static $classMap = array(
28 28
         'WP_Super_Duper' => __DIR__ . '/..' . '/ayecode/wp-super-duper/wp-super-duper.php',
29 29
     );
30 30
 
31 31
     public static function getInitializer(ClassLoader $loader)
32 32
     {
33
-        return \Closure::bind(function () use ($loader) {
33
+        return \Closure::bind(function() use ($loader) {
34 34
             $loader->prefixLengthsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixLengthsPsr4;
35 35
             $loader->prefixDirsPsr4 = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$prefixDirsPsr4;
36 36
             $loader->classMap = ComposerStaticInit8b6d4385c391849a80038f0b0e87c8b5::$classMap;
Please login to merge, or discard this patch.
vendor/composer/ClassLoader.php 2 patches
Doc Comments   +4 added lines patch added patch discarded remove patch
@@ -367,6 +367,10 @@
 block discarded – undo
367 367
         return $file;
368 368
     }
369 369
 
370
+    /**
371
+     * @param string $class
372
+     * @param string $ext
373
+     */
370 374
     private function findFileWithExtension($class, $ext)
371 375
     {
372 376
         // PSR-4 lookup
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
         if (!$prefix) {
112 112
             if ($prepend) {
113 113
                 $this->fallbackDirsPsr0 = array_merge(
114
-                    (array) $paths,
114
+                    (array)$paths,
115 115
                     $this->fallbackDirsPsr0
116 116
                 );
117 117
             } else {
118 118
                 $this->fallbackDirsPsr0 = array_merge(
119 119
                     $this->fallbackDirsPsr0,
120
-                    (array) $paths
120
+                    (array)$paths
121 121
                 );
122 122
             }
123 123
 
@@ -126,19 +126,19 @@  discard block
 block discarded – undo
126 126
 
127 127
         $first = $prefix[0];
128 128
         if (!isset($this->prefixesPsr0[$first][$prefix])) {
129
-            $this->prefixesPsr0[$first][$prefix] = (array) $paths;
129
+            $this->prefixesPsr0[$first][$prefix] = (array)$paths;
130 130
 
131 131
             return;
132 132
         }
133 133
         if ($prepend) {
134 134
             $this->prefixesPsr0[$first][$prefix] = array_merge(
135
-                (array) $paths,
135
+                (array)$paths,
136 136
                 $this->prefixesPsr0[$first][$prefix]
137 137
             );
138 138
         } else {
139 139
             $this->prefixesPsr0[$first][$prefix] = array_merge(
140 140
                 $this->prefixesPsr0[$first][$prefix],
141
-                (array) $paths
141
+                (array)$paths
142 142
             );
143 143
         }
144 144
     }
@@ -159,13 +159,13 @@  discard block
 block discarded – undo
159 159
             // Register directories for the root namespace.
160 160
             if ($prepend) {
161 161
                 $this->fallbackDirsPsr4 = array_merge(
162
-                    (array) $paths,
162
+                    (array)$paths,
163 163
                     $this->fallbackDirsPsr4
164 164
                 );
165 165
             } else {
166 166
                 $this->fallbackDirsPsr4 = array_merge(
167 167
                     $this->fallbackDirsPsr4,
168
-                    (array) $paths
168
+                    (array)$paths
169 169
                 );
170 170
             }
171 171
         } elseif (!isset($this->prefixDirsPsr4[$prefix])) {
@@ -175,18 +175,18 @@  discard block
 block discarded – undo
175 175
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
176 176
             }
177 177
             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
178
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
178
+            $this->prefixDirsPsr4[$prefix] = (array)$paths;
179 179
         } elseif ($prepend) {
180 180
             // Prepend directories for an already registered namespace.
181 181
             $this->prefixDirsPsr4[$prefix] = array_merge(
182
-                (array) $paths,
182
+                (array)$paths,
183 183
                 $this->prefixDirsPsr4[$prefix]
184 184
             );
185 185
         } else {
186 186
             // Append directories for an already registered namespace.
187 187
             $this->prefixDirsPsr4[$prefix] = array_merge(
188 188
                 $this->prefixDirsPsr4[$prefix],
189
-                (array) $paths
189
+                (array)$paths
190 190
             );
191 191
         }
192 192
     }
@@ -201,9 +201,9 @@  discard block
 block discarded – undo
201 201
     public function set($prefix, $paths)
202 202
     {
203 203
         if (!$prefix) {
204
-            $this->fallbackDirsPsr0 = (array) $paths;
204
+            $this->fallbackDirsPsr0 = (array)$paths;
205 205
         } else {
206
-            $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths;
206
+            $this->prefixesPsr0[$prefix[0]][$prefix] = (array)$paths;
207 207
         }
208 208
     }
209 209
 
@@ -219,14 +219,14 @@  discard block
 block discarded – undo
219 219
     public function setPsr4($prefix, $paths)
220 220
     {
221 221
         if (!$prefix) {
222
-            $this->fallbackDirsPsr4 = (array) $paths;
222
+            $this->fallbackDirsPsr4 = (array)$paths;
223 223
         } else {
224 224
             $length = strlen($prefix);
225 225
             if ('\\' !== $prefix[$length - 1]) {
226 226
                 throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator.");
227 227
             }
228 228
             $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length;
229
-            $this->prefixDirsPsr4[$prefix] = (array) $paths;
229
+            $this->prefixDirsPsr4[$prefix] = (array)$paths;
230 230
         }
231 231
     }
232 232
 
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
             return false;
343 343
         }
344 344
         if (null !== $this->apcuPrefix) {
345
-            $file = apcu_fetch($this->apcuPrefix.$class, $hit);
345
+            $file = apcu_fetch($this->apcuPrefix . $class, $hit);
346 346
             if ($hit) {
347 347
                 return $file;
348 348
             }
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
         }
357 357
 
358 358
         if (null !== $this->apcuPrefix) {
359
-            apcu_add($this->apcuPrefix.$class, $file);
359
+            apcu_add($this->apcuPrefix . $class, $file);
360 360
         }
361 361
 
362 362
         if (false === $file) {
Please login to merge, or discard this patch.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 2 patches
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
  * Bail if we are not in WP.
14 14
  */
15 15
 if ( ! defined( 'ABSPATH' ) ) {
16
-	exit;
16
+    exit;
17 17
 }
18 18
 
19 19
 /**
@@ -21,272 +21,272 @@  discard block
 block discarded – undo
21 21
  */
22 22
 if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
23 23
 
24
-	/**
25
-	 * A Class to be able to change settings for Font Awesome.
26
-	 *
27
-	 * Class WP_Font_Awesome_Settings
28
-	 * @ver 1.0.7
29
-	 * @todo decide how to implement textdomain
30
-	 */
31
-	class WP_Font_Awesome_Settings {
32
-
33
-		/**
34
-		 * Class version version.
35
-		 *
36
-		 * @var string
37
-		 */
38
-		public $version = '1.0.7';
39
-
40
-		/**
41
-		 * Latest version of Font Awesome at time of publish published.
42
-		 *
43
-		 * @var string
44
-		 */
45
-		public $latest = "5.5.0";
46
-
47
-		/**
48
-		 * The title.
49
-		 *
50
-		 * @var string
51
-		 */
52
-		public $name = 'Font Awesome';
53
-
54
-		/**
55
-		 * Holds the settings values.
56
-		 *
57
-		 * @var array
58
-		 */
59
-		private $settings;
60
-
61
-		/**
62
-		 * WP_Font_Awesome_Settings instance.
63
-		 *
64
-		 * @access private
65
-		 * @since  1.0.0
66
-		 * @var    WP_Font_Awesome_Settings There can be only one!
67
-		 */
68
-		private static $instance = null;
69
-
70
-		/**
71
-		 * Main WP_Font_Awesome_Settings Instance.
72
-		 *
73
-		 * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
74
-		 *
75
-		 * @since 1.0.0
76
-		 * @static
77
-		 * @return WP_Font_Awesome_Settings - Main instance.
78
-		 */
79
-		public static function instance() {
80
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
81
-				self::$instance = new WP_Font_Awesome_Settings;
82
-
83
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
84
-
85
-				if ( is_admin() ) {
86
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
88
-				}
89
-
90
-				do_action( 'wp_font_awesome_settings_loaded' );
91
-			}
92
-
93
-			return self::$instance;
94
-		}
95
-
96
-		/**
97
-		 * Initiate the settings and add the required action hooks.
98
-		 */
99
-		public function init() {
100
-			$this->settings = $this->get_settings();
101
-
102
-			if ( $this->settings['type'] == 'CSS' ) {
103
-
104
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
105
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
106
-				}
107
-
108
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
109
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
110
-				}
111
-
112
-			} else {
113
-
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
116
-				}
117
-
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
120
-				}
121
-			}
122
-
123
-			// remove font awesome if set to do so
124
-			if ( $this->settings['dequeue'] == '1' ) {
125
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
126
-			}
127
-
128
-		}
129
-
130
-		/**
131
-		 * Adds the Font Awesome styles.
132
-		 */
133
-		public function enqueue_style() {
134
-			// build url
135
-			$url = $this->get_url();
136
-
137
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
138
-			wp_register_style( 'font-awesome', $url, array(), null );
139
-			wp_enqueue_style( 'font-awesome' );
140
-
141
-			if ( $this->settings['shims'] ) {
142
-				$url = $this->get_url( true );
143
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
144
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
145
-				wp_enqueue_style( 'font-awesome-shims' );
146
-			}
147
-		}
148
-
149
-		/**
150
-		 * Adds the Font Awesome JS.
151
-		 */
152
-		public function enqueue_scripts() {
153
-			// build url
154
-			$url = $this->get_url();
155
-
156
-			wp_deregister_script( 'font-awesome' ); // deregister in case its already there
157
-			wp_register_script( 'font-awesome', $url, array(), null );
158
-			wp_enqueue_script( 'font-awesome' );
159
-
160
-			if ( $this->settings['shims'] ) {
161
-				$url = $this->get_url( true );
162
-				wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
163
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
164
-				wp_enqueue_script( 'font-awesome-shims' );
165
-			}
166
-		}
167
-
168
-		/**
169
-		 * Get the url of the Font Awesome files.
170
-		 *
171
-		 * @param bool $shims If this is a shim file or not.
172
-		 *
173
-		 * @return string The url to the file.
174
-		 */
175
-		public function get_url( $shims = false ) {
176
-			$script  = $shims ? 'v4-shims' : 'all';
177
-			$type    = $this->settings['type'];
178
-			$version = $this->settings['version'];
179
-
180
-			$url = "https://use.fontawesome.com/releases/"; // CDN
181
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
182
-			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
183
-			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
184
-			$url .= "?wpfas=true"; // set our var so our version is not removed
185
-
186
-			return $url;
187
-		}
188
-
189
-		/**
190
-		 * Try and remove any other versions of Font Awesome added by other plugins/themes.
191
-		 *
192
-		 * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
193
-		 *
194
-		 * @param $url
195
-		 * @param $original_url
196
-		 * @param $_context
197
-		 *
198
-		 * @return string The filtered url.
199
-		 */
200
-		public function remove_font_awesome( $url, $original_url, $_context ) {
201
-
202
-			if ( $_context == 'display'
203
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
204
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
205
-			) {// it's a font-awesome-url (probably)
206
-
207
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
208
-					if ( $this->settings['type'] == 'JS' ) {
209
-						if ( $this->settings['js-pseudo'] ) {
210
-							$url .= "' data-search-pseudo-elements defer='defer";
211
-						} else {
212
-							$url .= "' defer='defer";
213
-						}
214
-					}
215
-				} else {
216
-					$url = ''; // removing the url removes the file
217
-				}
218
-
219
-			}
220
-
221
-			return $url;
222
-		}
223
-
224
-		/**
225
-		 * Register the database settings with WordPress.
226
-		 */
227
-		public function register_settings() {
228
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
229
-		}
230
-
231
-		/**
232
-		 * Add the WordPress settings menu item.
233
-		 */
234
-		public function menu_item() {
235
-			add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
236
-				$this,
237
-				'settings_page'
238
-			) );
239
-		}
240
-
241
-		/**
242
-		 * Get the current Font Awesome output settings.
243
-		 *
244
-		 * @return array The array of settings.
245
-		 */
246
-		public function get_settings() {
247
-
248
-			$db_settings = get_option( 'wp-font-awesome-settings' );
249
-
250
-			$defaults = array(
251
-				'type'      => 'CSS', // type to use, CSS or JS
252
-				'version'   => '', // latest
253
-				'enqueue'   => '', // front and backend
254
-				'shims'     => '1', // default on for now, @todo maybe change to off in 2020
255
-				'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
256
-				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
257
-			);
258
-
259
-			$settings = wp_parse_args( $db_settings, $defaults );
260
-
261
-			/**
262
-			 * Filter the Font Awesome settings.
263
-			 *
264
-			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
265
-			 */
266
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
267
-		}
268
-
269
-
270
-		/**
271
-		 * The settings page html output.
272
-		 */
273
-		public function settings_page() {
274
-			if ( ! current_user_can( 'manage_options' ) ) {
275
-				wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
276
-			}
277
-
278
-			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
279
-			if(isset($_REQUEST['force-version-check'])){
280
-				$this->get_latest_version($force_api = true);
281
-			}
282
-			?>
24
+    /**
25
+     * A Class to be able to change settings for Font Awesome.
26
+     *
27
+     * Class WP_Font_Awesome_Settings
28
+     * @ver 1.0.7
29
+     * @todo decide how to implement textdomain
30
+     */
31
+    class WP_Font_Awesome_Settings {
32
+
33
+        /**
34
+         * Class version version.
35
+         *
36
+         * @var string
37
+         */
38
+        public $version = '1.0.7';
39
+
40
+        /**
41
+         * Latest version of Font Awesome at time of publish published.
42
+         *
43
+         * @var string
44
+         */
45
+        public $latest = "5.5.0";
46
+
47
+        /**
48
+         * The title.
49
+         *
50
+         * @var string
51
+         */
52
+        public $name = 'Font Awesome';
53
+
54
+        /**
55
+         * Holds the settings values.
56
+         *
57
+         * @var array
58
+         */
59
+        private $settings;
60
+
61
+        /**
62
+         * WP_Font_Awesome_Settings instance.
63
+         *
64
+         * @access private
65
+         * @since  1.0.0
66
+         * @var    WP_Font_Awesome_Settings There can be only one!
67
+         */
68
+        private static $instance = null;
69
+
70
+        /**
71
+         * Main WP_Font_Awesome_Settings Instance.
72
+         *
73
+         * Ensures only one instance of WP_Font_Awesome_Settings is loaded or can be loaded.
74
+         *
75
+         * @since 1.0.0
76
+         * @static
77
+         * @return WP_Font_Awesome_Settings - Main instance.
78
+         */
79
+        public static function instance() {
80
+            if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
81
+                self::$instance = new WP_Font_Awesome_Settings;
82
+
83
+                add_action( 'init', array( self::$instance, 'init' ) ); // set settings
84
+
85
+                if ( is_admin() ) {
86
+                    add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
+                    add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
88
+                }
89
+
90
+                do_action( 'wp_font_awesome_settings_loaded' );
91
+            }
92
+
93
+            return self::$instance;
94
+        }
95
+
96
+        /**
97
+         * Initiate the settings and add the required action hooks.
98
+         */
99
+        public function init() {
100
+            $this->settings = $this->get_settings();
101
+
102
+            if ( $this->settings['type'] == 'CSS' ) {
103
+
104
+                if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
105
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
106
+                }
107
+
108
+                if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
109
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
110
+                }
111
+
112
+            } else {
113
+
114
+                if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
115
+                    add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
116
+                }
117
+
118
+                if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
119
+                    add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
120
+                }
121
+            }
122
+
123
+            // remove font awesome if set to do so
124
+            if ( $this->settings['dequeue'] == '1' ) {
125
+                add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
126
+            }
127
+
128
+        }
129
+
130
+        /**
131
+         * Adds the Font Awesome styles.
132
+         */
133
+        public function enqueue_style() {
134
+            // build url
135
+            $url = $this->get_url();
136
+
137
+            wp_deregister_style( 'font-awesome' ); // deregister in case its already there
138
+            wp_register_style( 'font-awesome', $url, array(), null );
139
+            wp_enqueue_style( 'font-awesome' );
140
+
141
+            if ( $this->settings['shims'] ) {
142
+                $url = $this->get_url( true );
143
+                wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
144
+                wp_register_style( 'font-awesome-shims', $url, array(), null );
145
+                wp_enqueue_style( 'font-awesome-shims' );
146
+            }
147
+        }
148
+
149
+        /**
150
+         * Adds the Font Awesome JS.
151
+         */
152
+        public function enqueue_scripts() {
153
+            // build url
154
+            $url = $this->get_url();
155
+
156
+            wp_deregister_script( 'font-awesome' ); // deregister in case its already there
157
+            wp_register_script( 'font-awesome', $url, array(), null );
158
+            wp_enqueue_script( 'font-awesome' );
159
+
160
+            if ( $this->settings['shims'] ) {
161
+                $url = $this->get_url( true );
162
+                wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
163
+                wp_register_script( 'font-awesome-shims', $url, array(), null );
164
+                wp_enqueue_script( 'font-awesome-shims' );
165
+            }
166
+        }
167
+
168
+        /**
169
+         * Get the url of the Font Awesome files.
170
+         *
171
+         * @param bool $shims If this is a shim file or not.
172
+         *
173
+         * @return string The url to the file.
174
+         */
175
+        public function get_url( $shims = false ) {
176
+            $script  = $shims ? 'v4-shims' : 'all';
177
+            $type    = $this->settings['type'];
178
+            $version = $this->settings['version'];
179
+
180
+            $url = "https://use.fontawesome.com/releases/"; // CDN
181
+            $url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
182
+            $url .= $type == 'CSS' ? 'css/' : 'js/'; // type
183
+            $url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
184
+            $url .= "?wpfas=true"; // set our var so our version is not removed
185
+
186
+            return $url;
187
+        }
188
+
189
+        /**
190
+         * Try and remove any other versions of Font Awesome added by other plugins/themes.
191
+         *
192
+         * Uses the clean_url filter to try and remove any other Font Awesome files added, it can also add pseudo-elements flag for the JS version.
193
+         *
194
+         * @param $url
195
+         * @param $original_url
196
+         * @param $_context
197
+         *
198
+         * @return string The filtered url.
199
+         */
200
+        public function remove_font_awesome( $url, $original_url, $_context ) {
201
+
202
+            if ( $_context == 'display'
203
+                 && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
204
+                 && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
205
+            ) {// it's a font-awesome-url (probably)
206
+
207
+                if ( strstr( $url, "wpfas=true" ) !== false ) {
208
+                    if ( $this->settings['type'] == 'JS' ) {
209
+                        if ( $this->settings['js-pseudo'] ) {
210
+                            $url .= "' data-search-pseudo-elements defer='defer";
211
+                        } else {
212
+                            $url .= "' defer='defer";
213
+                        }
214
+                    }
215
+                } else {
216
+                    $url = ''; // removing the url removes the file
217
+                }
218
+
219
+            }
220
+
221
+            return $url;
222
+        }
223
+
224
+        /**
225
+         * Register the database settings with WordPress.
226
+         */
227
+        public function register_settings() {
228
+            register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
229
+        }
230
+
231
+        /**
232
+         * Add the WordPress settings menu item.
233
+         */
234
+        public function menu_item() {
235
+            add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
236
+                $this,
237
+                'settings_page'
238
+            ) );
239
+        }
240
+
241
+        /**
242
+         * Get the current Font Awesome output settings.
243
+         *
244
+         * @return array The array of settings.
245
+         */
246
+        public function get_settings() {
247
+
248
+            $db_settings = get_option( 'wp-font-awesome-settings' );
249
+
250
+            $defaults = array(
251
+                'type'      => 'CSS', // type to use, CSS or JS
252
+                'version'   => '', // latest
253
+                'enqueue'   => '', // front and backend
254
+                'shims'     => '1', // default on for now, @todo maybe change to off in 2020
255
+                'js-pseudo' => '0', // if the pseudo elements flag should be set (CPU intensive)
256
+                'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
257
+            );
258
+
259
+            $settings = wp_parse_args( $db_settings, $defaults );
260
+
261
+            /**
262
+             * Filter the Font Awesome settings.
263
+             *
264
+             * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
265
+             */
266
+            return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
267
+        }
268
+
269
+
270
+        /**
271
+         * The settings page html output.
272
+         */
273
+        public function settings_page() {
274
+            if ( ! current_user_can( 'manage_options' ) ) {
275
+                wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
276
+            }
277
+
278
+            // a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
279
+            if(isset($_REQUEST['force-version-check'])){
280
+                $this->get_latest_version($force_api = true);
281
+            }
282
+            ?>
283 283
 			<div class="wrap">
284 284
 				<h1><?php echo $this->name; ?></h1>
285 285
 				<form method="post" action="options.php">
286 286
 					<?php
287
-					settings_fields( 'wp-font-awesome-settings' );
288
-					do_settings_sections( 'wp-font-awesome-settings' );
289
-					?>
287
+                    settings_fields( 'wp-font-awesome-settings' );
288
+                    do_settings_sections( 'wp-font-awesome-settings' );
289
+                    ?>
290 290
 					<table class="form-table">
291 291
 						<tr valign="top">
292 292
 							<th scope="row"><label for="wpfas-type"><?php _e( 'Type' ); ?></label></th>
@@ -379,87 +379,87 @@  discard block
 block discarded – undo
379 379
 
380 380
 					</table>
381 381
 					<?php
382
-					submit_button();
383
-					?>
382
+                    submit_button();
383
+                    ?>
384 384
 				</form>
385 385
 
386 386
 				<div id="wpfas-version"><?php echo $this->version; ?></div>
387 387
 			</div>
388 388
 
389 389
 			<?php
390
-		}
391
-
392
-		/**
393
-		 * Check a version number is valid and if so return it or else return an empty string.
394
-		 *
395
-		 * @param $version string The version number to check.
396
-		 * @since 1.0.6
397
-		 *
398
-		 * @return string Either a valid version number or an empty string.
399
-		 */
400
-		public function validate_version_number( $version ) {
401
-
402
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
403
-				// valid
404
-			} else {
405
-				$version = '';// not validated
406
-			}
407
-
408
-			return $version;
409
-		}
410
-
411
-
412
-		/**
413
-		 * Get the latest version of Font Awesome.
414
-		 *
415
-		 * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
416
-		 *
417
-		 * @since 1.0.7
418
-		 * @return mixed|string The latest version number found.
419
-		 */
420
-		public function get_latest_version($force_api = false) {
421
-			$latest_version = $this->latest;
422
-
423
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
424
-
425
-			if ( $cache === false || $force_api) { // its not set
426
-				$api_ver = $this->get_latest_version_from_api();
427
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
428
-					$latest_version = $api_ver;
429
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
430
-				}
431
-			} elseif ( $this->validate_version_number( $cache ) ) {
432
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
433
-					$latest_version = $cache;
434
-				}
435
-			}
436
-
437
-			return $latest_version;
438
-		}
439
-
440
-		/**
441
-		 * Get the latest Font Awesome version from the github API.
442
-		 *
443
-		 * @since 1.0.7
444
-		 * @return string The latest version number or `0` on API fail.
445
-		 */
446
-		public function get_latest_version_from_api() {
447
-			$version  = "0";
448
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
449
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
450
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
451
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
452
-					$version = $api_response['tag_name'];
453
-				}
454
-			}
455
-
456
-			return $version;
457
-		}
458
-
459
-	}
460
-
461
-	/**
462
-	 * Run the class if found.
463
-	 */
464
-	WP_Font_Awesome_Settings::instance();
390
+        }
391
+
392
+        /**
393
+         * Check a version number is valid and if so return it or else return an empty string.
394
+         *
395
+         * @param $version string The version number to check.
396
+         * @since 1.0.6
397
+         *
398
+         * @return string Either a valid version number or an empty string.
399
+         */
400
+        public function validate_version_number( $version ) {
401
+
402
+            if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
403
+                // valid
404
+            } else {
405
+                $version = '';// not validated
406
+            }
407
+
408
+            return $version;
409
+        }
410
+
411
+
412
+        /**
413
+         * Get the latest version of Font Awesome.
414
+         *
415
+         * We check for a cached bersion and if none we will check for a live version via API and then cache it for 48 hours.
416
+         *
417
+         * @since 1.0.7
418
+         * @return mixed|string The latest version number found.
419
+         */
420
+        public function get_latest_version($force_api = false) {
421
+            $latest_version = $this->latest;
422
+
423
+            $cache = get_transient( 'wp-font-awesome-settings-version' );
424
+
425
+            if ( $cache === false || $force_api) { // its not set
426
+                $api_ver = $this->get_latest_version_from_api();
427
+                if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
428
+                    $latest_version = $api_ver;
429
+                    set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
430
+                }
431
+            } elseif ( $this->validate_version_number( $cache ) ) {
432
+                if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
433
+                    $latest_version = $cache;
434
+                }
435
+            }
436
+
437
+            return $latest_version;
438
+        }
439
+
440
+        /**
441
+         * Get the latest Font Awesome version from the github API.
442
+         *
443
+         * @since 1.0.7
444
+         * @return string The latest version number or `0` on API fail.
445
+         */
446
+        public function get_latest_version_from_api() {
447
+            $version  = "0";
448
+            $response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
449
+            if ( ! is_wp_error( $response ) && is_array( $response ) ) {
450
+                $api_response = json_decode( wp_remote_retrieve_body( $response ), true );
451
+                if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
452
+                    $version = $api_response['tag_name'];
453
+                }
454
+            }
455
+
456
+            return $version;
457
+        }
458
+
459
+    }
460
+
461
+    /**
462
+     * Run the class if found.
463
+     */
464
+    WP_Font_Awesome_Settings::instance();
465 465
 }
466 466
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -12,14 +12,14 @@  discard block
 block discarded – undo
12 12
 /**
13 13
  * Bail if we are not in WP.
14 14
  */
15
-if ( ! defined( 'ABSPATH' ) ) {
15
+if (!defined('ABSPATH')) {
16 16
 	exit;
17 17
 }
18 18
 
19 19
 /**
20 20
  * Only add if the class does not already exist.
21 21
  */
22
-if ( ! class_exists( 'WP_Font_Awesome_Settings' ) ) {
22
+if (!class_exists('WP_Font_Awesome_Settings')) {
23 23
 
24 24
 	/**
25 25
 	 * A Class to be able to change settings for Font Awesome.
@@ -77,17 +77,17 @@  discard block
 block discarded – undo
77 77
 		 * @return WP_Font_Awesome_Settings - Main instance.
78 78
 		 */
79 79
 		public static function instance() {
80
-			if ( ! isset( self::$instance ) && ! ( self::$instance instanceof WP_Font_Awesome_Settings ) ) {
80
+			if (!isset(self::$instance) && !(self::$instance instanceof WP_Font_Awesome_Settings)) {
81 81
 				self::$instance = new WP_Font_Awesome_Settings;
82 82
 
83
-				add_action( 'init', array( self::$instance, 'init' ) ); // set settings
83
+				add_action('init', array(self::$instance, 'init')); // set settings
84 84
 
85
-				if ( is_admin() ) {
86
-					add_action( 'admin_menu', array( self::$instance, 'menu_item' ) );
87
-					add_action( 'admin_init', array( self::$instance, 'register_settings' ) );
85
+				if (is_admin()) {
86
+					add_action('admin_menu', array(self::$instance, 'menu_item'));
87
+					add_action('admin_init', array(self::$instance, 'register_settings'));
88 88
 				}
89 89
 
90
-				do_action( 'wp_font_awesome_settings_loaded' );
90
+				do_action('wp_font_awesome_settings_loaded');
91 91
 			}
92 92
 
93 93
 			return self::$instance;
@@ -99,30 +99,30 @@  discard block
 block discarded – undo
99 99
 		public function init() {
100 100
 			$this->settings = $this->get_settings();
101 101
 
102
-			if ( $this->settings['type'] == 'CSS' ) {
102
+			if ($this->settings['type'] == 'CSS') {
103 103
 
104
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
105
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );//echo '###';exit;
104
+				if ($this->settings['enqueue'] == '' || $this->settings['frontend']) {
105
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_style'), 5000); //echo '###';exit;
106 106
 				}
107 107
 
108
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
109
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_style' ), 5000 );
108
+				if ($this->settings['enqueue'] == '' || $this->settings['backend']) {
109
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_style'), 5000);
110 110
 				}
111 111
 
112 112
 			} else {
113 113
 
114
-				if ( $this->settings['enqueue'] == '' || $this->settings['frontend'] ) {
115
-					add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );//echo '###';exit;
114
+				if ($this->settings['enqueue'] == '' || $this->settings['frontend']) {
115
+					add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'), 5000); //echo '###';exit;
116 116
 				}
117 117
 
118
-				if ( $this->settings['enqueue'] == '' || $this->settings['backend'] ) {
119
-					add_action( 'admin_enqueue_scripts', array( $this, 'enqueue_scripts' ), 5000 );
118
+				if ($this->settings['enqueue'] == '' || $this->settings['backend']) {
119
+					add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts'), 5000);
120 120
 				}
121 121
 			}
122 122
 
123 123
 			// remove font awesome if set to do so
124
-			if ( $this->settings['dequeue'] == '1' ) {
125
-				add_action( 'clean_url', array( $this, 'remove_font_awesome' ), 5000, 3 );
124
+			if ($this->settings['dequeue'] == '1') {
125
+				add_action('clean_url', array($this, 'remove_font_awesome'), 5000, 3);
126 126
 			}
127 127
 
128 128
 		}
@@ -134,15 +134,15 @@  discard block
 block discarded – undo
134 134
 			// build url
135 135
 			$url = $this->get_url();
136 136
 
137
-			wp_deregister_style( 'font-awesome' ); // deregister in case its already there
138
-			wp_register_style( 'font-awesome', $url, array(), null );
139
-			wp_enqueue_style( 'font-awesome' );
137
+			wp_deregister_style('font-awesome'); // deregister in case its already there
138
+			wp_register_style('font-awesome', $url, array(), null);
139
+			wp_enqueue_style('font-awesome');
140 140
 
141
-			if ( $this->settings['shims'] ) {
142
-				$url = $this->get_url( true );
143
-				wp_deregister_style( 'font-awesome-shims' ); // deregister in case its already there
144
-				wp_register_style( 'font-awesome-shims', $url, array(), null );
145
-				wp_enqueue_style( 'font-awesome-shims' );
141
+			if ($this->settings['shims']) {
142
+				$url = $this->get_url(true);
143
+				wp_deregister_style('font-awesome-shims'); // deregister in case its already there
144
+				wp_register_style('font-awesome-shims', $url, array(), null);
145
+				wp_enqueue_style('font-awesome-shims');
146 146
 			}
147 147
 		}
148 148
 
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
 			// build url
154 154
 			$url = $this->get_url();
155 155
 
156
-			wp_deregister_script( 'font-awesome' ); // deregister in case its already there
157
-			wp_register_script( 'font-awesome', $url, array(), null );
158
-			wp_enqueue_script( 'font-awesome' );
156
+			wp_deregister_script('font-awesome'); // deregister in case its already there
157
+			wp_register_script('font-awesome', $url, array(), null);
158
+			wp_enqueue_script('font-awesome');
159 159
 
160
-			if ( $this->settings['shims'] ) {
161
-				$url = $this->get_url( true );
162
-				wp_deregister_script( 'font-awesome-shims' ); // deregister in case its already there
163
-				wp_register_script( 'font-awesome-shims', $url, array(), null );
164
-				wp_enqueue_script( 'font-awesome-shims' );
160
+			if ($this->settings['shims']) {
161
+				$url = $this->get_url(true);
162
+				wp_deregister_script('font-awesome-shims'); // deregister in case its already there
163
+				wp_register_script('font-awesome-shims', $url, array(), null);
164
+				wp_enqueue_script('font-awesome-shims');
165 165
 			}
166 166
 		}
167 167
 
@@ -172,13 +172,13 @@  discard block
 block discarded – undo
172 172
 		 *
173 173
 		 * @return string The url to the file.
174 174
 		 */
175
-		public function get_url( $shims = false ) {
175
+		public function get_url($shims = false) {
176 176
 			$script  = $shims ? 'v4-shims' : 'all';
177 177
 			$type    = $this->settings['type'];
178 178
 			$version = $this->settings['version'];
179 179
 
180 180
 			$url = "https://use.fontawesome.com/releases/"; // CDN
181
-			$url .= ! empty( $version ) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
181
+			$url .= !empty($version) ? "v" . $version . '/' : "v" . $this->get_latest_version() . '/'; // version
182 182
 			$url .= $type == 'CSS' ? 'css/' : 'js/'; // type
183 183
 			$url .= $type == 'CSS' ? $script . '.css' : $script . '.js'; // type
184 184
 			$url .= "?wpfas=true"; // set our var so our version is not removed
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
 		 *
198 198
 		 * @return string The filtered url.
199 199
 		 */
200
-		public function remove_font_awesome( $url, $original_url, $_context ) {
200
+		public function remove_font_awesome($url, $original_url, $_context) {
201 201
 
202
-			if ( $_context == 'display'
203
-			     && ( strstr( $url, "fontawesome" ) !== false || strstr( $url, "font-awesome" ) !== false )
204
-			     && ( strstr( $url, ".js" ) !== false || strstr( $url, ".css" ) !== false )
202
+			if ($_context == 'display'
203
+			     && (strstr($url, "fontawesome") !== false || strstr($url, "font-awesome") !== false)
204
+			     && (strstr($url, ".js") !== false || strstr($url, ".css") !== false)
205 205
 			) {// it's a font-awesome-url (probably)
206 206
 
207
-				if ( strstr( $url, "wpfas=true" ) !== false ) {
208
-					if ( $this->settings['type'] == 'JS' ) {
209
-						if ( $this->settings['js-pseudo'] ) {
207
+				if (strstr($url, "wpfas=true") !== false) {
208
+					if ($this->settings['type'] == 'JS') {
209
+						if ($this->settings['js-pseudo']) {
210 210
 							$url .= "' data-search-pseudo-elements defer='defer";
211 211
 						} else {
212 212
 							$url .= "' defer='defer";
@@ -225,17 +225,17 @@  discard block
 block discarded – undo
225 225
 		 * Register the database settings with WordPress.
226 226
 		 */
227 227
 		public function register_settings() {
228
-			register_setting( 'wp-font-awesome-settings', 'wp-font-awesome-settings' );
228
+			register_setting('wp-font-awesome-settings', 'wp-font-awesome-settings');
229 229
 		}
230 230
 
231 231
 		/**
232 232
 		 * Add the WordPress settings menu item.
233 233
 		 */
234 234
 		public function menu_item() {
235
-			add_options_page( $this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
235
+			add_options_page($this->name, $this->name, 'manage_options', 'wp-font-awesome-settings', array(
236 236
 				$this,
237 237
 				'settings_page'
238
-			) );
238
+			));
239 239
 		}
240 240
 
241 241
 		/**
@@ -245,7 +245,7 @@  discard block
 block discarded – undo
245 245
 		 */
246 246
 		public function get_settings() {
247 247
 
248
-			$db_settings = get_option( 'wp-font-awesome-settings' );
248
+			$db_settings = get_option('wp-font-awesome-settings');
249 249
 
250 250
 			$defaults = array(
251 251
 				'type'      => 'CSS', // type to use, CSS or JS
@@ -256,14 +256,14 @@  discard block
 block discarded – undo
256 256
 				'dequeue'   => '0', // if we should try to remove other versions added by other plugins/themes
257 257
 			);
258 258
 
259
-			$settings = wp_parse_args( $db_settings, $defaults );
259
+			$settings = wp_parse_args($db_settings, $defaults);
260 260
 
261 261
 			/**
262 262
 			 * Filter the Font Awesome settings.
263 263
 			 *
264 264
 			 * @todo if we add this filer people might use it and then it defeates the purpose of this class :/
265 265
 			 */
266
-			return $this->settings = apply_filters( 'wp-font-awesome-settings', $settings, $db_settings, $defaults );
266
+			return $this->settings = apply_filters('wp-font-awesome-settings', $settings, $db_settings, $defaults);
267 267
 		}
268 268
 
269 269
 
@@ -271,12 +271,12 @@  discard block
 block discarded – undo
271 271
 		 * The settings page html output.
272 272
 		 */
273 273
 		public function settings_page() {
274
-			if ( ! current_user_can( 'manage_options' ) ) {
275
-				wp_die( __( 'You do not have sufficient permissions to access this page.' ) );
274
+			if (!current_user_can('manage_options')) {
275
+				wp_die(__('You do not have sufficient permissions to access this page.'));
276 276
 			}
277 277
 
278 278
 			// a hidden way to force the update of the verison number vai api instead of waiting the 48 hours
279
-			if(isset($_REQUEST['force-version-check'])){
279
+			if (isset($_REQUEST['force-version-check'])) {
280 280
 				$this->get_latest_version($force_api = true);
281 281
 			}
282 282
 			?>
@@ -284,43 +284,43 @@  discard block
 block discarded – undo
284 284
 				<h1><?php echo $this->name; ?></h1>
285 285
 				<form method="post" action="options.php">
286 286
 					<?php
287
-					settings_fields( 'wp-font-awesome-settings' );
288
-					do_settings_sections( 'wp-font-awesome-settings' );
287
+					settings_fields('wp-font-awesome-settings');
288
+					do_settings_sections('wp-font-awesome-settings');
289 289
 					?>
290 290
 					<table class="form-table">
291 291
 						<tr valign="top">
292
-							<th scope="row"><label for="wpfas-type"><?php _e( 'Type' ); ?></label></th>
292
+							<th scope="row"><label for="wpfas-type"><?php _e('Type'); ?></label></th>
293 293
 							<td>
294 294
 								<select name="wp-font-awesome-settings[type]" id="wpfas-type">
295 295
 									<option
296
-										value="CSS" <?php selected( $this->settings['type'], 'CSS' ); ?>><?php _e( 'CSS (default)' ); ?></option>
297
-									<option value="JS" <?php selected( $this->settings['type'], 'JS' ); ?>>JS</option>
296
+										value="CSS" <?php selected($this->settings['type'], 'CSS'); ?>><?php _e('CSS (default)'); ?></option>
297
+									<option value="JS" <?php selected($this->settings['type'], 'JS'); ?>>JS</option>
298 298
 								</select>
299 299
 							</td>
300 300
 						</tr>
301 301
 
302 302
 						<tr valign="top">
303
-							<th scope="row"><label for="wpfas-version"><?php _e( 'Version' ); ?></label></th>
303
+							<th scope="row"><label for="wpfas-version"><?php _e('Version'); ?></label></th>
304 304
 							<td>
305 305
 								<select name="wp-font-awesome-settings[version]" id="wpfas-version">
306 306
 									<option
307
-										value="" <?php selected( $this->settings['version'], '' ); ?>><?php echo sprintf( __( 'Latest - %s (default)' ), $this->get_latest_version() ); ?></option>
308
-									<option value="5.5.0" <?php selected( $this->settings['version'], '5.5.0' ); ?>>
307
+										value="" <?php selected($this->settings['version'], ''); ?>><?php echo sprintf(__('Latest - %s (default)'), $this->get_latest_version()); ?></option>
308
+									<option value="5.5.0" <?php selected($this->settings['version'], '5.5.0'); ?>>
309 309
 										5.5.0
310 310
 									</option>
311
-									<option value="5.4.0" <?php selected( $this->settings['version'], '5.4.0' ); ?>>
311
+									<option value="5.4.0" <?php selected($this->settings['version'], '5.4.0'); ?>>
312 312
 										5.4.0
313 313
 									</option>
314
-									<option value="5.3.0" <?php selected( $this->settings['version'], '5.3.0' ); ?>>
314
+									<option value="5.3.0" <?php selected($this->settings['version'], '5.3.0'); ?>>
315 315
 										5.3.0
316 316
 									</option>
317
-									<option value="5.2.0" <?php selected( $this->settings['version'], '5.2.0' ); ?>>
317
+									<option value="5.2.0" <?php selected($this->settings['version'], '5.2.0'); ?>>
318 318
 										5.2.0
319 319
 									</option>
320
-									<option value="5.1.0" <?php selected( $this->settings['version'], '5.1.0' ); ?>>
320
+									<option value="5.1.0" <?php selected($this->settings['version'], '5.1.0'); ?>>
321 321
 										5.1.0
322 322
 									</option>
323
-									<option value="4.7.0" <?php selected( $this->settings['version'], '4.7.0' ); ?>>
323
+									<option value="4.7.0" <?php selected($this->settings['version'], '4.7.0'); ?>>
324 324
 										4.7.1 (CSS only)
325 325
 									</option>
326 326
 								</select>
@@ -328,51 +328,51 @@  discard block
 block discarded – undo
328 328
 						</tr>
329 329
 
330 330
 						<tr valign="top">
331
-							<th scope="row"><label for="wpfas-enqueue"><?php _e( 'Enqueue' ); ?></label></th>
331
+							<th scope="row"><label for="wpfas-enqueue"><?php _e('Enqueue'); ?></label></th>
332 332
 							<td>
333 333
 								<select name="wp-font-awesome-settings[enqueue]" id="wpfas-enqueue">
334 334
 									<option
335
-										value="" <?php selected( $this->settings['enqueue'], '' ); ?>><?php _e( 'Frontend + Backend (default)' ); ?></option>
335
+										value="" <?php selected($this->settings['enqueue'], ''); ?>><?php _e('Frontend + Backend (default)'); ?></option>
336 336
 									<option
337
-										value="frontend" <?php selected( $this->settings['enqueue'], 'frontend' ); ?>><?php _e( 'Frontend' ); ?></option>
337
+										value="frontend" <?php selected($this->settings['enqueue'], 'frontend'); ?>><?php _e('Frontend'); ?></option>
338 338
 									<option
339
-										value="backend" <?php selected( $this->settings['enqueue'], 'backend' ); ?>><?php _e( 'Backend' ); ?></option>
339
+										value="backend" <?php selected($this->settings['enqueue'], 'backend'); ?>><?php _e('Backend'); ?></option>
340 340
 								</select>
341 341
 							</td>
342 342
 						</tr>
343 343
 
344 344
 						<tr valign="top">
345 345
 							<th scope="row"><label
346
-									for="wpfas-shims"><?php _e( 'Enable v4 shims compatibility' ); ?></label></th>
346
+									for="wpfas-shims"><?php _e('Enable v4 shims compatibility'); ?></label></th>
347 347
 							<td>
348 348
 								<input type="hidden" name="wp-font-awesome-settings[shims]" value="0"/>
349 349
 								<input type="checkbox" name="wp-font-awesome-settings[shims]"
350
-								       value="1" <?php checked( $this->settings['shims'], '1' ); ?> id="wpfas-shims"/>
351
-								<span><?php _e( 'This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.' ); ?></span>
350
+								       value="1" <?php checked($this->settings['shims'], '1'); ?> id="wpfas-shims"/>
351
+								<span><?php _e('This enables v4 classes to work with v5, sort of like a band-aid until everyone has updated everything to v5.'); ?></span>
352 352
 							</td>
353 353
 						</tr>
354 354
 
355 355
 						<tr valign="top">
356 356
 							<th scope="row"><label
357
-									for="wpfas-js-pseudo"><?php _e( 'Enable JS pseudo elements (not recommended)' ); ?></label>
357
+									for="wpfas-js-pseudo"><?php _e('Enable JS pseudo elements (not recommended)'); ?></label>
358 358
 							</th>
359 359
 							<td>
360 360
 								<input type="hidden" name="wp-font-awesome-settings[js-pseudo]" value="0"/>
361 361
 								<input type="checkbox" name="wp-font-awesome-settings[js-pseudo]"
362
-								       value="1" <?php checked( $this->settings['js-pseudo'], '1' ); ?>
362
+								       value="1" <?php checked($this->settings['js-pseudo'], '1'); ?>
363 363
 								       id="wpfas-js-pseudo"/>
364
-								<span><?php _e( 'Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.' ); ?></span>
364
+								<span><?php _e('Used only with the JS version, this will make pseudo-elements work but can be CPU intensive on some sites.'); ?></span>
365 365
 							</td>
366 366
 						</tr>
367 367
 
368 368
 						<tr valign="top">
369
-							<th scope="row"><label for="wpfas-dequeue"><?php _e( 'Dequeue' ); ?></label></th>
369
+							<th scope="row"><label for="wpfas-dequeue"><?php _e('Dequeue'); ?></label></th>
370 370
 							<td>
371 371
 								<input type="hidden" name="wp-font-awesome-settings[dequeue]" value="0"/>
372 372
 								<input type="checkbox" name="wp-font-awesome-settings[dequeue]"
373
-								       value="1" <?php checked( $this->settings['dequeue'], '1' ); ?>
373
+								       value="1" <?php checked($this->settings['dequeue'], '1'); ?>
374 374
 								       id="wpfas-dequeue"/>
375
-								<span><?php _e( 'This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.' ); ?></span>
375
+								<span><?php _e('This will try to dequeue any other Font Awesome versions loaded by other sources if they are added with `font-awesome` or `fontawesome` in the name.'); ?></span>
376 376
 							</td>
377 377
 						</tr>
378 378
 
@@ -397,12 +397,12 @@  discard block
 block discarded – undo
397 397
 		 *
398 398
 		 * @return string Either a valid version number or an empty string.
399 399
 		 */
400
-		public function validate_version_number( $version ) {
400
+		public function validate_version_number($version) {
401 401
 
402
-			if ( version_compare( $version, '0.0.1', '>=' ) >= 0 ) {
402
+			if (version_compare($version, '0.0.1', '>=') >= 0) {
403 403
 				// valid
404 404
 			} else {
405
-				$version = '';// not validated
405
+				$version = ''; // not validated
406 406
 			}
407 407
 
408 408
 			return $version;
@@ -420,16 +420,16 @@  discard block
 block discarded – undo
420 420
 		public function get_latest_version($force_api = false) {
421 421
 			$latest_version = $this->latest;
422 422
 
423
-			$cache = get_transient( 'wp-font-awesome-settings-version' );
423
+			$cache = get_transient('wp-font-awesome-settings-version');
424 424
 
425
-			if ( $cache === false || $force_api) { // its not set
425
+			if ($cache === false || $force_api) { // its not set
426 426
 				$api_ver = $this->get_latest_version_from_api();
427
-				if ( version_compare( $api_ver, $this->latest, '>=' ) >= 0 ) {
427
+				if (version_compare($api_ver, $this->latest, '>=') >= 0) {
428 428
 					$latest_version = $api_ver;
429
-					set_transient( 'wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS );
429
+					set_transient('wp-font-awesome-settings-version', $api_ver, 48 * HOUR_IN_SECONDS);
430 430
 				}
431
-			} elseif ( $this->validate_version_number( $cache ) ) {
432
-				if ( version_compare( $cache, $this->latest, '>=' ) >= 0 ) {
431
+			} elseif ($this->validate_version_number($cache)) {
432
+				if (version_compare($cache, $this->latest, '>=') >= 0) {
433 433
 					$latest_version = $cache;
434 434
 				}
435 435
 			}
@@ -445,10 +445,10 @@  discard block
 block discarded – undo
445 445
 		 */
446 446
 		public function get_latest_version_from_api() {
447 447
 			$version  = "0";
448
-			$response = wp_remote_get( "https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest" );
449
-			if ( ! is_wp_error( $response ) && is_array( $response ) ) {
450
-				$api_response = json_decode( wp_remote_retrieve_body( $response ), true );
451
-				if ( isset( $api_response['tag_name'] ) && version_compare( $api_response['tag_name'], $this->latest, '>=' ) >= 0 && empty( $api_response['prerelease'] ) ) {
448
+			$response = wp_remote_get("https://api.github.com/repos/FortAwesome/Font-Awesome/releases/latest");
449
+			if (!is_wp_error($response) && is_array($response)) {
450
+				$api_response = json_decode(wp_remote_retrieve_body($response), true);
451
+				if (isset($api_response['tag_name']) && version_compare($api_response['tag_name'], $this->latest, '>=') >= 0 && empty($api_response['prerelease'])) {
452 452
 					$version = $api_response['tag_name'];
453 453
 				}
454 454
 			}
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@
 block discarded – undo
35 35
     public function getLocations()
36 36
     {
37 37
         if ($this->matchesCakeVersion('>=', '3.0.0')) {
38
-            $this->locations['plugin'] =  $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
38
+            $this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
39 39
         }
40 40
         return $this->locations;
41 41
     }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/OxidInstaller.php 1 patch
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 
6 6
 class OxidInstaller extends BaseInstaller
7 7
 {
8
-	const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
8
+    const VENDOR_PATTERN = '/^modules\/(?P<vendor>.+)\/.+/';
9 9
 
10 10
     protected $locations = array(
11 11
         'module'    => 'modules/{$name}/',
@@ -13,47 +13,47 @@  discard block
 block discarded – undo
13 13
         'out'    => 'out/{$name}/',
14 14
     );
15 15
 
16
-	/**
17
-	 * getInstallPath
18
-	 *
19
-	 * @param PackageInterface $package
20
-	 * @param string $frameworkType
21
-	 * @return void
22
-	 */
23
-	public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
-	{
25
-		$installPath = parent::getInstallPath($package, $frameworkType);
26
-		$type = $this->package->getType();
27
-		if ($type === 'oxid-module') {
28
-			$this->prepareVendorDirectory($installPath);
29
-		}
30
-		return $installPath;
31
-	}
16
+    /**
17
+     * getInstallPath
18
+     *
19
+     * @param PackageInterface $package
20
+     * @param string $frameworkType
21
+     * @return void
22
+     */
23
+    public function getInstallPath(PackageInterface $package, $frameworkType = '')
24
+    {
25
+        $installPath = parent::getInstallPath($package, $frameworkType);
26
+        $type = $this->package->getType();
27
+        if ($type === 'oxid-module') {
28
+            $this->prepareVendorDirectory($installPath);
29
+        }
30
+        return $installPath;
31
+    }
32 32
 
33
-	/**
34
-	 * prepareVendorDirectory
35
-	 *
36
-	 * Makes sure there is a vendormetadata.php file inside
37
-	 * the vendor folder if there is a vendor folder.
38
-	 *
39
-	 * @param string $installPath
40
-	 * @return void
41
-	 */
42
-	protected function prepareVendorDirectory($installPath)
43
-	{
44
-		$matches = '';
45
-		$hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
-		if (!$hasVendorDirectory) {
47
-			return;
48
-		}
33
+    /**
34
+     * prepareVendorDirectory
35
+     *
36
+     * Makes sure there is a vendormetadata.php file inside
37
+     * the vendor folder if there is a vendor folder.
38
+     *
39
+     * @param string $installPath
40
+     * @return void
41
+     */
42
+    protected function prepareVendorDirectory($installPath)
43
+    {
44
+        $matches = '';
45
+        $hasVendorDirectory = preg_match(self::VENDOR_PATTERN, $installPath, $matches);
46
+        if (!$hasVendorDirectory) {
47
+            return;
48
+        }
49 49
 
50
-		$vendorDirectory = $matches['vendor'];
51
-		$vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
-		if (!file_exists($vendorPath)) {
53
-			mkdir($vendorPath, 0755, true);
54
-		}
50
+        $vendorDirectory = $matches['vendor'];
51
+        $vendorPath = getcwd() . '/modules/' . $vendorDirectory;
52
+        if (!file_exists($vendorPath)) {
53
+            mkdir($vendorPath, 0755, true);
54
+        }
55 55
 
56
-		$vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
-		touch($vendorMetaDataPath);
58
-	}
56
+        $vendorMetaDataPath = $vendorPath . '/vendormetadata.php';
57
+        touch($vendorMetaDataPath);
58
+    }
59 59
 }
Please login to merge, or discard this patch.
vendor/composer/installers/src/Composer/Installers/GravInstaller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
         $restrictedWords = implode('|', array_keys($this->locations));
21 21
 
22 22
         $vars['name'] = strtolower($vars['name']);
23
-        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:'.$restrictedWords.')-)?(.*?)(?:-(?:'.$restrictedWords.'))?$/ui',
23
+        $vars['name'] = preg_replace('/^(?:grav-)?(?:(?:' . $restrictedWords . ')-)?(.*?)(?:-(?:' . $restrictedWords . '))?$/ui',
24 24
             '$1',
25 25
             $vars['name']
26 26
         );
Please login to merge, or discard this patch.
composer/installers/src/Composer/Installers/ClanCatsFrameworkInstaller.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@
 block discarded – undo
3 3
 
4 4
 class ClanCatsFrameworkInstaller extends BaseInstaller
5 5
 {
6
-	protected $locations = array(
7
-		'ship'      => 'CCF/orbit/{$name}/',
8
-		'theme'     => 'CCF/app/themes/{$name}/',
9
-	);
6
+    protected $locations = array(
7
+        'ship'      => 'CCF/orbit/{$name}/',
8
+        'theme'     => 'CCF/app/themes/{$name}/',
9
+    );
10 10
 }
11 11
\ No newline at end of file
Please login to merge, or discard this patch.