Passed
Push — master ( 1d60eb...03dff3 )
by Stiofan
06:44 queued 03:02
created
includes/gateways/paypal.php 1 patch
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.
vendor/ayecode/wp-super-duper/wp-super-duper.php 1 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.
vendor/ayecode/wp-font-awesome-settings/wp-font-awesome-settings.php 1 patch
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.
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.
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.
vendor/composer/installers/src/Composer/Installers/DrupalInstaller.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
         'library'   => 'libraries/{$name}/',
11 11
         'profile'   => 'profiles/{$name}/',
12 12
         'drush'     => 'drush/{$name}/',
13
-	    'custom-theme' => 'themes/custom/{$name}/',
14
-	    'custom-module' => 'modules/custom/{$name}/',
13
+        'custom-theme' => 'themes/custom/{$name}/',
14
+        'custom-module' => 'modules/custom/{$name}/',
15 15
     );
16 16
 }
Please login to merge, or discard this patch.