Passed
Pull Request — master (#821)
by Kiran
04:42
created
includes/admin/views/html-tax-rule-edit.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -5,30 +5,30 @@
 block discarded – undo
5 5
  * @var array $tax_rule
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 ?>
11 11
 
12 12
 <tr>
13 13
 
14 14
     <td class="wpinv-tax-rule-key">
15
-        <input type="text" name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][key]" value="<?php echo esc_attr( $tax_rule['key'] ); ?>" required/>
15
+        <input type="text" name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][key]" value="<?php echo esc_attr($tax_rule['key']); ?>" required/>
16 16
     </td>
17 17
 
18 18
     <td class="wpinv-tax-rule-label">
19
-        <input type="text" name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][label]" value="<?php echo esc_attr( $tax_rule['label'] ); ?>" required/>
19
+        <input type="text" name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][label]" value="<?php echo esc_attr($tax_rule['label']); ?>" required/>
20 20
     </td>
21 21
 
22 22
     <td class="wpinv-tax-rule-base-address">
23
-        <select name="tax_rules[<?php echo esc_attr( $tax_rule['key'] ); ?>][tax_base]" class="getpaid-tax-rule-base-address" required>
24
-            <option value="billing" <?php selected( $tax_rule['tax_base'], 'billing' ); ?>><?php esc_html_e( 'Customer billing address', 'invoicing' ); ?></option>
25
-            <option value="base" <?php selected( $tax_rule['tax_base'], 'base' ); ?>><?php esc_html_e( 'Shop base address', 'invoicing' ); ?></option>
23
+        <select name="tax_rules[<?php echo esc_attr($tax_rule['key']); ?>][tax_base]" class="getpaid-tax-rule-base-address" required>
24
+            <option value="billing" <?php selected($tax_rule['tax_base'], 'billing'); ?>><?php esc_html_e('Customer billing address', 'invoicing'); ?></option>
25
+            <option value="base" <?php selected($tax_rule['tax_base'], 'base'); ?>><?php esc_html_e('Shop base address', 'invoicing'); ?></option>
26 26
         </select>
27 27
     </td>
28 28
 
29 29
     <td class="wpinv_tax_remove">
30
-        <button type="button" class="close btn-close wpinv_remove_tax_rule" aria-label="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>" title="<?php esc_attr_e( 'Delete', 'invoicing' ); ?>">
31
-            <?php if ( empty( $GLOBALS['aui_bs5'] ) ) : ?>
30
+        <button type="button" class="close btn-close wpinv_remove_tax_rule" aria-label="<?php esc_attr_e('Delete', 'invoicing'); ?>" title="<?php esc_attr_e('Delete', 'invoicing'); ?>">
31
+            <?php if (empty($GLOBALS['aui_bs5'])) : ?>
32 32
                 <span aria-hidden="true">×</span>
33 33
             <?php endif; ?>
34 34
         </button>
Please login to merge, or discard this patch.
includes/admin/register-settings.php 2 patches
Indentation   +360 added lines, -360 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@  discard block
 block discarded – undo
25 25
                     $defaults[ $key ] = $setting['std'];
26 26
                 }
27 27
             }
28
-		}
29
-	}
28
+        }
29
+    }
30 30
 
31 31
     return $defaults;
32 32
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
  *
145 145
  */
146 146
 function wpinv_register_settings() {
147
-	do_action( 'getpaid_before_register_settings' );
147
+    do_action( 'getpaid_before_register_settings' );
148 148
 
149 149
     // Loop through all tabs.
150 150
     foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
                 $settings = $sections;
160 160
             }
161 161
 
162
-			do_action( "getpaid_register_{$tab}_{$section}" );
162
+            do_action( "getpaid_register_{$tab}_{$section}" );
163 163
 
164 164
             // Register the setting section.
165 165
             add_settings_section(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
     // Creates our settings in the options table.
181 181
     register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
182 182
 
183
-	do_action( 'getpaid_after_register_settings' );
183
+    do_action( 'getpaid_after_register_settings' );
184 184
 }
185 185
 add_action( 'admin_init', 'wpinv_register_settings' );
186 186
 
@@ -197,13 +197,13 @@  discard block
 block discarded – undo
197 197
     $name       = isset( $option['name'] ) ? $option['name'] : '';
198 198
     $cb         = "wpinv_{$option['type']}_callback";
199 199
     $section    = "wpinv_settings_{$tab}_$section";
200
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
200
+    $is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
201 201
 
202
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
203
-		$tip   = wpinv_clean( $option['desc'] );
204
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
205
-		unset( $option['desc'] );
206
-	}
202
+    if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
203
+        $tip   = wpinv_clean( $option['desc'] );
204
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
205
+        unset( $option['desc'] );
206
+    }
207 207
 
208 208
     // Loop through all tabs.
209 209
     add_settings_field(
@@ -230,9 +230,9 @@  discard block
 block discarded – undo
230 230
             'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
231 231
             'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
232 232
             'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
233
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
234
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
235
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
233
+            'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
234
+            'class'           => isset( $option['class'] ) ? $option['class'] : '',
235
+            'style'           => isset( $option['style'] ) ? $option['style'] : '',
236 236
             'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
237 237
             'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
238 238
         )
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @return array
247 247
  */
248 248
 function wpinv_get_registered_settings() {
249
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
249
+    return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
250 250
 }
251 251
 
252 252
 /**
@@ -265,18 +265,18 @@  discard block
 block discarded – undo
265 265
  */
266 266
 function wpinv_settings_sanitize( $input = array() ) {
267 267
 
268
-	$wpinv_options = wpinv_get_options();
269
-	$raw_referrer  = wp_get_raw_referer();
268
+    $wpinv_options = wpinv_get_options();
269
+    $raw_referrer  = wp_get_raw_referer();
270 270
 
271 271
     if ( empty( $raw_referrer ) ) {
272
-		return array_merge( $wpinv_options, $input );
272
+        return array_merge( $wpinv_options, $input );
273 273
     }
274 274
 
275 275
     wp_parse_str( $raw_referrer, $referrer );
276 276
 
277
-	if ( in_array( 'gp-setup', $referrer ) ) {
278
-		return array_merge( $wpinv_options, $input );
279
-	}
277
+    if ( in_array( 'gp-setup', $referrer ) ) {
278
+        return array_merge( $wpinv_options, $input );
279
+    }
280 280
 
281 281
     $settings = wpinv_get_registered_settings();
282 282
     $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
@@ -298,10 +298,10 @@  discard block
 block discarded – undo
298 298
         }
299 299
 
300 300
         // General filter
301
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
301
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
302 302
 
303
-		// Key specific filter.
304
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
303
+        // Key specific filter.
304
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
305 305
     }
306 306
 
307 307
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -344,14 +344,14 @@  discard block
 block discarded – undo
344 344
 
345 345
     foreach ( $new_rates as $rate ) {
346 346
 
347
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
348
-		$rate['name']    = sanitize_text_field( $rate['name'] );
349
-		$rate['state']   = sanitize_text_field( $rate['state'] );
350
-		$rate['country'] = sanitize_text_field( $rate['country'] );
351
-		$rate['global']  = empty( $rate['state'] );
352
-		$tax_rates[]     = $rate;
347
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
348
+        $rate['name']    = sanitize_text_field( $rate['name'] );
349
+        $rate['state']   = sanitize_text_field( $rate['state'] );
350
+        $rate['country'] = sanitize_text_field( $rate['country'] );
351
+        $rate['global']  = empty( $rate['state'] );
352
+        $tax_rates[]     = $rate;
353 353
 
354
-	}
354
+    }
355 355
 
356 356
     update_option( 'wpinv_tax_rates', $tax_rates );
357 357
 
@@ -364,21 +364,21 @@  discard block
 block discarded – undo
364 364
         return $input;
365 365
     }
366 366
 
367
-	if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
368
-		return $input;
369
-	}
367
+    if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
368
+        return $input;
369
+    }
370 370
 
371 371
     $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array();
372 372
     $tax_rules = array();
373 373
 
374 374
     foreach ( $new_rules as $rule ) {
375 375
 
376
-		$rule['key']      = sanitize_title_with_dashes( $rule['key'] );
377
-		$rule['label']    = sanitize_text_field( $rule['label'] );
378
-		$rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
379
-		$tax_rules[]      = $rule;
376
+        $rule['key']      = sanitize_title_with_dashes( $rule['key'] );
377
+        $rule['label']    = sanitize_text_field( $rule['label'] );
378
+        $rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
379
+        $tax_rules[]      = $rule;
380 380
 
381
-	}
381
+    }
382 382
 
383 383
     update_option( 'wpinv_tax_rules', $tax_rules );
384 384
 
@@ -391,11 +391,11 @@  discard block
 block discarded – undo
391 391
     $tabs['general']  = __( 'General', 'invoicing' );
392 392
     $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
393 393
     $tabs['taxes']    = __( 'Taxes', 'invoicing' );
394
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
394
+    $tabs['emails']   = __( 'Emails', 'invoicing' );
395 395
 
396
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
397
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
398
-	}
396
+    if ( count( getpaid_get_integration_settings() ) > 0 ) {
397
+        $tabs['integrations'] = __( 'Integrations', 'invoicing' );
398
+    }
399 399
 
400 400
     $tabs['privacy']  = __( 'Privacy', 'invoicing' );
401 401
     $tabs['misc']     = __( 'Misc', 'invoicing' );
@@ -426,53 +426,53 @@  discard block
 block discarded – undo
426 426
         'general'      => apply_filters(
427 427
             'wpinv_settings_sections_general',
428 428
             array(
429
-				'main'             => __( 'General Settings', 'invoicing' ),
430
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
431
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
432
-				'labels'           => __( 'Label Texts', 'invoicing' ),
429
+                'main'             => __( 'General Settings', 'invoicing' ),
430
+                'page_section'     => __( 'Page Settings', 'invoicing' ),
431
+                'currency_section' => __( 'Currency Settings', 'invoicing' ),
432
+                'labels'           => __( 'Label Texts', 'invoicing' ),
433 433
             )
434 434
         ),
435 435
         'gateways'     => apply_filters(
436 436
             'wpinv_settings_sections_gateways',
437 437
             array(
438
-				'main' => __( 'Gateway Settings', 'invoicing' ),
438
+                'main' => __( 'Gateway Settings', 'invoicing' ),
439 439
             )
440 440
         ),
441 441
         'taxes'        => apply_filters(
442 442
             'wpinv_settings_sections_taxes',
443 443
             array(
444
-				'main'  => __( 'Tax Settings', 'invoicing' ),
445
-				'rules' => __( 'Tax Rules', 'invoicing' ),
446
-				'rates' => __( 'Tax Rates', 'invoicing' ),
447
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
444
+                'main'  => __( 'Tax Settings', 'invoicing' ),
445
+                'rules' => __( 'Tax Rules', 'invoicing' ),
446
+                'rates' => __( 'Tax Rates', 'invoicing' ),
447
+                'vat'   => __( 'EU VAT Settings', 'invoicing' ),
448 448
             )
449 449
         ),
450 450
         'emails'       => apply_filters(
451 451
             'wpinv_settings_sections_emails',
452 452
             array(
453
-				'main' => __( 'Email Settings', 'invoicing' ),
453
+                'main' => __( 'Email Settings', 'invoicing' ),
454 454
             )
455 455
         ),
456 456
 
457
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
457
+        'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
458 458
 
459 459
         'privacy'      => apply_filters(
460 460
             'wpinv_settings_sections_privacy',
461 461
             array(
462
-				'main' => __( 'Privacy policy', 'invoicing' ),
462
+                'main' => __( 'Privacy policy', 'invoicing' ),
463 463
             )
464 464
         ),
465 465
         'misc'         => apply_filters(
466 466
             'wpinv_settings_sections_misc',
467 467
             array(
468
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
469
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
468
+                'main'       => __( 'Miscellaneous', 'invoicing' ),
469
+                'custom-css' => __( 'Custom CSS', 'invoicing' ),
470 470
             )
471 471
         ),
472 472
         'tools'        => apply_filters(
473 473
             'wpinv_settings_sections_tools',
474 474
             array(
475
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
475
+                'main' => __( 'Diagnostic Tools', 'invoicing' ),
476 476
             )
477 477
         ),
478 478
     );
@@ -525,7 +525,7 @@  discard block
 block discarded – undo
525 525
     // Prepare the SQL query to include the excluded pages only if we have placeholders
526 526
     $pages = $exclude_pages_placeholders ? $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) ) : $wpdb->get_results( $sql );
527 527
 
528
-	$pages_options = array();
528
+    $pages_options = array();
529 529
 
530 530
     if ( $pages ) {
531 531
         foreach ( $pages as $page ) {
@@ -542,32 +542,32 @@  discard block
 block discarded – undo
542 542
         $pages_options = array( '' => $default_label ) + $pages_options; // Blank option
543 543
     }
544 544
 
545
-	return $pages_options;
545
+    return $pages_options;
546 546
 }
547 547
 
548 548
 function wpinv_header_callback( $args ) {
549
-	if ( ! empty( $args['desc'] ) ) {
549
+    if ( ! empty( $args['desc'] ) ) {
550 550
         echo wp_kses_post( $args['desc'] );
551 551
     }
552 552
 }
553 553
 
554 554
 function wpinv_hidden_callback( $args ) {
555 555
 
556
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
557
-	$value   = wpinv_get_option( $args['id'], $std );
556
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
557
+    $value   = wpinv_get_option( $args['id'], $std );
558 558
 
559
-	if ( isset( $args['set_value'] ) ) {
560
-		$value = $args['set_value'];
561
-	}
559
+    if ( isset( $args['set_value'] ) ) {
560
+        $value = $args['set_value'];
561
+    }
562 562
 
563
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
564
-		$args['readonly'] = true;
565
-		$name  = '';
566
-	} else {
567
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
568
-	}
563
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
564
+        $args['readonly'] = true;
565
+        $name  = '';
566
+    } else {
567
+        $name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
568
+    }
569 569
 
570
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
570
+    echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
571 571
 
572 572
 }
573 573
 
@@ -576,12 +576,12 @@  discard block
 block discarded – undo
576 576
  */
577 577
 function wpinv_checkbox_callback( $args ) {
578 578
 
579
-	$std = isset( $args['std'] ) ? $args['std'] : '';
580
-	$std = wpinv_get_option( $args['id'], $std );
581
-	$id  = esc_attr( $args['id'] );
579
+    $std = isset( $args['std'] ) ? $args['std'] : '';
580
+    $std = wpinv_get_option( $args['id'], $std );
581
+    $id  = esc_attr( $args['id'] );
582 582
 
583
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
584
-	?>
583
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
584
+    ?>
585 585
 		<label>
586 586
 			<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" />
587 587
 			<?php echo wp_kses_post( $args['desc'] ); ?>
@@ -591,75 +591,75 @@  discard block
 block discarded – undo
591 591
 
592 592
 function wpinv_multicheck_callback( $args ) {
593 593
 
594
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
595
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
594
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
595
+    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
596 596
 
597
-	if ( ! empty( $args['options'] ) ) {
597
+    if ( ! empty( $args['options'] ) ) {
598 598
 
599
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
600
-		$value   = wpinv_get_option( $args['id'], $std );
599
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
600
+        $value   = wpinv_get_option( $args['id'], $std );
601 601
 
602
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
602
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
603 603
         foreach ( $args['options'] as $key => $option ) :
604
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
605
-			if ( in_array( $sanitize_key, $value ) ) {
606
-				$enabled = $sanitize_key;
607
-			} else {
608
-				$enabled = null;
609
-			}
610
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
611
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
612
-		endforeach;
613
-		echo '</div>';
614
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
615
-	}
604
+            $sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
605
+            if ( in_array( $sanitize_key, $value ) ) {
606
+                $enabled = $sanitize_key;
607
+            } else {
608
+                $enabled = null;
609
+            }
610
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
611
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
612
+        endforeach;
613
+        echo '</div>';
614
+        echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
615
+    }
616 616
 }
617 617
 
618 618
 function wpinv_payment_icons_callback( $args ) {
619 619
 
620 620
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
621
-	$value   = wpinv_get_option( $args['id'], false );
621
+    $value   = wpinv_get_option( $args['id'], false );
622 622
 
623
-	if ( ! empty( $args['options'] ) ) {
624
-		foreach ( $args['options'] as $key => $option ) {
623
+    if ( ! empty( $args['options'] ) ) {
624
+        foreach ( $args['options'] as $key => $option ) {
625 625
             $sanitize_key = wpinv_sanitize_key( $key );
626 626
 
627
-			if ( empty( $value ) ) {
628
-				$enabled = $option;
629
-			} else {
630
-				$enabled = null;
631
-			}
632
-
633
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
634
-
635
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
636
-
637
-				if ( wpinv_string_is_image_url( $key ) ) {
638
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
639
-				} else {
640
-				$card = strtolower( str_replace( ' ', '', $option ) );
641
-
642
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
643
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
644
-					} else {
645
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
646
-					$content_dir = WP_CONTENT_DIR;
647
-
648
-					if ( function_exists( 'wp_normalize_path' ) ) {
649
-						// Replaces backslashes with forward slashes for Windows systems
650
-						$image = wp_normalize_path( $image );
651
-						$content_dir = wp_normalize_path( $content_dir );
652
-						}
653
-
654
-					$image = str_replace( $content_dir, content_url(), $image );
655
-					}
656
-
657
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
658
-				}
659
-			echo wp_kses_post( $option ) . '</label>';
660
-		}
661
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
662
-	}
627
+            if ( empty( $value ) ) {
628
+                $enabled = $option;
629
+            } else {
630
+                $enabled = null;
631
+            }
632
+
633
+            echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
634
+
635
+                echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
636
+
637
+                if ( wpinv_string_is_image_url( $key ) ) {
638
+                echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
639
+                } else {
640
+                $card = strtolower( str_replace( ' ', '', $option ) );
641
+
642
+                if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
643
+                    $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
644
+                    } else {
645
+                    $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
646
+                    $content_dir = WP_CONTENT_DIR;
647
+
648
+                    if ( function_exists( 'wp_normalize_path' ) ) {
649
+                        // Replaces backslashes with forward slashes for Windows systems
650
+                        $image = wp_normalize_path( $image );
651
+                        $content_dir = wp_normalize_path( $content_dir );
652
+                        }
653
+
654
+                    $image = str_replace( $content_dir, content_url(), $image );
655
+                    }
656
+
657
+                echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
658
+                }
659
+            echo wp_kses_post( $option ) . '</label>';
660
+        }
661
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
662
+    }
663 663
 }
664 664
 
665 665
 /**
@@ -667,9 +667,9 @@  discard block
 block discarded – undo
667 667
  */
668 668
 function wpinv_radio_callback( $args ) {
669 669
 
670
-	$std = isset( $args['std'] ) ? $args['std'] : '';
671
-	$std = wpinv_get_option( $args['id'], $std );
672
-	?>
670
+    $std = isset( $args['std'] ) ? $args['std'] : '';
671
+    $std = wpinv_get_option( $args['id'], $std );
672
+    ?>
673 673
 		<fieldset>
674 674
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
675 675
 				<?php foreach ( $args['options'] as $key => $option ) : ?>
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 			</ul>
684 684
 		</fieldset>
685 685
 	<?php
686
-	getpaid_settings_description_callback( $args );
686
+    getpaid_settings_description_callback( $args );
687 687
 }
688 688
 
689 689
 /**
@@ -691,10 +691,10 @@  discard block
 block discarded – undo
691 691
  */
692 692
 function getpaid_settings_description_callback( $args ) {
693 693
 
694
-	if ( ! empty( $args['desc'] ) ) {
695
-		$description = $args['desc'];
696
-		echo wp_kses_post( "<p class='description'>$description</p>" );
697
-	}
694
+    if ( ! empty( $args['desc'] ) ) {
695
+        $description = $args['desc'];
696
+        echo wp_kses_post( "<p class='description'>$description</p>" );
697
+    }
698 698
 
699 699
 }
700 700
 
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
  */
704 704
 function wpinv_gateways_callback() {
705 705
 
706
-	?>
706
+    ?>
707 707
 		</td>
708 708
 	</tr>
709 709
 	<tr class="bsui">
@@ -717,26 +717,26 @@  discard block
 block discarded – undo
717 717
 
718 718
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
719 719
     $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
720
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
721
-	$value   = wpinv_get_option( $args['id'], $std );
720
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
721
+    $value   = wpinv_get_option( $args['id'], $std );
722 722
 
723
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
723
+    echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
724 724
 
725
-	foreach ( $args['options'] as $key => $option ) :
725
+    foreach ( $args['options'] as $key => $option ) :
726 726
 
727
-		echo '<option value="' . esc_attr( $key ) . '" ';
727
+        echo '<option value="' . esc_attr( $key ) . '" ';
728 728
 
729
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
729
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
730 730
             selected( $key, $args['selected'] );
731 731
         } else {
732 732
             selected( $key, $value );
733 733
         }
734 734
 
735
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
736
-	endforeach;
735
+        echo '>' . esc_html( $option['admin_label'] ) . '</option>';
736
+    endforeach;
737 737
 
738
-	echo '</select>';
739
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
738
+    echo '</select>';
739
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
740 740
 }
741 741
 
742 742
 /**
@@ -747,38 +747,38 @@  discard block
 block discarded – undo
747 747
  */
748 748
 function wpinv_settings_attrs_helper( $args ) {
749 749
 
750
-	$value = isset( $args['std'] ) ? $args['std'] : '';
751
-	$id    = esc_attr( $args['id'] );
752
-	$value = is_scalar( $value ) ? $value : '';
753
-
754
-	$attrs = array(
755
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
756
-		'readonly' => ! empty( $args['faux'] ),
757
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
758
-		'id'       => 'wpinv-settings-' . $args['id'],
759
-		'style'    => $args['style'],
760
-		'class'    => $args['class'],
761
-		'placeholder' => $args['placeholder'],
762
-		'data-placeholder' => $args['placeholder'],
763
-	);
750
+    $value = isset( $args['std'] ) ? $args['std'] : '';
751
+    $id    = esc_attr( $args['id'] );
752
+    $value = is_scalar( $value ) ? $value : '';
753
+
754
+    $attrs = array(
755
+        'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
756
+        'readonly' => ! empty( $args['faux'] ),
757
+        'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
758
+        'id'       => 'wpinv-settings-' . $args['id'],
759
+        'style'    => $args['style'],
760
+        'class'    => $args['class'],
761
+        'placeholder' => $args['placeholder'],
762
+        'data-placeholder' => $args['placeholder'],
763
+    );
764 764
 
765
-	if ( ! empty( $args['onchange'] ) ) {
766
-		$attrs['onchange'] = $args['onchange'];
767
-	}
765
+    if ( ! empty( $args['onchange'] ) ) {
766
+        $attrs['onchange'] = $args['onchange'];
767
+    }
768 768
 
769
-	foreach ( $attrs as $key => $value ) {
769
+    foreach ( $attrs as $key => $value ) {
770 770
 
771
-		if ( false === $value ) {
772
-			continue;
773
-		}
771
+        if ( false === $value ) {
772
+            continue;
773
+        }
774 774
 
775
-		if ( true === $value ) {
776
-			echo ' ' . esc_attr( $key );
777
-		} else {
778
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
779
-		}
775
+        if ( true === $value ) {
776
+            echo ' ' . esc_attr( $key );
777
+        } else {
778
+            echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
779
+        }
780 780
 
781
-	}
781
+    }
782 782
 
783 783
 }
784 784
 
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
  */
788 788
 function wpinv_text_callback( $args ) {
789 789
 
790
-	?>
790
+    ?>
791 791
 		<label style="width: 100%;">
792 792
 			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
793 793
 			<?php getpaid_settings_description_callback( $args ); ?>
@@ -801,7 +801,7 @@  discard block
 block discarded – undo
801 801
  */
802 802
 function wpinv_number_callback( $args ) {
803 803
 
804
-	?>
804
+    ?>
805 805
 		<label style="width: 100%;">
806 806
 			<input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
807 807
 			<?php getpaid_settings_description_callback( $args ); ?>
@@ -813,34 +813,34 @@  discard block
 block discarded – undo
813 813
 function wpinv_textarea_callback( $args ) {
814 814
 
815 815
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
816
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
817
-	$value   = wpinv_get_option( $args['id'], $std );
816
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
817
+    $value   = wpinv_get_option( $args['id'], $std );
818 818
 
819 819
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
820 820
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
821 821
 
822
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
823
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
822
+    echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
823
+    echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
824 824
 
825 825
 }
826 826
 
827 827
 function wpinv_password_callback( $args ) {
828 828
 
829 829
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
830
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
831
-	$value   = wpinv_get_option( $args['id'], $std );
830
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
831
+    $value   = wpinv_get_option( $args['id'], $std );
832 832
 
833
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
834
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
835
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
833
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
834
+    echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
835
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
836 836
 
837 837
 }
838 838
 
839 839
 function wpinv_missing_callback( $args ) {
840
-	printf(
841
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
842
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
843
-	);
840
+    printf(
841
+        esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
842
+        '<strong>' . esc_html( $args['id'] ) . '</strong>'
843
+    );
844 844
 }
845 845
 
846 846
 /**
@@ -848,13 +848,13 @@  discard block
 block discarded – undo
848 848
  */
849 849
 function wpinv_select_callback( $args ) {
850 850
 
851
-	$desc   = wp_kses_post( $args['desc'] );
852
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
853
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
854
-	$value  = wpinv_get_option( $args['id'], $value );
855
-	$rand   = uniqid( 'random_id' );
851
+    $desc   = wp_kses_post( $args['desc'] );
852
+    $desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
853
+    $value  = isset( $args['std'] ) ? $args['std'] : '';
854
+    $value  = wpinv_get_option( $args['id'], $value );
855
+    $rand   = uniqid( 'random_id' );
856 856
 
857
-	?>
857
+    ?>
858 858
 		<label style="width: 100%;">
859 859
 			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
860 860
 				<?php foreach ( $args['options'] as $option => $name ) : ?>
@@ -887,50 +887,50 @@  discard block
 block discarded – undo
887 887
 function wpinv_color_select_callback( $args ) {
888 888
 
889 889
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
890
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
891
-	$value   = wpinv_get_option( $args['id'], $std );
890
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
891
+    $value   = wpinv_get_option( $args['id'], $std );
892 892
 
893
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
893
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
894 894
 
895
-	foreach ( $args['options'] as $option => $color ) {
896
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
897
-	}
895
+    foreach ( $args['options'] as $option => $color ) {
896
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
897
+    }
898 898
 
899
-	echo '</select>';
900
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
899
+    echo '</select>';
900
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
901 901
 
902 902
 }
903 903
 
904 904
 function wpinv_rich_editor_callback( $args ) {
905
-	global $wp_version;
905
+    global $wp_version;
906 906
 
907 907
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
908 908
 
909
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
910
-	$value   = wpinv_get_option( $args['id'], $std );
909
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
910
+    $value   = wpinv_get_option( $args['id'], $std );
911 911
 
912
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
913
-		$value = $std;
914
-	}
912
+    if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
913
+        $value = $std;
914
+    }
915 915
 
916
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
916
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
917 917
 
918
-	echo '<div class="getpaid-settings-editor-input">';
919
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
920
-		wp_editor(
918
+    echo '<div class="getpaid-settings-editor-input">';
919
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
920
+        wp_editor(
921 921
             stripslashes( $value ),
922 922
             'wpinv_settings_' . esc_attr( $args['id'] ),
923 923
             array(
924
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
925
-				'textarea_rows' => absint( $rows ),
926
-				'media_buttons' => false,
924
+                'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
925
+                'textarea_rows' => absint( $rows ),
926
+                'media_buttons' => false,
927 927
             )
928 928
         );
929
-	} else {
930
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
931
-	}
929
+    } else {
930
+        echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
931
+    }
932 932
 
933
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
933
+    echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
934 934
 
935 935
 }
936 936
 
@@ -938,51 +938,51 @@  discard block
 block discarded – undo
938 938
 
939 939
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
940 940
 
941
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
942
-	$value   = wpinv_get_option( $args['id'], $std );
941
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
942
+    $value   = wpinv_get_option( $args['id'], $std );
943 943
 
944
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
945
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
946
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
947
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
944
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
945
+    echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
946
+    echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
947
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
948 948
 
949 949
 }
950 950
 
951 951
 function wpinv_color_callback( $args ) {
952 952
 
953
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
954
-	$value       = wpinv_get_option( $args['id'], $std );
953
+    $std         = isset( $args['std'] ) ? $args['std'] : '';
954
+    $value       = wpinv_get_option( $args['id'], $std );
955 955
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
956 956
 
957
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
958
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
957
+    echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
958
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
959 959
 
960 960
 }
961 961
 
962 962
 function wpinv_country_states_callback( $args ) {
963 963
 
964
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
965
-	$value   = wpinv_get_option( $args['id'], $std );
964
+    $std     = isset( $args['std'] ) ? $args['std'] : '';
965
+    $value   = wpinv_get_option( $args['id'], $std );
966 966
 
967 967
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
968 968
 
969
-	if ( isset( $args['placeholder'] ) ) {
970
-		$placeholder = $args['placeholder'];
971
-	} else {
972
-		$placeholder = '';
973
-	}
969
+    if ( isset( $args['placeholder'] ) ) {
970
+        $placeholder = $args['placeholder'];
971
+    } else {
972
+        $placeholder = '';
973
+    }
974 974
 
975
-	$states = wpinv_get_country_states();
975
+    $states = wpinv_get_country_states();
976 976
 
977
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
978
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
977
+    $class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
978
+    echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
979 979
 
980
-	foreach ( $states as $option => $name ) {
981
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
982
-	}
980
+    foreach ( $states as $option => $name ) {
981
+        echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
982
+    }
983 983
 
984
-	echo '</select>';
985
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
984
+    echo '</select>';
985
+    echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
986 986
 
987 987
 }
988 988
 
@@ -991,7 +991,7 @@  discard block
 block discarded – undo
991 991
  */
992 992
 function wpinv_tax_rates_callback() {
993 993
 
994
-	?>
994
+    ?>
995 995
 		</td>
996 996
 	</tr>
997 997
 	<tr class="bsui">
@@ -1007,9 +1007,9 @@  discard block
 block discarded – undo
1007 1007
  */
1008 1008
 function wpinv_tax_rate_callback( $tax_rate, $key ) {
1009 1009
 
1010
-	$key                      = sanitize_key( $key );
1011
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
1012
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
1010
+    $key                      = sanitize_key( $key );
1011
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
1012
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
1013 1013
 
1014 1014
 }
1015 1015
 
@@ -1018,7 +1018,7 @@  discard block
 block discarded – undo
1018 1018
  */
1019 1019
 function wpinv_tax_rules_callback() {
1020 1020
 
1021
-	?>
1021
+    ?>
1022 1022
 		</td>
1023 1023
 	</tr>
1024 1024
 	<tr class="bsui">
@@ -1056,14 +1056,14 @@  discard block
 block discarded – undo
1056 1056
                 <td>
1057 1057
 					<a href="
1058 1058
                     <?php
1059
-						echo esc_url(
1060
-							wp_nonce_url(
1061
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1062
-								'getpaid-nonce',
1063
-								'getpaid-nonce'
1064
-							)
1065
-						);
1066
-					?>
1059
+                        echo esc_url(
1060
+                            wp_nonce_url(
1061
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1062
+                                'getpaid-nonce',
1063
+                                'getpaid-nonce'
1064
+                            )
1065
+                        );
1066
+                    ?>
1067 1067
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1068 1068
                 </td>
1069 1069
             </tr>
@@ -1075,14 +1075,14 @@  discard block
 block discarded – undo
1075 1075
                 <td>
1076 1076
 					<a href="
1077 1077
                     <?php
1078
-						echo esc_url(
1079
-							wp_nonce_url(
1080
-								add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ),
1081
-								'getpaid-nonce',
1082
-								'getpaid-nonce'
1083
-							)
1084
-						);
1085
-					?>
1078
+                        echo esc_url(
1079
+                            wp_nonce_url(
1080
+                                add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ),
1081
+                                'getpaid-nonce',
1082
+                                'getpaid-nonce'
1083
+                            )
1084
+                        );
1085
+                    ?>
1086 1086
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1087 1087
                 </td>
1088 1088
             </tr>
@@ -1094,14 +1094,14 @@  discard block
 block discarded – undo
1094 1094
                 <td>
1095 1095
 					<a href="
1096 1096
                     <?php
1097
-						echo esc_url(
1098
-							wp_nonce_url(
1099
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1100
-								'getpaid-nonce',
1101
-								'getpaid-nonce'
1102
-							)
1103
-						);
1104
-					?>
1097
+                        echo esc_url(
1098
+                            wp_nonce_url(
1099
+                                add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1100
+                                'getpaid-nonce',
1101
+                                'getpaid-nonce'
1102
+                            )
1103
+                        );
1104
+                    ?>
1105 1105
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1106 1106
                 </td>
1107 1107
             </tr>
@@ -1113,14 +1113,14 @@  discard block
 block discarded – undo
1113 1113
                 <td>
1114 1114
 					<a href="
1115 1115
                     <?php
1116
-						echo esc_url(
1117
-							wp_nonce_url(
1118
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1119
-								'getpaid-nonce',
1120
-								'getpaid-nonce'
1121
-							)
1122
-						);
1123
-					?>
1116
+                        echo esc_url(
1117
+                            wp_nonce_url(
1118
+                                add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1119
+                                'getpaid-nonce',
1120
+                                'getpaid-nonce'
1121
+                            )
1122
+                        );
1123
+                    ?>
1124 1124
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1125 1125
                 </td>
1126 1126
             </tr>
@@ -1133,14 +1133,14 @@  discard block
 block discarded – undo
1133 1133
                 <td>
1134 1134
 					<a href="
1135 1135
                     <?php
1136
-						echo esc_url(
1137
-							wp_nonce_url(
1138
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1139
-								'getpaid-nonce',
1140
-								'getpaid-nonce'
1141
-							)
1142
-						);
1143
-					?>
1136
+                        echo esc_url(
1137
+                            wp_nonce_url(
1138
+                                add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1139
+                                'getpaid-nonce',
1140
+                                'getpaid-nonce'
1141
+                            )
1142
+                        );
1143
+                    ?>
1144 1144
                     " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1145 1145
                 </td>
1146 1146
             </tr>
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
                 <td>
1154 1154
 					<a href="
1155 1155
                     <?php
1156
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1157
-					?>
1156
+                        echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1157
+                    ?>
1158 1158
                     " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1159 1159
                 </td>
1160 1160
             </tr>
@@ -1168,19 +1168,19 @@  discard block
 block discarded – undo
1168 1168
 
1169 1169
 
1170 1170
 function wpinv_descriptive_text_callback( $args ) {
1171
-	echo wp_kses_post( $args['desc'] );
1171
+    echo wp_kses_post( $args['desc'] );
1172 1172
 }
1173 1173
 
1174 1174
 function wpinv_raw_html_callback( $args ) {
1175
-	echo wp_kses( $args['desc'], getpaid_allowed_html() );
1175
+    echo wp_kses( $args['desc'], getpaid_allowed_html() );
1176 1176
 }
1177 1177
 
1178 1178
 function wpinv_hook_callback( $args ) {
1179
-	do_action( 'wpinv_' . $args['id'], $args );
1179
+    do_action( 'wpinv_' . $args['id'], $args );
1180 1180
 }
1181 1181
 
1182 1182
 function wpinv_set_settings_cap() {
1183
-	return wpinv_get_capability();
1183
+    return wpinv_get_capability();
1184 1184
 }
1185 1185
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1186 1186
 
@@ -1206,47 +1206,47 @@  discard block
 block discarded – undo
1206 1206
  * @return array
1207 1207
  */
1208 1208
 function wpinv_get_email_merge_tags( $subscription = false ) {
1209
-	$merge_tags = array(
1210
-		'{site_title}'           => __( 'Site Title', 'invoicing' ),
1211
-		'{name}'                 => __( "Customer's full name", 'invoicing' ),
1212
-		'{first_name}'           => __( "Customer's first name", 'invoicing' ),
1213
-		'{last_name}'            => __( "Customer's last name", 'invoicing' ),
1214
-		'{email}'                => __( "Customer's email address", 'invoicing' ),
1215
-		'{invoice_number}'       => __( 'The invoice number', 'invoicing' ),
1216
-		'{invoice_currency}'     => __( 'The invoice currency', 'invoicing' ),
1217
-		'{invoice_total}'        => __( 'The invoice total', 'invoicing' ),
1218
-		'{invoice_link}'         => __( 'The invoice link', 'invoicing' ),
1219
-		'{invoice_pay_link}'     => __( 'The payment link', 'invoicing' ),
1220
-		'{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ),
1221
-		'{invoice_date}'         => __( 'The date the invoice was created', 'invoicing' ),
1222
-		'{invoice_due_date}'     => __( 'The date the invoice is due', 'invoicing' ),
1223
-		'{date}'                 => __( "Today's date", 'invoicing' ),
1224
-		'{is_was}'               => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ),
1225
-		'{invoice_label}'        => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ),
1226
-		'{invoice_quote}'        => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ),
1227
-		'{invoice_description}'  => __( 'The description of the invoice', 'invoicing' ),
1228
-	);
1229
-
1230
-	if ( $subscription ) {
1231
-		$merge_tags = array_merge(
1232
-			$merge_tags,
1233
-			array(
1234
-				'{subscription_renewal_date}'     => __( 'The next renewal date of the subscription', 'invoicing' ),
1235
-				'{subscription_created}'          => __( "The subscription's creation date", 'invoicing' ),
1236
-				'{subscription_status}'           => __( "The subscription's status", 'invoicing' ),
1237
-				'{subscription_profile_id}'       => __( "The subscription's remote profile id", 'invoicing' ),
1238
-				'{subscription_id}'               => __( "The subscription's id", 'invoicing' ),
1239
-				'{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ),
1240
-				'{subscription_initial_amount}'   => __( 'The initial amount of the subscription', 'invoicing' ),
1241
-				'{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ),
1242
-				'{subscription_bill_times}'       => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ),
1243
-				'{subscription_url}'              => __( 'The URL to manage a subscription', 'invoicing' ),
1244
-				'{subscription_name}'             => __( 'The name of the recurring item', 'invoicing' ),
1245
-			)
1246
-		);
1247
-	}
1248
-
1249
-	return $merge_tags;
1209
+    $merge_tags = array(
1210
+        '{site_title}'           => __( 'Site Title', 'invoicing' ),
1211
+        '{name}'                 => __( "Customer's full name", 'invoicing' ),
1212
+        '{first_name}'           => __( "Customer's first name", 'invoicing' ),
1213
+        '{last_name}'            => __( "Customer's last name", 'invoicing' ),
1214
+        '{email}'                => __( "Customer's email address", 'invoicing' ),
1215
+        '{invoice_number}'       => __( 'The invoice number', 'invoicing' ),
1216
+        '{invoice_currency}'     => __( 'The invoice currency', 'invoicing' ),
1217
+        '{invoice_total}'        => __( 'The invoice total', 'invoicing' ),
1218
+        '{invoice_link}'         => __( 'The invoice link', 'invoicing' ),
1219
+        '{invoice_pay_link}'     => __( 'The payment link', 'invoicing' ),
1220
+        '{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ),
1221
+        '{invoice_date}'         => __( 'The date the invoice was created', 'invoicing' ),
1222
+        '{invoice_due_date}'     => __( 'The date the invoice is due', 'invoicing' ),
1223
+        '{date}'                 => __( "Today's date", 'invoicing' ),
1224
+        '{is_was}'               => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ),
1225
+        '{invoice_label}'        => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ),
1226
+        '{invoice_quote}'        => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ),
1227
+        '{invoice_description}'  => __( 'The description of the invoice', 'invoicing' ),
1228
+    );
1229
+
1230
+    if ( $subscription ) {
1231
+        $merge_tags = array_merge(
1232
+            $merge_tags,
1233
+            array(
1234
+                '{subscription_renewal_date}'     => __( 'The next renewal date of the subscription', 'invoicing' ),
1235
+                '{subscription_created}'          => __( "The subscription's creation date", 'invoicing' ),
1236
+                '{subscription_status}'           => __( "The subscription's status", 'invoicing' ),
1237
+                '{subscription_profile_id}'       => __( "The subscription's remote profile id", 'invoicing' ),
1238
+                '{subscription_id}'               => __( "The subscription's id", 'invoicing' ),
1239
+                '{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ),
1240
+                '{subscription_initial_amount}'   => __( 'The initial amount of the subscription', 'invoicing' ),
1241
+                '{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ),
1242
+                '{subscription_bill_times}'       => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ),
1243
+                '{subscription_url}'              => __( 'The URL to manage a subscription', 'invoicing' ),
1244
+                '{subscription_name}'             => __( 'The name of the recurring item', 'invoicing' ),
1245
+            )
1246
+        );
1247
+    }
1248
+
1249
+    return $merge_tags;
1250 1250
 }
1251 1251
 
1252 1252
 
@@ -1258,28 +1258,28 @@  discard block
 block discarded – undo
1258 1258
  * @return string
1259 1259
  */
1260 1260
 function wpinv_get_merge_tags_help_text( $subscription = false ) {
1261
-	$merge_tags = wpinv_get_email_merge_tags( $subscription );
1261
+    $merge_tags = wpinv_get_email_merge_tags( $subscription );
1262 1262
 
1263
-	$output = '<div class="bsui">';
1263
+    $output = '<div class="bsui">';
1264 1264
 
1265
-	$link = sprintf(
1266
-		'<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>',
1267
-		esc_html__( 'View available merge tags.', 'invoicing' )
1268
-	);
1265
+    $link = sprintf(
1266
+        '<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>',
1267
+        esc_html__( 'View available merge tags.', 'invoicing' )
1268
+    );
1269 1269
 
1270
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1270
+    $description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1271 1271
 	
1272
-	$output .= "$description $link";
1272
+    $output .= "$description $link";
1273 1273
 
1274
-	$output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">';
1275
-	$output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>';
1274
+    $output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">';
1275
+    $output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>';
1276 1276
 
1277
-	$output .= '<ul class="p-0 m-0">';
1278
-	foreach($merge_tags as $tag => $tag_description) {
1279
-		$output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> &mdash; $tag_description</li>";
1280
-	}
1277
+    $output .= '<ul class="p-0 m-0">';
1278
+    foreach($merge_tags as $tag => $tag_description) {
1279
+        $output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> &mdash; $tag_description</li>";
1280
+    }
1281 1281
 
1282
-	$output .= '</ul></div></div>';
1282
+    $output .= '</ul></div></div>';
1283 1283
 
1284
-	return $output;
1284
+    return $output;
1285 1285
 }
Please login to merge, or discard this patch.
Spacing   +429 added lines, -429 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @since   1.0.0
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves all default settings.
@@ -16,13 +16,13 @@  discard block
 block discarded – undo
16 16
 function wpinv_get_settings() {
17 17
     $defaults = array();
18 18
 
19
-    foreach ( array_values( wpinv_get_registered_settings() ) as $tab_settings ) {
19
+    foreach (array_values(wpinv_get_registered_settings()) as $tab_settings) {
20 20
 
21
-        foreach ( array_values( $tab_settings ) as $section_settings ) {
21
+        foreach (array_values($tab_settings) as $section_settings) {
22 22
 
23
-            foreach ( $section_settings as $key => $setting ) {
24
-                if ( isset( $setting['std'] ) ) {
25
-                    $defaults[ $key ] = $setting['std'];
23
+            foreach ($section_settings as $key => $setting) {
24
+                if (isset($setting['std'])) {
25
+                    $defaults[$key] = $setting['std'];
26 26
                 }
27 27
             }
28 28
 		}
@@ -41,12 +41,12 @@  discard block
 block discarded – undo
41 41
     global $wpinv_options;
42 42
 
43 43
     // Try fetching the saved options.
44
-    if ( empty( $wpinv_options ) ) {
45
-        $wpinv_options = get_option( 'wpinv_settings' );
44
+    if (empty($wpinv_options)) {
45
+        $wpinv_options = get_option('wpinv_settings');
46 46
     }
47 47
 
48 48
     // If that fails, don't fetch the default settings to prevent a loop.
49
-    if ( ! is_array( $wpinv_options ) ) {
49
+    if (!is_array($wpinv_options)) {
50 50
         $wpinv_options = array();
51 51
     }
52 52
 
@@ -60,13 +60,13 @@  discard block
 block discarded – undo
60 60
  * @param mixed $default The default value to use if the setting has not been set.
61 61
  * @return mixed
62 62
  */
63
-function wpinv_get_option( $key = '', $default = false ) {
63
+function wpinv_get_option($key = '', $default = false) {
64 64
 
65 65
     $options = wpinv_get_options();
66
-    $value   = isset( $options[ $key ] ) ? $options[ $key ] : $default;
67
-    $value   = apply_filters( 'wpinv_get_option', $value, $key, $default );
66
+    $value   = isset($options[$key]) ? $options[$key] : $default;
67
+    $value   = apply_filters('wpinv_get_option', $value, $key, $default);
68 68
 
69
-    return apply_filters( 'wpinv_get_option_' . $key, $value, $key, $default );
69
+    return apply_filters('wpinv_get_option_' . $key, $value, $key, $default);
70 70
 }
71 71
 
72 72
 /**
@@ -75,11 +75,11 @@  discard block
 block discarded – undo
75 75
  * @param array $options the new options.
76 76
  * @return bool
77 77
  */
78
-function wpinv_update_options( $options ) {
78
+function wpinv_update_options($options) {
79 79
     global $wpinv_options;
80 80
 
81 81
     // update the option.
82
-    if ( is_array( $options ) && update_option( 'wpinv_settings', $options ) ) {
82
+    if (is_array($options) && update_option('wpinv_settings', $options)) {
83 83
         $wpinv_options = $options;
84 84
         return true;
85 85
     }
@@ -94,24 +94,24 @@  discard block
 block discarded – undo
94 94
  * @param mixed $value The setting value.
95 95
  * @return bool
96 96
  */
97
-function wpinv_update_option( $key = '', $value = false ) {
97
+function wpinv_update_option($key = '', $value = false) {
98 98
 
99 99
     // If no key, exit.
100
-    if ( empty( $key ) ) {
100
+    if (empty($key)) {
101 101
         return false;
102 102
     }
103 103
 
104 104
     // Maybe delete the option instead.
105
-    if ( is_null( $value ) ) {
106
-        return wpinv_delete_option( $key );
105
+    if (is_null($value)) {
106
+        return wpinv_delete_option($key);
107 107
     }
108 108
 
109 109
     // Prepare the new options.
110 110
     $options         = wpinv_get_options();
111
-    $options[ $key ] = apply_filters( 'wpinv_update_option', $value, $key );
111
+    $options[$key] = apply_filters('wpinv_update_option', $value, $key);
112 112
 
113 113
     // Save the new options.
114
-    return wpinv_update_options( $options );
114
+    return wpinv_update_options($options);
115 115
 
116 116
 }
117 117
 
@@ -121,18 +121,18 @@  discard block
 block discarded – undo
121 121
  * @param string $key the setting key.
122 122
  * @return bool
123 123
  */
124
-function wpinv_delete_option( $key = '' ) {
124
+function wpinv_delete_option($key = '') {
125 125
 
126 126
     // If no key, exit
127
-    if ( empty( $key ) ) {
127
+    if (empty($key)) {
128 128
         return false;
129 129
     }
130 130
 
131 131
     $options = wpinv_get_options();
132 132
 
133
-    if ( isset( $options[ $key ] ) ) {
134
-        unset( $options[ $key ] );
135
-        return wpinv_update_options( $options );
133
+    if (isset($options[$key])) {
134
+        unset($options[$key]);
135
+        return wpinv_update_options($options);
136 136
     }
137 137
 
138 138
     return true;
@@ -144,22 +144,22 @@  discard block
 block discarded – undo
144 144
  *
145 145
  */
146 146
 function wpinv_register_settings() {
147
-	do_action( 'getpaid_before_register_settings' );
147
+	do_action('getpaid_before_register_settings');
148 148
 
149 149
     // Loop through all tabs.
150
-    foreach ( wpinv_get_registered_settings() as $tab => $sections ) {
150
+    foreach (wpinv_get_registered_settings() as $tab => $sections) {
151 151
 
152 152
         // In each tab, loop through sections.
153
-        foreach ( $sections as $section => $settings ) {
153
+        foreach ($sections as $section => $settings) {
154 154
 
155 155
             // Check for backwards compatibility
156
-            $section_tabs = wpinv_get_settings_tab_sections( $tab );
157
-            if ( ! is_array( $section_tabs ) || ! array_key_exists( $section, $section_tabs ) ) {
156
+            $section_tabs = wpinv_get_settings_tab_sections($tab);
157
+            if (!is_array($section_tabs) || !array_key_exists($section, $section_tabs)) {
158 158
                 $section = 'main';
159 159
                 $settings = $sections;
160 160
             }
161 161
 
162
-			do_action( "getpaid_register_{$tab}_{$section}" );
162
+			do_action("getpaid_register_{$tab}_{$section}");
163 163
 
164 164
             // Register the setting section.
165 165
             add_settings_section(
@@ -169,20 +169,20 @@  discard block
 block discarded – undo
169 169
                 'wpinv_settings_' . $tab . '_' . $section
170 170
             );
171 171
 
172
-            foreach ( $settings as $option ) {
173
-                if ( ! empty( $option['id'] ) ) {
174
-                    wpinv_register_settings_option( $tab, $section, $option );
172
+            foreach ($settings as $option) {
173
+                if (!empty($option['id'])) {
174
+                    wpinv_register_settings_option($tab, $section, $option);
175 175
                 }
176 176
             }
177 177
 }
178 178
     }
179 179
 
180 180
     // Creates our settings in the options table.
181
-    register_setting( 'wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize' );
181
+    register_setting('wpinv_settings', 'wpinv_settings', 'wpinv_settings_sanitize');
182 182
 
183
-	do_action( 'getpaid_after_register_settings' );
183
+	do_action('getpaid_after_register_settings');
184 184
 }
185
-add_action( 'admin_init', 'wpinv_register_settings' );
185
+add_action('admin_init', 'wpinv_register_settings');
186 186
 
187 187
 /**
188 188
  * Register a single settings option.
@@ -192,49 +192,49 @@  discard block
 block discarded – undo
192 192
  * @param string $option
193 193
  *
194 194
  */
195
-function wpinv_register_settings_option( $tab, $section, $option ) {
195
+function wpinv_register_settings_option($tab, $section, $option) {
196 196
 
197
-    $name       = isset( $option['name'] ) ? $option['name'] : '';
197
+    $name       = isset($option['name']) ? $option['name'] : '';
198 198
     $cb         = "wpinv_{$option['type']}_callback";
199 199
     $section    = "wpinv_settings_{$tab}_$section";
200
-	$is_wizzard = is_admin() && isset( $_GET['page'] ) && 'gp-setup' == $_GET['page'];
200
+	$is_wizzard = is_admin() && isset($_GET['page']) && 'gp-setup' == $_GET['page'];
201 201
 
202
-	if ( isset( $option['desc'] ) && ( ! $is_wizzard && ! empty( $option['help-tip'] ) ) ) {
203
-		$tip   = wpinv_clean( $option['desc'] );
202
+	if (isset($option['desc']) && (!$is_wizzard && !empty($option['help-tip']))) {
203
+		$tip   = wpinv_clean($option['desc']);
204 204
 		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
205
-		unset( $option['desc'] );
205
+		unset($option['desc']);
206 206
 	}
207 207
 
208 208
     // Loop through all tabs.
209 209
     add_settings_field(
210 210
         'wpinv_settings[' . $option['id'] . ']',
211 211
         $name,
212
-        function_exists( $cb ) ? $cb : 'wpinv_missing_callback',
212
+        function_exists($cb) ? $cb : 'wpinv_missing_callback',
213 213
         $section,
214 214
         $section,
215 215
         array(
216 216
             'section'         => $section,
217
-            'id'              => isset( $option['id'] ) ? $option['id'] : uniqid( 'wpinv-' ),
218
-            'desc'            => isset( $option['desc'] ) ? $option['desc'] : '',
217
+            'id'              => isset($option['id']) ? $option['id'] : uniqid('wpinv-'),
218
+            'desc'            => isset($option['desc']) ? $option['desc'] : '',
219 219
             'name'            => $name,
220
-            'size'            => isset( $option['size'] ) ? $option['size'] : null,
221
-            'options'         => isset( $option['options'] ) ? $option['options'] : '',
222
-            'selected'        => isset( $option['selected'] ) ? $option['selected'] : null,
223
-            'std'             => isset( $option['std'] ) ? $option['std'] : '',
224
-            'min'             => isset( $option['min'] ) ? $option['min'] : 0,
225
-            'max'             => isset( $option['max'] ) ? $option['max'] : 999999,
226
-            'step'            => isset( $option['step'] ) ? $option['step'] : 1,
227
-            'placeholder'     => isset( $option['placeholder'] ) ? $option['placeholder'] : null,
228
-            'allow_blank'     => isset( $option['allow_blank'] ) ? $option['allow_blank'] : true,
229
-            'readonly'        => isset( $option['readonly'] ) ? $option['readonly'] : false,
230
-            'faux'            => isset( $option['faux'] ) ? $option['faux'] : false,
231
-            'onchange'        => isset( $option['onchange'] ) ? $option['onchange'] : '',
232
-            'custom'          => isset( $option['custom'] ) ? $option['custom'] : '',
233
-			'default_content' => isset( $option['default_content'] ) ? $option['default_content'] : '',
234
-			'class'           => isset( $option['class'] ) ? $option['class'] : '',
235
-			'style'           => isset( $option['style'] ) ? $option['style'] : '',
236
-            'cols'            => isset( $option['cols'] ) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
237
-            'rows'            => isset( $option['rows'] ) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
220
+            'size'            => isset($option['size']) ? $option['size'] : null,
221
+            'options'         => isset($option['options']) ? $option['options'] : '',
222
+            'selected'        => isset($option['selected']) ? $option['selected'] : null,
223
+            'std'             => isset($option['std']) ? $option['std'] : '',
224
+            'min'             => isset($option['min']) ? $option['min'] : 0,
225
+            'max'             => isset($option['max']) ? $option['max'] : 999999,
226
+            'step'            => isset($option['step']) ? $option['step'] : 1,
227
+            'placeholder'     => isset($option['placeholder']) ? $option['placeholder'] : null,
228
+            'allow_blank'     => isset($option['allow_blank']) ? $option['allow_blank'] : true,
229
+            'readonly'        => isset($option['readonly']) ? $option['readonly'] : false,
230
+            'faux'            => isset($option['faux']) ? $option['faux'] : false,
231
+            'onchange'        => isset($option['onchange']) ? $option['onchange'] : '',
232
+            'custom'          => isset($option['custom']) ? $option['custom'] : '',
233
+			'default_content' => isset($option['default_content']) ? $option['default_content'] : '',
234
+			'class'           => isset($option['class']) ? $option['class'] : '',
235
+			'style'           => isset($option['style']) ? $option['style'] : '',
236
+            'cols'            => isset($option['cols']) && (int) $option['cols'] > 0 ? (int) $option['cols'] : 50,
237
+            'rows'            => isset($option['rows']) && (int) $option['rows'] > 0 ? (int) $option['rows'] : 5,
238 238
         )
239 239
     );
240 240
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @return array
247 247
  */
248 248
 function wpinv_get_registered_settings() {
249
-	return array_filter( apply_filters( 'wpinv_registered_settings', wpinv_get_data( 'admin-settings' ) ) );
249
+	return array_filter(apply_filters('wpinv_registered_settings', wpinv_get_data('admin-settings')));
250 250
 }
251 251
 
252 252
 /**
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
  * @return array
256 256
  */
257 257
 function getpaid_get_integration_settings() {
258
-    return apply_filters( 'getpaid_integration_settings', array() );
258
+    return apply_filters('getpaid_integration_settings', array());
259 259
 }
260 260
 
261 261
 /**
@@ -263,153 +263,153 @@  discard block
 block discarded – undo
263 263
  *
264 264
  * @return array
265 265
  */
266
-function wpinv_settings_sanitize( $input = array() ) {
266
+function wpinv_settings_sanitize($input = array()) {
267 267
 
268 268
 	$wpinv_options = wpinv_get_options();
269 269
 	$raw_referrer  = wp_get_raw_referer();
270 270
 
271
-    if ( empty( $raw_referrer ) ) {
272
-		return array_merge( $wpinv_options, $input );
271
+    if (empty($raw_referrer)) {
272
+		return array_merge($wpinv_options, $input);
273 273
     }
274 274
 
275
-    wp_parse_str( $raw_referrer, $referrer );
275
+    wp_parse_str($raw_referrer, $referrer);
276 276
 
277
-	if ( in_array( 'gp-setup', $referrer ) ) {
278
-		return array_merge( $wpinv_options, $input );
277
+	if (in_array('gp-setup', $referrer)) {
278
+		return array_merge($wpinv_options, $input);
279 279
 	}
280 280
 
281 281
     $settings = wpinv_get_registered_settings();
282
-    $tab      = isset( $referrer['tab'] ) ? $referrer['tab'] : 'general';
283
-    $section  = isset( $referrer['section'] ) ? $referrer['section'] : 'main';
282
+    $tab      = isset($referrer['tab']) ? $referrer['tab'] : 'general';
283
+    $section  = isset($referrer['section']) ? $referrer['section'] : 'main';
284 284
 
285 285
     $input = $input ? $input : array();
286
-    $input = apply_filters( 'wpinv_settings_tab_' . $tab . '_sanitize', $input );
287
-    $input = apply_filters( 'wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input );
286
+    $input = apply_filters('wpinv_settings_tab_' . $tab . '_sanitize', $input);
287
+    $input = apply_filters('wpinv_settings_' . $tab . '-' . $section . '_sanitize', $input);
288 288
 
289 289
     // Loop through each setting being saved and pass it through a sanitization filter
290
-    foreach ( $input as $key => $value ) {
290
+    foreach ($input as $key => $value) {
291 291
 
292 292
         // Get the setting type (checkbox, select, etc)
293
-        $type = isset( $settings[ $tab ][ $section ][ $key ]['type'] ) ? $settings[ $tab ][ $section ][ $key ]['type'] : false;
293
+        $type = isset($settings[$tab][$section][$key]['type']) ? $settings[$tab][$section][$key]['type'] : false;
294 294
 
295
-        if ( $type ) {
295
+        if ($type) {
296 296
             // Field type specific filter
297
-            $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$type", $value, $key );
297
+            $input[$key] = apply_filters("wpinv_settings_sanitize_$type", $value, $key);
298 298
         }
299 299
 
300 300
         // General filter
301
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
301
+		$input[$key] = apply_filters('wpinv_settings_sanitize', $input[$key], $key);
302 302
 
303 303
 		// Key specific filter.
304
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
304
+		$input[$key] = apply_filters("wpinv_settings_sanitize_$key", $input[$key]);
305 305
     }
306 306
 
307 307
     // Loop through the whitelist and unset any that are empty for the tab being saved
308
-    $main_settings    = isset( $settings[ $tab ] ) ? $settings[ $tab ] : array(); // Check for extensions that aren't using new sections
309
-    $section_settings = ! empty( $settings[ $tab ][ $section ] ) ? $settings[ $tab ][ $section ] : array();
308
+    $main_settings    = isset($settings[$tab]) ? $settings[$tab] : array(); // Check for extensions that aren't using new sections
309
+    $section_settings = !empty($settings[$tab][$section]) ? $settings[$tab][$section] : array();
310 310
 
311
-    $found_settings   = array_merge( $main_settings, $section_settings );
311
+    $found_settings   = array_merge($main_settings, $section_settings);
312 312
 
313
-    if ( ! empty( $found_settings ) ) {
314
-        foreach ( $found_settings as $key => $value ) {
313
+    if (!empty($found_settings)) {
314
+        foreach ($found_settings as $key => $value) {
315 315
 
316 316
             // settings used to have numeric keys, now they have keys that match the option ID. This ensures both methods work
317
-            if ( is_numeric( $key ) ) {
317
+            if (is_numeric($key)) {
318 318
                 $key = $value['id'];
319 319
             }
320 320
 
321
-            if ( ! isset( $input[ $key ] ) && isset( $wpinv_options[ $key ] ) ) {
322
-                unset( $wpinv_options[ $key ] );
321
+            if (!isset($input[$key]) && isset($wpinv_options[$key])) {
322
+                unset($wpinv_options[$key]);
323 323
             }
324 324
         }
325 325
     }
326 326
 
327 327
     // Merge our new settings with the existing
328
-    $output = array_merge( $wpinv_options, $input );
328
+    $output = array_merge($wpinv_options, $input);
329 329
 
330
-    add_settings_error( 'wpinv-notices', '', __( 'Settings updated.', 'invoicing' ), 'updated' );
330
+    add_settings_error('wpinv-notices', '', __('Settings updated.', 'invoicing'), 'updated');
331 331
 
332 332
     return $output;
333 333
 }
334
-add_filter( 'wpinv_settings_sanitize_text', 'trim', 10, 1 );
335
-add_filter( 'wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount' );
334
+add_filter('wpinv_settings_sanitize_text', 'trim', 10, 1);
335
+add_filter('wpinv_settings_sanitize_tax_rate', 'wpinv_sanitize_amount');
336 336
 
337
-function wpinv_settings_sanitize_tax_rates( $input ) {
338
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
337
+function wpinv_settings_sanitize_tax_rates($input) {
338
+    if (!wpinv_current_user_can_manage_invoicing()) {
339 339
         return $input;
340 340
     }
341 341
 
342
-    $new_rates = ! empty( $_POST['tax_rates'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rates'] ) ) : array();
342
+    $new_rates = !empty($_POST['tax_rates']) ? wp_kses_post_deep(array_values($_POST['tax_rates'])) : array();
343 343
     $tax_rates = array();
344 344
 
345
-    foreach ( $new_rates as $rate ) {
345
+    foreach ($new_rates as $rate) {
346 346
 
347
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
348
-		$rate['name']    = sanitize_text_field( $rate['name'] );
349
-		$rate['state']   = sanitize_text_field( $rate['state'] );
350
-		$rate['country'] = sanitize_text_field( $rate['country'] );
351
-		$rate['global']  = empty( $rate['state'] );
347
+		$rate['rate']    = wpinv_sanitize_amount($rate['rate']);
348
+		$rate['name']    = sanitize_text_field($rate['name']);
349
+		$rate['state']   = sanitize_text_field($rate['state']);
350
+		$rate['country'] = sanitize_text_field($rate['country']);
351
+		$rate['global']  = empty($rate['state']);
352 352
 		$tax_rates[]     = $rate;
353 353
 
354 354
 	}
355 355
 
356
-    update_option( 'wpinv_tax_rates', $tax_rates );
356
+    update_option('wpinv_tax_rates', $tax_rates);
357 357
 
358 358
     return $input;
359 359
 }
360
-add_filter( 'wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates' );
360
+add_filter('wpinv_settings_taxes-rates_sanitize', 'wpinv_settings_sanitize_tax_rates');
361 361
 
362
-function wpinv_settings_sanitize_tax_rules( $input ) {
363
-    if ( ! wpinv_current_user_can_manage_invoicing() ) {
362
+function wpinv_settings_sanitize_tax_rules($input) {
363
+    if (!wpinv_current_user_can_manage_invoicing()) {
364 364
         return $input;
365 365
     }
366 366
 
367
-	if ( empty( $_POST['wpinv_tax_rules_nonce'] ) || ! wp_verify_nonce( $_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules' ) ) {
367
+	if (empty($_POST['wpinv_tax_rules_nonce']) || !wp_verify_nonce($_POST['wpinv_tax_rules_nonce'], 'wpinv_tax_rules')) {
368 368
 		return $input;
369 369
 	}
370 370
 
371
-    $new_rules = ! empty( $_POST['tax_rules'] ) ? wp_kses_post_deep( array_values( $_POST['tax_rules'] ) ) : array();
371
+    $new_rules = !empty($_POST['tax_rules']) ? wp_kses_post_deep(array_values($_POST['tax_rules'])) : array();
372 372
     $tax_rules = array();
373 373
 
374
-    foreach ( $new_rules as $rule ) {
374
+    foreach ($new_rules as $rule) {
375 375
 
376
-		$rule['key']      = sanitize_title_with_dashes( $rule['key'] );
377
-		$rule['label']    = sanitize_text_field( $rule['label'] );
378
-		$rule['tax_base'] = sanitize_text_field( $rule['tax_base'] );
376
+		$rule['key']      = sanitize_title_with_dashes($rule['key']);
377
+		$rule['label']    = sanitize_text_field($rule['label']);
378
+		$rule['tax_base'] = sanitize_text_field($rule['tax_base']);
379 379
 		$tax_rules[]      = $rule;
380 380
 
381 381
 	}
382 382
 
383
-    update_option( 'wpinv_tax_rules', $tax_rules );
383
+    update_option('wpinv_tax_rules', $tax_rules);
384 384
 
385 385
     return $input;
386 386
 }
387
-add_filter( 'wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules' );
387
+add_filter('wpinv_settings_taxes-rules_sanitize', 'wpinv_settings_sanitize_tax_rules');
388 388
 
389 389
 function wpinv_get_settings_tabs() {
390 390
     $tabs             = array();
391
-    $tabs['general']  = __( 'General', 'invoicing' );
392
-    $tabs['gateways'] = __( 'Payment Gateways', 'invoicing' );
393
-    $tabs['taxes']    = __( 'Taxes', 'invoicing' );
394
-	$tabs['emails']   = __( 'Emails', 'invoicing' );
391
+    $tabs['general']  = __('General', 'invoicing');
392
+    $tabs['gateways'] = __('Payment Gateways', 'invoicing');
393
+    $tabs['taxes']    = __('Taxes', 'invoicing');
394
+	$tabs['emails'] = __('Emails', 'invoicing');
395 395
 
396
-	if ( count( getpaid_get_integration_settings() ) > 0 ) {
397
-		$tabs['integrations'] = __( 'Integrations', 'invoicing' );
396
+	if (count(getpaid_get_integration_settings()) > 0) {
397
+		$tabs['integrations'] = __('Integrations', 'invoicing');
398 398
 	}
399 399
 
400
-    $tabs['privacy']  = __( 'Privacy', 'invoicing' );
401
-    $tabs['misc']     = __( 'Misc', 'invoicing' );
402
-    $tabs['tools']    = __( 'Tools', 'invoicing' );
400
+    $tabs['privacy']  = __('Privacy', 'invoicing');
401
+    $tabs['misc']     = __('Misc', 'invoicing');
402
+    $tabs['tools']    = __('Tools', 'invoicing');
403 403
 
404
-    return apply_filters( 'wpinv_settings_tabs', $tabs );
404
+    return apply_filters('wpinv_settings_tabs', $tabs);
405 405
 }
406 406
 
407
-function wpinv_get_settings_tab_sections( $tab = false ) {
407
+function wpinv_get_settings_tab_sections($tab = false) {
408 408
     $tabs     = false;
409 409
     $sections = wpinv_get_registered_settings_sections();
410 410
 
411
-    if ( $tab && ! empty( $sections[ $tab ] ) ) {
412
-        $tabs = $sections[ $tab ];
411
+    if ($tab && !empty($sections[$tab])) {
412
+        $tabs = $sections[$tab];
413 413
     }
414 414
 
415 415
     return $tabs;
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 function wpinv_get_registered_settings_sections() {
419 419
     static $sections = false;
420 420
 
421
-    if ( false !== $sections ) {
421
+    if (false !== $sections) {
422 422
         return $sections;
423 423
     }
424 424
 
@@ -426,90 +426,90 @@  discard block
 block discarded – undo
426 426
         'general'      => apply_filters(
427 427
             'wpinv_settings_sections_general',
428 428
             array(
429
-				'main'             => __( 'General Settings', 'invoicing' ),
430
-				'page_section'     => __( 'Page Settings', 'invoicing' ),
431
-				'currency_section' => __( 'Currency Settings', 'invoicing' ),
432
-				'labels'           => __( 'Label Texts', 'invoicing' ),
429
+				'main'             => __('General Settings', 'invoicing'),
430
+				'page_section'     => __('Page Settings', 'invoicing'),
431
+				'currency_section' => __('Currency Settings', 'invoicing'),
432
+				'labels'           => __('Label Texts', 'invoicing'),
433 433
             )
434 434
         ),
435 435
         'gateways'     => apply_filters(
436 436
             'wpinv_settings_sections_gateways',
437 437
             array(
438
-				'main' => __( 'Gateway Settings', 'invoicing' ),
438
+				'main' => __('Gateway Settings', 'invoicing'),
439 439
             )
440 440
         ),
441 441
         'taxes'        => apply_filters(
442 442
             'wpinv_settings_sections_taxes',
443 443
             array(
444
-				'main'  => __( 'Tax Settings', 'invoicing' ),
445
-				'rules' => __( 'Tax Rules', 'invoicing' ),
446
-				'rates' => __( 'Tax Rates', 'invoicing' ),
447
-				'vat'   => __( 'EU VAT Settings', 'invoicing' ),
444
+				'main'  => __('Tax Settings', 'invoicing'),
445
+				'rules' => __('Tax Rules', 'invoicing'),
446
+				'rates' => __('Tax Rates', 'invoicing'),
447
+				'vat'   => __('EU VAT Settings', 'invoicing'),
448 448
             )
449 449
         ),
450 450
         'emails'       => apply_filters(
451 451
             'wpinv_settings_sections_emails',
452 452
             array(
453
-				'main' => __( 'Email Settings', 'invoicing' ),
453
+				'main' => __('Email Settings', 'invoicing'),
454 454
             )
455 455
         ),
456 456
 
457
-		'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'label', 'id' ),
457
+		'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'label', 'id'),
458 458
 
459 459
         'privacy'      => apply_filters(
460 460
             'wpinv_settings_sections_privacy',
461 461
             array(
462
-				'main' => __( 'Privacy policy', 'invoicing' ),
462
+				'main' => __('Privacy policy', 'invoicing'),
463 463
             )
464 464
         ),
465 465
         'misc'         => apply_filters(
466 466
             'wpinv_settings_sections_misc',
467 467
             array(
468
-				'main'       => __( 'Miscellaneous', 'invoicing' ),
469
-				'custom-css' => __( 'Custom CSS', 'invoicing' ),
468
+				'main'       => __('Miscellaneous', 'invoicing'),
469
+				'custom-css' => __('Custom CSS', 'invoicing'),
470 470
             )
471 471
         ),
472 472
         'tools'        => apply_filters(
473 473
             'wpinv_settings_sections_tools',
474 474
             array(
475
-				'main' => __( 'Diagnostic Tools', 'invoicing' ),
475
+				'main' => __('Diagnostic Tools', 'invoicing'),
476 476
             )
477 477
         ),
478 478
     );
479 479
 
480
-    $sections = apply_filters( 'wpinv_settings_sections', $sections );
480
+    $sections = apply_filters('wpinv_settings_sections', $sections);
481 481
 
482 482
     return $sections;
483 483
 }
484 484
 
485
-function wpinv_get_pages( $with_slug = false, $default_label = null ) {
485
+function wpinv_get_pages($with_slug = false, $default_label = null) {
486 486
     global $wpdb, $gp_tmpl_page_options;
487 487
 
488 488
     // Same function, lets not call it twice if we don't need to.
489
-    if ( function_exists( 'sd_template_page_options' ) ) {
489
+    if (function_exists('sd_template_page_options')) {
490 490
         $args = array(
491 491
             'with_slug' => $with_slug,
492 492
             'default_label' => $default_label
493 493
         );
494 494
 
495
-        return sd_template_page_options( $args );
495
+        return sd_template_page_options($args);
496 496
     }
497 497
 
498
-    if ( ! empty( $gp_tmpl_page_options ) ) {
498
+    if (!empty($gp_tmpl_page_options)) {
499 499
         return $gp_tmpl_page_options;
500 500
     }
501 501
 
502 502
     $exclude_pages = array();
503
-    if ( $page_on_front = get_option( 'page_on_front' ) ) {
503
+    if ($page_on_front = get_option('page_on_front')) {
504 504
         $exclude_pages[] = $page_on_front;
505 505
     }
506 506
 
507
-    if ( $page_for_posts = get_option( 'page_for_posts' ) ) {
507
+    if ($page_for_posts = get_option('page_for_posts')) {
508 508
         $exclude_pages[] = $page_for_posts;
509 509
     }
510 510
 
511 511
     $exclude_pages_placeholders = '';
512
-    if ( ! empty( $exclude_pages ) ) {
512
+    if (!empty($exclude_pages)) {
513 513
         // Sanitize the array of excluded pages and implode it for the SQL query
514 514
         $exclude_pages_placeholders = implode(',', array_fill(0, count($exclude_pages), '%d'));
515 515
     }
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
 	";
524 524
 
525 525
     // Add the exclusion if there are pages to exclude
526
-    if ( ! empty( $exclude_pages ) ) {
526
+    if (!empty($exclude_pages)) {
527 527
         $sql .= " AND ID NOT IN ($exclude_pages_placeholders)";
528 528
     }
529 529
 
@@ -531,18 +531,18 @@  discard block
 block discarded – undo
531 531
     $sql .= " ORDER BY post_title ASC";
532 532
 
533 533
     // Add a sanity limit
534
-    $limit = absint( apply_filters('wpinv_get_pages_limit',500) );
534
+    $limit = absint(apply_filters('wpinv_get_pages_limit', 500));
535 535
     $sql .= " LIMIT " . absint($limit);
536 536
 
537 537
     // Prepare the SQL query to include the excluded pages only if we have placeholders
538
-    $pages = $exclude_pages_placeholders ? $wpdb->get_results( $wpdb->prepare( $sql, ...$exclude_pages ) ) : $wpdb->get_results( $sql );
538
+    $pages = $exclude_pages_placeholders ? $wpdb->get_results($wpdb->prepare($sql, ...$exclude_pages)) : $wpdb->get_results($sql);
539 539
 
540 540
 	$pages_options = array();
541 541
 
542
-    if ( $pages ) {
543
-        foreach ( $pages as $page ) {
542
+    if ($pages) {
543
+        foreach ($pages as $page) {
544 544
             $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
545
-            $pages_options[ $page->ID ] = $title;
545
+            $pages_options[$page->ID] = $title;
546 546
         }
547 547
     }
548 548
 
@@ -550,162 +550,162 @@  discard block
 block discarded – undo
550 550
 
551 551
     $gp_tmpl_page_options = $pages_options;
552 552
 
553
-    if ( $default_label !== null && $default_label !== false ) {
554
-        $pages_options = array( '' => $default_label ) + $pages_options; // Blank option
553
+    if ($default_label !== null && $default_label !== false) {
554
+        $pages_options = array('' => $default_label) + $pages_options; // Blank option
555 555
     }
556 556
 
557 557
 	return $pages_options;
558 558
 }
559 559
 
560
-function wpinv_header_callback( $args ) {
561
-	if ( ! empty( $args['desc'] ) ) {
562
-        echo wp_kses_post( $args['desc'] );
560
+function wpinv_header_callback($args) {
561
+	if (!empty($args['desc'])) {
562
+        echo wp_kses_post($args['desc']);
563 563
     }
564 564
 }
565 565
 
566
-function wpinv_hidden_callback( $args ) {
566
+function wpinv_hidden_callback($args) {
567 567
 
568
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
569
-	$value   = wpinv_get_option( $args['id'], $std );
568
+	$std     = isset($args['std']) ? $args['std'] : '';
569
+	$value   = wpinv_get_option($args['id'], $std);
570 570
 
571
-	if ( isset( $args['set_value'] ) ) {
571
+	if (isset($args['set_value'])) {
572 572
 		$value = $args['set_value'];
573 573
 	}
574 574
 
575
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
575
+	if (isset($args['faux']) && true === $args['faux']) {
576 576
 		$args['readonly'] = true;
577
-		$name  = '';
577
+		$name = '';
578 578
 	} else {
579
-		$name = 'wpinv_settings[' . esc_attr( $args['id'] ) . ']';
579
+		$name = 'wpinv_settings[' . esc_attr($args['id']) . ']';
580 580
 	}
581 581
 
582
-	echo '<input type="hidden" id="wpinv_settings[' . esc_attr( $args['id'] ) . ']" name="' . esc_attr( $name ) . '" value="' . esc_attr( stripslashes( $value ) ) . '" />';
582
+	echo '<input type="hidden" id="wpinv_settings[' . esc_attr($args['id']) . ']" name="' . esc_attr($name) . '" value="' . esc_attr(stripslashes($value)) . '" />';
583 583
 
584 584
 }
585 585
 
586 586
 /**
587 587
  * Displays a checkbox settings callback.
588 588
  */
589
-function wpinv_checkbox_callback( $args ) {
589
+function wpinv_checkbox_callback($args) {
590 590
 
591
-	$std = isset( $args['std'] ) ? $args['std'] : '';
592
-	$std = wpinv_get_option( $args['id'], $std );
593
-	$id  = esc_attr( $args['id'] );
591
+	$std = isset($args['std']) ? $args['std'] : '';
592
+	$std = wpinv_get_option($args['id'], $std);
593
+	$id  = esc_attr($args['id']);
594 594
 
595
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
595
+	getpaid_hidden_field("wpinv_settings[$id]", '0');
596 596
 	?>
597 597
 		<label>
598
-			<input id="wpinv-settings-<?php echo esc_attr( $id ); ?>" name="wpinv_settings[<?php echo esc_attr( $id ); ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox" />
599
-			<?php echo wp_kses_post( $args['desc'] ); ?>
598
+			<input id="wpinv-settings-<?php echo esc_attr($id); ?>" name="wpinv_settings[<?php echo esc_attr($id); ?>]" <?php checked(empty($std), false); ?> value="1" type="checkbox" />
599
+			<?php echo wp_kses_post($args['desc']); ?>
600 600
 		</label>
601 601
 	<?php
602 602
 }
603 603
 
604
-function wpinv_multicheck_callback( $args ) {
604
+function wpinv_multicheck_callback($args) {
605 605
 
606
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
607
-	$class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
606
+	$sanitize_id = wpinv_sanitize_key($args['id']);
607
+	$class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
608 608
 
609
-	if ( ! empty( $args['options'] ) ) {
609
+	if (!empty($args['options'])) {
610 610
 
611
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
612
-		$value   = wpinv_get_option( $args['id'], $std );
611
+		$std     = isset($args['std']) ? $args['std'] : array();
612
+		$value   = wpinv_get_option($args['id'], $std);
613 613
 
614
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr( $sanitize_id . $class ) . '">';
615
-        foreach ( $args['options'] as $key => $option ) :
616
-			$sanitize_key = esc_attr( wpinv_sanitize_key( $key ) );
617
-			if ( in_array( $sanitize_key, $value ) ) {
614
+		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . esc_attr($sanitize_id . $class) . '">';
615
+        foreach ($args['options'] as $key => $option) :
616
+			$sanitize_key = esc_attr(wpinv_sanitize_key($key));
617
+			if (in_array($sanitize_key, $value)) {
618 618
 				$enabled = $sanitize_key;
619 619
 			} else {
620 620
 				$enabled = null;
621 621
 			}
622
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
623
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']">' . wp_kses_post( $option ) . '</label></div>';
622
+			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($sanitize_key) . '" ' . checked($sanitize_key, $enabled, false) . '/>&nbsp;';
623
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']">' . wp_kses_post($option) . '</label></div>';
624 624
 		endforeach;
625 625
 		echo '</div>';
626
-		echo '<p class="description">' . wp_kses_post( $args['desc'] ) . '</p>';
626
+		echo '<p class="description">' . wp_kses_post($args['desc']) . '</p>';
627 627
 	}
628 628
 }
629 629
 
630
-function wpinv_payment_icons_callback( $args ) {
630
+function wpinv_payment_icons_callback($args) {
631 631
 
632
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
633
-	$value   = wpinv_get_option( $args['id'], false );
632
+    $sanitize_id = wpinv_sanitize_key($args['id']);
633
+	$value = wpinv_get_option($args['id'], false);
634 634
 
635
-	if ( ! empty( $args['options'] ) ) {
636
-		foreach ( $args['options'] as $key => $option ) {
637
-            $sanitize_key = wpinv_sanitize_key( $key );
635
+	if (!empty($args['options'])) {
636
+		foreach ($args['options'] as $key => $option) {
637
+            $sanitize_key = wpinv_sanitize_key($key);
638 638
 
639
-			if ( empty( $value ) ) {
639
+			if (empty($value)) {
640 640
 				$enabled = $option;
641 641
 			} else {
642 642
 				$enabled = null;
643 643
 			}
644 644
 
645
-			echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
645
+			echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
646 646
 
647
-				echo '<input name="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" id="wpinv_settings[' . esc_attr( $sanitize_id ) . '][' . esc_attr( $sanitize_key ) . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
647
+				echo '<input name="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" id="wpinv_settings[' . esc_attr($sanitize_id) . '][' . esc_attr($sanitize_key) . ']" type="checkbox" value="' . esc_attr($option) . '" ' . checked($option, $enabled, false) . '/>&nbsp;';
648 648
 
649
-				if ( wpinv_string_is_image_url( $key ) ) {
650
-				echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
649
+				if (wpinv_string_is_image_url($key)) {
650
+				echo '<img class="payment-icon" src="' . esc_url($key) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
651 651
 				} else {
652
-				$card = strtolower( str_replace( ' ', '', $option ) );
652
+				$card = strtolower(str_replace(' ', '', $option));
653 653
 
654
-				if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
655
-					$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
654
+				if (has_filter('wpinv_accepted_payment_' . $card . '_image')) {
655
+					$image = apply_filters('wpinv_accepted_payment_' . $card . '_image', '');
656 656
 					} else {
657
-					$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
657
+					$image       = wpinv_locate_template('images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false);
658 658
 					$content_dir = WP_CONTENT_DIR;
659 659
 
660
-					if ( function_exists( 'wp_normalize_path' ) ) {
660
+					if (function_exists('wp_normalize_path')) {
661 661
 						// Replaces backslashes with forward slashes for Windows systems
662
-						$image = wp_normalize_path( $image );
663
-						$content_dir = wp_normalize_path( $content_dir );
662
+						$image = wp_normalize_path($image);
663
+						$content_dir = wp_normalize_path($content_dir);
664 664
 						}
665 665
 
666
-					$image = str_replace( $content_dir, content_url(), $image );
666
+					$image = str_replace($content_dir, content_url(), $image);
667 667
 					}
668 668
 
669
-				echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
669
+				echo '<img class="payment-icon" src="' . esc_url($image) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
670 670
 				}
671
-			echo wp_kses_post( $option ) . '</label>';
671
+			echo wp_kses_post($option) . '</label>';
672 672
 		}
673
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
673
+		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post($args['desc']) . '</p>';
674 674
 	}
675 675
 }
676 676
 
677 677
 /**
678 678
  * Displays a radio settings field.
679 679
  */
680
-function wpinv_radio_callback( $args ) {
680
+function wpinv_radio_callback($args) {
681 681
 
682
-	$std = isset( $args['std'] ) ? $args['std'] : '';
683
-	$std = wpinv_get_option( $args['id'], $std );
682
+	$std = isset($args['std']) ? $args['std'] : '';
683
+	$std = wpinv_get_option($args['id'], $std);
684 684
 	?>
685 685
 		<fieldset>
686
-			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
687
-				<?php foreach ( $args['options'] as $key => $option ) : ?>
686
+			<ul id="wpinv-settings-<?php echo esc_attr($args['id']); ?>" style="margin-top: 0;">
687
+				<?php foreach ($args['options'] as $key => $option) : ?>
688 688
 					<li>
689 689
 						<label>
690
-							<input name="wpinv_settings[<?php echo esc_attr( $args['id'] ); ?>]" <?php checked( $std, $key ); ?> value="<?php echo esc_attr( $key ); ?>" type="radio">
691
-							<?php echo wp_kses_post( $option ); ?>
690
+							<input name="wpinv_settings[<?php echo esc_attr($args['id']); ?>]" <?php checked($std, $key); ?> value="<?php echo esc_attr($key); ?>" type="radio">
691
+							<?php echo wp_kses_post($option); ?>
692 692
 						</label>
693 693
 					</li>
694 694
 				<?php endforeach; ?>
695 695
 			</ul>
696 696
 		</fieldset>
697 697
 	<?php
698
-	getpaid_settings_description_callback( $args );
698
+	getpaid_settings_description_callback($args);
699 699
 }
700 700
 
701 701
 /**
702 702
  * Displays a description if available.
703 703
  */
704
-function getpaid_settings_description_callback( $args ) {
704
+function getpaid_settings_description_callback($args) {
705 705
 
706
-	if ( ! empty( $args['desc'] ) ) {
706
+	if (!empty($args['desc'])) {
707 707
 		$description = $args['desc'];
708
-		echo wp_kses_post( "<p class='description'>$description</p>" );
708
+		echo wp_kses_post("<p class='description'>$description</p>");
709 709
 	}
710 710
 
711 711
 }
@@ -720,35 +720,35 @@  discard block
 block discarded – undo
720 720
 	</tr>
721 721
 	<tr class="bsui">
722 722
     	<td colspan="2" class="p-0">
723
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-gateways-edit.php'; ?>
723
+			<?php include plugin_dir_path(__FILE__) . 'views/html-gateways-edit.php'; ?>
724 724
 
725 725
 	<?php
726 726
 }
727 727
 
728
-function wpinv_gateway_select_callback( $args ) {
728
+function wpinv_gateway_select_callback($args) {
729 729
 
730
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
731
-    $class = ! empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
732
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
733
-	$value   = wpinv_get_option( $args['id'], $std );
730
+    $sanitize_id = wpinv_sanitize_key($args['id']);
731
+    $class = !empty($args['class']) ? ' ' . esc_attr($args['class']) : '';
732
+	$std     = isset($args['std']) ? $args['std'] : '';
733
+	$value   = wpinv_get_option($args['id'], $std);
734 734
 
735
-	echo '<select name="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" class="' . esc_attr( $class ) . '" >';
735
+	echo '<select name="wpinv_settings[' . esc_attr($sanitize_id) . ']"" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" class="' . esc_attr($class) . '" >';
736 736
 
737
-	foreach ( $args['options'] as $key => $option ) :
737
+	foreach ($args['options'] as $key => $option) :
738 738
 
739
-		echo '<option value="' . esc_attr( $key ) . '" ';
739
+		echo '<option value="' . esc_attr($key) . '" ';
740 740
 
741
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
742
-            selected( $key, $args['selected'] );
741
+		if (isset($args['selected']) && $args['selected'] !== null && $args['selected'] !== false) {
742
+            selected($key, $args['selected']);
743 743
         } else {
744
-            selected( $key, $value );
744
+            selected($key, $value);
745 745
         }
746 746
 
747
-		echo '>' . esc_html( $option['admin_label'] ) . '</option>';
747
+		echo '>' . esc_html($option['admin_label']) . '</option>';
748 748
 	endforeach;
749 749
 
750 750
 	echo '</select>';
751
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
751
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
752 752
 }
753 753
 
754 754
 /**
@@ -757,16 +757,16 @@  discard block
 block discarded – undo
757 757
  * @param array $args
758 758
  * @return string
759 759
  */
760
-function wpinv_settings_attrs_helper( $args ) {
760
+function wpinv_settings_attrs_helper($args) {
761 761
 
762
-	$value = isset( $args['std'] ) ? $args['std'] : '';
763
-	$id    = esc_attr( $args['id'] );
764
-	$value = is_scalar( $value ) ? $value : '';
762
+	$value = isset($args['std']) ? $args['std'] : '';
763
+	$id    = esc_attr($args['id']);
764
+	$value = is_scalar($value) ? $value : '';
765 765
 
766 766
 	$attrs = array(
767
-		'name'     => ! empty( $args['faux'] ) ? false : "wpinv_settings[$id]",
768
-		'readonly' => ! empty( $args['faux'] ),
769
-		'value'    => ! empty( $args['faux'] ) ? $value : wpinv_get_option( $args['id'], $value ),
767
+		'name'     => !empty($args['faux']) ? false : "wpinv_settings[$id]",
768
+		'readonly' => !empty($args['faux']),
769
+		'value'    => !empty($args['faux']) ? $value : wpinv_get_option($args['id'], $value),
770 770
 		'id'       => 'wpinv-settings-' . $args['id'],
771 771
 		'style'    => $args['style'],
772 772
 		'class'    => $args['class'],
@@ -774,20 +774,20 @@  discard block
 block discarded – undo
774 774
 		'data-placeholder' => $args['placeholder'],
775 775
 	);
776 776
 
777
-	if ( ! empty( $args['onchange'] ) ) {
777
+	if (!empty($args['onchange'])) {
778 778
 		$attrs['onchange'] = $args['onchange'];
779 779
 	}
780 780
 
781
-	foreach ( $attrs as $key => $value ) {
781
+	foreach ($attrs as $key => $value) {
782 782
 
783
-		if ( false === $value ) {
783
+		if (false === $value) {
784 784
 			continue;
785 785
 		}
786 786
 
787
-		if ( true === $value ) {
788
-			echo ' ' . esc_attr( $key );
787
+		if (true === $value) {
788
+			echo ' ' . esc_attr($key);
789 789
 		} else {
790
-			echo ' ' . esc_attr( $key ) . '="' . esc_attr( $value ) . '"';
790
+			echo ' ' . esc_attr($key) . '="' . esc_attr($value) . '"';
791 791
 		}
792 792
 
793 793
 	}
@@ -797,12 +797,12 @@  discard block
 block discarded – undo
797 797
 /**
798 798
  * Displays a text input settings callback.
799 799
  */
800
-function wpinv_text_callback( $args ) {
800
+function wpinv_text_callback($args) {
801 801
 
802 802
 	?>
803 803
 		<label style="width: 100%;">
804
-			<input type="text" <?php wpinv_settings_attrs_helper( $args ); ?>>
805
-			<?php getpaid_settings_description_callback( $args ); ?>
804
+			<input type="text" <?php wpinv_settings_attrs_helper($args); ?>>
805
+			<?php getpaid_settings_description_callback($args); ?>
806 806
 		</label>
807 807
 	<?php
808 808
 
@@ -811,174 +811,174 @@  discard block
 block discarded – undo
811 811
 /**
812 812
  * Displays a number input settings callback.
813 813
  */
814
-function wpinv_number_callback( $args ) {
814
+function wpinv_number_callback($args) {
815 815
 
816 816
 	?>
817 817
 		<label style="width: 100%;">
818
-			<input type="number" step="<?php echo esc_attr( $args['step'] ); ?>" max="<?php echo intval( $args['max'] ); ?>" min="<?php echo intval( $args['min'] ); ?>" <?php wpinv_settings_attrs_helper( $args ); ?>>
819
-			<?php getpaid_settings_description_callback( $args ); ?>
818
+			<input type="number" step="<?php echo esc_attr($args['step']); ?>" max="<?php echo intval($args['max']); ?>" min="<?php echo intval($args['min']); ?>" <?php wpinv_settings_attrs_helper($args); ?>>
819
+			<?php getpaid_settings_description_callback($args); ?>
820 820
 		</label>
821 821
 	<?php
822 822
 
823 823
 }
824 824
 
825
-function wpinv_textarea_callback( $args ) {
825
+function wpinv_textarea_callback($args) {
826 826
 
827
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
828
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
829
-	$value   = wpinv_get_option( $args['id'], $std );
827
+    $sanitize_id = wpinv_sanitize_key($args['id']);
828
+	$std     = isset($args['std']) ? $args['std'] : '';
829
+	$value   = wpinv_get_option($args['id'], $std);
830 830
 
831
-    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
832
-    $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
831
+    $size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
832
+    $class = (isset($args['class']) && !is_null($args['class'])) ? $args['class'] : 'large-text';
833 833
 
834
-	echo '<textarea class="' . esc_attr( $class ) . ' txtarea-' . esc_attr( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . esc_attr( $args['cols'] ) . '" rows="' . esc_attr( $args['rows'] ) . '" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
835
-	echo '<br /><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
834
+	echo '<textarea class="' . esc_attr($class) . ' txtarea-' . esc_attr($size) . ' wpi-' . esc_attr(sanitize_html_class($sanitize_id)) . ' " cols="' . esc_attr($args['cols']) . '" rows="' . esc_attr($args['rows']) . '" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']">' . esc_textarea(stripslashes($value)) . '</textarea>';
835
+	echo '<br /><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
836 836
 
837 837
 }
838 838
 
839
-function wpinv_password_callback( $args ) {
839
+function wpinv_password_callback($args) {
840 840
 
841
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
842
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
843
-	$value   = wpinv_get_option( $args['id'], $std );
841
+    $sanitize_id = wpinv_sanitize_key($args['id']);
842
+	$std     = isset($args['std']) ? $args['std'] : '';
843
+	$value   = wpinv_get_option($args['id'], $std);
844 844
 
845
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
846
-	echo '<input type="password" class="' . esc_attr( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
847
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
845
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
846
+	echo '<input type="password" class="' . esc_attr($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '"/>';
847
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
848 848
 
849 849
 }
850 850
 
851
-function wpinv_missing_callback( $args ) {
851
+function wpinv_missing_callback($args) {
852 852
 	printf(
853
-		esc_html__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
854
-		'<strong>' . esc_html( $args['id'] ) . '</strong>'
853
+		esc_html__('The callback function used for the %s setting is missing.', 'invoicing'),
854
+		'<strong>' . esc_html($args['id']) . '</strong>'
855 855
 	);
856 856
 }
857 857
 
858 858
 /**
859 859
  * Displays a number input settings callback.
860 860
  */
861
-function wpinv_select_callback( $args ) {
861
+function wpinv_select_callback($args) {
862 862
 
863
-	$desc   = wp_kses_post( $args['desc'] );
864
-	$desc   = empty( $desc ) ? '' : "<p class='description'>$desc</p>";
865
-	$value  = isset( $args['std'] ) ? $args['std'] : '';
866
-	$value  = wpinv_get_option( $args['id'], $value );
867
-	$rand   = uniqid( 'random_id' );
863
+	$desc   = wp_kses_post($args['desc']);
864
+	$desc   = empty($desc) ? '' : "<p class='description'>$desc</p>";
865
+	$value  = isset($args['std']) ? $args['std'] : '';
866
+	$value  = wpinv_get_option($args['id'], $value);
867
+	$rand   = uniqid('random_id');
868 868
 
869 869
 	?>
870 870
 		<label style="width: 100%;">
871
-			<select <?php wpinv_settings_attrs_helper( $args ); ?> data-allow-clear="true">
872
-				<?php foreach ( $args['options'] as $option => $name ) : ?>
873
-					<option value="<?php echo esc_attr( $option ); ?>" <?php echo selected( $option, $value ); ?>><?php echo esc_html( $name ); ?></option>
871
+			<select <?php wpinv_settings_attrs_helper($args); ?> data-allow-clear="true">
872
+				<?php foreach ($args['options'] as $option => $name) : ?>
873
+					<option value="<?php echo esc_attr($option); ?>" <?php echo selected($option, $value); ?>><?php echo esc_html($name); ?></option>
874 874
 				<?php endforeach; ?>
875 875
 			</select>
876 876
 
877
-			<?php if ( substr( $args['id'], -5 ) === '_page' && is_numeric( $value ) ) : ?>
878
-				<a href="<?php echo esc_url( get_edit_post_link( $value ) ); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e( 'Edit Page', 'invoicing' ); ?></a>
877
+			<?php if (substr($args['id'], -5) === '_page' && is_numeric($value)) : ?>
878
+				<a href="<?php echo esc_url(get_edit_post_link($value)); ?>" target="_blank" class="button getpaid-page-setting-edit"><?php esc_html_e('Edit Page', 'invoicing'); ?></a>
879 879
 			<?php endif; ?>
880 880
 
881
-			<?php if ( substr( $args['id'], -5 ) === '_page' && ! empty( $args['default_content'] ) ) : ?>
882
-				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr( $rand ); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e( 'View Default Content', 'invoicing' ); ?></a>
883
-				<div id='<?php echo esc_attr( $rand ); ?>' style='display:none;'>
881
+			<?php if (substr($args['id'], -5) === '_page' && !empty($args['default_content'])) : ?>
882
+				&nbsp;<a href="#TB_inline?&width=400&height=550&inlineId=<?php echo esc_attr($rand); ?>" class="button thickbox getpaid-page-setting-view-default"><?php esc_html_e('View Default Content', 'invoicing'); ?></a>
883
+				<div id='<?php echo esc_attr($rand); ?>' style='display:none;'>
884 884
 					<div>
885
-						<h3><?php esc_html_e( 'Original Content', 'invoicing' ); ?></h3>
886
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post( gepaid_trim_lines( $args['default_content'] ) ); ?></textarea>
887
-						<h3><?php esc_html_e( 'Current Content', 'invoicing' ); ?></h3>
888
-						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post( $value ); echo empty( $_post ) ? '' : wp_kses_post( gepaid_trim_lines( $_post->post_content ) ); ?></textarea>
885
+						<h3><?php esc_html_e('Original Content', 'invoicing'); ?></h3>
886
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php echo wp_kses_post(gepaid_trim_lines($args['default_content'])); ?></textarea>
887
+						<h3><?php esc_html_e('Current Content', 'invoicing'); ?></h3>
888
+						<textarea readonly onclick="this.select()" rows="8" style="width: 100%;"><?php $_post = get_post($value); echo empty($_post) ? '' : wp_kses_post(gepaid_trim_lines($_post->post_content)); ?></textarea>
889 889
 					</div>
890 890
 				</div>
891 891
 			<?php endif; ?>
892 892
 
893
-			<?php echo wp_kses_post( $desc ); ?>
893
+			<?php echo wp_kses_post($desc); ?>
894 894
 		</label>
895 895
 	<?php
896 896
 
897 897
 }
898 898
 
899
-function wpinv_color_select_callback( $args ) {
899
+function wpinv_color_select_callback($args) {
900 900
 
901
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
902
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
903
-	$value   = wpinv_get_option( $args['id'], $std );
901
+    $sanitize_id = wpinv_sanitize_key($args['id']);
902
+	$std     = isset($args['std']) ? $args['std'] : '';
903
+	$value   = wpinv_get_option($args['id'], $std);
904 904
 
905
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
905
+	echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']"/>';
906 906
 
907
-	foreach ( $args['options'] as $option => $color ) {
908
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $color['label'] ) . '</option>';
907
+	foreach ($args['options'] as $option => $color) {
908
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($color['label']) . '</option>';
909 909
 	}
910 910
 
911 911
 	echo '</select>';
912
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
912
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
913 913
 
914 914
 }
915 915
 
916
-function wpinv_rich_editor_callback( $args ) {
916
+function wpinv_rich_editor_callback($args) {
917 917
 	global $wp_version;
918 918
 
919
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
919
+    $sanitize_id = wpinv_sanitize_key($args['id']);
920 920
 
921
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
922
-	$value   = wpinv_get_option( $args['id'], $std );
921
+	$std     = isset($args['std']) ? $args['std'] : '';
922
+	$value   = wpinv_get_option($args['id'], $std);
923 923
 
924
-	if ( ! empty( $args['allow_blank'] ) && empty( $value ) ) {
924
+	if (!empty($args['allow_blank']) && empty($value)) {
925 925
 		$value = $std;
926 926
 	}
927 927
 
928
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
928
+	$rows = isset($args['size']) ? $args['size'] : 20;
929 929
 
930 930
 	echo '<div class="getpaid-settings-editor-input">';
931
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
931
+	if ($wp_version >= 3.3 && function_exists('wp_editor')) {
932 932
 		wp_editor(
933
-            stripslashes( $value ),
934
-            'wpinv_settings_' . esc_attr( $args['id'] ),
933
+            stripslashes($value),
934
+            'wpinv_settings_' . esc_attr($args['id']),
935 935
             array(
936
-				'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']',
937
-				'textarea_rows' => absint( $rows ),
936
+				'textarea_name' => 'wpinv_settings[' . esc_attr($args['id']) . ']',
937
+				'textarea_rows' => absint($rows),
938 938
 				'media_buttons' => false,
939 939
             )
940 940
         );
941 941
 	} else {
942
-		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
942
+		echo '<textarea class="large-text" rows="10" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="wpi-' . esc_attr(sanitize_html_class($args['id'])) . '">' . esc_textarea(stripslashes($value)) . '</textarea>';
943 943
 	}
944 944
 
945
-	echo '</div><br/><label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
945
+	echo '</div><br/><label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
946 946
 
947 947
 }
948 948
 
949
-function wpinv_upload_callback( $args ) {
949
+function wpinv_upload_callback($args) {
950 950
 
951
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
951
+    $sanitize_id = wpinv_sanitize_key($args['id']);
952 952
 
953
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
954
-	$value   = wpinv_get_option( $args['id'], $std );
953
+	$std     = isset($args['std']) ? $args['std'] : '';
954
+	$value   = wpinv_get_option($args['id'], $std);
955 955
 
956
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
957
-	echo '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
958
-	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__( 'Upload File', 'invoicing' ) . '"/></span>';
959
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
956
+	$size = (isset($args['size']) && !is_null($args['size'])) ? $args['size'] : 'regular';
957
+	echo '<input type="text" class="' . sanitize_html_class($size) . '-text" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr(stripslashes($value)) . '"/>';
958
+	echo '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . esc_attr__('Upload File', 'invoicing') . '"/></span>';
959
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
960 960
 
961 961
 }
962 962
 
963
-function wpinv_color_callback( $args ) {
963
+function wpinv_color_callback($args) {
964 964
 
965
-	$std         = isset( $args['std'] ) ? $args['std'] : '';
966
-	$value       = wpinv_get_option( $args['id'], $std );
967
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
965
+	$std         = isset($args['std']) ? $args['std'] : '';
966
+	$value       = wpinv_get_option($args['id'], $std);
967
+    $sanitize_id = wpinv_sanitize_key($args['id']);
968 968
 
969
-	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $std ) . '" />';
970
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
969
+	echo '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" value="' . esc_attr($value) . '" data-default-color="' . esc_attr($std) . '" />';
970
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
971 971
 
972 972
 }
973 973
 
974
-function wpinv_country_states_callback( $args ) {
974
+function wpinv_country_states_callback($args) {
975 975
 
976
-	$std     = isset( $args['std'] ) ? $args['std'] : '';
977
-	$value   = wpinv_get_option( $args['id'], $std );
976
+	$std     = isset($args['std']) ? $args['std'] : '';
977
+	$value   = wpinv_get_option($args['id'], $std);
978 978
 
979
-    $sanitize_id = wpinv_sanitize_key( $args['id'] );
979
+    $sanitize_id = wpinv_sanitize_key($args['id']);
980 980
 
981
-	if ( isset( $args['placeholder'] ) ) {
981
+	if (isset($args['placeholder'])) {
982 982
 		$placeholder = $args['placeholder'];
983 983
 	} else {
984 984
 		$placeholder = '';
@@ -986,15 +986,15 @@  discard block
 block discarded – undo
986 986
 
987 987
 	$states = wpinv_get_country_states();
988 988
 
989
-	$class = empty( $states ) ? 'wpinv-no-states' : 'wpi_select2';
990
-	echo '<select id="wpinv_settings[' . esc_attr( $sanitize_id ) . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="' . esc_attr( $class ) . '" data-placeholder="' . esc_html( $placeholder ) . '"/>';
989
+	$class = empty($states) ? 'wpinv-no-states' : 'wpi_select2';
990
+	echo '<select id="wpinv_settings[' . esc_attr($sanitize_id) . ']" name="wpinv_settings[' . esc_attr($args['id']) . ']" class="' . esc_attr($class) . '" data-placeholder="' . esc_html($placeholder) . '"/>';
991 991
 
992
-	foreach ( $states as $option => $name ) {
993
-		echo '<option value="' . esc_attr( $option ) . '" ' . selected( $option, $value ) . '>' . esc_html( $name ) . '</option>';
992
+	foreach ($states as $option => $name) {
993
+		echo '<option value="' . esc_attr($option) . '" ' . selected($option, $value) . '>' . esc_html($name) . '</option>';
994 994
 	}
995 995
 
996 996
 	echo '</select>';
997
-	echo '<label for="wpinv_settings[' . esc_attr( $sanitize_id ) . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
997
+	echo '<label for="wpinv_settings[' . esc_attr($sanitize_id) . ']"> ' . wp_kses_post($args['desc']) . '</label>';
998 998
 
999 999
 }
1000 1000
 
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
 	</tr>
1009 1009
 	<tr class="bsui">
1010 1010
     	<td colspan="2" class="p-0">
1011
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rates-edit.php'; ?>
1011
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rates-edit.php'; ?>
1012 1012
 
1013 1013
 	<?php
1014 1014
 
@@ -1017,11 +1017,11 @@  discard block
 block discarded – undo
1017 1017
 /**
1018 1018
  * Displays a tax rate' edit row.
1019 1019
  */
1020
-function wpinv_tax_rate_callback( $tax_rate, $key ) {
1020
+function wpinv_tax_rate_callback($tax_rate, $key) {
1021 1021
 
1022
-	$key                      = sanitize_key( $key );
1023
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
1024
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
1022
+	$key                      = sanitize_key($key);
1023
+	$tax_rate['reduced_rate'] = empty($tax_rate['reduced_rate']) ? 0 : $tax_rate['reduced_rate'];
1024
+	include plugin_dir_path(__FILE__) . 'views/html-tax-rate-edit.php';
1025 1025
 
1026 1026
 }
1027 1027
 
@@ -1035,177 +1035,177 @@  discard block
 block discarded – undo
1035 1035
 	</tr>
1036 1036
 	<tr class="bsui">
1037 1037
     	<td colspan="2" class="p-0">
1038
-			<?php include plugin_dir_path( __FILE__ ) . 'views/html-tax-rules-edit.php'; ?>
1038
+			<?php include plugin_dir_path(__FILE__) . 'views/html-tax-rules-edit.php'; ?>
1039 1039
 
1040 1040
 	<?php
1041 1041
 
1042 1042
 }
1043 1043
 
1044
-function wpinv_tools_callback( $args ) {
1044
+function wpinv_tools_callback($args) {
1045 1045
     ?>
1046 1046
     </td><tr>
1047 1047
     <td colspan="2" class="wpinv_tools_tdbox">
1048 1048
     <?php
1049
-    if ( $args['desc'] ) {
1049
+    if ($args['desc']) {
1050 1050
 ?>
1051
-<p><?php echo wp_kses_post( $args['desc'] ); ?></p><?php } ?>
1052
-    <?php do_action( 'wpinv_tools_before' ); ?>
1051
+<p><?php echo wp_kses_post($args['desc']); ?></p><?php } ?>
1052
+    <?php do_action('wpinv_tools_before'); ?>
1053 1053
     <table id="wpinv_tools_table" class="wp-list-table widefat fixed posts">
1054 1054
         <thead>
1055 1055
             <tr>
1056
-                <th scope="col" class="wpinv-th-tool"><?php esc_html_e( 'Tool', 'invoicing' ); ?></th>
1057
-                <th scope="col" class="wpinv-th-desc"><?php esc_html_e( 'Description', 'invoicing' ); ?></th>
1058
-                <th scope="col" class="wpinv-th-action"><?php esc_html_e( 'Action', 'invoicing' ); ?></th>
1056
+                <th scope="col" class="wpinv-th-tool"><?php esc_html_e('Tool', 'invoicing'); ?></th>
1057
+                <th scope="col" class="wpinv-th-desc"><?php esc_html_e('Description', 'invoicing'); ?></th>
1058
+                <th scope="col" class="wpinv-th-action"><?php esc_html_e('Action', 'invoicing'); ?></th>
1059 1059
             </tr>
1060 1060
         </thead>
1061 1061
 
1062 1062
         <tbody>
1063 1063
 			<tr>
1064
-                <td><?php esc_html_e( 'Check Pages', 'invoicing' ); ?></td>
1064
+                <td><?php esc_html_e('Check Pages', 'invoicing'); ?></td>
1065 1065
                 <td>
1066
-                    <small><?php esc_html_e( 'Creates any missing GetPaid pages.', 'invoicing' ); ?></small>
1066
+                    <small><?php esc_html_e('Creates any missing GetPaid pages.', 'invoicing'); ?></small>
1067 1067
                 </td>
1068 1068
                 <td>
1069 1069
 					<a href="
1070 1070
                     <?php
1071 1071
 						echo esc_url(
1072 1072
 							wp_nonce_url(
1073
-								add_query_arg( 'getpaid-admin-action', 'create_missing_pages' ),
1073
+								add_query_arg('getpaid-admin-action', 'create_missing_pages'),
1074 1074
 								'getpaid-nonce',
1075 1075
 								'getpaid-nonce'
1076 1076
 							)
1077 1077
 						);
1078 1078
 					?>
1079
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1079
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1080 1080
                 </td>
1081 1081
             </tr>
1082 1082
 			<tr>
1083
-                <td><?php esc_html_e( 'Refresh Permalinks', 'invoicing' ); ?></td>
1083
+                <td><?php esc_html_e('Refresh Permalinks', 'invoicing'); ?></td>
1084 1084
                 <td>
1085
-                    <small><?php esc_html_e( 'Might fix the page not found error when viewing an invoice.', 'invoicing' ); ?></small>
1085
+                    <small><?php esc_html_e('Might fix the page not found error when viewing an invoice.', 'invoicing'); ?></small>
1086 1086
                 </td>
1087 1087
                 <td>
1088 1088
 					<a href="
1089 1089
                     <?php
1090 1090
 						echo esc_url(
1091 1091
 							wp_nonce_url(
1092
-								add_query_arg( 'getpaid-admin-action', 'refresh_permalinks' ),
1092
+								add_query_arg('getpaid-admin-action', 'refresh_permalinks'),
1093 1093
 								'getpaid-nonce',
1094 1094
 								'getpaid-nonce'
1095 1095
 							)
1096 1096
 						);
1097 1097
 					?>
1098
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1098
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1099 1099
                 </td>
1100 1100
             </tr>
1101 1101
 			<tr>
1102
-                <td><?php esc_html_e( 'Repair Database Tables', 'invoicing' ); ?></td>
1102
+                <td><?php esc_html_e('Repair Database Tables', 'invoicing'); ?></td>
1103 1103
                 <td>
1104
-                    <small><?php esc_html_e( 'Run this tool to create any missing database tables.', 'invoicing' ); ?></small>
1104
+                    <small><?php esc_html_e('Run this tool to create any missing database tables.', 'invoicing'); ?></small>
1105 1105
                 </td>
1106 1106
                 <td>
1107 1107
 					<a href="
1108 1108
                     <?php
1109 1109
 						echo esc_url(
1110 1110
 							wp_nonce_url(
1111
-								add_query_arg( 'getpaid-admin-action', 'create_missing_tables' ),
1111
+								add_query_arg('getpaid-admin-action', 'create_missing_tables'),
1112 1112
 								'getpaid-nonce',
1113 1113
 								'getpaid-nonce'
1114 1114
 							)
1115 1115
 						);
1116 1116
 					?>
1117
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1117
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1118 1118
                 </td>
1119 1119
             </tr>
1120 1120
 			<tr>
1121
-                <td><?php esc_html_e( 'Migrate old invoices', 'invoicing' ); ?></td>
1121
+                <td><?php esc_html_e('Migrate old invoices', 'invoicing'); ?></td>
1122 1122
                 <td>
1123
-                    <small><?php esc_html_e( 'If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing' ); ?></small>
1123
+                    <small><?php esc_html_e('If your old invoices were not migrated after updating from Invoicing to GetPaid, you can use this tool to migrate them.', 'invoicing'); ?></small>
1124 1124
                 </td>
1125 1125
                 <td>
1126 1126
 					<a href="
1127 1127
                     <?php
1128 1128
 						echo esc_url(
1129 1129
 							wp_nonce_url(
1130
-								add_query_arg( 'getpaid-admin-action', 'migrate_old_invoices' ),
1130
+								add_query_arg('getpaid-admin-action', 'migrate_old_invoices'),
1131 1131
 								'getpaid-nonce',
1132 1132
 								'getpaid-nonce'
1133 1133
 							)
1134 1134
 						);
1135 1135
 					?>
1136
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1136
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1137 1137
                 </td>
1138 1138
             </tr>
1139 1139
 
1140 1140
 			<tr>
1141
-                <td><?php esc_html_e( 'Recalculate Discounts', 'invoicing' ); ?></td>
1141
+                <td><?php esc_html_e('Recalculate Discounts', 'invoicing'); ?></td>
1142 1142
                 <td>
1143
-                    <small><?php esc_html_e( 'Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing' ); ?></small>
1143
+                    <small><?php esc_html_e('Recalculate discounts for existing invoices that have discount codes but are not discounted.', 'invoicing'); ?></small>
1144 1144
                 </td>
1145 1145
                 <td>
1146 1146
 					<a href="
1147 1147
                     <?php
1148 1148
 						echo esc_url(
1149 1149
 							wp_nonce_url(
1150
-								add_query_arg( 'getpaid-admin-action', 'recalculate_discounts' ),
1150
+								add_query_arg('getpaid-admin-action', 'recalculate_discounts'),
1151 1151
 								'getpaid-nonce',
1152 1152
 								'getpaid-nonce'
1153 1153
 							)
1154 1154
 						);
1155 1155
 					?>
1156
-                    " class="button button-primary"><?php esc_html_e( 'Run', 'invoicing' ); ?></a>
1156
+                    " class="button button-primary"><?php esc_html_e('Run', 'invoicing'); ?></a>
1157 1157
                 </td>
1158 1158
             </tr>
1159 1159
 
1160 1160
 			<tr>
1161
-                <td><?php esc_html_e( 'Set-up Wizard', 'invoicing' ); ?></td>
1161
+                <td><?php esc_html_e('Set-up Wizard', 'invoicing'); ?></td>
1162 1162
                 <td>
1163
-                    <small><?php esc_html_e( 'Launch the quick set-up wizard.', 'invoicing' ); ?></small>
1163
+                    <small><?php esc_html_e('Launch the quick set-up wizard.', 'invoicing'); ?></small>
1164 1164
                 </td>
1165 1165
                 <td>
1166 1166
 					<a href="
1167 1167
                     <?php
1168
-						echo esc_url( admin_url( 'index.php?page=gp-setup' ) );
1168
+						echo esc_url(admin_url('index.php?page=gp-setup'));
1169 1169
 					?>
1170
-                    " class="button button-primary"><?php esc_html_e( 'Launch', 'invoicing' ); ?></a>
1170
+                    " class="button button-primary"><?php esc_html_e('Launch', 'invoicing'); ?></a>
1171 1171
                 </td>
1172 1172
             </tr>
1173 1173
 
1174
-			<?php do_action( 'wpinv_tools_row' ); ?>
1174
+			<?php do_action('wpinv_tools_row'); ?>
1175 1175
         </tbody>
1176 1176
     </table>
1177
-    <?php do_action( 'wpinv_tools_after' ); ?>
1177
+    <?php do_action('wpinv_tools_after'); ?>
1178 1178
     <?php
1179 1179
 }
1180 1180
 
1181 1181
 
1182
-function wpinv_descriptive_text_callback( $args ) {
1183
-	echo wp_kses_post( $args['desc'] );
1182
+function wpinv_descriptive_text_callback($args) {
1183
+	echo wp_kses_post($args['desc']);
1184 1184
 }
1185 1185
 
1186
-function wpinv_raw_html_callback( $args ) {
1187
-	echo wp_kses( $args['desc'], getpaid_allowed_html() );
1186
+function wpinv_raw_html_callback($args) {
1187
+	echo wp_kses($args['desc'], getpaid_allowed_html());
1188 1188
 }
1189 1189
 
1190
-function wpinv_hook_callback( $args ) {
1191
-	do_action( 'wpinv_' . $args['id'], $args );
1190
+function wpinv_hook_callback($args) {
1191
+	do_action('wpinv_' . $args['id'], $args);
1192 1192
 }
1193 1193
 
1194 1194
 function wpinv_set_settings_cap() {
1195 1195
 	return wpinv_get_capability();
1196 1196
 }
1197
-add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
1197
+add_filter('option_page_capability_wpinv_settings', 'wpinv_set_settings_cap');
1198 1198
 
1199 1199
 
1200
-function wpinv_on_update_settings( $old_value, $value, $option ) {
1201
-    $old = ! empty( $old_value['remove_data_on_unistall'] ) ? 1 : '';
1202
-    $new = ! empty( $value['remove_data_on_unistall'] ) ? 1 : '';
1200
+function wpinv_on_update_settings($old_value, $value, $option) {
1201
+    $old = !empty($old_value['remove_data_on_unistall']) ? 1 : '';
1202
+    $new = !empty($value['remove_data_on_unistall']) ? 1 : '';
1203 1203
 
1204
-    if ( $old != $new ) {
1205
-        update_option( 'wpinv_remove_data_on_invoice_unistall', $new );
1204
+    if ($old != $new) {
1205
+        update_option('wpinv_remove_data_on_invoice_unistall', $new);
1206 1206
     }
1207 1207
 }
1208
-add_action( 'update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3 );
1208
+add_action('update_option_wpinv_settings', 'wpinv_on_update_settings', 10, 3);
1209 1209
 
1210 1210
 
1211 1211
 /**
@@ -1217,43 +1217,43 @@  discard block
 block discarded – undo
1217 1217
  *
1218 1218
  * @return array
1219 1219
  */
1220
-function wpinv_get_email_merge_tags( $subscription = false ) {
1220
+function wpinv_get_email_merge_tags($subscription = false) {
1221 1221
 	$merge_tags = array(
1222
-		'{site_title}'           => __( 'Site Title', 'invoicing' ),
1223
-		'{name}'                 => __( "Customer's full name", 'invoicing' ),
1224
-		'{first_name}'           => __( "Customer's first name", 'invoicing' ),
1225
-		'{last_name}'            => __( "Customer's last name", 'invoicing' ),
1226
-		'{email}'                => __( "Customer's email address", 'invoicing' ),
1227
-		'{invoice_number}'       => __( 'The invoice number', 'invoicing' ),
1228
-		'{invoice_currency}'     => __( 'The invoice currency', 'invoicing' ),
1229
-		'{invoice_total}'        => __( 'The invoice total', 'invoicing' ),
1230
-		'{invoice_link}'         => __( 'The invoice link', 'invoicing' ),
1231
-		'{invoice_pay_link}'     => __( 'The payment link', 'invoicing' ),
1232
-		'{invoice_receipt_link}' => __( 'The receipt link', 'invoicing' ),
1233
-		'{invoice_date}'         => __( 'The date the invoice was created', 'invoicing' ),
1234
-		'{invoice_due_date}'     => __( 'The date the invoice is due', 'invoicing' ),
1235
-		'{date}'                 => __( "Today's date", 'invoicing' ),
1236
-		'{is_was}'               => __( 'If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing' ),
1237
-		'{invoice_label}'        => __( 'Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing' ),
1238
-		'{invoice_quote}'        => __( 'Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing' ),
1239
-		'{invoice_description}'  => __( 'The description of the invoice', 'invoicing' ),
1222
+		'{site_title}'           => __('Site Title', 'invoicing'),
1223
+		'{name}'                 => __("Customer's full name", 'invoicing'),
1224
+		'{first_name}'           => __("Customer's first name", 'invoicing'),
1225
+		'{last_name}'            => __("Customer's last name", 'invoicing'),
1226
+		'{email}'                => __("Customer's email address", 'invoicing'),
1227
+		'{invoice_number}'       => __('The invoice number', 'invoicing'),
1228
+		'{invoice_currency}'     => __('The invoice currency', 'invoicing'),
1229
+		'{invoice_total}'        => __('The invoice total', 'invoicing'),
1230
+		'{invoice_link}'         => __('The invoice link', 'invoicing'),
1231
+		'{invoice_pay_link}'     => __('The payment link', 'invoicing'),
1232
+		'{invoice_receipt_link}' => __('The receipt link', 'invoicing'),
1233
+		'{invoice_date}'         => __('The date the invoice was created', 'invoicing'),
1234
+		'{invoice_due_date}'     => __('The date the invoice is due', 'invoicing'),
1235
+		'{date}'                 => __("Today's date", 'invoicing'),
1236
+		'{is_was}'               => __('If due date of invoice is past, displays "was" otherwise displays "is"', 'invoicing'),
1237
+		'{invoice_label}'        => __('Invoices/quotes singular name. Ex: Invoice/Quote', 'invoicing'),
1238
+		'{invoice_quote}'        => __('Invoices/quotes singular name in small letters. Ex: invoice/quote', 'invoicing'),
1239
+		'{invoice_description}'  => __('The description of the invoice', 'invoicing'),
1240 1240
 	);
1241 1241
 
1242
-	if ( $subscription ) {
1242
+	if ($subscription) {
1243 1243
 		$merge_tags = array_merge(
1244 1244
 			$merge_tags,
1245 1245
 			array(
1246
-				'{subscription_renewal_date}'     => __( 'The next renewal date of the subscription', 'invoicing' ),
1247
-				'{subscription_created}'          => __( "The subscription's creation date", 'invoicing' ),
1248
-				'{subscription_status}'           => __( "The subscription's status", 'invoicing' ),
1249
-				'{subscription_profile_id}'       => __( "The subscription's remote profile id", 'invoicing' ),
1250
-				'{subscription_id}'               => __( "The subscription's id", 'invoicing' ),
1251
-				'{subscription_recurring_amount}' => __( 'The renewal amount of the subscription', 'invoicing' ),
1252
-				'{subscription_initial_amount}'   => __( 'The initial amount of the subscription', 'invoicing' ),
1253
-				'{subscription_recurring_period}' => __( 'The recurring period of the subscription (e.g 1 year)', 'invoicing' ),
1254
-				'{subscription_bill_times}'       => __( 'The maximum number of times the subscription can be renewed', 'invoicing' ),
1255
-				'{subscription_url}'              => __( 'The URL to manage a subscription', 'invoicing' ),
1256
-				'{subscription_name}'             => __( 'The name of the recurring item', 'invoicing' ),
1246
+				'{subscription_renewal_date}'     => __('The next renewal date of the subscription', 'invoicing'),
1247
+				'{subscription_created}'          => __("The subscription's creation date", 'invoicing'),
1248
+				'{subscription_status}'           => __("The subscription's status", 'invoicing'),
1249
+				'{subscription_profile_id}'       => __("The subscription's remote profile id", 'invoicing'),
1250
+				'{subscription_id}'               => __("The subscription's id", 'invoicing'),
1251
+				'{subscription_recurring_amount}' => __('The renewal amount of the subscription', 'invoicing'),
1252
+				'{subscription_initial_amount}'   => __('The initial amount of the subscription', 'invoicing'),
1253
+				'{subscription_recurring_period}' => __('The recurring period of the subscription (e.g 1 year)', 'invoicing'),
1254
+				'{subscription_bill_times}'       => __('The maximum number of times the subscription can be renewed', 'invoicing'),
1255
+				'{subscription_url}'              => __('The URL to manage a subscription', 'invoicing'),
1256
+				'{subscription_name}'             => __('The name of the recurring item', 'invoicing'),
1257 1257
 			)
1258 1258
 		);
1259 1259
 	}
@@ -1269,25 +1269,25 @@  discard block
 block discarded – undo
1269 1269
  *
1270 1270
  * @return string
1271 1271
  */
1272
-function wpinv_get_merge_tags_help_text( $subscription = false ) {
1273
-	$merge_tags = wpinv_get_email_merge_tags( $subscription );
1272
+function wpinv_get_merge_tags_help_text($subscription = false) {
1273
+	$merge_tags = wpinv_get_email_merge_tags($subscription);
1274 1274
 
1275 1275
 	$output = '<div class="bsui">';
1276 1276
 
1277 1277
 	$link = sprintf(
1278 1278
 		'<strong class="getpaid-merge-tags text-primary" role="button">%s</strong>',
1279
-		esc_html__( 'View available merge tags.', 'invoicing' )
1279
+		esc_html__('View available merge tags.', 'invoicing')
1280 1280
 	);
1281 1281
 
1282
-	$description = esc_html__( 'The content of the email (Merge Tags and HTML are allowed).', 'invoicing' );
1282
+	$description = esc_html__('The content of the email (Merge Tags and HTML are allowed).', 'invoicing');
1283 1283
 	
1284 1284
 	$output .= "$description $link";
1285 1285
 
1286 1286
 	$output .= '<div class="getpaid-merge-tags-content mt-2 p-1 d-none">';
1287
-	$output .= '<p class="mb-2">' . esc_html__( 'The following wildcards can be used in email subjects, heading and content:', 'invoicing' ) . '</p>';
1287
+	$output .= '<p class="mb-2">' . esc_html__('The following wildcards can be used in email subjects, heading and content:', 'invoicing') . '</p>';
1288 1288
 
1289 1289
 	$output .= '<ul class="p-0 m-0">';
1290
-	foreach($merge_tags as $tag => $tag_description) {
1290
+	foreach ($merge_tags as $tag => $tag_description) {
1291 1291
 		$output .= "<li class='mb-2'><strong class='text-dark'>$tag</strong> &mdash; $tag_description</li>";
1292 1292
 	}
1293 1293
 
Please login to merge, or discard this patch.
includes/admin/meta-boxes/class-getpaid-meta-box-item-details.php 3 patches
Indentation   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  */
9 9
 
10 10
 if ( ! defined( 'ABSPATH' ) ) {
11
-	exit; // Exit if accessed directly
11
+    exit; // Exit if accessed directly
12 12
 }
13 13
 
14 14
 /**
@@ -17,12 +17,12 @@  discard block
 block discarded – undo
17 17
 class GetPaid_Meta_Box_Item_Details {
18 18
 
19 19
     /**
20
-	 * Output the metabox.
21
-	 *
22
-	 * @param WP_Post $post
23
-	 */
20
+     * Output the metabox.
21
+     *
22
+     * @param WP_Post $post
23
+     */
24 24
     public static function output( $post ) {
25
-		global $aui_bs5;
25
+        global $aui_bs5;
26 26
 
27 27
         // Prepare the item.
28 28
         $item = new WPInv_Item( $post );
@@ -119,24 +119,24 @@  discard block
 block discarded – undo
119 119
                                 // Dynamic pricing.
120 120
                                 if ( $item->supports_dynamic_pricing() ) {
121 121
 
122
-								do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
122
+                                do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
123 123
 
124
-								// NYP toggle.
125
-								aui()->input(
124
+                                // NYP toggle.
125
+                                aui()->input(
126 126
                                     array(
127
-										'id'      => 'wpinv_name_your_price',
128
-										'name'    => 'wpinv_name_your_price',
129
-										'type'    => 'checkbox',
130
-										'label'   => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
131
-										'value'   => '1',
132
-										'checked' => $item->user_can_set_their_price(),
133
-										'no_wrap' => true,
134
-										'switch'  => 'sm',
127
+                                        'id'      => 'wpinv_name_your_price',
128
+                                        'name'    => 'wpinv_name_your_price',
129
+                                        'type'    => 'checkbox',
130
+                                        'label'   => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
131
+                                        'value'   => '1',
132
+                                        'checked' => $item->user_can_set_their_price(),
133
+                                        'no_wrap' => true,
134
+                                        'switch'  => 'sm',
135 135
                                     ),
136 136
                                     true
137 137
                                 );
138 138
 
139
-							do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
139
+                            do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
140 140
 
141 141
                                 }
142 142
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                                         'value'   => '1',
152 152
                                         'checked' => $item->is_recurring(),
153 153
                                         'no_wrap' => true,
154
-										'switch'  => 'sm',
154
+                                        'switch'  => 'sm',
155 155
                                     ),
156 156
                                     true
157 157
                                 );
@@ -293,35 +293,35 @@  discard block
 block discarded – undo
293 293
     }
294 294
 
295 295
     /**
296
-	 * Save meta box data.
297
-	 *
298
-	 * @param int $post_id
299
-	 */
300
-	public static function save( $post_id ) {
296
+     * Save meta box data.
297
+     *
298
+     * @param int $post_id
299
+     */
300
+    public static function save( $post_id ) {
301 301
 
302 302
         // Prepare the item.
303 303
         $item = new WPInv_Item( $post_id );
304 304
 
305 305
         // Load new data.
306 306
         $item->set_props(
307
-			array(
308
-				'price'              => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
309
-				'vat_rule'           => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
310
-				'vat_class'          => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
311
-				'type'               => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
312
-				'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ),
307
+            array(
308
+                'price'              => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
309
+                'vat_rule'           => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
310
+                'vat_class'          => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
311
+                'type'               => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
312
+                'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ),
313 313
                 'minimum_price'      => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
314
-				'is_recurring'       => ! empty( $_POST['wpinv_is_recurring'] ),
315
-				'recurring_period'   => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
316
-				'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
317
-				'recurring_limit'    => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
318
-				'is_free_trial'      => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
319
-				'trial_period'       => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
320
-				'trial_interval'     => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
321
-			)
314
+                'is_recurring'       => ! empty( $_POST['wpinv_is_recurring'] ),
315
+                'recurring_period'   => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
316
+                'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
317
+                'recurring_limit'    => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
318
+                'is_free_trial'      => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
319
+                'trial_period'       => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
320
+                'trial_interval'     => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
321
+            )
322 322
         );
323 323
 
324
-		$item->save();
325
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
326
-	}
324
+        $item->save();
325
+        do_action( 'getpaid_item_metabox_save', $post_id, $item );
326
+    }
327 327
 }
Please login to merge, or discard this patch.
Spacing   +90 added lines, -90 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  *
8 8
  */
9 9
 
10
-if ( ! defined( 'ABSPATH' ) ) {
10
+if (!defined('ABSPATH')) {
11 11
 	exit; // Exit if accessed directly
12 12
 }
13 13
 
@@ -21,59 +21,59 @@  discard block
 block discarded – undo
21 21
 	 *
22 22
 	 * @param WP_Post $post
23 23
 	 */
24
-    public static function output( $post ) {
24
+    public static function output($post) {
25 25
 		global $aui_bs5;
26 26
 
27 27
         // Prepare the item.
28
-        $item = new WPInv_Item( $post );
28
+        $item = new WPInv_Item($post);
29 29
 
30 30
         // Nonce field.
31
-        wp_nonce_field( 'getpaid_meta_nonce', 'getpaid_meta_nonce' );
31
+        wp_nonce_field('getpaid_meta_nonce', 'getpaid_meta_nonce');
32 32
 
33 33
         // Set the currency position.
34 34
         $position = wpinv_currency_position();
35 35
 
36
-        if ( $position == 'left_space' ) {
36
+        if ($position == 'left_space') {
37 37
             $position = 'left';
38 38
         }
39 39
 
40
-        if ( $position == 'right_space' ) {
40
+        if ($position == 'right_space') {
41 41
             $position = 'right';
42 42
         }
43 43
 
44 44
         ?>
45
-        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr( $item->get_type( 'edit' ) ); ?>" />
45
+        <input type="hidden" id="_wpi_current_type" value="<?php echo esc_attr($item->get_type('edit')); ?>" />
46 46
         <style>#poststuff .input-group-text,#poststuff .form-control{border-color:#7e8993}.bsui label.col-sm-3.col-form-label{font-weight:600}.form-check input[type="checkbox"]:checked::before{content:none}</style>
47 47
         <div class='bsui' style='max-width:650px;'><div class="pt-3">
48
-            <?php do_action( 'wpinv_item_details_metabox_before_price', $item ); ?>
48
+            <?php do_action('wpinv_item_details_metabox_before_price', $item); ?>
49 49
             <div class="form-group mb-3 row">
50
-                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_e( 'Item Price', 'invoicing' ); ?></span></label>
50
+                <label class="col-sm-3 col-form-label" for="wpinv_item_price"><span><?php esc_html_e('Item Price', 'invoicing'); ?></span></label>
51 51
                 <div class="col-sm-8">
52 52
                     <div class="row">
53 53
                         <div class="col-sm-4 getpaid-price-input">
54 54
                             <div class="mb-3 input-group input-group-sm">
55
-                                <?php if ( 'left' == $position ) : ?>
56
-                                    <?php if ( empty( $aui_bs5 ) ) : ?>
55
+                                <?php if ('left' == $position) : ?>
56
+                                    <?php if (empty($aui_bs5)) : ?>
57 57
                                         <div class="input-group-prepend">
58
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
58
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
59 59
                                         </div>
60 60
                                     <?php else : ?>
61 61
                                         <span class="input-group-text">
62
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
62
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
63 63
                                         </span>
64 64
                                     <?php endif; ?>
65 65
                                 <?php endif; ?>
66 66
 
67
-                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
67
+                                <input type="text" name="wpinv_item_price" id="wpinv_item_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
68 68
 
69
-                                <?php if ( 'left' != $position ) : ?>
70
-                                    <?php if ( empty( $aui_bs5 ) ) : ?>
69
+                                <?php if ('left' != $position) : ?>
70
+                                    <?php if (empty($aui_bs5)) : ?>
71 71
                                         <div class="input-group-append">
72
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
72
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
73 73
                                         </div>
74 74
                                     <?php else : ?>
75 75
                                         <span class="input-group-text">
76
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
76
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
77 77
                                         </span>
78 78
                                     <?php endif; ?>
79 79
                                 <?php endif; ?>
@@ -81,12 +81,12 @@  discard block
 block discarded – undo
81 81
                         </div>
82 82
                         <div class="col-sm-4 wpinv_show_if_recurring">
83 83
                             <div class="mb-3 input-group input-group-sm">
84
-                                <?php if ( empty( $aui_bs5 ) ) : ?>
85
-                                    <div class="input-group-prepend"><span class="input-group-text pl-0 pr-2 border-0 bg-transparent"><?php esc_html_e( 'every' ); ?></span></div>
84
+                                <?php if (empty($aui_bs5)) : ?>
85
+                                    <div class="input-group-prepend"><span class="input-group-text pl-0 pr-2 border-0 bg-transparent"><?php esc_html_e('every'); ?></span></div>
86 86
                                 <?php else : ?>
87
-                                    <span class="input-group-text ps-0 pe-2 border-0"><?php esc_html_e( 'every' ); ?></span>
87
+                                    <span class="input-group-text ps-0 pe-2 border-0"><?php esc_html_e('every'); ?></span>
88 88
                                 <?php endif; ?>
89
-                                <input type="number" name="wpinv_recurring_interval" id="wpinv_recurring_interval" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" class="form-control rounded-1 rounded-sm">
89
+                                <input type="number" name="wpinv_recurring_interval" id="wpinv_recurring_interval" value="<?php echo esc_attr($item->get_recurring_interval('edit')); ?>" placeholder="1" class="form-control rounded-1 rounded-sm">
90 90
                             </div>
91 91
                         </div>
92 92
                         <div class="col-sm-4 wpinv_show_if_recurring">
@@ -95,16 +95,16 @@  discard block
 block discarded – undo
95 95
                                     array(
96 96
                                         'id'               => 'wpinv_recurring_period',
97 97
                                         'name'             => 'wpinv_recurring_period',
98
-                                        'label'            => __( 'Period', 'invoicing' ),
99
-                                        'placeholder'      => __( 'Select Period', 'invoicing' ),
100
-                                        'value'            => $item->get_recurring_period( 'edit' ),
98
+                                        'label'            => __('Period', 'invoicing'),
99
+                                        'placeholder'      => __('Select Period', 'invoicing'),
100
+                                        'value'            => $item->get_recurring_period('edit'),
101 101
                                         'data-allow-clear' => 'false',
102
-                                        'class'            => ( $aui_bs5 ? 'form-select-sm' : 'custom-select-sm' ),
102
+                                        'class'            => ($aui_bs5 ? 'form-select-sm' : 'custom-select-sm'),
103 103
                                         'options'          => array(
104
-                                            'D' => __( 'day(s)', 'invoicing' ),
105
-                                            'W' => __( 'week(s)', 'invoicing' ),
106
-                                            'M' => __( 'month(s)', 'invoicing' ),
107
-                                            'Y' => __( 'year(s)', 'invoicing' ),
104
+                                            'D' => __('day(s)', 'invoicing'),
105
+                                            'W' => __('week(s)', 'invoicing'),
106
+                                            'M' => __('month(s)', 'invoicing'),
107
+                                            'Y' => __('year(s)', 'invoicing'),
108 108
                                         ),
109 109
                                     ),
110 110
                                     true
@@ -117,9 +117,9 @@  discard block
 block discarded – undo
117 117
                             <?php
118 118
 
119 119
                                 // Dynamic pricing.
120
-                                if ( $item->supports_dynamic_pricing() ) {
120
+                                if ($item->supports_dynamic_pricing()) {
121 121
 
122
-								do_action( 'wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item );
122
+								do_action('wpinv_item_details_metabox_before_dynamic_pricing_checkbox', $item);
123 123
 
124 124
 								// NYP toggle.
125 125
 								aui()->input(
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
 										'id'      => 'wpinv_name_your_price',
128 128
 										'name'    => 'wpinv_name_your_price',
129 129
 										'type'    => 'checkbox',
130
-										'label'   => apply_filters( 'wpinv_name_your_price_toggle_text', __( 'Let customers name their price', 'invoicing' ) ),
130
+										'label'   => apply_filters('wpinv_name_your_price_toggle_text', __('Let customers name their price', 'invoicing')),
131 131
 										'value'   => '1',
132 132
 										'checked' => $item->user_can_set_their_price(),
133 133
 										'no_wrap' => true,
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
                                     true
137 137
                                 );
138 138
 
139
-							do_action( 'wpinv_item_details_metabox_dynamic_pricing_checkbox', $item );
139
+							do_action('wpinv_item_details_metabox_dynamic_pricing_checkbox', $item);
140 140
 
141 141
                                 }
142 142
 
143 143
                                 // Subscriptions.
144
-                                do_action( 'wpinv_item_details_metabox_before_subscription_checkbox', $item );
144
+                                do_action('wpinv_item_details_metabox_before_subscription_checkbox', $item);
145 145
                                 aui()->input(
146 146
                                     array(
147 147
                                         'id'      => 'wpinv_is_recurring',
148 148
                                         'name'    => 'wpinv_is_recurring',
149 149
                                         'type'    => 'checkbox',
150
-                                        'label'   => apply_filters( 'wpinv_is_recurring_toggle_text', __( 'Charge customers a recurring amount for this item', 'invoicing' ) ),
150
+                                        'label'   => apply_filters('wpinv_is_recurring_toggle_text', __('Charge customers a recurring amount for this item', 'invoicing')),
151 151
                                         'value'   => '1',
152 152
                                         'checked' => $item->is_recurring(),
153 153
                                         'no_wrap' => true,
@@ -155,53 +155,53 @@  discard block
 block discarded – undo
155 155
                                     ),
156 156
                                     true
157 157
                                 );
158
-                                do_action( 'wpinv_item_details_metabox_subscription_checkbox', $item );
158
+                                do_action('wpinv_item_details_metabox_subscription_checkbox', $item);
159 159
 
160 160
                             ?>
161 161
                             <div class="wpinv_show_if_recurring">
162
-                                <em><?php echo wp_kses_post( wpinv_get_recurring_gateways_text() ); ?></em>
162
+                                <em><?php echo wp_kses_post(wpinv_get_recurring_gateways_text()); ?></em>
163 163
                             </div>
164 164
                         </div>
165 165
                     </div>
166 166
                 </div>
167 167
                 <div class="col-sm-1 pt-2 pl-0">
168
-                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e( 'Set the subscription price, billing interval and period.', 'invoicing' ); ?>"></span>
168
+                    <span class="wpi-help-tip dashicons dashicons-editor-help wpinv_show_if_recurring" title="<?php esc_attr_e('Set the subscription price, billing interval and period.', 'invoicing'); ?>"></span>
169 169
                 </div>
170 170
             </div>
171
-            <?php do_action( 'wpinv_item_details_metabox_after_price', $item ); ?>
171
+            <?php do_action('wpinv_item_details_metabox_after_price', $item); ?>
172 172
 
173
-            <?php if ( $item->supports_dynamic_pricing() ) : ?>
174
-                <?php do_action( 'wpinv_item_details_metabox_before_minimum_price', $item ); ?>
173
+            <?php if ($item->supports_dynamic_pricing()) : ?>
174
+                <?php do_action('wpinv_item_details_metabox_before_minimum_price', $item); ?>
175 175
                 <div class="wpinv_show_if_dynamic wpinv_minimum_price">
176 176
 
177 177
                     <div class="form-group mb-3 row">
178 178
                         <label for="wpinv_minimum_price" class="col-sm-3 col-form-label">
179
-                            <?php esc_html_e( 'Minimum Price', 'invoicing' ); ?>
179
+                            <?php esc_html_e('Minimum Price', 'invoicing'); ?>
180 180
                         </label>
181 181
                         <div class="col-sm-8">
182 182
                             <div class="input-group input-group-sm">
183
-                                <?php if ( 'left' == $position ) : ?>
184
-                                    <?php if ( empty( $aui_bs5 ) ) : ?>
183
+                                <?php if ('left' == $position) : ?>
184
+                                    <?php if (empty($aui_bs5)) : ?>
185 185
                                         <div class="input-group-prepend">
186
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
186
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
187 187
                                         </div>
188 188
                                     <?php else : ?>
189 189
                                         <span class="input-group-text">
190
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
190
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
191 191
                                         </span>
192 192
                                     <?php endif; ?>
193 193
                                 <?php endif; ?>
194 194
 
195
-                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr( getpaid_unstandardize_amount( $item->get_minimum_price( 'edit' ) ) ); ?>" placeholder="<?php echo esc_attr( wpinv_sanitize_amount( 0 ) ); ?>" class="form-control">
195
+                                <input type="text" name="wpinv_minimum_price" id="wpinv_minimum_price" value="<?php echo esc_attr(getpaid_unstandardize_amount($item->get_minimum_price('edit'))); ?>" placeholder="<?php echo esc_attr(wpinv_sanitize_amount(0)); ?>" class="form-control">
196 196
 
197
-                                <?php if ( 'left' != $position ) : ?>
198
-                                    <?php if ( empty( $aui_bs5 ) ) : ?>
197
+                                <?php if ('left' != $position) : ?>
198
+                                    <?php if (empty($aui_bs5)) : ?>
199 199
                                         <div class="input-group-append">
200
-                                            <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
200
+                                            <span class="input-group-text"><?php echo wp_kses_post(wpinv_currency_symbol()); ?></span>
201 201
                                         </div>
202 202
                                     <?php else : ?>
203 203
                                         <span class="input-group-text">
204
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
204
+                                            <?php echo wp_kses_post(wpinv_currency_symbol()); ?>
205 205
                                         </span>
206 206
                                     <?php endif; ?>
207 207
                                 <?php endif; ?>
@@ -209,45 +209,45 @@  discard block
 block discarded – undo
209 209
                         </div>
210 210
 
211 211
                         <div class="col-sm-1 pt-2 pl-0">
212
-                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Enter the minimum amount that users are allowed to set', 'invoicing' ); ?>"></span>
212
+                            <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Enter the minimum amount that users are allowed to set', 'invoicing'); ?>"></span>
213 213
                         </div>
214 214
                     </div>
215 215
 
216 216
                 </div>
217
-                <?php do_action( 'wpinv_item_details_metabox_minimum_price', $item ); ?>
217
+                <?php do_action('wpinv_item_details_metabox_minimum_price', $item); ?>
218 218
             <?php endif; ?>
219 219
 
220
-            <?php do_action( 'wpinv_item_details_metabox_before_maximum_renewals', $item ); ?>
220
+            <?php do_action('wpinv_item_details_metabox_before_maximum_renewals', $item); ?>
221 221
             <div class="wpinv_show_if_recurring wpinv_maximum_renewals">
222 222
 
223 223
                 <div class="form-group mb-3 row">
224 224
                     <label for="wpinv_recurring_limit" class="col-sm-3 col-form-label">
225
-                        <?php esc_html_e( 'Maximum Renewals', 'invoicing' ); ?>
225
+                        <?php esc_html_e('Maximum Renewals', 'invoicing'); ?>
226 226
                     </label>
227 227
                     <div class="col-sm-8">
228
-                        <input type="number" value="<?php echo esc_attr( $item->get_recurring_limit( 'edit' ) ); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" class="form-control form-control-sm" />
228
+                        <input type="number" value="<?php echo esc_attr($item->get_recurring_limit('edit')); ?>" placeholder="0" name="wpinv_recurring_limit" id="wpinv_recurring_limit" class="form-control form-control-sm" />
229 229
                     </div>
230 230
                     <div class="col-sm-1 pt-2 pl-0">
231
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing' ); ?>"></span>
231
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('Leave empty if you want the subscription to renew until it is cancelled.', 'invoicing'); ?>"></span>
232 232
                     </div>
233 233
                 </div>
234 234
 
235 235
             </div>
236
-            <?php do_action( 'wpinv_item_details_metabox_maximum_renewals', $item ); ?>
236
+            <?php do_action('wpinv_item_details_metabox_maximum_renewals', $item); ?>
237 237
 
238
-            <?php do_action( 'wpinv_item_details_metabox_before_free_trial', $item ); ?>
238
+            <?php do_action('wpinv_item_details_metabox_before_free_trial', $item); ?>
239 239
             <div class="wpinv_show_if_recurring wpinv_free_trial">
240 240
 
241 241
                 <div class="form-group mb-3 row">
242
-                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined( 'GETPAID_PAID_TRIALS_VERSION' ) ? esc_html_e( 'Free/Paid Trial', 'invoicing' ) : esc_html_e( 'Free Trial', 'invoicing' ); ?></label>
242
+                    <label class="col-sm-3 col-form-label" for="wpinv_trial_interval"><?php defined('GETPAID_PAID_TRIALS_VERSION') ? esc_html_e('Free/Paid Trial', 'invoicing') : esc_html_e('Free Trial', 'invoicing'); ?></label>
243 243
 
244 244
                     <div class="col-sm-8">
245 245
                         <div class="row">
246 246
                             <div class="col-sm-6">
247
-                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval( 'edit' ) : 0; ?>
247
+                                <?php $value = $item->has_free_trial() ? $item->get_trial_interval('edit') : 0; ?>
248 248
 
249 249
                                 <div>
250
-                                    <input type="number" name="wpinv_trial_interval" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr( $value ); ?>" class="form-control form-control-sm">
250
+                                    <input type="number" name="wpinv_trial_interval" placeholder="0" id="wpinv_trial_interval" value="<?php echo esc_attr($value); ?>" class="form-control form-control-sm">
251 251
                                 </div>
252 252
                             </div>
253 253
                             <div class="col-sm-6">
@@ -256,17 +256,17 @@  discard block
 block discarded – undo
256 256
                                         array(
257 257
                                             'id'          => 'wpinv_trial_period',
258 258
                                             'name'        => 'wpinv_trial_period',
259
-                                            'label'       => __( 'Trial Period', 'invoicing' ),
260
-                                            'placeholder' => __( 'Trial Period', 'invoicing' ),
261
-                                            'value'       => $item->get_trial_period( 'edit' ),
259
+                                            'label'       => __('Trial Period', 'invoicing'),
260
+                                            'placeholder' => __('Trial Period', 'invoicing'),
261
+                                            'value'       => $item->get_trial_period('edit'),
262 262
                                             'data-allow-clear' => 'false',
263 263
                                             'no_wrap'     => true,
264
-                                            'class'       => ( $aui_bs5 ? 'form-select-sm' : 'custom-select-sm' ),
264
+                                            'class'       => ($aui_bs5 ? 'form-select-sm' : 'custom-select-sm'),
265 265
                                             'options'     => array(
266
-                                                'D' => __( 'day(s)', 'invoicing' ),
267
-                                                'W' => __( 'week(s)', 'invoicing' ),
268
-                                                'M' => __( 'month(s)', 'invoicing' ),
269
-                                                'Y' => __( 'year(s)', 'invoicing' ),
266
+                                                'D' => __('day(s)', 'invoicing'),
267
+                                                'W' => __('week(s)', 'invoicing'),
268
+                                                'M' => __('month(s)', 'invoicing'),
269
+                                                'Y' => __('year(s)', 'invoicing'),
270 270
                                             ),
271 271
                                         ),
272 272
                                         true
@@ -278,15 +278,15 @@  discard block
 block discarded – undo
278 278
                     </div>
279 279
 
280 280
                     <div class="col-sm-1 pt-2 pl-0">
281
-                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e( 'An optional period of time to wait before charging the first recurring payment.', 'invoicing' ); ?>"></span>
281
+                        <span class="wpi-help-tip dashicons dashicons-editor-help" title="<?php esc_attr_e('An optional period of time to wait before charging the first recurring payment.', 'invoicing'); ?>"></span>
282 282
                     </div>
283 283
 
284 284
                 </div>
285 285
 
286 286
             </div>
287
-            <?php do_action( 'wpinv_item_details_metabox__free_trial', $item ); ?>
287
+            <?php do_action('wpinv_item_details_metabox__free_trial', $item); ?>
288 288
 
289
-            <?php do_action( 'wpinv_item_details_metabox_item_details', $item ); ?>
289
+            <?php do_action('wpinv_item_details_metabox_item_details', $item); ?>
290 290
         </div>
291 291
         </div>
292 292
         <?php
@@ -297,31 +297,31 @@  discard block
 block discarded – undo
297 297
 	 *
298 298
 	 * @param int $post_id
299 299
 	 */
300
-	public static function save( $post_id ) {
300
+	public static function save($post_id) {
301 301
 
302 302
         // Prepare the item.
303
-        $item = new WPInv_Item( $post_id );
303
+        $item = new WPInv_Item($post_id);
304 304
 
305 305
         // Load new data.
306 306
         $item->set_props(
307 307
 			array(
308
-				'price'              => isset( $_POST['wpinv_item_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_item_price'] ) : null,
309
-				'vat_rule'           => isset( $_POST['wpinv_vat_rules'] ) ? wpinv_clean( $_POST['wpinv_vat_rules'] ) : null,
310
-				'vat_class'          => isset( $_POST['wpinv_vat_class'] ) ? wpinv_clean( $_POST['wpinv_vat_class'] ) : null,
311
-				'type'               => isset( $_POST['wpinv_item_type'] ) ? wpinv_clean( $_POST['wpinv_item_type'] ) : null,
312
-				'is_dynamic_pricing' => ! empty( $_POST['wpinv_name_your_price'] ),
313
-                'minimum_price'      => isset( $_POST['wpinv_minimum_price'] ) ? getpaid_standardize_amount( $_POST['wpinv_minimum_price'] ) : null,
314
-				'is_recurring'       => ! empty( $_POST['wpinv_is_recurring'] ),
315
-				'recurring_period'   => isset( $_POST['wpinv_recurring_period'] ) ? wpinv_clean( $_POST['wpinv_recurring_period'] ) : null,
316
-				'recurring_interval' => isset( $_POST['wpinv_recurring_interval'] ) ? (int) $_POST['wpinv_recurring_interval'] : 1,
317
-				'recurring_limit'    => isset( $_POST['wpinv_recurring_limit'] ) ? (int) $_POST['wpinv_recurring_limit'] : null,
318
-				'is_free_trial'      => isset( $_POST['wpinv_trial_interval'] ) ? ( 0 != (int) $_POST['wpinv_trial_interval'] ) : null,
319
-				'trial_period'       => isset( $_POST['wpinv_trial_period'] ) ? wpinv_clean( $_POST['wpinv_trial_period'] ) : null,
320
-				'trial_interval'     => isset( $_POST['wpinv_trial_interval'] ) ? (int) $_POST['wpinv_trial_interval'] : null,
308
+				'price'              => isset($_POST['wpinv_item_price']) ? getpaid_standardize_amount($_POST['wpinv_item_price']) : null,
309
+				'vat_rule'           => isset($_POST['wpinv_vat_rules']) ? wpinv_clean($_POST['wpinv_vat_rules']) : null,
310
+				'vat_class'          => isset($_POST['wpinv_vat_class']) ? wpinv_clean($_POST['wpinv_vat_class']) : null,
311
+				'type'               => isset($_POST['wpinv_item_type']) ? wpinv_clean($_POST['wpinv_item_type']) : null,
312
+				'is_dynamic_pricing' => !empty($_POST['wpinv_name_your_price']),
313
+                'minimum_price'      => isset($_POST['wpinv_minimum_price']) ? getpaid_standardize_amount($_POST['wpinv_minimum_price']) : null,
314
+				'is_recurring'       => !empty($_POST['wpinv_is_recurring']),
315
+				'recurring_period'   => isset($_POST['wpinv_recurring_period']) ? wpinv_clean($_POST['wpinv_recurring_period']) : null,
316
+				'recurring_interval' => isset($_POST['wpinv_recurring_interval']) ? (int) $_POST['wpinv_recurring_interval'] : 1,
317
+				'recurring_limit'    => isset($_POST['wpinv_recurring_limit']) ? (int) $_POST['wpinv_recurring_limit'] : null,
318
+				'is_free_trial'      => isset($_POST['wpinv_trial_interval']) ? (0 != (int) $_POST['wpinv_trial_interval']) : null,
319
+				'trial_period'       => isset($_POST['wpinv_trial_period']) ? wpinv_clean($_POST['wpinv_trial_period']) : null,
320
+				'trial_interval'     => isset($_POST['wpinv_trial_interval']) ? (int) $_POST['wpinv_trial_interval'] : null,
321 321
 			)
322 322
         );
323 323
 
324 324
 		$item->save();
325
-		do_action( 'getpaid_item_metabox_save', $post_id, $item );
325
+		do_action('getpaid_item_metabox_save', $post_id, $item);
326 326
 	}
327 327
 }
Please login to merge, or discard this patch.
Braces   +25 added lines, -10 removed lines patch added patch discarded remove patch
@@ -57,9 +57,12 @@  discard block
 block discarded – undo
57 57
                                         <div class="input-group-prepend">
58 58
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
59 59
                                         </div>
60
-                                    <?php else : ?>
60
+                                    <?php else {
61
+    : ?>
61 62
                                         <span class="input-group-text">
62
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
63
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
64
+}
65
+?>
63 66
                                         </span>
64 67
                                     <?php endif; ?>
65 68
                                 <?php endif; ?>
@@ -71,9 +74,12 @@  discard block
 block discarded – undo
71 74
                                         <div class="input-group-append">
72 75
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
73 76
                                         </div>
74
-                                    <?php else : ?>
77
+                                    <?php else {
78
+    : ?>
75 79
                                         <span class="input-group-text">
76
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
80
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
81
+}
82
+?>
77 83
                                         </span>
78 84
                                     <?php endif; ?>
79 85
                                 <?php endif; ?>
@@ -83,8 +89,11 @@  discard block
 block discarded – undo
83 89
                             <div class="mb-3 input-group input-group-sm">
84 90
                                 <?php if ( empty( $aui_bs5 ) ) : ?>
85 91
                                     <div class="input-group-prepend"><span class="input-group-text pl-0 pr-2 border-0 bg-transparent"><?php esc_html_e( 'every' ); ?></span></div>
86
-                                <?php else : ?>
87
-                                    <span class="input-group-text ps-0 pe-2 border-0"><?php esc_html_e( 'every' ); ?></span>
92
+                                <?php else {
93
+    : ?>
94
+                                    <span class="input-group-text ps-0 pe-2 border-0"><?php esc_html_e( 'every' );
95
+}
96
+?></span>
88 97
                                 <?php endif; ?>
89 98
                                 <input type="number" name="wpinv_recurring_interval" id="wpinv_recurring_interval" value="<?php echo esc_attr( $item->get_recurring_interval( 'edit' ) ); ?>" placeholder="1" class="form-control rounded-1 rounded-sm">
90 99
                             </div>
@@ -185,9 +194,12 @@  discard block
 block discarded – undo
185 194
                                         <div class="input-group-prepend">
186 195
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
187 196
                                         </div>
188
-                                    <?php else : ?>
197
+                                    <?php else {
198
+    : ?>
189 199
                                         <span class="input-group-text">
190
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
200
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
201
+}
202
+?>
191 203
                                         </span>
192 204
                                     <?php endif; ?>
193 205
                                 <?php endif; ?>
@@ -199,9 +211,12 @@  discard block
 block discarded – undo
199 211
                                         <div class="input-group-append">
200 212
                                             <span class="input-group-text"><?php echo wp_kses_post( wpinv_currency_symbol() ); ?></span>
201 213
                                         </div>
202
-                                    <?php else : ?>
214
+                                    <?php else {
215
+    : ?>
203 216
                                         <span class="input-group-text">
204
-                                            <?php echo wp_kses_post( wpinv_currency_symbol() ); ?>
217
+                                            <?php echo wp_kses_post( wpinv_currency_symbol() );
218
+}
219
+?>
205 220
                                         </span>
206 221
                                     <?php endif; ?>
207 222
                                 <?php endif; ?>
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 3 patches
Switch Indentation   +109 added lines, -109 removed lines patch added patch discarded remove patch
@@ -577,40 +577,40 @@  discard block
 block discarded – undo
577 577
 
578 578
 								switch ( $key ) {
579 579
 
580
-								case 'total':
581
-										echo '<strong>';
582
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
583
-										echo '</strong>';
584
-									break;
585
-
586
-								case 'relationship':
587
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
588
-									break;
589
-
590
-								case 'date':
591
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
592
-									break;
593
-
594
-								case 'status':
595
-										$status = $payment->get_status_nicename();
596
-										if ( is_admin() ) {
597
-										$status = $payment->get_status_label_html();
598
-										}
599
-
600
-										echo wp_kses_post( $status );
601
-									break;
602
-
603
-								case 'invoice':
604
-										if ( ! is_admin() ) {
605
-											$link = $payment->get_view_url();
606
-										} else {
607
-											$link = get_edit_post_link( $payment->get_id() );
608
-										}
609
-
610
-										$invoice = esc_html( $payment->get_number() );
611
-
612
-										echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
613
-									break;
580
+								    case 'total':
581
+										    echo '<strong>';
582
+										    wpinv_the_price( $payment->get_total(), $payment->get_currency() );
583
+										    echo '</strong>';
584
+									    break;
585
+
586
+								    case 'relationship':
587
+										    echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
588
+									    break;
589
+
590
+								    case 'date':
591
+									    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
592
+									    break;
593
+
594
+								    case 'status':
595
+										    $status = $payment->get_status_nicename();
596
+										    if ( is_admin() ) {
597
+										    $status = $payment->get_status_label_html();
598
+										    }
599
+
600
+										    echo wp_kses_post( $status );
601
+									    break;
602
+
603
+								    case 'invoice':
604
+										    if ( ! is_admin() ) {
605
+											    $link = $payment->get_view_url();
606
+										    } else {
607
+											    $link = get_edit_post_link( $payment->get_id() );
608
+										    }
609
+
610
+										    $invoice = esc_html( $payment->get_number() );
611
+
612
+										    echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
613
+									    break;
614 614
 										}
615 615
 
616 616
 								echo '</td>';
@@ -705,37 +705,37 @@  discard block
 block discarded – undo
705 705
 
706 706
 								switch ( $key ) {
707 707
 
708
-								case 'item_name':
709
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
710
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
708
+								    case 'item_name':
709
+										    $item_name = get_the_title( $subscription_group_item['item_id'] );
710
+										    $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
711 711
 
712
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
713
-										echo esc_html( $item_name );
714
-										} else {
715
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
716
-											}
712
+										    if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
713
+										    echo esc_html( $item_name );
714
+										    } else {
715
+										    printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
716
+											    }
717 717
 
718
-									break;
718
+									    break;
719 719
 
720
-								case 'price':
721
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
722
-									break;
720
+								    case 'price':
721
+									    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
722
+									    break;
723 723
 
724
-								case 'tax':
725
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
726
-									break;
724
+								    case 'tax':
725
+									    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
726
+									    break;
727 727
 
728
-								case 'discount':
729
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
730
-									break;
728
+								    case 'discount':
729
+									    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
730
+									    break;
731 731
 
732
-								case 'initial':
733
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
734
-									break;
732
+								    case 'initial':
733
+									    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
734
+									    break;
735 735
 
736
-								case 'recurring':
737
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
738
-									break;
736
+								    case 'recurring':
737
+										    echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
738
+									    break;
739 739
 
740 740
 										}
741 741
 
@@ -759,29 +759,29 @@  discard block
 block discarded – undo
759 759
 
760 760
 								switch ( $key ) {
761 761
 
762
-								case 'item_name':
763
-										echo esc_html( $subscription_group_fee['name'] );
764
-									break;
762
+								    case 'item_name':
763
+										    echo esc_html( $subscription_group_fee['name'] );
764
+									    break;
765 765
 
766
-								case 'price':
767
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
768
-									break;
766
+								    case 'price':
767
+									    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
768
+									    break;
769 769
 
770
-								case 'tax':
771
-									echo '&mdash;';
772
-									break;
770
+								    case 'tax':
771
+									    echo '&mdash;';
772
+									    break;
773 773
 
774
-								case 'discount':
775
-										echo '&mdash;';
776
-									break;
774
+								    case 'discount':
775
+										    echo '&mdash;';
776
+									    break;
777 777
 
778
-								case 'initial':
779
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
780
-									break;
778
+								    case 'initial':
779
+									    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
780
+									    break;
781 781
 
782
-								case 'recurring':
783
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
784
-									break;
782
+								    case 'recurring':
783
+										    echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
784
+									    break;
785 785
 
786 786
 										}
787 787
 
@@ -886,39 +886,39 @@  discard block
 block discarded – undo
886 886
 
887 887
 								switch ( $key ) {
888 888
 
889
-								case 'status':
890
-										echo wp_kses_post( $_suscription->get_status_label_html() );
891
-									break;
892
-
893
-								case 'item':
894
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
895
-											echo wp_kses_post( implode( ' | ', $markup ) );
896
-									break;
897
-
898
-								case 'renewals':
899
-									$max_bills = $_suscription->get_bill_times();
900
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
901
-									break;
902
-
903
-								case 'renewal_date':
904
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
905
-									break;
906
-
907
-								case 'start_date':
908
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
909
-									break;
910
-
911
-								case 'subscription':
912
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
913
-										printf(
914
-                                            '%1$s#%2$s%3$s',
915
-                                            '<a href="' . esc_url( $url ) . '">',
916
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
917
-											'</a>'
918
-                                        );
919
-
920
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
921
-									break;
889
+								    case 'status':
890
+										    echo wp_kses_post( $_suscription->get_status_label_html() );
891
+									    break;
892
+
893
+								    case 'item':
894
+											    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
895
+											    echo wp_kses_post( implode( ' | ', $markup ) );
896
+									    break;
897
+
898
+								    case 'renewals':
899
+									    $max_bills = $_suscription->get_bill_times();
900
+									    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
901
+									    break;
902
+
903
+								    case 'renewal_date':
904
+										    echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
905
+									    break;
906
+
907
+								    case 'start_date':
908
+										    echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
909
+									    break;
910
+
911
+								    case 'subscription':
912
+										    $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
913
+										    printf(
914
+                                                '%1$s#%2$s%3$s',
915
+                                                '<a href="' . esc_url( $url ) . '">',
916
+                                                '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
917
+											    '</a>'
918
+                                            );
919
+
920
+											    echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
921
+									    break;
922 922
 
923 923
 										}
924 924
 
Please login to merge, or discard this patch.
Indentation   +484 added lines, -484 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,28 +22,28 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-				aui()->alert(
28
+                aui()->alert(
29 29
                     array(
30
-						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-					),
33
-					true
30
+                        'type'    => 'danger',
31
+                        'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                    ),
33
+                    true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+                } elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
37 37
 
38
-				// Display a single subscription.
39
-				wpinv_recurring_subscription_details();
40
-				} else {
38
+                // Display a single subscription.
39
+                wpinv_recurring_subscription_details();
40
+                } else {
41 41
 
42
-				// Display a list of available subscriptions.
43
-				getpaid_print_subscriptions_list();
44
-				}
42
+                // Display a list of available subscriptions.
43
+                getpaid_print_subscriptions_list();
44
+                }
45 45
 
46
-			?>
46
+            ?>
47 47
 
48 48
 		</div>
49 49
 	</div>
@@ -60,10 +60,10 @@  discard block
 block discarded – undo
60 60
  */
61 61
 function getpaid_print_subscriptions_list() {
62 62
 
63
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
64
-	$subscribers_table->prepare_items();
63
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
64
+    $subscribers_table->prepare_items();
65 65
 
66
-	?>
66
+    ?>
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
@@ -82,42 +82,42 @@  discard block
 block discarded – undo
82 82
  */
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85
-	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
85
+    // Fetch the subscription.
86
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
87
+    if ( ! $sub->exists() ) {
88 88
 
89
-		aui()->alert(
90
-			array(
91
-				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
93
-			),
94
-			true
95
-		);
89
+        aui()->alert(
90
+            array(
91
+                'type'    => 'danger',
92
+                'content' => __( 'Subscription not found.', 'invoicing' ),
93
+            ),
94
+            true
95
+        );
96 96
 
97
-		return;
98
-	}
97
+        return;
98
+    }
99 99
 
100
-	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
100
+    // Use metaboxes to display the subscription details.
101
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
103 103
 
104
-	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
104
+    $subscription_id     = $sub->get_id();
105
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
+    $subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
110
-	}
108
+    if ( 1 < count( $subscription_groups ) ) {
109
+        add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
110
+    }
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
114
-	}
112
+    if ( ! empty( $subscription_group ) ) {
113
+        add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
114
+    }
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
119 119
 
120
-	?>
120
+    ?>
121 121
 
122 122
 		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
123 123
 
@@ -157,49 +157,49 @@  discard block
 block discarded – undo
157 157
  */
158 158
 function getpaid_admin_subscription_details_metabox( $sub ) {
159 159
 
160
-	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
163
-
164
-	// Prepare subscription detail columns.
165
-	$fields = apply_filters(
166
-		'getpaid_subscription_admin_page_fields',
167
-		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
-			'item'         => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ),
175
-			'gateway'      => __( 'Payment Method', 'invoicing' ),
176
-			'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
-			'status'       => __( 'Status', 'invoicing' ),
178
-		)
179
-	);
180
-
181
-	if ( ! $sub->is_active() ) {
182
-
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
185
-		}
186
-
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
189
-		}
190
-	} elseif ( $sub->is_last_renewal() ) {
191
-
192
-		if ( isset( $fields['renews_on'] ) ) {
193
-			$fields['renews_on'] = __( 'End Date', 'invoicing' );
194
-		}
195
-	}
196
-
197
-	$profile_id = $sub->get_profile_id();
198
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
-		unset( $fields['profile_id'] );
200
-	}
201
-
202
-	?>
160
+    // Subscription items.
161
+    $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
+    $items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
163
+
164
+    // Prepare subscription detail columns.
165
+    $fields = apply_filters(
166
+        'getpaid_subscription_admin_page_fields',
167
+        array(
168
+            'subscription' => __( 'Subscription', 'invoicing' ),
169
+            'customer'     => __( 'Customer', 'invoicing' ),
170
+            'amount'       => __( 'Amount', 'invoicing' ),
171
+            'start_date'   => __( 'Start Date', 'invoicing' ),
172
+            'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
+            'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
+            'item'         => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ),
175
+            'gateway'      => __( 'Payment Method', 'invoicing' ),
176
+            'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
+            'status'       => __( 'Status', 'invoicing' ),
178
+        )
179
+    );
180
+
181
+    if ( ! $sub->is_active() ) {
182
+
183
+        if ( isset( $fields['renews_on'] ) ) {
184
+            unset( $fields['renews_on'] );
185
+        }
186
+
187
+        if ( isset( $fields['gateway'] ) ) {
188
+            unset( $fields['gateway'] );
189
+        }
190
+    } elseif ( $sub->is_last_renewal() ) {
191
+
192
+        if ( isset( $fields['renews_on'] ) ) {
193
+            $fields['renews_on'] = __( 'End Date', 'invoicing' );
194
+        }
195
+    }
196
+
197
+    $profile_id = $sub->get_profile_id();
198
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
+        unset( $fields['profile_id'] );
200
+    }
201
+
202
+    ?>
203 203
 
204 204
 		<table class="table table-borderless" style="font-size: 14px;">
205 205
 			<tbody>
@@ -233,20 +233,20 @@  discard block
 block discarded – undo
233 233
  */
234 234
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
235 235
 
236
-	$username = __( '(Missing User)', 'invoicing' );
236
+    $username = __( '(Missing User)', 'invoicing' );
237 237
 
238
-	$user = get_userdata( $subscription->get_customer_id() );
239
-	if ( $user ) {
238
+    $user = get_userdata( $subscription->get_customer_id() );
239
+    if ( $user ) {
240 240
 
241
-		$username = sprintf(
242
-			'<a href="user-edit.php?user_id=%s">%s</a>',
243
-			absint( $user->ID ),
244
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
-		);
241
+        $username = sprintf(
242
+            '<a href="user-edit.php?user_id=%s">%s</a>',
243
+            absint( $user->ID ),
244
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
+        );
246 246
 
247
-	}
247
+    }
248 248
 
249
-	echo wp_kses_post( $username );
249
+    echo wp_kses_post( $username );
250 250
 }
251 251
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
252 252
 
@@ -256,8 +256,8 @@  discard block
 block discarded – undo
256 256
  * @param WPInv_Subscription $subscription
257 257
  */
258 258
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
259
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
-	echo wp_kses_post( "<span>$amount</span>" );
259
+    $amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
+    echo wp_kses_post( "<span>$amount</span>" );
261 261
 }
262 262
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
263 263
 
@@ -268,11 +268,11 @@  discard block
 block discarded – undo
268 268
  */
269 269
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
270 270
 
271
-	printf(
272
-		'<a href="%s">#%s</a>',
273
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
-		absint( $subscription->get_id() )
275
-	);
271
+    printf(
272
+        '<a href="%s">#%s</a>',
273
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
+        absint( $subscription->get_id() )
275
+    );
276 276
 
277 277
 }
278 278
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -284,24 +284,24 @@  discard block
 block discarded – undo
284 284
  */
285 285
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
286 286
 
287
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
288
-		aui()->input(
289
-			array(
290
-				'type'        => 'text',
291
-				'id'          => 'wpinv_subscription_date_created',
292
-				'name'        => 'wpinv_subscription_date_created',
293
-				'label'       => __( 'Start Date', 'invoicing' ),
294
-				'label_type'  => 'hidden',
295
-				'placeholder' => 'YYYY-MM-DD',
296
-				'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
297
-				'no_wrap'     => true,
298
-				'size'        => 'sm',
299
-			),
300
-			true
301
-		);
302
-	} else {
303
-		echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
304
-	}
287
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
288
+        aui()->input(
289
+            array(
290
+                'type'        => 'text',
291
+                'id'          => 'wpinv_subscription_date_created',
292
+                'name'        => 'wpinv_subscription_date_created',
293
+                'label'       => __( 'Start Date', 'invoicing' ),
294
+                'label_type'  => 'hidden',
295
+                'placeholder' => 'YYYY-MM-DD',
296
+                'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
297
+                'no_wrap'     => true,
298
+                'size'        => 'sm',
299
+            ),
300
+            true
301
+        );
302
+    } else {
303
+        echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
304
+    }
305 305
 
306 306
 }
307 307
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
@@ -313,24 +313,24 @@  discard block
 block discarded – undo
313 313
  */
314 314
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
315 315
 
316
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
317
-		aui()->input(
318
-			array(
319
-				'type'        => 'text',
320
-				'id'          => 'wpinv_subscription_expiration',
321
-				'name'        => 'wpinv_subscription_expiration',
322
-				'label'       => __( 'Renews On', 'invoicing' ),
323
-				'label_type'  => 'hidden',
324
-				'placeholder' => 'YYYY-MM-DD',
325
-				'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
326
-				'no_wrap'     => true,
327
-				'size'        => 'sm',
328
-			),
329
-			true
330
-		);
331
-	} else {
332
-		echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
333
-	}
316
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
317
+        aui()->input(
318
+            array(
319
+                'type'        => 'text',
320
+                'id'          => 'wpinv_subscription_expiration',
321
+                'name'        => 'wpinv_subscription_expiration',
322
+                'label'       => __( 'Renews On', 'invoicing' ),
323
+                'label_type'  => 'hidden',
324
+                'placeholder' => 'YYYY-MM-DD',
325
+                'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
326
+                'no_wrap'     => true,
327
+                'size'        => 'sm',
328
+            ),
329
+            true
330
+        );
331
+    } else {
332
+        echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
333
+    }
334 334
 }
335 335
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
336 336
 
@@ -341,32 +341,32 @@  discard block
 block discarded – undo
341 341
  */
342 342
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
343 343
 
344
-	$max_bills    = $subscription->get_bill_times();
345
-	$times_billed = (int) $subscription->get_times_billed();
346
-
347
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
348
-		aui()->input(
349
-			array(
350
-				'type'             => 'number',
351
-				'id'               => 'wpinv_subscription_max_bill_times',
352
-				'name'             => 'wpinv_subscription_max_bill_times',
353
-				'label'            => __( 'Maximum bill times', 'invoicing' ),
354
-				'label_type'       => 'hidden',
355
-				'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
-				'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
357
-				'no_wrap'          => true,
358
-				'size'             => 'sm',
359
-				'input_group_left' => sprintf(
360
-					// translators: %d: Number of times billed
361
-					__( '%d of', 'invoicing' ),
362
-					$times_billed
363
-				),
364
-			),
365
-			true
366
-		);
367
-	} else {
368
-		echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
369
-	}
344
+    $max_bills    = $subscription->get_bill_times();
345
+    $times_billed = (int) $subscription->get_times_billed();
346
+
347
+    if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
348
+        aui()->input(
349
+            array(
350
+                'type'             => 'number',
351
+                'id'               => 'wpinv_subscription_max_bill_times',
352
+                'name'             => 'wpinv_subscription_max_bill_times',
353
+                'label'            => __( 'Maximum bill times', 'invoicing' ),
354
+                'label_type'       => 'hidden',
355
+                'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
+                'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
357
+                'no_wrap'          => true,
358
+                'size'             => 'sm',
359
+                'input_group_left' => sprintf(
360
+                    // translators: %d: Number of times billed
361
+                    __( '%d of', 'invoicing' ),
362
+                    $times_billed
363
+                ),
364
+            ),
365
+            true
366
+        );
367
+    } else {
368
+        echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
369
+    }
370 370
 }
371 371
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
372 372
 
@@ -378,13 +378,13 @@  discard block
 block discarded – undo
378 378
  */
379 379
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
380 380
 
381
-	if ( empty( $subscription_group ) ) {
382
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
383
-		return;
384
-	}
381
+    if ( empty( $subscription_group ) ) {
382
+        echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
383
+        return;
384
+    }
385 385
 
386
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
-	echo wp_kses_post( implode( ' | ', $markup ) );
386
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
+    echo wp_kses_post( implode( ' | ', $markup ) );
388 388
 
389 389
 }
390 390
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -396,13 +396,13 @@  discard block
 block discarded – undo
396 396
  */
397 397
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
398 398
 
399
-	$gateway = $subscription->get_gateway();
399
+    $gateway = $subscription->get_gateway();
400 400
 
401
-	if ( ! empty( $gateway ) ) {
402
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
403
-	} else {
404
-		echo '&mdash;';
405
-	}
401
+    if ( ! empty( $gateway ) ) {
402
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
403
+    } else {
404
+        echo '&mdash;';
405
+    }
406 406
 
407 407
 }
408 408
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
  * @param WPInv_Subscription $subscription
414 414
  */
415 415
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
416
-	echo wp_kses_post( $subscription->get_status_label_html() );
416
+    echo wp_kses_post( $subscription->get_status_label_html() );
417 417
 }
418 418
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
419 419
 
@@ -424,28 +424,28 @@  discard block
 block discarded – undo
424 424
  */
425 425
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
426 426
 
427
-	$profile_id = $subscription->get_profile_id();
428
-
429
-	aui()->input(
430
-		array(
431
-			'type'              => 'text',
432
-			'id'                => 'wpinv_subscription_profile_id',
433
-			'name'              => 'wpinv_subscription_profile_id',
434
-			'label'             => __( 'Profile Id', 'invoicing' ),
435
-			'label_type'        => 'hidden',
436
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
-			'value'             => esc_attr( $profile_id ),
438
-			'input_group_right' => '',
439
-			'no_wrap'           => true,
440
-			'size'              => 'sm',
441
-		),
442
-		true
443
-	);
444
-
445
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
-	if ( ! empty( $url ) ) {
447
-		echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448
-	}
427
+    $profile_id = $subscription->get_profile_id();
428
+
429
+    aui()->input(
430
+        array(
431
+            'type'              => 'text',
432
+            'id'                => 'wpinv_subscription_profile_id',
433
+            'name'              => 'wpinv_subscription_profile_id',
434
+            'label'             => __( 'Profile Id', 'invoicing' ),
435
+            'label_type'        => 'hidden',
436
+            'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
+            'value'             => esc_attr( $profile_id ),
438
+            'input_group_right' => '',
439
+            'no_wrap'           => true,
440
+            'size'              => 'sm',
441
+        ),
442
+        true
443
+    );
444
+
445
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
+    if ( ! empty( $url ) ) {
447
+        echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448
+    }
449 449
 
450 450
 }
451 451
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -456,40 +456,40 @@  discard block
 block discarded – undo
456 456
  * @param WPInv_Subscription $subscription
457 457
  */
458 458
 function getpaid_admin_subscription_update_metabox( $subscription ) {
459
-	global $aui_bs5;
459
+    global $aui_bs5;
460 460
 
461
-	?>
461
+    ?>
462 462
 	<div class="mt-3">
463 463
 		<?php
464
-			aui()->select(
465
-				array(
466
-					'options'   => getpaid_get_subscription_statuses(),
467
-					'name'      => 'subscription_status',
468
-					'id'        => 'subscription_status_update_select',
469
-					'required'  => true,
470
-					'no_wrap'   => false,
471
-					'label'     => __( 'Subscription Status', 'invoicing' ),
472
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
473
-					'select2'   => true,
474
-					'value'     => $subscription->get_status( 'edit' ),
475
-				),
476
-				true
477
-			);
478
-		?>
464
+            aui()->select(
465
+                array(
466
+                    'options'   => getpaid_get_subscription_statuses(),
467
+                    'name'      => 'subscription_status',
468
+                    'id'        => 'subscription_status_update_select',
469
+                    'required'  => true,
470
+                    'no_wrap'   => false,
471
+                    'label'     => __( 'Subscription Status', 'invoicing' ),
472
+                    'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
473
+                    'select2'   => true,
474
+                    'value'     => $subscription->get_status( 'edit' ),
475
+                ),
476
+                true
477
+            );
478
+        ?>
479 479
 
480 480
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin:-12px">
481 481
 		<?php
482
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
482
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
483 483
 
484
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
485
-			$anchor = __( 'Renew Subscription', 'invoicing' );
486
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
484
+            $url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
485
+            $anchor = __( 'Renew Subscription', 'invoicing' );
486
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
487 487
 
488
-			if ( $subscription->is_active() ) {
489
-				echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>";
490
-			}
488
+            if ( $subscription->is_active() ) {
489
+                echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>";
490
+            }
491 491
 
492
-	echo '</div></div>';
492
+    echo '</div></div>';
493 493
 }
494 494
 
495 495
 /**
@@ -500,33 +500,33 @@  discard block
 block discarded – undo
500 500
  */
501 501
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
502 502
 
503
-	$columns = apply_filters(
504
-		'getpaid_subscription_related_invoices_columns',
505
-		array(
506
-			'invoice'      => __( 'Invoice', 'invoicing' ),
507
-			'relationship' => __( 'Relationship', 'invoicing' ),
508
-			'date'         => __( 'Date', 'invoicing' ),
509
-			'status'       => __( 'Status', 'invoicing' ),
510
-			'total'        => __( 'Total', 'invoicing' ),
511
-		),
512
-		$subscription
513
-	);
514
-
515
-	// Prepare the invoices.
516
-	$payments = $subscription->get_child_payments( ! is_admin() );
517
-	$parent   = $subscription->get_parent_invoice();
518
-
519
-	if ( $parent->exists() ) {
520
-		$payments = array_merge( array( $parent ), $payments );
521
-	}
522
-
523
-	$table_class = 'w-100 bg-white';
524
-
525
-	if ( ! is_admin() ) {
526
-		$table_class = 'table table-bordered';
527
-	}
528
-
529
-	?>
503
+    $columns = apply_filters(
504
+        'getpaid_subscription_related_invoices_columns',
505
+        array(
506
+            'invoice'      => __( 'Invoice', 'invoicing' ),
507
+            'relationship' => __( 'Relationship', 'invoicing' ),
508
+            'date'         => __( 'Date', 'invoicing' ),
509
+            'status'       => __( 'Status', 'invoicing' ),
510
+            'total'        => __( 'Total', 'invoicing' ),
511
+        ),
512
+        $subscription
513
+    );
514
+
515
+    // Prepare the invoices.
516
+    $payments = $subscription->get_child_payments( ! is_admin() );
517
+    $parent   = $subscription->get_parent_invoice();
518
+
519
+    if ( $parent->exists() ) {
520
+        $payments = array_merge( array( $parent ), $payments );
521
+    }
522
+
523
+    $table_class = 'w-100 bg-white';
524
+
525
+    if ( ! is_admin() ) {
526
+        $table_class = 'table table-bordered';
527
+    }
528
+
529
+    ?>
530 530
 		<div class="m-0" style="overflow: auto;">
531 531
 
532 532
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -534,10 +534,10 @@  discard block
 block discarded – undo
534 534
 				<thead>
535 535
 					<tr>
536 536
 						<?php
537
-							foreach ( $columns as $key => $label ) {
538
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
539
-							}
540
-						?>
537
+                            foreach ( $columns as $key => $label ) {
538
+                            echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
539
+                            }
540
+                        ?>
541 541
 					</tr>
542 542
 				</thead>
543 543
 
@@ -553,73 +553,73 @@  discard block
 block discarded – undo
553 553
 
554 554
 					<?php
555 555
 
556
-						foreach ( $payments as $payment ) :
556
+                        foreach ( $payments as $payment ) :
557 557
 
558
-						// Ensure that we have an invoice.
559
-						$payment = new WPInv_Invoice( $payment );
558
+                        // Ensure that we have an invoice.
559
+                        $payment = new WPInv_Invoice( $payment );
560 560
 
561
-						// Abort if the invoice is invalid...
562
-						if ( ! $payment->exists() ) {
563
-							continue;
564
-							}
561
+                        // Abort if the invoice is invalid...
562
+                        if ( ! $payment->exists() ) {
563
+                            continue;
564
+                            }
565 565
 
566
-						// ... or belongs to a different subscription.
567
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
568
-							continue;
569
-							}
566
+                        // ... or belongs to a different subscription.
567
+                        if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
568
+                            continue;
569
+                            }
570 570
 
571
-						echo '<tr>';
571
+                        echo '<tr>';
572 572
 
573
-						foreach ( array_keys( $columns ) as $key ) {
573
+                        foreach ( array_keys( $columns ) as $key ) {
574 574
 
575
-							echo "<td class='p-2 text-left'>";
575
+                            echo "<td class='p-2 text-left'>";
576 576
 
577
-								switch ( $key ) {
577
+                                switch ( $key ) {
578 578
 
579
-								case 'total':
580
-										echo '<strong>';
581
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
582
-										echo '</strong>';
583
-									break;
579
+                                case 'total':
580
+                                        echo '<strong>';
581
+                                        wpinv_the_price( $payment->get_total(), $payment->get_currency() );
582
+                                        echo '</strong>';
583
+                                    break;
584 584
 
585
-								case 'relationship':
586
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
587
-									break;
585
+                                case 'relationship':
586
+                                        echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
587
+                                    break;
588 588
 
589
-								case 'date':
590
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
591
-									break;
589
+                                case 'date':
590
+                                    echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
591
+                                    break;
592 592
 
593
-								case 'status':
594
-										$status = $payment->get_status_nicename();
595
-										if ( is_admin() ) {
596
-										$status = $payment->get_status_label_html();
597
-										}
593
+                                case 'status':
594
+                                        $status = $payment->get_status_nicename();
595
+                                        if ( is_admin() ) {
596
+                                        $status = $payment->get_status_label_html();
597
+                                        }
598 598
 
599
-										echo wp_kses_post( $status );
600
-									break;
599
+                                        echo wp_kses_post( $status );
600
+                                    break;
601 601
 
602
-								case 'invoice':
603
-										if ( ! is_admin() ) {
604
-											$link = $payment->get_view_url();
605
-										} else {
606
-											$link = get_edit_post_link( $payment->get_id() );
607
-										}
602
+                                case 'invoice':
603
+                                        if ( ! is_admin() ) {
604
+                                            $link = $payment->get_view_url();
605
+                                        } else {
606
+                                            $link = get_edit_post_link( $payment->get_id() );
607
+                                        }
608 608
 
609
-										$invoice = esc_html( $payment->get_number() );
609
+                                        $invoice = esc_html( $payment->get_number() );
610 610
 
611
-										echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
612
-									break;
613
-										}
611
+                                        echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
612
+                                    break;
613
+                                        }
614 614
 
615
-								echo '</td>';
615
+                                echo '</td>';
616 616
 
617
-							}
617
+                            }
618 618
 
619
-						echo '</tr>';
619
+                        echo '</tr>';
620 620
 
621
-						endforeach;
622
-					?>
621
+                        endforeach;
622
+                    ?>
623 623
 
624 624
 				</tbody>
625 625
 
@@ -637,42 +637,42 @@  discard block
 block discarded – undo
637 637
  */
638 638
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
639 639
 
640
-	// Fetch the subscription group.
641
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
640
+    // Fetch the subscription group.
641
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
642 642
 
643
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
644
-		return;
645
-	}
643
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
644
+        return;
645
+    }
646 646
 
647
-	// Prepare table columns.
648
-	$columns = apply_filters(
649
-		'getpaid_subscription_item_details_columns',
650
-		array(
651
-			'item_name' => __( 'Item', 'invoicing' ),
652
-			'price'     => __( 'Price', 'invoicing' ),
653
-			'tax'       => __( 'Tax', 'invoicing' ),
654
-			'discount'  => __( 'Discount', 'invoicing' ),
655
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
656
-			'recurring' => __( 'Subtotal', 'invoicing' ),
657
-		),
658
-		$subscription
659
-	);
647
+    // Prepare table columns.
648
+    $columns = apply_filters(
649
+        'getpaid_subscription_item_details_columns',
650
+        array(
651
+            'item_name' => __( 'Item', 'invoicing' ),
652
+            'price'     => __( 'Price', 'invoicing' ),
653
+            'tax'       => __( 'Tax', 'invoicing' ),
654
+            'discount'  => __( 'Discount', 'invoicing' ),
655
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
656
+            'recurring' => __( 'Subtotal', 'invoicing' ),
657
+        ),
658
+        $subscription
659
+    );
660 660
 
661
-	// Prepare the invoices.
661
+    // Prepare the invoices.
662 662
 
663
-	$invoice = $subscription->get_parent_invoice();
663
+    $invoice = $subscription->get_parent_invoice();
664 664
 
665
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
-		unset( $columns['tax'] );
667
-	}
665
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
+        unset( $columns['tax'] );
667
+    }
668 668
 
669
-	$table_class = 'w-100 bg-white';
669
+    $table_class = 'w-100 bg-white';
670 670
 
671
-	if ( ! is_admin() ) {
672
-		$table_class = 'table table-bordered';
673
-	}
671
+    if ( ! is_admin() ) {
672
+        $table_class = 'table table-bordered';
673
+    }
674 674
 
675
-	?>
675
+    ?>
676 676
 		<div class="m-0" style="overflow: auto;">
677 677
 
678 678
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -681,10 +681,10 @@  discard block
 block discarded – undo
681 681
 					<tr>
682 682
 						<?php
683 683
 
684
-							foreach ( $columns as $key => $label ) {
685
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
686
-							}
687
-						?>
684
+                            foreach ( $columns as $key => $label ) {
685
+                            echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
686
+                            }
687
+                        ?>
688 688
 					</tr>
689 689
 				</thead>
690 690
 
@@ -692,106 +692,106 @@  discard block
 block discarded – undo
692 692
 
693 693
 					<?php
694 694
 
695
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
695
+                        foreach ( $subscription_group['items'] as $subscription_group_item ) :
696 696
 
697
-						echo '<tr>';
697
+                        echo '<tr>';
698 698
 
699
-						foreach ( array_keys( $columns ) as $key ) {
699
+                        foreach ( array_keys( $columns ) as $key ) {
700 700
 
701
-							$class = 'text-left';
701
+                            $class = 'text-left';
702 702
 
703
-							echo "<td class='p-2 text-left'>";
703
+                            echo "<td class='p-2 text-left'>";
704 704
 
705
-								switch ( $key ) {
705
+                                switch ( $key ) {
706 706
 
707
-								case 'item_name':
708
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
709
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
707
+                                case 'item_name':
708
+                                        $item_name = get_the_title( $subscription_group_item['item_id'] );
709
+                                        $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
710 710
 
711
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
-										echo esc_html( $item_name );
713
-										} else {
714
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
715
-											}
711
+                                        if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
+                                        echo esc_html( $item_name );
713
+                                        } else {
714
+                                        printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
715
+                                            }
716 716
 
717
-									break;
717
+                                    break;
718 718
 
719
-								case 'price':
720
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
721
-									break;
719
+                                case 'price':
720
+                                    wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
721
+                                    break;
722 722
 
723
-								case 'tax':
724
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
725
-									break;
723
+                                case 'tax':
724
+                                    wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
725
+                                    break;
726 726
 
727
-								case 'discount':
728
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
729
-									break;
727
+                                case 'discount':
728
+                                    wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
729
+                                    break;
730 730
 
731
-								case 'initial':
732
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
733
-									break;
731
+                                case 'initial':
732
+                                    wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
733
+                                    break;
734 734
 
735
-								case 'recurring':
736
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
737
-									break;
735
+                                case 'recurring':
736
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
737
+                                    break;
738 738
 
739
-										}
739
+                                        }
740 740
 
741
-								echo '</td>';
741
+                                echo '</td>';
742 742
 
743
-							}
743
+                            }
744 744
 
745
-						echo '</tr>';
745
+                        echo '</tr>';
746 746
 
747
-						endforeach;
747
+                        endforeach;
748 748
 
749
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
749
+                        foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
750 750
 
751
-						echo '<tr>';
751
+                        echo '<tr>';
752 752
 
753
-						foreach ( array_keys( $columns ) as $key ) {
753
+                        foreach ( array_keys( $columns ) as $key ) {
754 754
 
755
-							$class = 'text-left';
755
+                            $class = 'text-left';
756 756
 
757
-							echo "<td class='p-2 text-left'>";
757
+                            echo "<td class='p-2 text-left'>";
758 758
 
759
-								switch ( $key ) {
759
+                                switch ( $key ) {
760 760
 
761
-								case 'item_name':
762
-										echo esc_html( $subscription_group_fee['name'] );
763
-									break;
761
+                                case 'item_name':
762
+                                        echo esc_html( $subscription_group_fee['name'] );
763
+                                    break;
764 764
 
765
-								case 'price':
766
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
767
-									break;
765
+                                case 'price':
766
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
767
+                                    break;
768 768
 
769
-								case 'tax':
770
-									echo '&mdash;';
771
-									break;
769
+                                case 'tax':
770
+                                    echo '&mdash;';
771
+                                    break;
772 772
 
773
-								case 'discount':
774
-										echo '&mdash;';
775
-									break;
773
+                                case 'discount':
774
+                                        echo '&mdash;';
775
+                                    break;
776 776
 
777
-								case 'initial':
778
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
779
-									break;
777
+                                case 'initial':
778
+                                    wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
779
+                                    break;
780 780
 
781
-								case 'recurring':
782
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
783
-									break;
781
+                                case 'recurring':
782
+                                        echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
783
+                                    break;
784 784
 
785
-										}
785
+                                        }
786 786
 
787
-								echo '</td>';
787
+                                echo '</td>';
788 788
 
789
-							}
789
+                            }
790 790
 
791
-						echo '</tr>';
791
+                        echo '</tr>';
792 792
 
793
-						endforeach;
794
-					?>
793
+                        endforeach;
794
+                    ?>
795 795
 
796 796
 				</tbody>
797 797
 
@@ -810,38 +810,38 @@  discard block
 block discarded – undo
810 810
  */
811 811
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
812 812
 
813
-	// Fetch the subscription groups.
814
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
815
-
816
-	if ( empty( $subscription_groups ) ) {
817
-		return;
818
-	}
819
-
820
-	// Prepare table columns.
821
-	$columns = apply_filters(
822
-		'getpaid_subscription_related_subscriptions_columns',
823
-		array(
824
-			'subscription' => __( 'Subscription', 'invoicing' ),
825
-			'start_date'   => __( 'Start Date', 'invoicing' ),
826
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
-			'renewals'     => __( 'Payments', 'invoicing' ),
828
-			'item'         => __( 'Items', 'invoicing' ),
829
-			'status'       => __( 'Status', 'invoicing' ),
830
-		),
831
-		$subscription
832
-	);
833
-
834
-	if ( $subscription->get_status() == 'pending' ) {
835
-		unset( $columns['start_date'], $columns['renewal_date'] );
836
-	}
837
-
838
-	$table_class = 'w-100 bg-white';
839
-
840
-	if ( ! is_admin() ) {
841
-		$table_class = 'table table-bordered';
842
-	}
843
-
844
-	?>
813
+    // Fetch the subscription groups.
814
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
815
+
816
+    if ( empty( $subscription_groups ) ) {
817
+        return;
818
+    }
819
+
820
+    // Prepare table columns.
821
+    $columns = apply_filters(
822
+        'getpaid_subscription_related_subscriptions_columns',
823
+        array(
824
+            'subscription' => __( 'Subscription', 'invoicing' ),
825
+            'start_date'   => __( 'Start Date', 'invoicing' ),
826
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
+            'renewals'     => __( 'Payments', 'invoicing' ),
828
+            'item'         => __( 'Items', 'invoicing' ),
829
+            'status'       => __( 'Status', 'invoicing' ),
830
+        ),
831
+        $subscription
832
+    );
833
+
834
+    if ( $subscription->get_status() == 'pending' ) {
835
+        unset( $columns['start_date'], $columns['renewal_date'] );
836
+    }
837
+
838
+    $table_class = 'w-100 bg-white';
839
+
840
+    if ( ! is_admin() ) {
841
+        $table_class = 'table table-bordered';
842
+    }
843
+
844
+    ?>
845 845
 		<div class="m-0" style="overflow: auto;">
846 846
 
847 847
 			<table class="<?php echo esc_attr( $table_class ); ?>">
@@ -850,10 +850,10 @@  discard block
 block discarded – undo
850 850
 					<tr>
851 851
 						<?php
852 852
 
853
-							foreach ( $columns as $key => $label ) {
854
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
855
-							}
856
-						?>
853
+                            foreach ( $columns as $key => $label ) {
854
+                            echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
855
+                            }
856
+                        ?>
857 857
 					</tr>
858 858
 				</thead>
859 859
 
@@ -861,74 +861,74 @@  discard block
 block discarded – undo
861 861
 
862 862
 					<?php
863 863
 
864
-						foreach ( $subscription_groups as $subscription_group ) :
864
+                        foreach ( $subscription_groups as $subscription_group ) :
865 865
 
866
-						// Do not list current subscription.
867
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
868
-							continue;
869
-							}
866
+                        // Do not list current subscription.
867
+                        if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
868
+                            continue;
869
+                            }
870 870
 
871
-						// Ensure the subscription exists.
872
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
871
+                        // Ensure the subscription exists.
872
+                        $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
873 873
 
874
-						if ( ! $_suscription->exists() ) {
875
-							continue;
876
-							}
874
+                        if ( ! $_suscription->exists() ) {
875
+                            continue;
876
+                            }
877 877
 
878
-						echo '<tr>';
878
+                        echo '<tr>';
879 879
 
880
-						foreach ( array_keys( $columns ) as $key ) {
880
+                        foreach ( array_keys( $columns ) as $key ) {
881 881
 
882
-							$class = 'text-left';
882
+                            $class = 'text-left';
883 883
 
884
-							echo "<td class='p-2 text-left'>";
884
+                            echo "<td class='p-2 text-left'>";
885 885
 
886
-								switch ( $key ) {
886
+                                switch ( $key ) {
887 887
 
888
-								case 'status':
889
-										echo wp_kses_post( $_suscription->get_status_label_html() );
890
-									break;
888
+                                case 'status':
889
+                                        echo wp_kses_post( $_suscription->get_status_label_html() );
890
+                                    break;
891 891
 
892
-								case 'item':
893
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
-											echo wp_kses_post( implode( ' | ', $markup ) );
895
-									break;
892
+                                case 'item':
893
+                                            $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
+                                            echo wp_kses_post( implode( ' | ', $markup ) );
895
+                                    break;
896 896
 
897
-								case 'renewals':
898
-									$max_bills = $_suscription->get_bill_times();
899
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
900
-									break;
897
+                                case 'renewals':
898
+                                    $max_bills = $_suscription->get_bill_times();
899
+                                    echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
900
+                                    break;
901 901
 
902
-								case 'renewal_date':
903
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
904
-									break;
902
+                                case 'renewal_date':
903
+                                        echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
904
+                                    break;
905 905
 
906
-								case 'start_date':
907
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
908
-									break;
906
+                                case 'start_date':
907
+                                        echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
908
+                                    break;
909 909
 
910
-								case 'subscription':
911
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
912
-										printf(
910
+                                case 'subscription':
911
+                                        $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
912
+                                        printf(
913 913
                                             '%1$s#%2$s%3$s',
914 914
                                             '<a href="' . esc_url( $url ) . '">',
915 915
                                             '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
916
-											'</a>'
916
+                                            '</a>'
917 917
                                         );
918 918
 
919
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
920
-									break;
919
+                                            echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
920
+                                    break;
921 921
 
922
-										}
922
+                                        }
923 923
 
924
-								echo '</td>';
924
+                                echo '</td>';
925 925
 
926
-							}
926
+                            }
927 927
 
928
-						echo '</tr>';
928
+                        echo '</tr>';
929 929
 
930
-						endforeach;
931
-					?>
930
+                        endforeach;
931
+                    ?>
932 932
 
933 933
 				</tbody>
934 934
 
Please login to merge, or discard this patch.
Spacing   +216 added lines, -216 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,23 +17,23 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 				aui()->alert(
29 29
                     array(
30 30
 						'type'    => 'danger',
31
-						'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+						'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 					),
33 33
 					true
34 34
                 );
35 35
 
36
-				} elseif ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36
+				} elseif (!empty($_GET['id']) && is_numeric($_GET['id'])) {
37 37
 
38 38
 				// Display a single subscription.
39 39
 				wpinv_recurring_subscription_details();
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 	<?php $subscribers_table->views(); ?>
68 68
 	<form id="subscribers-filter" class="bsui" method="get">
69 69
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
70
-		<?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?>
70
+		<?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?>
71 71
 		<?php $subscribers_table->display(); ?>
72 72
 	</form>
73 73
 	<?php
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
 function wpinv_recurring_subscription_details() {
84 84
 
85 85
 	// Fetch the subscription.
86
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
87
-	if ( ! $sub->exists() ) {
86
+	$sub = new WPInv_Subscription((int) $_GET['id']);
87
+	if (!$sub->exists()) {
88 88
 
89 89
 		aui()->alert(
90 90
 			array(
91 91
 				'type'    => 'danger',
92
-				'content' => __( 'Subscription not found.', 'invoicing' ),
92
+				'content' => __('Subscription not found.', 'invoicing'),
93 93
 			),
94 94
 			true
95 95
 		);
@@ -98,32 +98,32 @@  discard block
 block discarded – undo
98 98
 	}
99 99
 
100 100
 	// Use metaboxes to display the subscription details.
101
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
102
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
101
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
102
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
103 103
 
104 104
 	$subscription_id     = $sub->get_id();
105
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
106
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
105
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
106
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
107 107
 
108
-	if ( 1 < count( $subscription_groups ) ) {
109
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
+	if (1 < count($subscription_groups)) {
109
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
110 110
 	}
111 111
 
112
-	if ( ! empty( $subscription_group ) ) {
113
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
+	if (!empty($subscription_group)) {
113
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
114 114
 	}
115 115
 
116
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
116
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
117 117
 
118
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
118
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
119 119
 
120 120
 	?>
121 121
 
122
-		<form method="post" action="<?php echo esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ) ); ?>">
122
+		<form method="post" action="<?php echo esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id()))); ?>">
123 123
 
124
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
125
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
126
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
124
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
125
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
126
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
127 127
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
128 128
 			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
129 129
 
@@ -131,12 +131,12 @@  discard block
 block discarded – undo
131 131
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
132 132
 
133 133
 					<div id="postbox-container-1" class="postbox-container">
134
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
134
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
135 135
 					</div>
136 136
 
137 137
 					<div id="postbox-container-2" class="postbox-container">
138
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
139
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
138
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
139
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
140 140
 					</div>
141 141
 
142 142
 				</div>
@@ -155,48 +155,48 @@  discard block
 block discarded – undo
155 155
  *
156 156
  * @param WPInv_Subscription $sub
157 157
  */
158
-function getpaid_admin_subscription_details_metabox( $sub ) {
158
+function getpaid_admin_subscription_details_metabox($sub) {
159 159
 
160 160
 	// Subscription items.
161
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
162
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
162
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
163 163
 
164 164
 	// Prepare subscription detail columns.
165 165
 	$fields = apply_filters(
166 166
 		'getpaid_subscription_admin_page_fields',
167 167
 		array(
168
-			'subscription' => __( 'Subscription', 'invoicing' ),
169
-			'customer'     => __( 'Customer', 'invoicing' ),
170
-			'amount'       => __( 'Amount', 'invoicing' ),
171
-			'start_date'   => __( 'Start Date', 'invoicing' ),
172
-			'renews_on'    => __( 'Next Payment', 'invoicing' ),
173
-			'renewals'     => __( 'Collected Payments', 'invoicing' ),
174
-			'item'         => $items_count > 1 ? __( 'Items', 'invoicing' ) : __( 'Item', 'invoicing' ),
175
-			'gateway'      => __( 'Payment Method', 'invoicing' ),
176
-			'profile_id'   => __( 'Profile ID', 'invoicing' ),
177
-			'status'       => __( 'Status', 'invoicing' ),
168
+			'subscription' => __('Subscription', 'invoicing'),
169
+			'customer'     => __('Customer', 'invoicing'),
170
+			'amount'       => __('Amount', 'invoicing'),
171
+			'start_date'   => __('Start Date', 'invoicing'),
172
+			'renews_on'    => __('Next Payment', 'invoicing'),
173
+			'renewals'     => __('Collected Payments', 'invoicing'),
174
+			'item'         => $items_count > 1 ? __('Items', 'invoicing') : __('Item', 'invoicing'),
175
+			'gateway'      => __('Payment Method', 'invoicing'),
176
+			'profile_id'   => __('Profile ID', 'invoicing'),
177
+			'status'       => __('Status', 'invoicing'),
178 178
 		)
179 179
 	);
180 180
 
181
-	if ( ! $sub->is_active() ) {
181
+	if (!$sub->is_active()) {
182 182
 
183
-		if ( isset( $fields['renews_on'] ) ) {
184
-			unset( $fields['renews_on'] );
183
+		if (isset($fields['renews_on'])) {
184
+			unset($fields['renews_on']);
185 185
 		}
186 186
 
187
-		if ( isset( $fields['gateway'] ) ) {
188
-			unset( $fields['gateway'] );
187
+		if (isset($fields['gateway'])) {
188
+			unset($fields['gateway']);
189 189
 		}
190
-	} elseif ( $sub->is_last_renewal() ) {
190
+	} elseif ($sub->is_last_renewal()) {
191 191
 
192
-		if ( isset( $fields['renews_on'] ) ) {
193
-			$fields['renews_on'] = __( 'End Date', 'invoicing' );
192
+		if (isset($fields['renews_on'])) {
193
+			$fields['renews_on'] = __('End Date', 'invoicing');
194 194
 		}
195 195
 	}
196 196
 
197 197
 	$profile_id = $sub->get_profile_id();
198
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
199
-		unset( $fields['profile_id'] );
198
+	if (empty($profile_id) && isset($fields['profile_id'])) {
199
+		unset($fields['profile_id']);
200 200
 	}
201 201
 
202 202
 	?>
@@ -204,16 +204,16 @@  discard block
 block discarded – undo
204 204
 		<table class="table table-borderless" style="font-size: 14px;">
205 205
 			<tbody>
206 206
 
207
-				<?php foreach ( $fields as $key => $label ) : ?>
207
+				<?php foreach ($fields as $key => $label) : ?>
208 208
 
209
-					<tr class="getpaid-subscription-meta-<?php echo esc_attr( $key ); ?>">
209
+					<tr class="getpaid-subscription-meta-<?php echo esc_attr($key); ?>">
210 210
 
211 211
 						<th class="w-25" style="font-weight: 500;">
212
-							<?php echo esc_html( $label ); ?>
212
+							<?php echo esc_html($label); ?>
213 213
 						</th>
214 214
 
215 215
 						<td class="w-75 text-muted">
216
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
216
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
217 217
 						</td>
218 218
 
219 219
 					</tr>
@@ -231,144 +231,144 @@  discard block
 block discarded – undo
231 231
  *
232 232
  * @param WPInv_Subscription $subscription
233 233
  */
234
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
234
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
235 235
 
236
-	$username = __( '(Missing User)', 'invoicing' );
236
+	$username = __('(Missing User)', 'invoicing');
237 237
 
238
-	$user = get_userdata( $subscription->get_customer_id() );
239
-	if ( $user ) {
238
+	$user = get_userdata($subscription->get_customer_id());
239
+	if ($user) {
240 240
 
241 241
 		$username = sprintf(
242 242
 			'<a href="user-edit.php?user_id=%s">%s</a>',
243
-			absint( $user->ID ),
244
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
243
+			absint($user->ID),
244
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
245 245
 		);
246 246
 
247 247
 	}
248 248
 
249
-	echo wp_kses_post( $username );
249
+	echo wp_kses_post($username);
250 250
 }
251
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
251
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
252 252
 
253 253
 /**
254 254
  * Displays the subscription amount.
255 255
  *
256 256
  * @param WPInv_Subscription $subscription
257 257
  */
258
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
259
-	$amount    = getpaid_get_formatted_subscription_amount( $subscription );
260
-	echo wp_kses_post( "<span>$amount</span>" );
258
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
259
+	$amount = getpaid_get_formatted_subscription_amount($subscription);
260
+	echo wp_kses_post("<span>$amount</span>");
261 261
 }
262
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
262
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
263 263
 
264 264
 /**
265 265
  * Displays the subscription id.
266 266
  *
267 267
  * @param WPInv_Subscription $subscription
268 268
  */
269
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
269
+function getpaid_admin_subscription_metabox_display_id($subscription) {
270 270
 
271 271
 	printf(
272 272
 		'<a href="%s">#%s</a>',
273
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
274
-		absint( $subscription->get_id() )
273
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
274
+		absint($subscription->get_id())
275 275
 	);
276 276
 
277 277
 }
278
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
278
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
279 279
 
280 280
 /**
281 281
  * Displays the subscription renewal date.
282 282
  *
283 283
  * @param WPInv_Subscription $subscription
284 284
  */
285
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
285
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
286 286
 
287
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
287
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) {
288 288
 		aui()->input(
289 289
 			array(
290 290
 				'type'        => 'text',
291 291
 				'id'          => 'wpinv_subscription_date_created',
292 292
 				'name'        => 'wpinv_subscription_date_created',
293
-				'label'       => __( 'Start Date', 'invoicing' ),
293
+				'label'       => __('Start Date', 'invoicing'),
294 294
 				'label_type'  => 'hidden',
295 295
 				'placeholder' => 'YYYY-MM-DD',
296
-				'value'       => esc_attr( $subscription->get_date_created( 'edit' ) ),
296
+				'value'       => esc_attr($subscription->get_date_created('edit')),
297 297
 				'no_wrap'     => true,
298 298
 				'size'        => 'sm',
299 299
 			),
300 300
 			true
301 301
 		);
302 302
 	} else {
303
-		echo esc_html( getpaid_format_date_value( $subscription->get_date_created() ) );
303
+		echo esc_html(getpaid_format_date_value($subscription->get_date_created()));
304 304
 	}
305 305
 
306 306
 }
307
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
307
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
308 308
 
309 309
 /**
310 310
  * Displays the subscription renewal date.
311 311
  *
312 312
  * @param WPInv_Subscription $subscription
313 313
  */
314
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
314
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
315 315
 
316
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_date_change' ) ) {
316
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_date_change')) {
317 317
 		aui()->input(
318 318
 			array(
319 319
 				'type'        => 'text',
320 320
 				'id'          => 'wpinv_subscription_expiration',
321 321
 				'name'        => 'wpinv_subscription_expiration',
322
-				'label'       => __( 'Renews On', 'invoicing' ),
322
+				'label'       => __('Renews On', 'invoicing'),
323 323
 				'label_type'  => 'hidden',
324 324
 				'placeholder' => 'YYYY-MM-DD',
325
-				'value'       => esc_attr( $subscription->get_expiration( 'edit' ) ),
325
+				'value'       => esc_attr($subscription->get_expiration('edit')),
326 326
 				'no_wrap'     => true,
327 327
 				'size'        => 'sm',
328 328
 			),
329 329
 			true
330 330
 		);
331 331
 	} else {
332
-		echo esc_html( getpaid_format_date_value( $subscription->get_expiration() ) );
332
+		echo esc_html(getpaid_format_date_value($subscription->get_expiration()));
333 333
 	}
334 334
 }
335
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
335
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
336 336
 
337 337
 /**
338 338
  * Displays the subscription renewal count.
339 339
  *
340 340
  * @param WPInv_Subscription $subscription
341 341
  */
342
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
342
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
343 343
 
344 344
 	$max_bills    = $subscription->get_bill_times();
345 345
 	$times_billed = (int) $subscription->get_times_billed();
346 346
 
347
-	if ( $subscription->has_status( 'active trialling' ) && getpaid_payment_gateway_supports( $subscription->get_gateway(), 'subscription_bill_times_change' ) ) {
347
+	if ($subscription->has_status('active trialling') && getpaid_payment_gateway_supports($subscription->get_gateway(), 'subscription_bill_times_change')) {
348 348
 		aui()->input(
349 349
 			array(
350 350
 				'type'             => 'number',
351 351
 				'id'               => 'wpinv_subscription_max_bill_times',
352 352
 				'name'             => 'wpinv_subscription_max_bill_times',
353
-				'label'            => __( 'Maximum bill times', 'invoicing' ),
353
+				'label'            => __('Maximum bill times', 'invoicing'),
354 354
 				'label_type'       => 'hidden',
355
-				'placeholder'      => __( 'Unlimited', 'invoicing' ),
356
-				'value'            => empty( $max_bills ) ? '' : (int) $max_bills,
355
+				'placeholder'      => __('Unlimited', 'invoicing'),
356
+				'value'            => empty($max_bills) ? '' : (int) $max_bills,
357 357
 				'no_wrap'          => true,
358 358
 				'size'             => 'sm',
359 359
 				'input_group_left' => sprintf(
360 360
 					// translators: %d: Number of times billed
361
-					__( '%d of', 'invoicing' ),
361
+					__('%d of', 'invoicing'),
362 362
 					$times_billed
363 363
 				),
364 364
 			),
365 365
 			true
366 366
 		);
367 367
 	} else {
368
-		echo esc_html( $times_billed ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
368
+		echo esc_html($times_billed) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
369 369
 	}
370 370
 }
371
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
371
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
372 372
 
373 373
 /**
374 374
  * Displays the subscription item.
@@ -376,53 +376,53 @@  discard block
 block discarded – undo
376 376
  * @param WPInv_Subscription $subscription
377 377
  * @param false|array $subscription_group
378 378
  */
379
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
379
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
380 380
 
381
-	if ( empty( $subscription_group ) ) {
382
-		echo wp_kses_post( WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ) );
381
+	if (empty($subscription_group)) {
382
+		echo wp_kses_post(WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()));
383 383
 		return;
384 384
 	}
385 385
 
386
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
387
-	echo wp_kses_post( implode( ' | ', $markup ) );
386
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
387
+	echo wp_kses_post(implode(' | ', $markup));
388 388
 
389 389
 }
390
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
390
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
391 391
 
392 392
 /**
393 393
  * Displays the subscription gateway.
394 394
  *
395 395
  * @param WPInv_Subscription $subscription
396 396
  */
397
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
397
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
398 398
 
399 399
 	$gateway = $subscription->get_gateway();
400 400
 
401
-	if ( ! empty( $gateway ) ) {
402
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
401
+	if (!empty($gateway)) {
402
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
403 403
 	} else {
404 404
 		echo '&mdash;';
405 405
 	}
406 406
 
407 407
 }
408
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
408
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
409 409
 
410 410
 /**
411 411
  * Displays the subscription status.
412 412
  *
413 413
  * @param WPInv_Subscription $subscription
414 414
  */
415
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
416
-	echo wp_kses_post( $subscription->get_status_label_html() );
415
+function getpaid_admin_subscription_metabox_display_status($subscription) {
416
+	echo wp_kses_post($subscription->get_status_label_html());
417 417
 }
418
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
418
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
419 419
 
420 420
 /**
421 421
  * Displays the subscription profile id.
422 422
  *
423 423
  * @param WPInv_Subscription $subscription
424 424
  */
425
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
425
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
426 426
 
427 427
 	$profile_id = $subscription->get_profile_id();
428 428
 
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
 			'type'              => 'text',
432 432
 			'id'                => 'wpinv_subscription_profile_id',
433 433
 			'name'              => 'wpinv_subscription_profile_id',
434
-			'label'             => __( 'Profile Id', 'invoicing' ),
434
+			'label'             => __('Profile Id', 'invoicing'),
435 435
 			'label_type'        => 'hidden',
436
-			'placeholder'       => __( 'Profile Id', 'invoicing' ),
437
-			'value'             => esc_attr( $profile_id ),
436
+			'placeholder'       => __('Profile Id', 'invoicing'),
437
+			'value'             => esc_attr($profile_id),
438 438
 			'input_group_right' => '',
439 439
 			'no_wrap'           => true,
440 440
 			'size'              => 'sm',
@@ -442,20 +442,20 @@  discard block
 block discarded – undo
442 442
 		true
443 443
 	);
444 444
 
445
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
446
-	if ( ! empty( $url ) ) {
447
-		echo '&nbsp;<a href="' . esc_url_raw( $url ) . '" title="' . esc_attr__( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
445
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
446
+	if (!empty($url)) {
447
+		echo '&nbsp;<a href="' . esc_url_raw($url) . '" title="' . esc_attr__('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
448 448
 	}
449 449
 
450 450
 }
451
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
451
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
452 452
 
453 453
 /**
454 454
  * Displays the subscriptions update metabox.
455 455
  *
456 456
  * @param WPInv_Subscription $subscription
457 457
  */
458
-function getpaid_admin_subscription_update_metabox( $subscription ) {
458
+function getpaid_admin_subscription_update_metabox($subscription) {
459 459
 	global $aui_bs5;
460 460
 
461 461
 	?>
@@ -468,10 +468,10 @@  discard block
 block discarded – undo
468 468
 					'id'        => 'subscription_status_update_select',
469 469
 					'required'  => true,
470 470
 					'no_wrap'   => false,
471
-					'label'     => __( 'Subscription Status', 'invoicing' ),
472
-					'help_text' => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
471
+					'label'     => __('Subscription Status', 'invoicing'),
472
+					'help_text' => __('Updating the status will trigger related actions and hooks', 'invoicing'),
473 473
 					'select2'   => true,
474
-					'value'     => $subscription->get_status( 'edit' ),
474
+					'value'     => $subscription->get_status('edit'),
475 475
 				),
476 476
 				true
477 477
 			);
@@ -479,14 +479,14 @@  discard block
 block discarded – undo
479 479
 
480 480
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin:-12px">
481 481
 		<?php
482
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
482
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
483 483
 
484
-			$url    = wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' );
485
-			$anchor = __( 'Renew Subscription', 'invoicing' );
486
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
484
+			$url    = wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce');
485
+			$anchor = __('Renew Subscription', 'invoicing');
486
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
487 487
 
488
-			if ( $subscription->is_active() ) {
489
-				echo "<a href='" . esc_url( $url ) . "' class='" . ( $aui_bs5 ? 'float-end' : 'float-right' ) . " button button-secondary' onclick='return confirm(\"" . esc_attr( $title ) . "\")' title='" . esc_attr__( 'Renew subscription manually', 'invoicing' ) . "'>" . esc_html( $anchor ) . "</a>";
488
+			if ($subscription->is_active()) {
489
+				echo "<a href='" . esc_url($url) . "' class='" . ($aui_bs5 ? 'float-end' : 'float-right') . " button button-secondary' onclick='return confirm(\"" . esc_attr($title) . "\")' title='" . esc_attr__('Renew subscription manually', 'invoicing') . "'>" . esc_html($anchor) . "</a>";
490 490
 			}
491 491
 
492 492
 	echo '</div></div>';
@@ -498,44 +498,44 @@  discard block
 block discarded – undo
498 498
  * @param WPInv_Subscription $subscription
499 499
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
500 500
  */
501
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
501
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
502 502
 
503 503
 	$columns = apply_filters(
504 504
 		'getpaid_subscription_related_invoices_columns',
505 505
 		array(
506
-			'invoice'      => __( 'Invoice', 'invoicing' ),
507
-			'relationship' => __( 'Relationship', 'invoicing' ),
508
-			'date'         => __( 'Date', 'invoicing' ),
509
-			'status'       => __( 'Status', 'invoicing' ),
510
-			'total'        => __( 'Total', 'invoicing' ),
506
+			'invoice'      => __('Invoice', 'invoicing'),
507
+			'relationship' => __('Relationship', 'invoicing'),
508
+			'date'         => __('Date', 'invoicing'),
509
+			'status'       => __('Status', 'invoicing'),
510
+			'total'        => __('Total', 'invoicing'),
511 511
 		),
512 512
 		$subscription
513 513
 	);
514 514
 
515 515
 	// Prepare the invoices.
516
-	$payments = $subscription->get_child_payments( ! is_admin() );
516
+	$payments = $subscription->get_child_payments(!is_admin());
517 517
 	$parent   = $subscription->get_parent_invoice();
518 518
 
519
-	if ( $parent->exists() ) {
520
-		$payments = array_merge( array( $parent ), $payments );
519
+	if ($parent->exists()) {
520
+		$payments = array_merge(array($parent), $payments);
521 521
 	}
522 522
 
523 523
 	$table_class = 'w-100 bg-white';
524 524
 
525
-	if ( ! is_admin() ) {
525
+	if (!is_admin()) {
526 526
 		$table_class = 'table table-bordered';
527 527
 	}
528 528
 
529 529
 	?>
530 530
 		<div class="m-0" style="overflow: auto;">
531 531
 
532
-			<table class="<?php echo esc_attr( $table_class ); ?>">
532
+			<table class="<?php echo esc_attr($table_class); ?>">
533 533
 
534 534
 				<thead>
535 535
 					<tr>
536 536
 						<?php
537
-							foreach ( $columns as $key => $label ) {
538
-							echo "<th class='subscription-invoice-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
537
+							foreach ($columns as $key => $label) {
538
+							echo "<th class='subscription-invoice-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
539 539
 							}
540 540
 						?>
541 541
 					</tr>
@@ -543,72 +543,72 @@  discard block
 block discarded – undo
543 543
 
544 544
 				<tbody>
545 545
 
546
-					<?php if ( empty( $payments ) ) : ?>
546
+					<?php if (empty($payments)) : ?>
547 547
 						<tr>
548
-							<td colspan="<?php echo count( $columns ); ?>" class="p-2 text-left text-muted">
549
-								<?php esc_html_e( 'This subscription has no invoices.', 'invoicing' ); ?>
548
+							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
549
+								<?php esc_html_e('This subscription has no invoices.', 'invoicing'); ?>
550 550
 							</td>
551 551
 						</tr>
552 552
 					<?php endif; ?>
553 553
 
554 554
 					<?php
555 555
 
556
-						foreach ( $payments as $payment ) :
556
+						foreach ($payments as $payment) :
557 557
 
558 558
 						// Ensure that we have an invoice.
559
-						$payment = new WPInv_Invoice( $payment );
559
+						$payment = new WPInv_Invoice($payment);
560 560
 
561 561
 						// Abort if the invoice is invalid...
562
-						if ( ! $payment->exists() ) {
562
+						if (!$payment->exists()) {
563 563
 							continue;
564 564
 							}
565 565
 
566 566
 						// ... or belongs to a different subscription.
567
-						if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
567
+						if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
568 568
 							continue;
569 569
 							}
570 570
 
571 571
 						echo '<tr>';
572 572
 
573
-						foreach ( array_keys( $columns ) as $key ) {
573
+						foreach (array_keys($columns) as $key) {
574 574
 
575 575
 							echo "<td class='p-2 text-left'>";
576 576
 
577
-								switch ( $key ) {
577
+								switch ($key) {
578 578
 
579 579
 								case 'total':
580 580
 										echo '<strong>';
581
-										wpinv_the_price( $payment->get_total(), $payment->get_currency() );
581
+										wpinv_the_price($payment->get_total(), $payment->get_currency());
582 582
 										echo '</strong>';
583 583
 									break;
584 584
 
585 585
 								case 'relationship':
586
-										echo $payment->is_renewal() ? esc_html__( 'Renewal Invoice', 'invoicing' ) : esc_html__( 'Initial Invoice', 'invoicing' );
586
+										echo $payment->is_renewal() ? esc_html__('Renewal Invoice', 'invoicing') : esc_html__('Initial Invoice', 'invoicing');
587 587
 									break;
588 588
 
589 589
 								case 'date':
590
-									echo esc_html( getpaid_format_date_value( $payment->get_date_created() ) );
590
+									echo esc_html(getpaid_format_date_value($payment->get_date_created()));
591 591
 									break;
592 592
 
593 593
 								case 'status':
594 594
 										$status = $payment->get_status_nicename();
595
-										if ( is_admin() ) {
595
+										if (is_admin()) {
596 596
 										$status = $payment->get_status_label_html();
597 597
 										}
598 598
 
599
-										echo wp_kses_post( $status );
599
+										echo wp_kses_post($status);
600 600
 									break;
601 601
 
602 602
 								case 'invoice':
603
-										if ( ! is_admin() ) {
603
+										if (!is_admin()) {
604 604
 											$link = $payment->get_view_url();
605 605
 										} else {
606
-											$link = get_edit_post_link( $payment->get_id() );
606
+											$link = get_edit_post_link($payment->get_id());
607 607
 										}
608 608
 
609
-										$invoice = esc_html( $payment->get_number() );
609
+										$invoice = esc_html($payment->get_number());
610 610
 
611
-										echo wp_kses_post( "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$invoice</a>" );
611
+										echo wp_kses_post("<a href='" . ($link ? esc_url($link) : '#') . "'>$invoice</a>");
612 612
 									break;
613 613
 										}
614 614
 
@@ -635,12 +635,12 @@  discard block
 block discarded – undo
635 635
  *
636 636
  * @param WPInv_Subscription $subscription
637 637
  */
638
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
638
+function getpaid_admin_subscription_item_details_metabox($subscription) {
639 639
 
640 640
 	// Fetch the subscription group.
641
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
641
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
642 642
 
643
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
643
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
644 644
 		return;
645 645
 	}
646 646
 
@@ -648,12 +648,12 @@  discard block
 block discarded – undo
648 648
 	$columns = apply_filters(
649 649
 		'getpaid_subscription_item_details_columns',
650 650
 		array(
651
-			'item_name' => __( 'Item', 'invoicing' ),
652
-			'price'     => __( 'Price', 'invoicing' ),
653
-			'tax'       => __( 'Tax', 'invoicing' ),
654
-			'discount'  => __( 'Discount', 'invoicing' ),
651
+			'item_name' => __('Item', 'invoicing'),
652
+			'price'     => __('Price', 'invoicing'),
653
+			'tax'       => __('Tax', 'invoicing'),
654
+			'discount'  => __('Discount', 'invoicing'),
655 655
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
656
-			'recurring' => __( 'Subtotal', 'invoicing' ),
656
+			'recurring' => __('Subtotal', 'invoicing'),
657 657
 		),
658 658
 		$subscription
659 659
 	);
@@ -662,27 +662,27 @@  discard block
 block discarded – undo
662 662
 
663 663
 	$invoice = $subscription->get_parent_invoice();
664 664
 
665
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
666
-		unset( $columns['tax'] );
665
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
666
+		unset($columns['tax']);
667 667
 	}
668 668
 
669 669
 	$table_class = 'w-100 bg-white';
670 670
 
671
-	if ( ! is_admin() ) {
671
+	if (!is_admin()) {
672 672
 		$table_class = 'table table-bordered';
673 673
 	}
674 674
 
675 675
 	?>
676 676
 		<div class="m-0" style="overflow: auto;">
677 677
 
678
-			<table class="<?php echo esc_attr( $table_class ); ?>">
678
+			<table class="<?php echo esc_attr($table_class); ?>">
679 679
 
680 680
 				<thead>
681 681
 					<tr>
682 682
 						<?php
683 683
 
684
-							foreach ( $columns as $key => $label ) {
685
-							echo "<th class='subscription-item-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
684
+							foreach ($columns as $key => $label) {
685
+							echo "<th class='subscription-item-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
686 686
 							}
687 687
 						?>
688 688
 					</tr>
@@ -692,48 +692,48 @@  discard block
 block discarded – undo
692 692
 
693 693
 					<?php
694 694
 
695
-						foreach ( $subscription_group['items'] as $subscription_group_item ) :
695
+						foreach ($subscription_group['items'] as $subscription_group_item) :
696 696
 
697 697
 						echo '<tr>';
698 698
 
699
-						foreach ( array_keys( $columns ) as $key ) {
699
+						foreach (array_keys($columns) as $key) {
700 700
 
701 701
 							$class = 'text-left';
702 702
 
703 703
 							echo "<td class='p-2 text-left'>";
704 704
 
705
-								switch ( $key ) {
705
+								switch ($key) {
706 706
 
707 707
 								case 'item_name':
708
-										$item_name = get_the_title( $subscription_group_item['item_id'] );
709
-										$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
708
+										$item_name = get_the_title($subscription_group_item['item_id']);
709
+										$item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name;
710 710
 
711
-										if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
712
-										echo esc_html( $item_name );
711
+										if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
712
+										echo esc_html($item_name);
713 713
 										} else {
714
-										printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
714
+										printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
715 715
 											}
716 716
 
717 717
 									break;
718 718
 
719 719
 								case 'price':
720
-									wpinv_the_price( $subscription_group_item['item_price'], $invoice->get_currency() );
720
+									wpinv_the_price($subscription_group_item['item_price'], $invoice->get_currency());
721 721
 									break;
722 722
 
723 723
 								case 'tax':
724
-									wpinv_the_price( $subscription_group_item['tax'], $invoice->get_currency() );
724
+									wpinv_the_price($subscription_group_item['tax'], $invoice->get_currency());
725 725
 									break;
726 726
 
727 727
 								case 'discount':
728
-									wpinv_the_price( $subscription_group_item['discount'], $invoice->get_currency() );
728
+									wpinv_the_price($subscription_group_item['discount'], $invoice->get_currency());
729 729
 									break;
730 730
 
731 731
 								case 'initial':
732
-									wpinv_the_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
732
+									wpinv_the_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
733 733
 									break;
734 734
 
735 735
 								case 'recurring':
736
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>' );
736
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>');
737 737
 									break;
738 738
 
739 739
 										}
@@ -746,24 +746,24 @@  discard block
 block discarded – undo
746 746
 
747 747
 						endforeach;
748 748
 
749
-						foreach ( $subscription_group['fees'] as $subscription_group_fee ) :
749
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
750 750
 
751 751
 						echo '<tr>';
752 752
 
753
-						foreach ( array_keys( $columns ) as $key ) {
753
+						foreach (array_keys($columns) as $key) {
754 754
 
755 755
 							$class = 'text-left';
756 756
 
757 757
 							echo "<td class='p-2 text-left'>";
758 758
 
759
-								switch ( $key ) {
759
+								switch ($key) {
760 760
 
761 761
 								case 'item_name':
762
-										echo esc_html( $subscription_group_fee['name'] );
762
+										echo esc_html($subscription_group_fee['name']);
763 763
 									break;
764 764
 
765 765
 								case 'price':
766
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
766
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
767 767
 									break;
768 768
 
769 769
 								case 'tax':
@@ -775,11 +775,11 @@  discard block
 block discarded – undo
775 775
 									break;
776 776
 
777 777
 								case 'initial':
778
-									wpinv_the_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
778
+									wpinv_the_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
779 779
 									break;
780 780
 
781 781
 								case 'recurring':
782
-										echo wp_kses_post( '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>' );
782
+										echo wp_kses_post('<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>');
783 783
 									break;
784 784
 
785 785
 										}
@@ -808,12 +808,12 @@  discard block
 block discarded – undo
808 808
  * @param WPInv_Subscription $subscription
809 809
  * @param bool $skip_current
810 810
  */
811
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
811
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
812 812
 
813 813
 	// Fetch the subscription groups.
814
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
814
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
815 815
 
816
-	if ( empty( $subscription_groups ) ) {
816
+	if (empty($subscription_groups)) {
817 817
 		return;
818 818
 	}
819 819
 
@@ -821,37 +821,37 @@  discard block
 block discarded – undo
821 821
 	$columns = apply_filters(
822 822
 		'getpaid_subscription_related_subscriptions_columns',
823 823
 		array(
824
-			'subscription' => __( 'Subscription', 'invoicing' ),
825
-			'start_date'   => __( 'Start Date', 'invoicing' ),
826
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
827
-			'renewals'     => __( 'Payments', 'invoicing' ),
828
-			'item'         => __( 'Items', 'invoicing' ),
829
-			'status'       => __( 'Status', 'invoicing' ),
824
+			'subscription' => __('Subscription', 'invoicing'),
825
+			'start_date'   => __('Start Date', 'invoicing'),
826
+			'renewal_date' => __('Next Payment', 'invoicing'),
827
+			'renewals'     => __('Payments', 'invoicing'),
828
+			'item'         => __('Items', 'invoicing'),
829
+			'status'       => __('Status', 'invoicing'),
830 830
 		),
831 831
 		$subscription
832 832
 	);
833 833
 
834
-	if ( $subscription->get_status() == 'pending' ) {
835
-		unset( $columns['start_date'], $columns['renewal_date'] );
834
+	if ($subscription->get_status() == 'pending') {
835
+		unset($columns['start_date'], $columns['renewal_date']);
836 836
 	}
837 837
 
838 838
 	$table_class = 'w-100 bg-white';
839 839
 
840
-	if ( ! is_admin() ) {
840
+	if (!is_admin()) {
841 841
 		$table_class = 'table table-bordered';
842 842
 	}
843 843
 
844 844
 	?>
845 845
 		<div class="m-0" style="overflow: auto;">
846 846
 
847
-			<table class="<?php echo esc_attr( $table_class ); ?>">
847
+			<table class="<?php echo esc_attr($table_class); ?>">
848 848
 
849 849
 				<thead>
850 850
 					<tr>
851 851
 						<?php
852 852
 
853
-							foreach ( $columns as $key => $label ) {
854
-							echo "<th class='related-subscription-field-" . esc_attr( $key ) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html( $label ) . "</th>";
853
+							foreach ($columns as $key => $label) {
854
+							echo "<th class='related-subscription-field-" . esc_attr($key) . " bg-light p-2 text-left color-dark font-weight-bold'>" . esc_html($label) . "</th>";
855 855
 							}
856 856
 						?>
857 857
 					</tr>
@@ -861,62 +861,62 @@  discard block
 block discarded – undo
861 861
 
862 862
 					<?php
863 863
 
864
-						foreach ( $subscription_groups as $subscription_group ) :
864
+						foreach ($subscription_groups as $subscription_group) :
865 865
 
866 866
 						// Do not list current subscription.
867
-						if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
867
+						if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
868 868
 							continue;
869 869
 							}
870 870
 
871 871
 						// Ensure the subscription exists.
872
-						$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
872
+						$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
873 873
 
874
-						if ( ! $_suscription->exists() ) {
874
+						if (!$_suscription->exists()) {
875 875
 							continue;
876 876
 							}
877 877
 
878 878
 						echo '<tr>';
879 879
 
880
-						foreach ( array_keys( $columns ) as $key ) {
880
+						foreach (array_keys($columns) as $key) {
881 881
 
882 882
 							$class = 'text-left';
883 883
 
884 884
 							echo "<td class='p-2 text-left'>";
885 885
 
886
-								switch ( $key ) {
886
+								switch ($key) {
887 887
 
888 888
 								case 'status':
889
-										echo wp_kses_post( $_suscription->get_status_label_html() );
889
+										echo wp_kses_post($_suscription->get_status_label_html());
890 890
 									break;
891 891
 
892 892
 								case 'item':
893
-											$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
894
-											echo wp_kses_post( implode( ' | ', $markup ) );
893
+											$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
894
+											echo wp_kses_post(implode(' | ', $markup));
895 895
 									break;
896 896
 
897 897
 								case 'renewals':
898 898
 									$max_bills = $_suscription->get_bill_times();
899
-									echo ( (int) $_suscription->get_times_billed() ) . ' / ' . ( empty( $max_bills ) ? '&infin;' : (int) $max_bills );
899
+									echo ((int) $_suscription->get_times_billed()) . ' / ' . (empty($max_bills) ? '&infin;' : (int) $max_bills);
900 900
 									break;
901 901
 
902 902
 								case 'renewal_date':
903
-										echo $_suscription->is_active() ? esc_html( getpaid_format_date_value( $_suscription->get_expiration() ) ) : '&mdash;';
903
+										echo $_suscription->is_active() ? esc_html(getpaid_format_date_value($_suscription->get_expiration())) : '&mdash;';
904 904
 									break;
905 905
 
906 906
 								case 'start_date':
907
-										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html( getpaid_format_date_value( $_suscription->get_date_created() ) );
907
+										echo 'pending' == $_suscription->get_status() ? '&mdash;' : esc_html(getpaid_format_date_value($_suscription->get_date_created()));
908 908
 									break;
909 909
 
910 910
 								case 'subscription':
911
-										$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
911
+										$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
912 912
 										printf(
913 913
                                             '%1$s#%2$s%3$s',
914
-                                            '<a href="' . esc_url( $url ) . '">',
915
-                                            '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
914
+                                            '<a href="' . esc_url($url) . '">',
915
+                                            '<strong>' . intval($_suscription->get_id()) . '</strong>',
916 916
 											'</a>'
917 917
                                         );
918 918
 
919
-											echo wp_kses_post( WPInv_Subscriptions_List_Table::column_amount( $_suscription ) );
919
+											echo wp_kses_post(WPInv_Subscriptions_List_Table::column_amount($_suscription));
920 920
 									break;
921 921
 
922 922
 										}
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 2 patches
Indentation   +467 added lines, -467 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
 }
9 9
 
10 10
 if ( ! class_exists( 'WP_List_Table' ) ) {
11
-	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
11
+    include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12 12
 }
13 13
 
14 14
 /**
@@ -16,471 +16,471 @@  discard block
 block discarded – undo
16 16
  */
17 17
 class WPInv_Subscriptions_List_Table extends WP_List_Table {
18 18
 
19
-	/**
20
-	 * URL of this page
21
-	 *
22
-	 * @var   string
23
-	 * @since 1.0.19
24
-	 */
25
-	public $base_url;
26
-
27
-	/**
28
-	 * Query
29
-	 *
30
-	 * @var   GetPaid_Subscriptions_Query
31
-	 * @since 1.0.19
32
-	 */
33
-	public $query;
34
-
35
-	/**
36
-	 * Total subscriptions
37
-	 *
38
-	 * @var   string
39
-	 * @since 1.0.0
40
-	 */
41
-	public $total_count;
42
-
43
-	/**
44
-	 * Current status subscriptions
45
-	 *
46
-	 * @var   string
47
-	 * @since 1.0.0
48
-	 */
49
-	public $current_total_count;
50
-
51
-	/**
52
-	 * Status counts
53
-	 *
54
-	 * @var   array
55
-	 * @since 1.0.19
56
-	 */
57
-	public $status_counts;
58
-
59
-	/**
60
-	 * Number of results to show per page
61
-	 *
62
-	 * @var   int
63
-	 * @since 1.0.0
64
-	 */
65
-	public $per_page = 10;
66
-
67
-	/**
68
-	 *  Constructor function.
69
-	 */
70
-	public function __construct() {
71
-
72
-		parent::__construct(
73
-			array(
74
-				'singular' => 'subscription',
75
-				'plural'   => 'subscriptions',
76
-			)
77
-		);
78
-
79
-		$this->process_bulk_action();
80
-
81
-		$this->prepare_query();
82
-
83
-		$this->base_url = remove_query_arg( 'status' );
84
-
85
-	}
86
-
87
-	/**
88
-	 *  Prepares the display query
89
-	 */
90
-	public function prepare_query() {
91
-
92
-		// Prepare query args.
93
-		$query = array(
94
-			'number'      => $this->per_page,
95
-			'paged'       => $this->get_paged(),
96
-			'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
-			'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
-			'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
99
-			'customer_in' => $this->get_user_in(),
100
-		);
101
-
102
-		if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
103
-			$this->total_count         = 0;
104
-			$this->current_total_count = 0;
105
-			$this->items               = array();
106
-			$this->status_counts       = array();
107
-			return;
108
-		}
109
-
110
-		// Prepare class properties.
111
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
112
-		$this->total_count         = $this->query->get_total();
113
-		$this->current_total_count = $this->query->get_total();
114
-		$this->items               = $this->query->get_results();
115
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
116
-
117
-		if ( 'all' != $query['status'] ) {
118
-			unset( $query['status'] );
119
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
120
-		}
121
-
122
-	}
123
-
124
-	/**
125
-	 * Get user in.
126
-	 *
127
-	 */
128
-	public function get_user_in() {
129
-
130
-		// Abort if no user.
131
-		if ( empty( $_GET['s'] ) ) {
132
-			return null;
133
-		}
134
-
135
-		// Or invalid user.
136
-		$user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
137
-
138
-		if ( empty( $user ) ) {
139
-			return null;
140
-		}
141
-
142
-		// Search matching users.
143
-		$user  = '*' . $user . '*';
144
-		$users = new WP_User_Query(
145
-			array(
146
-				'fields'      => 'ID',
147
-				'search'      => $user,
148
-				'count_total' => false,
149
-			)
150
-		);
151
-
152
-		return $users->get_results();
153
-	}
154
-
155
-	/**
156
-	 * Gets the list of views available on this table.
157
-	 *
158
-	 * The format is an associative array:
159
-	 * - `'id' => 'link'`
160
-	 *
161
-	 * @since 1.0.0
162
-	 *
163
-	 * @return array
164
-	 */
165
-	public function get_views() {
166
-
167
-		$current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
168
-		$views    = array(
169
-
170
-			'all' => sprintf(
171
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
173
-				$current === 'all' ? ' class="current"' : '',
174
-				__( 'All', 'invoicing' ),
175
-				$this->total_count
176
-			),
177
-
178
-		);
179
-
180
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
181
-
182
-			$views[ $status ] = sprintf(
183
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
185
-				$current === $status ? ' class="current"' : '',
186
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
187
-				$count
188
-			);
189
-
190
-		}
191
-
192
-		return $views;
193
-
194
-	}
195
-
196
-	/**
197
-	 * Render most columns
198
-	 *
199
-	 * @access      private
200
-	 * @since       1.0.0
201
-	 * @return      string
202
-	 */
203
-	public function column_default( $item, $column_name ) {
204
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
205
-	}
206
-
207
-	/**
208
-	 * This is how checkbox column renders.
209
-	 *
210
-	 * @param WPInv_Subscription $item
211
-	 * @return string
212
-	 */
213
-	public function column_cb( $item ) {
214
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
215
-	}
216
-
217
-	/**
218
-	 * Status column
219
-	 *
220
-	 * @param WPInv_Subscription $item
221
-	 * @since       1.0.0
222
-	 * @return      string
223
-	 */
224
-	public function column_status( $item ) {
225
-		return $item->get_status_label_html();
226
-	}
227
-
228
-	/**
229
-	 * Subscription column
230
-	 *
231
-	 * @param WPInv_Subscription $item
232
-	 * @since       1.0.0
233
-	 * @return      string
234
-	 */
235
-	public function column_subscription( $item ) {
236
-
237
-		$username = __( '(Missing User)', 'invoicing' );
238
-
239
-		$user = get_userdata( $item->get_customer_id() );
240
-		$capabilities = wpinv_current_user_can_manage_invoicing();
241
-
242
-		if ( $user ) {
243
-			$username = sprintf(
244
-				'<a href="user-edit.php?user_id=%s">%s</a>',
245
-				absint( $user->ID ),
246
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
247
-			);
248
-		}
249
-
250
-		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
251
-		$column_content = sprintf(
252
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
253
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
254
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>',
255
-			'</a>',
256
-			$username
257
-		);
258
-
259
-		$row_actions = array();
260
-
261
-		// View subscription.
262
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
263
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
264
-
265
-		// View invoice.
266
-		$invoice = get_post( $item->get_parent_invoice_id() );
267
-
268
-		if ( ! empty( $invoice ) ) {
269
-			$invoice_url            = get_edit_post_link( $invoice );
270
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
271
-		}
272
-
273
-		$delete_url            = esc_url(
274
-			wp_nonce_url(
275
-				add_query_arg(
276
-					array(
277
-						'getpaid-admin-action' => 'subscription_manual_delete',
278
-						'id'                   => $item->get_id(),
279
-					)
280
-				),
281
-				'getpaid-nonce',
282
-				'getpaid-nonce'
283
-			)
284
-		);
285
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
286
-
287
-		if ( ! $capabilities ) {
288
-			$row_actions = array();
289
-		}
290
-
291
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
292
-
293
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
294
-	}
295
-
296
-	/**
297
-	 * Renewal date column
298
-	 *
299
-	 * @param WPInv_Subscription $item
300
-	 * @since       1.0.0
301
-	 * @return      string
302
-	 */
303
-	public function column_renewal_date( $item ) {
304
-		return getpaid_format_date_value( $item->get_expiration() );
305
-	}
306
-
307
-	/**
308
-	 * Start date column
309
-	 *
310
-	 * @param WPInv_Subscription $item
311
-	 * @since       1.0.0
312
-	 * @return      string
313
-	 */
314
-	public function column_start_date( $item ) {
315
-
316
-		$gateway = $item->get_parent_invoice()->get_gateway_title();
317
-
318
-		if ( empty( $gateway ) ) {
319
-			return getpaid_format_date_value( $item->get_date_created() );
320
-		}
321
-
322
-		$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
323
-		if ( ! empty( $url ) ) {
324
-
325
-			return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
-				__( 'Via %s', 'invoicing' ),
327
-				'<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
328
-			);
329
-
330
-		}
331
-
332
-		return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
333
-			__( 'Via %s', 'invoicing' ),
334
-			'<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
335
-		);
336
-
337
-	}
338
-
339
-	/**
340
-	 * Amount column
341
-	 *
342
-	 * @param WPInv_Subscription $item
343
-	 * @since       1.0.19
344
-	 * @return      string
345
-	 */
346
-	public static function column_amount( $item ) {
347
-		$amount = getpaid_get_formatted_subscription_amount( $item );
348
-		return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
349
-	}
350
-
351
-	/**
352
-	 * Billing Times column
353
-	 *
354
-	 * @param WPInv_Subscription $item
355
-	 * @since       1.0.0
356
-	 * @return      string
357
-	 */
358
-	public function column_renewals( $item ) {
359
-		$max_bills = $item->get_bill_times();
360
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
361
-	}
362
-
363
-	/**
364
-	 * Product ID column
365
-	 *
366
-	 * @param WPInv_Subscription $item
367
-	 * @since       1.0.0
368
-	 * @return      string
369
-	 */
370
-	public function column_item( $item ) {
371
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
372
-
373
-		if ( empty( $subscription_group ) ) {
374
-			return $this->generate_item_markup( $item->get_product_id() );
375
-		}
376
-
377
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
378
-		return implode( ' | ', $markup );
379
-
380
-	}
381
-
382
-	/**
383
-	 * Generates the items markup.
384
-	 *
385
-	 * @param int $item_id
386
-	 * @since       1.0.0
387
-	 * @return      string
388
-	 */
389
-	public static function generate_item_markup( $item_id ) {
390
-		$item = get_post( $item_id );
391
-
392
-		if ( ! empty( $item ) ) {
393
-			$link = get_edit_post_link( $item );
394
-			$name = esc_html( get_the_title( $item ) );
395
-			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
396
-		} else {
397
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
398
-		}
399
-
400
-	}
401
-
402
-	/**
403
-	 * Retrieve the current page number
404
-	 *
405
-	 * @return      int
406
-	 */
407
-	public function get_paged() {
408
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
409
-	}
410
-
411
-	/**
412
-	 * Setup the final data for the table
413
-	 *
414
-	 */
415
-	public function prepare_items() {
416
-
417
-		$columns  = $this->get_columns();
418
-		$hidden   = array();
419
-		$sortable = $this->get_sortable_columns();
420
-
421
-		$this->_column_headers = array( $columns, $hidden, $sortable );
422
-
423
-		$this->set_pagination_args(
424
-			array(
425
-				'total_items' => $this->current_total_count,
426
-				'per_page'    => $this->per_page,
427
-				'total_pages' => ceil( $this->current_total_count / $this->per_page ),
428
-			)
429
-		);
430
-	}
431
-
432
-	/**
433
-	 * Table columns
434
-	 *
435
-	 * @return array
436
-	 */
437
-	public function get_columns() {
438
-		$columns = array(
439
-			'cb'           => '<input type="checkbox" />',
440
-			'subscription' => __( 'Subscription', 'invoicing' ),
441
-			'start_date'   => __( 'Start Date', 'invoicing' ),
442
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
443
-			'renewals'     => __( 'Payments', 'invoicing' ),
444
-			'item'         => __( 'Items', 'invoicing' ),
445
-			'status'       => __( 'Status', 'invoicing' ),
446
-		);
447
-
448
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
449
-	}
450
-
451
-	/**
452
-	 * Sortable table columns.
453
-	 *
454
-	 * @return array
455
-	 */
456
-	public function get_sortable_columns() {
457
-		$sortable = array(
458
-			'subscription' => array( 'id', true ),
459
-			'start_date'   => array( 'created', true ),
460
-			'renewal_date' => array( 'expiration', true ),
461
-			'renewals'     => array( 'bill_times', true ),
462
-			'item'         => array( 'product_id', true ),
463
-			'status'       => array( 'status', true ),
464
-		);
465
-
466
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
467
-	}
468
-
469
-	/**
470
-	 * Whether the table has items to display or not
471
-	 *
472
-	 * @return bool
473
-	 */
474
-	public function has_items() {
475
-		return ! empty( $this->current_total_count );
476
-	}
477
-
478
-	/**
479
-	 * Processes bulk actions.
480
-	 *
481
-	 */
482
-	public function process_bulk_action() {
483
-
484
-	}
19
+    /**
20
+     * URL of this page
21
+     *
22
+     * @var   string
23
+     * @since 1.0.19
24
+     */
25
+    public $base_url;
26
+
27
+    /**
28
+     * Query
29
+     *
30
+     * @var   GetPaid_Subscriptions_Query
31
+     * @since 1.0.19
32
+     */
33
+    public $query;
34
+
35
+    /**
36
+     * Total subscriptions
37
+     *
38
+     * @var   string
39
+     * @since 1.0.0
40
+     */
41
+    public $total_count;
42
+
43
+    /**
44
+     * Current status subscriptions
45
+     *
46
+     * @var   string
47
+     * @since 1.0.0
48
+     */
49
+    public $current_total_count;
50
+
51
+    /**
52
+     * Status counts
53
+     *
54
+     * @var   array
55
+     * @since 1.0.19
56
+     */
57
+    public $status_counts;
58
+
59
+    /**
60
+     * Number of results to show per page
61
+     *
62
+     * @var   int
63
+     * @since 1.0.0
64
+     */
65
+    public $per_page = 10;
66
+
67
+    /**
68
+     *  Constructor function.
69
+     */
70
+    public function __construct() {
71
+
72
+        parent::__construct(
73
+            array(
74
+                'singular' => 'subscription',
75
+                'plural'   => 'subscriptions',
76
+            )
77
+        );
78
+
79
+        $this->process_bulk_action();
80
+
81
+        $this->prepare_query();
82
+
83
+        $this->base_url = remove_query_arg( 'status' );
84
+
85
+    }
86
+
87
+    /**
88
+     *  Prepares the display query
89
+     */
90
+    public function prepare_query() {
91
+
92
+        // Prepare query args.
93
+        $query = array(
94
+            'number'      => $this->per_page,
95
+            'paged'       => $this->get_paged(),
96
+            'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
+            'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
+            'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
99
+            'customer_in' => $this->get_user_in(),
100
+        );
101
+
102
+        if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
103
+            $this->total_count         = 0;
104
+            $this->current_total_count = 0;
105
+            $this->items               = array();
106
+            $this->status_counts       = array();
107
+            return;
108
+        }
109
+
110
+        // Prepare class properties.
111
+        $this->query               = new GetPaid_Subscriptions_Query( $query );
112
+        $this->total_count         = $this->query->get_total();
113
+        $this->current_total_count = $this->query->get_total();
114
+        $this->items               = $this->query->get_results();
115
+        $this->status_counts       = getpaid_get_subscription_status_counts( $query );
116
+
117
+        if ( 'all' != $query['status'] ) {
118
+            unset( $query['status'] );
119
+            $this->total_count   = getpaid_get_subscriptions( $query, 'count' );
120
+        }
121
+
122
+    }
123
+
124
+    /**
125
+     * Get user in.
126
+     *
127
+     */
128
+    public function get_user_in() {
129
+
130
+        // Abort if no user.
131
+        if ( empty( $_GET['s'] ) ) {
132
+            return null;
133
+        }
134
+
135
+        // Or invalid user.
136
+        $user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
137
+
138
+        if ( empty( $user ) ) {
139
+            return null;
140
+        }
141
+
142
+        // Search matching users.
143
+        $user  = '*' . $user . '*';
144
+        $users = new WP_User_Query(
145
+            array(
146
+                'fields'      => 'ID',
147
+                'search'      => $user,
148
+                'count_total' => false,
149
+            )
150
+        );
151
+
152
+        return $users->get_results();
153
+    }
154
+
155
+    /**
156
+     * Gets the list of views available on this table.
157
+     *
158
+     * The format is an associative array:
159
+     * - `'id' => 'link'`
160
+     *
161
+     * @since 1.0.0
162
+     *
163
+     * @return array
164
+     */
165
+    public function get_views() {
166
+
167
+        $current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
168
+        $views    = array(
169
+
170
+            'all' => sprintf(
171
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
+                esc_url( add_query_arg( 'status', false, $this->base_url ) ),
173
+                $current === 'all' ? ' class="current"' : '',
174
+                __( 'All', 'invoicing' ),
175
+                $this->total_count
176
+            ),
177
+
178
+        );
179
+
180
+        foreach ( array_filter( $this->status_counts ) as $status => $count ) {
181
+
182
+            $views[ $status ] = sprintf(
183
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
+                esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
185
+                $current === $status ? ' class="current"' : '',
186
+                esc_html( getpaid_get_subscription_status_label( $status ) ),
187
+                $count
188
+            );
189
+
190
+        }
191
+
192
+        return $views;
193
+
194
+    }
195
+
196
+    /**
197
+     * Render most columns
198
+     *
199
+     * @access      private
200
+     * @since       1.0.0
201
+     * @return      string
202
+     */
203
+    public function column_default( $item, $column_name ) {
204
+        return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
205
+    }
206
+
207
+    /**
208
+     * This is how checkbox column renders.
209
+     *
210
+     * @param WPInv_Subscription $item
211
+     * @return string
212
+     */
213
+    public function column_cb( $item ) {
214
+        return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
215
+    }
216
+
217
+    /**
218
+     * Status column
219
+     *
220
+     * @param WPInv_Subscription $item
221
+     * @since       1.0.0
222
+     * @return      string
223
+     */
224
+    public function column_status( $item ) {
225
+        return $item->get_status_label_html();
226
+    }
227
+
228
+    /**
229
+     * Subscription column
230
+     *
231
+     * @param WPInv_Subscription $item
232
+     * @since       1.0.0
233
+     * @return      string
234
+     */
235
+    public function column_subscription( $item ) {
236
+
237
+        $username = __( '(Missing User)', 'invoicing' );
238
+
239
+        $user = get_userdata( $item->get_customer_id() );
240
+        $capabilities = wpinv_current_user_can_manage_invoicing();
241
+
242
+        if ( $user ) {
243
+            $username = sprintf(
244
+                '<a href="user-edit.php?user_id=%s">%s</a>',
245
+                absint( $user->ID ),
246
+                ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
247
+            );
248
+        }
249
+
250
+        // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
251
+        $column_content = sprintf(
252
+            _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
253
+            '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
254
+            '<strong>' . esc_attr( $item->get_id() ) . '</strong>',
255
+            '</a>',
256
+            $username
257
+        );
258
+
259
+        $row_actions = array();
260
+
261
+        // View subscription.
262
+        $view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
263
+        $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
264
+
265
+        // View invoice.
266
+        $invoice = get_post( $item->get_parent_invoice_id() );
267
+
268
+        if ( ! empty( $invoice ) ) {
269
+            $invoice_url            = get_edit_post_link( $invoice );
270
+            $row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
271
+        }
272
+
273
+        $delete_url            = esc_url(
274
+            wp_nonce_url(
275
+                add_query_arg(
276
+                    array(
277
+                        'getpaid-admin-action' => 'subscription_manual_delete',
278
+                        'id'                   => $item->get_id(),
279
+                    )
280
+                ),
281
+                'getpaid-nonce',
282
+                'getpaid-nonce'
283
+            )
284
+        );
285
+        $row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
286
+
287
+        if ( ! $capabilities ) {
288
+            $row_actions = array();
289
+        }
290
+
291
+        $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
292
+
293
+        return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
294
+    }
295
+
296
+    /**
297
+     * Renewal date column
298
+     *
299
+     * @param WPInv_Subscription $item
300
+     * @since       1.0.0
301
+     * @return      string
302
+     */
303
+    public function column_renewal_date( $item ) {
304
+        return getpaid_format_date_value( $item->get_expiration() );
305
+    }
306
+
307
+    /**
308
+     * Start date column
309
+     *
310
+     * @param WPInv_Subscription $item
311
+     * @since       1.0.0
312
+     * @return      string
313
+     */
314
+    public function column_start_date( $item ) {
315
+
316
+        $gateway = $item->get_parent_invoice()->get_gateway_title();
317
+
318
+        if ( empty( $gateway ) ) {
319
+            return getpaid_format_date_value( $item->get_date_created() );
320
+        }
321
+
322
+        $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
323
+        if ( ! empty( $url ) ) {
324
+
325
+            return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
+                __( 'Via %s', 'invoicing' ),
327
+                '<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
328
+            );
329
+
330
+        }
331
+
332
+        return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
333
+            __( 'Via %s', 'invoicing' ),
334
+            '<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
335
+        );
336
+
337
+    }
338
+
339
+    /**
340
+     * Amount column
341
+     *
342
+     * @param WPInv_Subscription $item
343
+     * @since       1.0.19
344
+     * @return      string
345
+     */
346
+    public static function column_amount( $item ) {
347
+        $amount = getpaid_get_formatted_subscription_amount( $item );
348
+        return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
349
+    }
350
+
351
+    /**
352
+     * Billing Times column
353
+     *
354
+     * @param WPInv_Subscription $item
355
+     * @since       1.0.0
356
+     * @return      string
357
+     */
358
+    public function column_renewals( $item ) {
359
+        $max_bills = $item->get_bill_times();
360
+        return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
361
+    }
362
+
363
+    /**
364
+     * Product ID column
365
+     *
366
+     * @param WPInv_Subscription $item
367
+     * @since       1.0.0
368
+     * @return      string
369
+     */
370
+    public function column_item( $item ) {
371
+        $subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
372
+
373
+        if ( empty( $subscription_group ) ) {
374
+            return $this->generate_item_markup( $item->get_product_id() );
375
+        }
376
+
377
+        $markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
378
+        return implode( ' | ', $markup );
379
+
380
+    }
381
+
382
+    /**
383
+     * Generates the items markup.
384
+     *
385
+     * @param int $item_id
386
+     * @since       1.0.0
387
+     * @return      string
388
+     */
389
+    public static function generate_item_markup( $item_id ) {
390
+        $item = get_post( $item_id );
391
+
392
+        if ( ! empty( $item ) ) {
393
+            $link = get_edit_post_link( $item );
394
+            $name = esc_html( get_the_title( $item ) );
395
+            return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
396
+        } else {
397
+            return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
398
+        }
399
+
400
+    }
401
+
402
+    /**
403
+     * Retrieve the current page number
404
+     *
405
+     * @return      int
406
+     */
407
+    public function get_paged() {
408
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
409
+    }
410
+
411
+    /**
412
+     * Setup the final data for the table
413
+     *
414
+     */
415
+    public function prepare_items() {
416
+
417
+        $columns  = $this->get_columns();
418
+        $hidden   = array();
419
+        $sortable = $this->get_sortable_columns();
420
+
421
+        $this->_column_headers = array( $columns, $hidden, $sortable );
422
+
423
+        $this->set_pagination_args(
424
+            array(
425
+                'total_items' => $this->current_total_count,
426
+                'per_page'    => $this->per_page,
427
+                'total_pages' => ceil( $this->current_total_count / $this->per_page ),
428
+            )
429
+        );
430
+    }
431
+
432
+    /**
433
+     * Table columns
434
+     *
435
+     * @return array
436
+     */
437
+    public function get_columns() {
438
+        $columns = array(
439
+            'cb'           => '<input type="checkbox" />',
440
+            'subscription' => __( 'Subscription', 'invoicing' ),
441
+            'start_date'   => __( 'Start Date', 'invoicing' ),
442
+            'renewal_date' => __( 'Next Payment', 'invoicing' ),
443
+            'renewals'     => __( 'Payments', 'invoicing' ),
444
+            'item'         => __( 'Items', 'invoicing' ),
445
+            'status'       => __( 'Status', 'invoicing' ),
446
+        );
447
+
448
+        return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
449
+    }
450
+
451
+    /**
452
+     * Sortable table columns.
453
+     *
454
+     * @return array
455
+     */
456
+    public function get_sortable_columns() {
457
+        $sortable = array(
458
+            'subscription' => array( 'id', true ),
459
+            'start_date'   => array( 'created', true ),
460
+            'renewal_date' => array( 'expiration', true ),
461
+            'renewals'     => array( 'bill_times', true ),
462
+            'item'         => array( 'product_id', true ),
463
+            'status'       => array( 'status', true ),
464
+        );
465
+
466
+        return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
467
+    }
468
+
469
+    /**
470
+     * Whether the table has items to display or not
471
+     *
472
+     * @return bool
473
+     */
474
+    public function has_items() {
475
+        return ! empty( $this->current_total_count );
476
+    }
477
+
478
+    /**
479
+     * Processes bulk actions.
480
+     *
481
+     */
482
+    public function process_bulk_action() {
483
+
484
+    }
485 485
 
486 486
 }
Please login to merge, or discard this patch.
Spacing   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -3,11 +3,11 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) {
6
+if (!defined('ABSPATH')) {
7 7
 exit;
8 8
 }
9 9
 
10
-if ( ! class_exists( 'WP_List_Table' ) ) {
10
+if (!class_exists('WP_List_Table')) {
11 11
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
12 12
 }
13 13
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 
81 81
 		$this->prepare_query();
82 82
 
83
-		$this->base_url = remove_query_arg( 'status' );
83
+		$this->base_url = remove_query_arg('status');
84 84
 
85 85
 	}
86 86
 
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 		$query = array(
94 94
 			'number'      => $this->per_page,
95 95
 			'paged'       => $this->get_paged(),
96
-			'status'      => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? sanitize_text_field( $_GET['status'] ) : 'all',
97
-			'orderby'     => ( isset( $_GET['orderby'] ) ) ? sanitize_text_field( $_GET['orderby'] ) : 'id',
98
-			'order'       => ( isset( $_GET['order'] ) ) ? sanitize_text_field( $_GET['order'] ) : 'DESC',
96
+			'status'      => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? sanitize_text_field($_GET['status']) : 'all',
97
+			'orderby'     => (isset($_GET['orderby'])) ? sanitize_text_field($_GET['orderby']) : 'id',
98
+			'order'       => (isset($_GET['order'])) ? sanitize_text_field($_GET['order']) : 'DESC',
99 99
 			'customer_in' => $this->get_user_in(),
100 100
 		);
101 101
 
102
-		if ( is_array( $query['customer_in'] ) && empty( $query['customer_in'] ) ) {
102
+		if (is_array($query['customer_in']) && empty($query['customer_in'])) {
103 103
 			$this->total_count         = 0;
104 104
 			$this->current_total_count = 0;
105 105
 			$this->items               = array();
@@ -108,15 +108,15 @@  discard block
 block discarded – undo
108 108
 		}
109 109
 
110 110
 		// Prepare class properties.
111
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
111
+		$this->query               = new GetPaid_Subscriptions_Query($query);
112 112
 		$this->total_count         = $this->query->get_total();
113 113
 		$this->current_total_count = $this->query->get_total();
114 114
 		$this->items               = $this->query->get_results();
115
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
115
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
116 116
 
117
-		if ( 'all' != $query['status'] ) {
118
-			unset( $query['status'] );
119
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
117
+		if ('all' != $query['status']) {
118
+			unset($query['status']);
119
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
120 120
 		}
121 121
 
122 122
 	}
@@ -128,14 +128,14 @@  discard block
 block discarded – undo
128 128
 	public function get_user_in() {
129 129
 
130 130
 		// Abort if no user.
131
-		if ( empty( $_GET['s'] ) ) {
131
+		if (empty($_GET['s'])) {
132 132
 			return null;
133 133
 		}
134 134
 
135 135
 		// Or invalid user.
136
-		$user = wp_unslash( sanitize_text_field( $_REQUEST['s'] ) );
136
+		$user = wp_unslash(sanitize_text_field($_REQUEST['s']));
137 137
 
138
-		if ( empty( $user ) ) {
138
+		if (empty($user)) {
139 139
 			return null;
140 140
 		}
141 141
 
@@ -164,26 +164,26 @@  discard block
 block discarded – undo
164 164
 	 */
165 165
 	public function get_views() {
166 166
 
167
-		$current  = isset( $_GET['status'] ) ? sanitize_text_field( $_GET['status'] ) : 'all';
167
+		$current  = isset($_GET['status']) ? sanitize_text_field($_GET['status']) : 'all';
168 168
 		$views    = array(
169 169
 
170 170
 			'all' => sprintf(
171 171
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
172
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
172
+				esc_url(add_query_arg('status', false, $this->base_url)),
173 173
 				$current === 'all' ? ' class="current"' : '',
174
-				__( 'All', 'invoicing' ),
174
+				__('All', 'invoicing'),
175 175
 				$this->total_count
176 176
 			),
177 177
 
178 178
 		);
179 179
 
180
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
180
+		foreach (array_filter($this->status_counts) as $status => $count) {
181 181
 
182
-			$views[ $status ] = sprintf(
182
+			$views[$status] = sprintf(
183 183
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
184
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
184
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
185 185
 				$current === $status ? ' class="current"' : '',
186
-				esc_html( getpaid_get_subscription_status_label( $status ) ),
186
+				esc_html(getpaid_get_subscription_status_label($status)),
187 187
 				$count
188 188
 			);
189 189
 
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
 	 * @since       1.0.0
201 201
 	 * @return      string
202 202
 	 */
203
-	public function column_default( $item, $column_name ) {
204
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
203
+	public function column_default($item, $column_name) {
204
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
205 205
 	}
206 206
 
207 207
 	/**
@@ -210,8 +210,8 @@  discard block
 block discarded – undo
210 210
 	 * @param WPInv_Subscription $item
211 211
 	 * @return string
212 212
 	 */
213
-	public function column_cb( $item ) {
214
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
213
+	public function column_cb($item) {
214
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
215 215
 	}
216 216
 
217 217
 	/**
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
 	 * @since       1.0.0
222 222
 	 * @return      string
223 223
 	 */
224
-	public function column_status( $item ) {
224
+	public function column_status($item) {
225 225
 		return $item->get_status_label_html();
226 226
 	}
227 227
 
@@ -232,26 +232,26 @@  discard block
 block discarded – undo
232 232
 	 * @since       1.0.0
233 233
 	 * @return      string
234 234
 	 */
235
-	public function column_subscription( $item ) {
235
+	public function column_subscription($item) {
236 236
 
237
-		$username = __( '(Missing User)', 'invoicing' );
237
+		$username = __('(Missing User)', 'invoicing');
238 238
 
239
-		$user = get_userdata( $item->get_customer_id() );
239
+		$user = get_userdata($item->get_customer_id());
240 240
 		$capabilities = wpinv_current_user_can_manage_invoicing();
241 241
 
242
-		if ( $user ) {
242
+		if ($user) {
243 243
 			$username = sprintf(
244 244
 				'<a href="user-edit.php?user_id=%s">%s</a>',
245
-				absint( $user->ID ),
246
-				! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
245
+				absint($user->ID),
246
+				!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
247 247
 			);
248 248
 		}
249 249
 
250 250
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
251 251
 		$column_content = sprintf(
252
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
253
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
254
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>',
252
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
253
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
254
+			'<strong>' . esc_attr($item->get_id()) . '</strong>',
255 255
 			'</a>',
256 256
 			$username
257 257
 		);
@@ -259,18 +259,18 @@  discard block
 block discarded – undo
259 259
 		$row_actions = array();
260 260
 
261 261
 		// View subscription.
262
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ) );
263
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
262
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
263
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
264 264
 
265 265
 		// View invoice.
266
-		$invoice = get_post( $item->get_parent_invoice_id() );
266
+		$invoice = get_post($item->get_parent_invoice_id());
267 267
 
268
-		if ( ! empty( $invoice ) ) {
269
-			$invoice_url            = get_edit_post_link( $invoice );
270
-			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
268
+		if (!empty($invoice)) {
269
+			$invoice_url            = get_edit_post_link($invoice);
270
+			$row_actions['invoice'] = '<a href="' . $invoice_url . '">' . __('View Invoice', 'invoicing') . '</a>';
271 271
 		}
272 272
 
273
-		$delete_url            = esc_url(
273
+		$delete_url = esc_url(
274 274
 			wp_nonce_url(
275 275
 				add_query_arg(
276 276
 					array(
@@ -282,15 +282,15 @@  discard block
 block discarded – undo
282 282
 				'getpaid-nonce'
283 283
 			)
284 284
 		);
285
-		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __( 'Delete Subscription', 'invoicing' ) . '</a>';
285
+		$row_actions['delete'] = '<a class="text-danger" href="' . $delete_url . '">' . __('Delete Subscription', 'invoicing') . '</a>';
286 286
 
287
-		if ( ! $capabilities ) {
287
+		if (!$capabilities) {
288 288
 			$row_actions = array();
289 289
 		}
290 290
 
291
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
291
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
292 292
 
293
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
293
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
294 294
 	}
295 295
 
296 296
 	/**
@@ -300,8 +300,8 @@  discard block
 block discarded – undo
300 300
 	 * @since       1.0.0
301 301
 	 * @return      string
302 302
 	 */
303
-	public function column_renewal_date( $item ) {
304
-		return getpaid_format_date_value( $item->get_expiration() );
303
+	public function column_renewal_date($item) {
304
+		return getpaid_format_date_value($item->get_expiration());
305 305
 	}
306 306
 
307 307
 	/**
@@ -311,27 +311,27 @@  discard block
 block discarded – undo
311 311
 	 * @since       1.0.0
312 312
 	 * @return      string
313 313
 	 */
314
-	public function column_start_date( $item ) {
314
+	public function column_start_date($item) {
315 315
 
316 316
 		$gateway = $item->get_parent_invoice()->get_gateway_title();
317 317
 
318
-		if ( empty( $gateway ) ) {
319
-			return getpaid_format_date_value( $item->get_date_created() );
318
+		if (empty($gateway)) {
319
+			return getpaid_format_date_value($item->get_date_created());
320 320
 		}
321 321
 
322
-		$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $item );
323
-		if ( ! empty( $url ) ) {
322
+		$url = apply_filters('getpaid_remote_subscription_profile_url', '', $item);
323
+		if (!empty($url)) {
324 324
 
325
-			return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
326
-				__( 'Via %s', 'invoicing' ),
327
-				'<strong><a href="' . esc_url( $url ) . '" target="_blank">' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</a></strong>'
325
+			return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
326
+				__('Via %s', 'invoicing'),
327
+				'<strong><a href="' . esc_url($url) . '" target="_blank">' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</a></strong>'
328 328
 			);
329 329
 
330 330
 		}
331 331
 
332
-		return getpaid_format_date_value( $item->get_date_created() ) . '<br>' . sprintf(
333
-			__( 'Via %s', 'invoicing' ),
334
-			'<strong>' . esc_html( $item->get_parent_invoice()->get_gateway_title() ) . '</strong>'
332
+		return getpaid_format_date_value($item->get_date_created()) . '<br>' . sprintf(
333
+			__('Via %s', 'invoicing'),
334
+			'<strong>' . esc_html($item->get_parent_invoice()->get_gateway_title()) . '</strong>'
335 335
 		);
336 336
 
337 337
 	}
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @since       1.0.19
344 344
 	 * @return      string
345 345
 	 */
346
-	public static function column_amount( $item ) {
347
-		$amount = getpaid_get_formatted_subscription_amount( $item );
346
+	public static function column_amount($item) {
347
+		$amount = getpaid_get_formatted_subscription_amount($item);
348 348
 		return "<span class='text-muted form-text mt-2 mb-2 ms-1 ml-1'>$amount</span>";
349 349
 	}
350 350
 
@@ -355,9 +355,9 @@  discard block
 block discarded – undo
355 355
 	 * @since       1.0.0
356 356
 	 * @return      string
357 357
 	 */
358
-	public function column_renewals( $item ) {
358
+	public function column_renewals($item) {
359 359
 		$max_bills = $item->get_bill_times();
360
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? '&infin;' : $max_bills );
360
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? '&infin;' : $max_bills);
361 361
 	}
362 362
 
363 363
 	/**
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 	 * @since       1.0.0
368 368
 	 * @return      string
369 369
 	 */
370
-	public function column_item( $item ) {
371
-		$subscription_group = getpaid_get_invoice_subscription_group( $item->get_parent_invoice_id(), $item->get_id() );
370
+	public function column_item($item) {
371
+		$subscription_group = getpaid_get_invoice_subscription_group($item->get_parent_invoice_id(), $item->get_id());
372 372
 
373
-		if ( empty( $subscription_group ) ) {
374
-			return $this->generate_item_markup( $item->get_product_id() );
373
+		if (empty($subscription_group)) {
374
+			return $this->generate_item_markup($item->get_product_id());
375 375
 		}
376 376
 
377
-		$markup = array_map( array( $this, 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
378
-		return implode( ' | ', $markup );
377
+		$markup = array_map(array($this, 'generate_item_markup'), array_keys($subscription_group['items']));
378
+		return implode(' | ', $markup);
379 379
 
380 380
 	}
381 381
 
@@ -386,15 +386,15 @@  discard block
 block discarded – undo
386 386
 	 * @since       1.0.0
387 387
 	 * @return      string
388 388
 	 */
389
-	public static function generate_item_markup( $item_id ) {
390
-		$item = get_post( $item_id );
389
+	public static function generate_item_markup($item_id) {
390
+		$item = get_post($item_id);
391 391
 
392
-		if ( ! empty( $item ) ) {
393
-			$link = get_edit_post_link( $item );
394
-			$name = esc_html( get_the_title( $item ) );
395
-			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ( $link ? esc_url( $link ) : '#' ) . "'>$name</a>" : $name;
392
+		if (!empty($item)) {
393
+			$link = get_edit_post_link($item);
394
+			$name = esc_html(get_the_title($item));
395
+			return wpinv_current_user_can_manage_invoicing() ? "<a href='" . ($link ? esc_url($link) : '#') . "'>$name</a>" : $name;
396 396
 		} else {
397
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item_id );
397
+			return sprintf(__('Item #%s', 'invoicing'), $item_id);
398 398
 		}
399 399
 
400 400
 	}
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 	 * @return      int
406 406
 	 */
407 407
 	public function get_paged() {
408
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
408
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
409 409
 	}
410 410
 
411 411
 	/**
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 		$hidden   = array();
419 419
 		$sortable = $this->get_sortable_columns();
420 420
 
421
-		$this->_column_headers = array( $columns, $hidden, $sortable );
421
+		$this->_column_headers = array($columns, $hidden, $sortable);
422 422
 
423 423
 		$this->set_pagination_args(
424 424
 			array(
425 425
 				'total_items' => $this->current_total_count,
426 426
 				'per_page'    => $this->per_page,
427
-				'total_pages' => ceil( $this->current_total_count / $this->per_page ),
427
+				'total_pages' => ceil($this->current_total_count / $this->per_page),
428 428
 			)
429 429
 		);
430 430
 	}
@@ -437,15 +437,15 @@  discard block
 block discarded – undo
437 437
 	public function get_columns() {
438 438
 		$columns = array(
439 439
 			'cb'           => '<input type="checkbox" />',
440
-			'subscription' => __( 'Subscription', 'invoicing' ),
441
-			'start_date'   => __( 'Start Date', 'invoicing' ),
442
-			'renewal_date' => __( 'Next Payment', 'invoicing' ),
443
-			'renewals'     => __( 'Payments', 'invoicing' ),
444
-			'item'         => __( 'Items', 'invoicing' ),
445
-			'status'       => __( 'Status', 'invoicing' ),
440
+			'subscription' => __('Subscription', 'invoicing'),
441
+			'start_date'   => __('Start Date', 'invoicing'),
442
+			'renewal_date' => __('Next Payment', 'invoicing'),
443
+			'renewals'     => __('Payments', 'invoicing'),
444
+			'item'         => __('Items', 'invoicing'),
445
+			'status'       => __('Status', 'invoicing'),
446 446
 		);
447 447
 
448
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
448
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
449 449
 	}
450 450
 
451 451
 	/**
@@ -455,15 +455,15 @@  discard block
 block discarded – undo
455 455
 	 */
456 456
 	public function get_sortable_columns() {
457 457
 		$sortable = array(
458
-			'subscription' => array( 'id', true ),
459
-			'start_date'   => array( 'created', true ),
460
-			'renewal_date' => array( 'expiration', true ),
461
-			'renewals'     => array( 'bill_times', true ),
462
-			'item'         => array( 'product_id', true ),
463
-			'status'       => array( 'status', true ),
458
+			'subscription' => array('id', true),
459
+			'start_date'   => array('created', true),
460
+			'renewal_date' => array('expiration', true),
461
+			'renewals'     => array('bill_times', true),
462
+			'item'         => array('product_id', true),
463
+			'status'       => array('status', true),
464 464
 		);
465 465
 
466
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
466
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
467 467
 	}
468 468
 
469 469
 	/**
@@ -472,7 +472,7 @@  discard block
 block discarded – undo
472 472
 	 * @return bool
473 473
 	 */
474 474
 	public function has_items() {
475
-		return ! empty( $this->current_total_count );
475
+		return !empty($this->current_total_count);
476 476
 	}
477 477
 
478 478
 	/**
Please login to merge, or discard this patch.
includes/subscription-functions.php 2 patches
Indentation   +323 added lines, -323 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
  */
51 51
 function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52 52
     $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
53
+    $matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54 54
     return reset( $matching_group );
55 55
 }
56 56
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
  */
64 64
 function getpaid_get_subscription( $subscription ) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
68
-	}
66
+    if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
+        $subscription = new WPInv_Subscription( $subscription );
68
+    }
69 69
 
70
-	return $subscription->exists() ? $subscription : false;
70
+    return $subscription->exists() ? $subscription : false;
71 71
 }
72 72
 
73 73
 /**
@@ -81,28 +81,28 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
83 83
 
84
-	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
86
-		$args['fields'] = 'id';
87
-		$args['number'] = 1;
88
-	}
84
+    // Do not retrieve all fields if we just want the count.
85
+    if ( 'count' == $return ) {
86
+        $args['fields'] = 'id';
87
+        $args['number'] = 1;
88
+    }
89 89
 
90
-	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
92
-		$args['count_total'] = false;
93
-	}
90
+    // Do not count all matches if we just want the results.
91
+    if ( 'results' == $return ) {
92
+        $args['count_total'] = false;
93
+    }
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+    $query = new GetPaid_Subscriptions_Query( $args );
96 96
 
97
-	if ( 'results' == $return ) {
98
-		return $query->get_results();
99
-	}
97
+    if ( 'results' == $return ) {
98
+        return $query->get_results();
99
+    }
100 100
 
101
-	if ( 'count' == $return ) {
102
-		return $query->get_total();
103
-	}
101
+    if ( 'count' == $return ) {
102
+        return $query->get_total();
103
+    }
104 104
 
105
-	return $query;
105
+    return $query;
106 106
 }
107 107
 
108 108
 /**
@@ -112,18 +112,18 @@  discard block
 block discarded – undo
112 112
  */
113 113
 function getpaid_get_subscription_statuses() {
114 114
 
115
-	return apply_filters(
116
-		'getpaid_get_subscription_statuses',
117
-		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
125
-		)
126
-	);
115
+    return apply_filters(
116
+        'getpaid_get_subscription_statuses',
117
+        array(
118
+            'pending'   => __( 'Pending', 'invoicing' ),
119
+            'trialling' => __( 'Trialing', 'invoicing' ),
120
+            'active'    => __( 'Active', 'invoicing' ),
121
+            'failing'   => __( 'Failing', 'invoicing' ),
122
+            'expired'   => __( 'Expired', 'invoicing' ),
123
+            'completed' => __( 'Complete', 'invoicing' ),
124
+            'cancelled' => __( 'Cancelled', 'invoicing' ),
125
+        )
126
+    );
127 127
 
128 128
 }
129 129
 
@@ -133,8 +133,8 @@  discard block
 block discarded – undo
133 133
  * @return string
134 134
  */
135 135
 function getpaid_get_subscription_status_label( $status ) {
136
-	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
136
+    $statuses = getpaid_get_subscription_statuses();
137
+    return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
138 138
 }
139 139
 
140 140
 /**
@@ -144,18 +144,18 @@  discard block
 block discarded – undo
144 144
  */
145 145
 function getpaid_get_subscription_status_classes() {
146 146
 
147
-	return apply_filters(
148
-		'getpaid_get_subscription_status_classes',
149
-		array(
150
-			'pending'   => 'bg-dark',
151
-			'trialling' => 'bg-info',
152
-			'active'    => 'bg-success',
153
-			'failing'   => 'bg-warning text-dark',
154
-			'expired'   => 'bg-danger',
155
-			'completed' => 'bg-primary',
156
-			'cancelled' => 'bg-secondary',
157
-		)
158
-	);
147
+    return apply_filters(
148
+        'getpaid_get_subscription_status_classes',
149
+        array(
150
+            'pending'   => 'bg-dark',
151
+            'trialling' => 'bg-info',
152
+            'active'    => 'bg-success',
153
+            'failing'   => 'bg-warning text-dark',
154
+            'expired'   => 'bg-danger',
155
+            'completed' => 'bg-primary',
156
+            'cancelled' => 'bg-secondary',
157
+        )
158
+    );
159 159
 
160 160
 }
161 161
 
@@ -166,15 +166,15 @@  discard block
 block discarded – undo
166 166
  */
167 167
 function getpaid_get_subscription_status_counts( $args = array() ) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
170
-	$counts   = array();
169
+    $statuses = array_keys( getpaid_get_subscription_statuses() );
170
+    $counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
-	}
172
+    foreach ( $statuses as $status ) {
173
+        $_args             = wp_parse_args( "status=$status", $args );
174
+        $counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
175
+    }
176 176
 
177
-	return $counts;
177
+    return $counts;
178 178
 
179 179
 }
180 180
 
@@ -185,32 +185,32 @@  discard block
 block discarded – undo
185 185
  */
186 186
 function getpaid_get_subscription_periods() {
187 187
 
188
-	return apply_filters(
189
-		'getpaid_get_subscription_periods',
190
-		array(
188
+    return apply_filters(
189
+        'getpaid_get_subscription_periods',
190
+        array(
191 191
 
192
-			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
195
-			),
192
+            'day'   => array(
193
+                'singular' => __( '%s day', 'invoicing' ),
194
+                'plural'   => __( '%d days', 'invoicing' ),
195
+            ),
196 196
 
197
-			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
200
-			),
197
+            'week'  => array(
198
+                'singular' => __( '%s week', 'invoicing' ),
199
+                'plural'   => __( '%d weeks', 'invoicing' ),
200
+            ),
201 201
 
202
-			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
205
-			),
202
+            'month' => array(
203
+                'singular' => __( '%s month', 'invoicing' ),
204
+                'plural'   => __( '%d months', 'invoicing' ),
205
+            ),
206 206
 
207
-			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
210
-			),
207
+            'year'  => array(
208
+                'singular' => __( '%s year', 'invoicing' ),
209
+                'plural'   => __( '%d years', 'invoicing' ),
210
+            ),
211 211
 
212
-		)
213
-	);
212
+        )
213
+    );
214 214
 
215 215
 }
216 216
 
@@ -221,7 +221,7 @@  discard block
 block discarded – undo
221 221
  * @return int
222 222
  */
223 223
 function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
224
+    return (int) preg_replace( '/[^0-9]/', '', $trial_period );
225 225
 }
226 226
 
227 227
 /**
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
  * @return string
232 232
  */
233 233
 function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
234
+    return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
235 235
 }
236 236
 
237 237
 /**
@@ -242,8 +242,8 @@  discard block
 block discarded – undo
242 242
  * @return string
243 243
  */
244 244
 function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
245
+    $label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
+    return strtolower( sanitize_text_field( $label ) );
247 247
 }
248 248
 
249 249
 /**
@@ -254,22 +254,22 @@  discard block
 block discarded – undo
254 254
  */
255 255
 function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
256 256
 
257
-	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
257
+    $periods = getpaid_get_subscription_periods();
258
+    $period  = strtolower( $period );
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
-	}
260
+    if ( isset( $periods[ $period ] ) ) {
261
+        return sprintf( $periods[ $period ]['singular'], $singular_prefix );
262
+    }
263 263
 
264
-	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
268
-		}
269
-	}
264
+    // Backwards compatibility.
265
+    foreach ( $periods as $key => $data ) {
266
+        if ( strpos( $key, $period ) === 0 ) {
267
+            return sprintf( $data['singular'], $singular_prefix );
268
+        }
269
+    }
270 270
 
271
-	// Invalid string.
272
-	return '';
271
+    // Invalid string.
272
+    return '';
273 273
 }
274 274
 
275 275
 /**
@@ -281,22 +281,22 @@  discard block
 block discarded – undo
281 281
  */
282 282
 function getpaid_get_plural_subscription_period_label( $period, $interval ) {
283 283
 
284
-	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
284
+    $periods = getpaid_get_subscription_periods();
285
+    $period  = strtolower( $period );
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
289
-	}
287
+    if ( isset( $periods[ $period ] ) ) {
288
+        return sprintf( $periods[ $period ]['plural'], $interval );
289
+    }
290 290
 
291
-	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
295
-		}
296
-	}
291
+    // Backwards compatibility.
292
+    foreach ( $periods as $key => $data ) {
293
+        if ( strpos( $key, $period ) === 0 ) {
294
+            return sprintf( $data['plural'], $interval );
295
+        }
296
+    }
297 297
 
298
-	// Invalid string.
299
-	return '';
298
+    // Invalid string.
299
+    return '';
300 300
 }
301 301
 
302 302
 /**
@@ -307,92 +307,92 @@  discard block
 block discarded – undo
307 307
  */
308 308
 function getpaid_get_formatted_subscription_amount( $subscription ) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
-	$bill_times = $subscription->get_bill_times();
314
-	$bill_times_less = $bill_times - 1;
315
-
316
-	if ( ! empty( $bill_times ) ) {
317
-		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
-	}
321
-
322
-	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
324
-
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
-
328
-		if ( empty( $bill_times ) ) {
329
-
330
-			return sprintf(
331
-				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
-				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
-				$recurring,
336
-				$period
337
-			);
338
-
339
-		}
340
-
341
-		return sprintf(
342
-			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
-			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
-			$recurring,
347
-			$period,
348
-			$bill_times
349
-		);
350
-
351
-	}
352
-
353
-	if ( $initial != $recurring ) {
354
-
355
-		if ( empty( $bill_times ) ) {
356
-
357
-			return sprintf(
358
-				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
-				$initial,
361
-				$recurring,
362
-				$period
363
-			);
364
-
365
-		}
366
-
367
-		return sprintf(
368
-			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
-			$initial,
371
-			$recurring,
372
-			$period,
373
-			$bill_times_less
374
-		);
375
-
376
-	}
377
-
378
-	if ( empty( $bill_times ) ) {
379
-
380
-		return sprintf(
381
-			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
-			$initial,
384
-			$period
385
-		);
386
-
387
-	}
388
-
389
-	return sprintf(
390
-		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
-		$bill_times,
393
-		$initial,
394
-		$period
395
-	);
310
+    $initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
+    $recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
+    $period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
313
+    $bill_times = $subscription->get_bill_times();
314
+    $bill_times_less = $bill_times - 1;
315
+
316
+    if ( ! empty( $bill_times ) ) {
317
+        $bill_times = $subscription->get_frequency() * $bill_times;
318
+        $bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() );
319
+        $bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
320
+    }
321
+
322
+    // Trial periods.
323
+    if ( $subscription->has_trial_period() ) {
324
+
325
+        $trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
+        $trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
327
+
328
+        if ( empty( $bill_times ) ) {
329
+
330
+            return sprintf(
331
+                // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
+                _x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
333
+                $initial,
334
+                getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
335
+                $recurring,
336
+                $period
337
+            );
338
+
339
+        }
340
+
341
+        return sprintf(
342
+            // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
+            _x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
344
+            $initial,
345
+            getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
346
+            $recurring,
347
+            $period,
348
+            $bill_times
349
+        );
350
+
351
+    }
352
+
353
+    if ( $initial != $recurring ) {
354
+
355
+        if ( empty( $bill_times ) ) {
356
+
357
+            return sprintf(
358
+                // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
+                _x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
360
+                $initial,
361
+                $recurring,
362
+                $period
363
+            );
364
+
365
+        }
366
+
367
+        return sprintf(
368
+            // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
+            _x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
370
+            $initial,
371
+            $recurring,
372
+            $period,
373
+            $bill_times_less
374
+        );
375
+
376
+    }
377
+
378
+    if ( empty( $bill_times ) ) {
379
+
380
+        return sprintf(
381
+            // translators: $1: is the recurring amount, $2: is the recurring period
382
+            _x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
383
+            $initial,
384
+            $period
385
+        );
386
+
387
+    }
388
+
389
+    return sprintf(
390
+        // translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
+        _x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
392
+        $bill_times,
393
+        $initial,
394
+        $period
395
+    );
396 396
 
397 397
 }
398 398
 
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
  * @return WPInv_Subscription|false
404 404
  */
405 405
 function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
406
+    return getpaid_subscriptions()->get_invoice_subscription( $invoice );
407 407
 }
408 408
 
409 409
 /**
@@ -412,10 +412,10 @@  discard block
 block discarded – undo
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414 414
 function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
-		$subscription->activate();
418
-	}
415
+    $subscription = getpaid_get_invoice_subscription( $invoice );
416
+    if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
417
+        $subscription->activate();
418
+    }
419 419
 }
420 420
 
421 421
 /**
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+    return getpaid()->get( 'subscriptions' );
428 428
 }
429 429
 
430 430
 /**
@@ -443,15 +443,15 @@  discard block
 block discarded – undo
443 443
         return false;
444 444
     }
445 445
 
446
-	// Fetch the invoice subscription.
447
-	$subscription = getpaid_get_subscriptions(
448
-		array(
449
-			'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
-			'number'     => 1,
451
-		)
452
-	);
446
+    // Fetch the invoice subscription.
447
+    $subscription = getpaid_get_subscriptions(
448
+        array(
449
+            'invoice_in' => $invoice->is_renewal() ? $invoice->get_parent_id() : $invoice->get_id(),
450
+            'number'     => 1,
451
+        )
452
+    );
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+    return empty( $subscription ) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -468,48 +468,48 @@  discard block
 block discarded – undo
468 468
  */
469 469
 function getpaid_get_recurring_item_key( $cart_item ) {
470 470
 
471
-	$cart_key     = 'renews_';
472
-	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
474
-	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
476
-	$trial_length = $cart_item->get_trial_interval();
477
-
478
-	// First start with the billing interval and period
479
-	switch ( $interval ) {
480
-		case 1:
481
-			if ( 'day' == $period ) {
482
-				$cart_key .= 'daily';
483
-			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
485
-			}
486
-			break;
487
-		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
489
-			break;
490
-		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
492
-		    break;
493
-		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
-			break;
496
-	}
497
-
498
-	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
500
-		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
503
-			$cart_key .= 's';
504
-		}
505
-	}
506
-
507
-	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
-	}
511
-
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
471
+    $cart_key     = 'renews_';
472
+    $interval     = $cart_item->get_recurring_interval();
473
+    $period       = $cart_item->get_recurring_period( true );
474
+    $length       = $cart_item->get_recurring_limit() * $interval;
475
+    $trial_period = $cart_item->get_trial_period( true );
476
+    $trial_length = $cart_item->get_trial_interval();
477
+
478
+    // First start with the billing interval and period
479
+    switch ( $interval ) {
480
+        case 1:
481
+            if ( 'day' == $period ) {
482
+                $cart_key .= 'daily';
483
+            } else {
484
+                $cart_key .= sprintf( '%sly', $period );
485
+            }
486
+            break;
487
+        case 2:
488
+            $cart_key .= sprintf( 'every_2nd_%s', $period );
489
+            break;
490
+        case 3:
491
+            $cart_key .= sprintf( 'every_3rd_%s', $period );
492
+            break;
493
+        default:
494
+            $cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
495
+            break;
496
+    }
497
+
498
+    // Maybe add the optional maximum billing periods...
499
+    if ( $length > 0 ) {
500
+        $cart_key .= '_for_';
501
+        $cart_key .= sprintf( '%d_%s', $length, $period );
502
+        if ( $length > 1 ) {
503
+            $cart_key .= 's';
504
+        }
505
+    }
506
+
507
+    // And an optional free trial.
508
+    if ( $cart_item->has_free_trial() ) {
509
+        $cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
510
+    }
511
+
512
+    return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
513 513
 }
514 514
 
515 515
 /**
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
  */
521 521
 function getpaid_get_subscription_groups( $invoice ) {
522 522
 
523
-	// Generate subscription groups.
524
-	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
523
+    // Generate subscription groups.
524
+    $subscription_groups = array();
525
+    foreach ( $invoice->get_items() as $item ) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
-		}
527
+        if ( $item->is_recurring() ) {
528
+            $subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
529
+        }
530 530
 }
531 531
 
532
-	return $subscription_groups;
532
+    return $subscription_groups;
533 533
 }
534 534
 
535 535
 /**
@@ -543,56 +543,56 @@  discard block
 block discarded – undo
543 543
  */
544 544
 function getpaid_calculate_subscription_totals( $invoice ) {
545 545
 
546
-	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
546
+    // Generate subscription groups.
547
+    $subscription_groups = getpaid_get_subscription_groups( $invoice );
548 548
 
549
-	// Now let's calculate the totals for each group of subscriptions
550
-	$subscription_totals = array();
549
+    // Now let's calculate the totals for each group of subscriptions
550
+    $subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+    foreach ( $subscription_groups as $subscription_key => $items ) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+        if ( empty( $subscription_totals[ $subscription_key ] ) ) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
557
-				'initial_total'   => 0,
558
-				'recurring_total' => 0,
559
-				'items'           => array(),
560
-				'trialling'       => false,
561
-			);
556
+            $subscription_totals[ $subscription_key ] = array(
557
+                'initial_total'   => 0,
558
+                'recurring_total' => 0,
559
+                'items'           => array(),
560
+                'trialling'       => false,
561
+            );
562 562
 
563
-		}
563
+        }
564 564
 
565
-		/**
566
-		 * Get the totals of the group.
567
-		 * @var GetPaid_Form_Item $item
568
-		 */
569
-		foreach ( $items as $item ) {
565
+        /**
566
+         * Get the totals of the group.
567
+         * @var GetPaid_Form_Item $item
568
+         */
569
+        foreach ( $items as $item ) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+            $subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
+            $subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
+            $subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
+            $subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
+            $subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+            $subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+            $subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579
-			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
581
-			$interval     = $item->get_recurring_interval();
579
+            // Calculate the next renewal date.
580
+            $period       = $item->get_recurring_period( true );
581
+            $interval     = $item->get_recurring_interval();
582 582
 
583
-			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
586
-				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
-			}
583
+            // If the subscription item has a trial period...
584
+            if ( $item->has_free_trial() ) {
585
+                $period   = $item->get_trial_period( true );
586
+                $interval = $item->get_trial_interval();
587
+                $subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
588
+            }
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+            $subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
591 591
 
592
-		}
592
+        }
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+    return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
596 596
 }
597 597
 
598 598
 /**
@@ -603,16 +603,16 @@  discard block
 block discarded – undo
603 603
  */
604 604
 function getpaid_should_group_subscriptions( $invoice ) {
605 605
 
606
-	$recurring_items = 0;
606
+    $recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+    foreach ( $invoice->get_items() as $item ) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
612
-		}
610
+        if ( $item->is_recurring() ) {
611
+            $recurring_items ++;
612
+        }
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+    return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
616 616
 }
617 617
 
618 618
 /**
@@ -623,39 +623,39 @@  discard block
 block discarded – undo
623 623
  * @return int
624 624
  */
625 625
 function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
626
-	global $wpdb;
626
+    global $wpdb;
627 627
 
628
-	$parent_invoice_id = (int) $parent_invoice_id;
628
+    $parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+    if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
631 631
 
632
-		return (int) $wpdb->get_var(
633
-			$wpdb->prepare(
634
-				"SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
-				$parent_invoice_id,
636
-				$parent_invoice_id
637
-			)
638
-		);
632
+        return (int) $wpdb->get_var(
633
+            $wpdb->prepare(
634
+                "SELECT COUNT(ID) FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
635
+                $parent_invoice_id,
636
+                $parent_invoice_id
637
+            )
638
+        );
639 639
 
640
-	}
640
+    }
641 641
 
642
-	$invoice_ids = $wpdb->get_col(
643
-		$wpdb->prepare(
644
-			"SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
-			$parent_invoice_id,
646
-			$parent_invoice_id
647
-		)
648
-	);
642
+    $invoice_ids = $wpdb->get_col(
643
+        $wpdb->prepare(
644
+            "SELECT ID FROM $wpdb->posts WHERE ( post_parent=%d OR ID=%d ) AND post_status IN ( 'publish', 'wpi-processing', 'wpi-renewal' )",
645
+            $parent_invoice_id,
646
+            $parent_invoice_id
647
+        )
648
+    );
649 649
 
650
-	$count = 0;
650
+    $count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+    foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
656
-			continue;
657
-		}
654
+        if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
+            $count ++;
656
+            continue;
657
+        }
658 658
 }
659 659
 
660
-	return $count;
660
+    return $count;
661 661
 }
Please login to merge, or discard this patch.
Spacing   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -13,18 +13,18 @@  discard block
 block discarded – undo
13 13
  * @return      WPInv_Subscription[]|WPInv_Subscription|false
14 14
  * @since       2.3.0
15 15
  */
16
-function getpaid_get_invoice_subscriptions( $invoice ) {
16
+function getpaid_get_invoice_subscriptions($invoice) {
17 17
 
18 18
     // Retrieve subscription groups.
19
-    $subscription_ids = wp_list_pluck( getpaid_get_invoice_subscription_groups( $invoice->get_id() ), 'subscription_id' );
19
+    $subscription_ids = wp_list_pluck(getpaid_get_invoice_subscription_groups($invoice->get_id()), 'subscription_id');
20 20
 
21 21
     // No subscription groups, normal subscription.
22
-    if ( empty( $subscription_ids ) ) {
23
-        return getpaid_subscriptions()->get_invoice_subscription( $invoice );
22
+    if (empty($subscription_ids)) {
23
+        return getpaid_subscriptions()->get_invoice_subscription($invoice);
24 24
     }
25 25
 
26 26
     // Subscription groups.
27
-    return array_filter( array_map( 'getpaid_get_subscription', $subscription_ids ) );
27
+    return array_filter(array_map('getpaid_get_subscription', $subscription_ids));
28 28
 
29 29
 }
30 30
 
@@ -35,9 +35,9 @@  discard block
 block discarded – undo
35 35
  * @return      array
36 36
  * @since       2.3.0
37 37
  */
38
-function getpaid_get_invoice_subscription_groups( $invoice_id ) {
39
-    $subscription_groups = get_post_meta( $invoice_id, 'getpaid_subscription_groups', true );
40
-    return empty( $subscription_groups ) ? array() : $subscription_groups;
38
+function getpaid_get_invoice_subscription_groups($invoice_id) {
39
+    $subscription_groups = get_post_meta($invoice_id, 'getpaid_subscription_groups', true);
40
+    return empty($subscription_groups) ? array() : $subscription_groups;
41 41
 }
42 42
 
43 43
 /**
@@ -48,10 +48,10 @@  discard block
 block discarded – undo
48 48
  * @return      array|false
49 49
  * @since       2.3.0
50 50
  */
51
-function getpaid_get_invoice_subscription_group( $invoice_id, $subscription_id ) {
52
-    $subscription_groups = getpaid_get_invoice_subscription_groups( $invoice_id );
53
-	$matching_group      = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
54
-    return reset( $matching_group );
51
+function getpaid_get_invoice_subscription_group($invoice_id, $subscription_id) {
52
+    $subscription_groups = getpaid_get_invoice_subscription_groups($invoice_id);
53
+	$matching_group = wp_list_filter($subscription_groups, compact('subscription_id'));
54
+    return reset($matching_group);
55 55
 }
56 56
 
57 57
 /**
@@ -61,10 +61,10 @@  discard block
 block discarded – undo
61 61
  * @since       2.3.0
62 62
  * @return WPInv_Subscription|false
63 63
  */
64
-function getpaid_get_subscription( $subscription ) {
64
+function getpaid_get_subscription($subscription) {
65 65
 
66
-	if ( ! is_a( $subscription, 'WPInv_Subscription' ) ) {
67
-		$subscription = new WPInv_Subscription( $subscription );
66
+	if (!is_a($subscription, 'WPInv_Subscription')) {
67
+		$subscription = new WPInv_Subscription($subscription);
68 68
 	}
69 69
 
70 70
 	return $subscription->exists() ? $subscription : false;
@@ -79,26 +79,26 @@  discard block
 block discarded – undo
79 79
  *
80 80
  * @return int|array|WPInv_Subscription[]|GetPaid_Subscriptions_Query
81 81
  */
82
-function getpaid_get_subscriptions( $args = array(), $return = 'results' ) {
82
+function getpaid_get_subscriptions($args = array(), $return = 'results') {
83 83
 
84 84
 	// Do not retrieve all fields if we just want the count.
85
-	if ( 'count' == $return ) {
85
+	if ('count' == $return) {
86 86
 		$args['fields'] = 'id';
87 87
 		$args['number'] = 1;
88 88
 	}
89 89
 
90 90
 	// Do not count all matches if we just want the results.
91
-	if ( 'results' == $return ) {
91
+	if ('results' == $return) {
92 92
 		$args['count_total'] = false;
93 93
 	}
94 94
 
95
-	$query = new GetPaid_Subscriptions_Query( $args );
95
+	$query = new GetPaid_Subscriptions_Query($args);
96 96
 
97
-	if ( 'results' == $return ) {
97
+	if ('results' == $return) {
98 98
 		return $query->get_results();
99 99
 	}
100 100
 
101
-	if ( 'count' == $return ) {
101
+	if ('count' == $return) {
102 102
 		return $query->get_total();
103 103
 	}
104 104
 
@@ -115,13 +115,13 @@  discard block
 block discarded – undo
115 115
 	return apply_filters(
116 116
 		'getpaid_get_subscription_statuses',
117 117
 		array(
118
-			'pending'   => __( 'Pending', 'invoicing' ),
119
-			'trialling' => __( 'Trialing', 'invoicing' ),
120
-			'active'    => __( 'Active', 'invoicing' ),
121
-			'failing'   => __( 'Failing', 'invoicing' ),
122
-			'expired'   => __( 'Expired', 'invoicing' ),
123
-			'completed' => __( 'Complete', 'invoicing' ),
124
-			'cancelled' => __( 'Cancelled', 'invoicing' ),
118
+			'pending'   => __('Pending', 'invoicing'),
119
+			'trialling' => __('Trialing', 'invoicing'),
120
+			'active'    => __('Active', 'invoicing'),
121
+			'failing'   => __('Failing', 'invoicing'),
122
+			'expired'   => __('Expired', 'invoicing'),
123
+			'completed' => __('Complete', 'invoicing'),
124
+			'cancelled' => __('Cancelled', 'invoicing'),
125 125
 		)
126 126
 	);
127 127
 
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
  *
133 133
  * @return string
134 134
  */
135
-function getpaid_get_subscription_status_label( $status ) {
135
+function getpaid_get_subscription_status_label($status) {
136 136
 	$statuses = getpaid_get_subscription_statuses();
137
-	return isset( $statuses[ $status ] ) ? $statuses[ $status ] : ucfirst( sanitize_text_field( $status ) );
137
+	return isset($statuses[$status]) ? $statuses[$status] : ucfirst(sanitize_text_field($status));
138 138
 }
139 139
 
140 140
 /**
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
  *
165 165
  * @return array
166 166
  */
167
-function getpaid_get_subscription_status_counts( $args = array() ) {
167
+function getpaid_get_subscription_status_counts($args = array()) {
168 168
 
169
-	$statuses = array_keys( getpaid_get_subscription_statuses() );
169
+	$statuses = array_keys(getpaid_get_subscription_statuses());
170 170
 	$counts   = array();
171 171
 
172
-	foreach ( $statuses as $status ) {
173
-		$_args             = wp_parse_args( "status=$status", $args );
174
-		$counts[ $status ] = getpaid_get_subscriptions( $_args, 'count' );
172
+	foreach ($statuses as $status) {
173
+		$_args             = wp_parse_args("status=$status", $args);
174
+		$counts[$status] = getpaid_get_subscriptions($_args, 'count');
175 175
 	}
176 176
 
177 177
 	return $counts;
@@ -190,23 +190,23 @@  discard block
 block discarded – undo
190 190
 		array(
191 191
 
192 192
 			'day'   => array(
193
-				'singular' => __( '%s day', 'invoicing' ),
194
-				'plural'   => __( '%d days', 'invoicing' ),
193
+				'singular' => __('%s day', 'invoicing'),
194
+				'plural'   => __('%d days', 'invoicing'),
195 195
 			),
196 196
 
197 197
 			'week'  => array(
198
-				'singular' => __( '%s week', 'invoicing' ),
199
-				'plural'   => __( '%d weeks', 'invoicing' ),
198
+				'singular' => __('%s week', 'invoicing'),
199
+				'plural'   => __('%d weeks', 'invoicing'),
200 200
 			),
201 201
 
202 202
 			'month' => array(
203
-				'singular' => __( '%s month', 'invoicing' ),
204
-				'plural'   => __( '%d months', 'invoicing' ),
203
+				'singular' => __('%s month', 'invoicing'),
204
+				'plural'   => __('%d months', 'invoicing'),
205 205
 			),
206 206
 
207 207
 			'year'  => array(
208
-				'singular' => __( '%s year', 'invoicing' ),
209
-				'plural'   => __( '%d years', 'invoicing' ),
208
+				'singular' => __('%s year', 'invoicing'),
209
+				'plural'   => __('%d years', 'invoicing'),
210 210
 			),
211 211
 
212 212
 		)
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
  * @param string $trial_period
221 221
  * @return int
222 222
  */
223
-function getpaid_get_subscription_trial_period_interval( $trial_period ) {
224
-	return (int) preg_replace( '/[^0-9]/', '', $trial_period );
223
+function getpaid_get_subscription_trial_period_interval($trial_period) {
224
+	return (int) preg_replace('/[^0-9]/', '', $trial_period);
225 225
 }
226 226
 
227 227
 /**
@@ -230,8 +230,8 @@  discard block
 block discarded – undo
230 230
  * @param string $trial_period
231 231
  * @return string
232 232
  */
233
-function getpaid_get_subscription_trial_period_period( $trial_period ) {
234
-	return preg_replace( '/[^a-z]/', '', strtolower( $trial_period ) );
233
+function getpaid_get_subscription_trial_period_period($trial_period) {
234
+	return preg_replace('/[^a-z]/', '', strtolower($trial_period));
235 235
 }
236 236
 
237 237
 /**
@@ -241,9 +241,9 @@  discard block
 block discarded – undo
241 241
  * @param int $interval
242 242
  * @return string
243 243
  */
244
-function getpaid_get_subscription_period_label( $period, $interval = 1, $singular_prefix = '1' ) {
245
-	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label( $period, $interval ) : getpaid_get_singular_subscription_period_label( $period, $singular_prefix );
246
-	return strtolower( sanitize_text_field( $label ) );
244
+function getpaid_get_subscription_period_label($period, $interval = 1, $singular_prefix = '1') {
245
+	$label = (int) $interval > 1 ? getpaid_get_plural_subscription_period_label($period, $interval) : getpaid_get_singular_subscription_period_label($period, $singular_prefix);
246
+	return strtolower(sanitize_text_field($label));
247 247
 }
248 248
 
249 249
 /**
@@ -252,19 +252,19 @@  discard block
 block discarded – undo
252 252
  * @param string $period
253 253
  * @return string
254 254
  */
255
-function getpaid_get_singular_subscription_period_label( $period, $singular_prefix = '1' ) {
255
+function getpaid_get_singular_subscription_period_label($period, $singular_prefix = '1') {
256 256
 
257 257
 	$periods = getpaid_get_subscription_periods();
258
-	$period  = strtolower( $period );
258
+	$period  = strtolower($period);
259 259
 
260
-	if ( isset( $periods[ $period ] ) ) {
261
-		return sprintf( $periods[ $period ]['singular'], $singular_prefix );
260
+	if (isset($periods[$period])) {
261
+		return sprintf($periods[$period]['singular'], $singular_prefix);
262 262
 	}
263 263
 
264 264
 	// Backwards compatibility.
265
-	foreach ( $periods as $key => $data ) {
266
-		if ( strpos( $key, $period ) === 0 ) {
267
-			return sprintf( $data['singular'], $singular_prefix );
265
+	foreach ($periods as $key => $data) {
266
+		if (strpos($key, $period) === 0) {
267
+			return sprintf($data['singular'], $singular_prefix);
268 268
 		}
269 269
 	}
270 270
 
@@ -279,19 +279,19 @@  discard block
 block discarded – undo
279 279
  * @param int $interval
280 280
  * @return string
281 281
  */
282
-function getpaid_get_plural_subscription_period_label( $period, $interval ) {
282
+function getpaid_get_plural_subscription_period_label($period, $interval) {
283 283
 
284 284
 	$periods = getpaid_get_subscription_periods();
285
-	$period  = strtolower( $period );
285
+	$period  = strtolower($period);
286 286
 
287
-	if ( isset( $periods[ $period ] ) ) {
288
-		return sprintf( $periods[ $period ]['plural'], $interval );
287
+	if (isset($periods[$period])) {
288
+		return sprintf($periods[$period]['plural'], $interval);
289 289
 	}
290 290
 
291 291
 	// Backwards compatibility.
292
-	foreach ( $periods as $key => $data ) {
293
-		if ( strpos( $key, $period ) === 0 ) {
294
-			return sprintf( $data['plural'], $interval );
292
+	foreach ($periods as $key => $data) {
293
+		if (strpos($key, $period) === 0) {
294
+			return sprintf($data['plural'], $interval);
295 295
 		}
296 296
 	}
297 297
 
@@ -305,33 +305,33 @@  discard block
 block discarded – undo
305 305
  * @param WPInv_Subscription $subscription
306 306
  * @return string
307 307
  */
308
-function getpaid_get_formatted_subscription_amount( $subscription ) {
308
+function getpaid_get_formatted_subscription_amount($subscription) {
309 309
 
310
-	$initial    = wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() );
311
-	$recurring  = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() );
312
-	$period     = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' );
310
+	$initial    = wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency());
311
+	$recurring  = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency());
312
+	$period     = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), '');
313 313
 	$bill_times = $subscription->get_bill_times();
314 314
 	$bill_times_less = $bill_times - 1;
315 315
 
316
-	if ( ! empty( $bill_times ) ) {
316
+	if (!empty($bill_times)) {
317 317
 		$bill_times = $subscription->get_frequency() * $bill_times;
318
-		$bill_times_less = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times - $subscription->get_frequency() );
319
-		$bill_times = getpaid_get_subscription_period_label( $subscription->get_period(), $bill_times );
318
+		$bill_times_less = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times - $subscription->get_frequency());
319
+		$bill_times = getpaid_get_subscription_period_label($subscription->get_period(), $bill_times);
320 320
 	}
321 321
 
322 322
 	// Trial periods.
323
-	if ( $subscription->has_trial_period() ) {
323
+	if ($subscription->has_trial_period()) {
324 324
 
325
-		$trial_period   = getpaid_get_subscription_trial_period_period( $subscription->get_trial_period() );
326
-		$trial_interval = getpaid_get_subscription_trial_period_interval( $subscription->get_trial_period() );
325
+		$trial_period   = getpaid_get_subscription_trial_period_period($subscription->get_trial_period());
326
+		$trial_interval = getpaid_get_subscription_trial_period_interval($subscription->get_trial_period());
327 327
 
328
-		if ( empty( $bill_times ) ) {
328
+		if (empty($bill_times)) {
329 329
 
330 330
 			return sprintf(
331 331
 				// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
332
-				_x( '%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
332
+				_x('%1$s trial for %2$s then %3$s / %4$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
333 333
 				$initial,
334
-				getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
334
+				getpaid_get_subscription_period_label($trial_period, $trial_interval),
335 335
 				$recurring,
336 336
 				$period
337 337
 			);
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
 
341 341
 		return sprintf(
342 342
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period, $5: is the bill times
343
-			_x( '%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing' ),
343
+			_x('%1$s trial for %2$s then %3$s / %4$s for %5$s', 'Subscription amount. (e.g.: $10 trial for 1 month then $120 / year for 4 years)', 'invoicing'),
344 344
 			$initial,
345
-			getpaid_get_subscription_period_label( $trial_period, $trial_interval ),
345
+			getpaid_get_subscription_period_label($trial_period, $trial_interval),
346 346
 			$recurring,
347 347
 			$period,
348 348
 			$bill_times
@@ -350,13 +350,13 @@  discard block
 block discarded – undo
350 350
 
351 351
 	}
352 352
 
353
-	if ( $initial != $recurring ) {
353
+	if ($initial != $recurring) {
354 354
 
355
-		if ( empty( $bill_times ) ) {
355
+		if (empty($bill_times)) {
356 356
 
357 357
 			return sprintf(
358 358
 				// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period
359
-				_x( 'Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing' ),
359
+				_x('Initial payment of %1$s which renews at %2$s / %3$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year)', 'invoicing'),
360 360
 				$initial,
361 361
 				$recurring,
362 362
 				$period
@@ -366,7 +366,7 @@  discard block
 block discarded – undo
366 366
 
367 367
 		return sprintf(
368 368
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring period, $4: is the bill times
369
-			_x( 'Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing' ),
369
+			_x('Initial payment of %1$s which renews at %2$s / %3$s for %4$s', 'Subscription amount. (e.g.:Initial payment of $100 which renews at $120 / year for 5 years)', 'invoicing'),
370 370
 			$initial,
371 371
 			$recurring,
372 372
 			$period,
@@ -375,11 +375,11 @@  discard block
 block discarded – undo
375 375
 
376 376
 	}
377 377
 
378
-	if ( empty( $bill_times ) ) {
378
+	if (empty($bill_times)) {
379 379
 
380 380
 		return sprintf(
381 381
 			// translators: $1: is the recurring amount, $2: is the recurring period
382
-			_x( '%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing' ),
382
+			_x('%1$s / %2$s', 'Subscription amount. (e.g.: $120 / year)', 'invoicing'),
383 383
 			$initial,
384 384
 			$period
385 385
 		);
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 
389 389
 	return sprintf(
390 390
 		// translators: $1: is the bill times, $2: is the recurring amount, $3: is the recurring period
391
-		_x( '%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing' ),
391
+		_x('%2$s / %3$s for %1$s', 'Subscription amount. (e.g.: $120 / year for 5 years)', 'invoicing'),
392 392
 		$bill_times,
393 393
 		$initial,
394 394
 		$period
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
  * @param WPInv_Invoice $invoice
403 403
  * @return WPInv_Subscription|false
404 404
  */
405
-function getpaid_get_invoice_subscription( $invoice ) {
406
-	return getpaid_subscriptions()->get_invoice_subscription( $invoice );
405
+function getpaid_get_invoice_subscription($invoice) {
406
+	return getpaid_subscriptions()->get_invoice_subscription($invoice);
407 407
 }
408 408
 
409 409
 /**
@@ -411,9 +411,9 @@  discard block
 block discarded – undo
411 411
  *
412 412
  * @param WPInv_Invoice $invoice
413 413
  */
414
-function getpaid_activate_invoice_subscription( $invoice ) {
415
-	$subscription = getpaid_get_invoice_subscription( $invoice );
416
-	if ( is_a( $subscription, 'WPInv_Subscription' ) ) {
414
+function getpaid_activate_invoice_subscription($invoice) {
415
+	$subscription = getpaid_get_invoice_subscription($invoice);
416
+	if (is_a($subscription, 'WPInv_Subscription')) {
417 417
 		$subscription->activate();
418 418
 	}
419 419
 }
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @return WPInv_Subscriptions
425 425
  */
426 426
 function getpaid_subscriptions() {
427
-	return getpaid()->get( 'subscriptions' );
427
+	return getpaid()->get('subscriptions');
428 428
 }
429 429
 
430 430
 /**
@@ -433,13 +433,13 @@  discard block
 block discarded – undo
433 433
  * @since 2.3.0
434 434
  * @return WPInv_Subscription|bool
435 435
  */
436
-function wpinv_get_invoice_subscription( $invoice ) {
436
+function wpinv_get_invoice_subscription($invoice) {
437 437
 
438 438
     // Retrieve the invoice.
439
-    $invoice = new WPInv_Invoice( $invoice );
439
+    $invoice = new WPInv_Invoice($invoice);
440 440
 
441 441
     // Ensure it is a recurring invoice.
442
-    if ( ! $invoice->is_recurring() ) {
442
+    if (!$invoice->is_recurring()) {
443 443
         return false;
444 444
     }
445 445
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 		)
452 452
 	);
453 453
 
454
-	return empty( $subscription ) ? false : $subscription[0];
454
+	return empty($subscription) ? false : $subscription[0];
455 455
 
456 456
 }
457 457
 
@@ -466,50 +466,50 @@  discard block
 block discarded – undo
466 466
  * @param GetPaid_Form_Item|WPInv_Item $cart_item
467 467
  * @return string
468 468
  */
469
-function getpaid_get_recurring_item_key( $cart_item ) {
469
+function getpaid_get_recurring_item_key($cart_item) {
470 470
 
471 471
 	$cart_key     = 'renews_';
472 472
 	$interval     = $cart_item->get_recurring_interval();
473
-	$period       = $cart_item->get_recurring_period( true );
473
+	$period       = $cart_item->get_recurring_period(true);
474 474
 	$length       = $cart_item->get_recurring_limit() * $interval;
475
-	$trial_period = $cart_item->get_trial_period( true );
475
+	$trial_period = $cart_item->get_trial_period(true);
476 476
 	$trial_length = $cart_item->get_trial_interval();
477 477
 
478 478
 	// First start with the billing interval and period
479
-	switch ( $interval ) {
479
+	switch ($interval) {
480 480
 		case 1:
481
-			if ( 'day' == $period ) {
481
+			if ('day' == $period) {
482 482
 				$cart_key .= 'daily';
483 483
 			} else {
484
-				$cart_key .= sprintf( '%sly', $period );
484
+				$cart_key .= sprintf('%sly', $period);
485 485
 			}
486 486
 			break;
487 487
 		case 2:
488
-			$cart_key .= sprintf( 'every_2nd_%s', $period );
488
+			$cart_key .= sprintf('every_2nd_%s', $period);
489 489
 			break;
490 490
 		case 3:
491
-			$cart_key .= sprintf( 'every_3rd_%s', $period );
491
+			$cart_key .= sprintf('every_3rd_%s', $period);
492 492
 		    break;
493 493
 		default:
494
-			$cart_key .= sprintf( 'every_%dth_%s', $interval, $period );
494
+			$cart_key .= sprintf('every_%dth_%s', $interval, $period);
495 495
 			break;
496 496
 	}
497 497
 
498 498
 	// Maybe add the optional maximum billing periods...
499
-	if ( $length > 0 ) {
499
+	if ($length > 0) {
500 500
 		$cart_key .= '_for_';
501
-		$cart_key .= sprintf( '%d_%s', $length, $period );
502
-		if ( $length > 1 ) {
501
+		$cart_key .= sprintf('%d_%s', $length, $period);
502
+		if ($length > 1) {
503 503
 			$cart_key .= 's';
504 504
 		}
505 505
 	}
506 506
 
507 507
 	// And an optional free trial.
508
-	if ( $cart_item->has_free_trial() ) {
509
-		$cart_key .= sprintf( '_after_a_%d_%s_trial', $trial_length, $trial_period );
508
+	if ($cart_item->has_free_trial()) {
509
+		$cart_key .= sprintf('_after_a_%d_%s_trial', $trial_length, $trial_period);
510 510
 	}
511 511
 
512
-	return apply_filters( 'getpaid_get_recurring_item_key', $cart_key, $cart_item );
512
+	return apply_filters('getpaid_get_recurring_item_key', $cart_key, $cart_item);
513 513
 }
514 514
 
515 515
 /**
@@ -518,14 +518,14 @@  discard block
 block discarded – undo
518 518
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
519 519
  * @return array
520 520
  */
521
-function getpaid_get_subscription_groups( $invoice ) {
521
+function getpaid_get_subscription_groups($invoice) {
522 522
 
523 523
 	// Generate subscription groups.
524 524
 	$subscription_groups = array();
525
-	foreach ( $invoice->get_items() as $item ) {
525
+	foreach ($invoice->get_items() as $item) {
526 526
 
527
-		if ( $item->is_recurring() ) {
528
-			$subscription_groups[ getpaid_get_recurring_item_key( $item ) ][] = $item;
527
+		if ($item->is_recurring()) {
528
+			$subscription_groups[getpaid_get_recurring_item_key($item)][] = $item;
529 529
 		}
530 530
 }
531 531
 
@@ -541,19 +541,19 @@  discard block
 block discarded – undo
541 541
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
542 542
  * @return array
543 543
  */
544
-function getpaid_calculate_subscription_totals( $invoice ) {
544
+function getpaid_calculate_subscription_totals($invoice) {
545 545
 
546 546
 	// Generate subscription groups.
547
-	$subscription_groups = getpaid_get_subscription_groups( $invoice );
547
+	$subscription_groups = getpaid_get_subscription_groups($invoice);
548 548
 
549 549
 	// Now let's calculate the totals for each group of subscriptions
550 550
 	$subscription_totals = array();
551 551
 
552
-	foreach ( $subscription_groups as $subscription_key => $items ) {
552
+	foreach ($subscription_groups as $subscription_key => $items) {
553 553
 
554
-		if ( empty( $subscription_totals[ $subscription_key ] ) ) {
554
+		if (empty($subscription_totals[$subscription_key])) {
555 555
 
556
-			$subscription_totals[ $subscription_key ] = array(
556
+			$subscription_totals[$subscription_key] = array(
557 557
 				'initial_total'   => 0,
558 558
 				'recurring_total' => 0,
559 559
 				'items'           => array(),
@@ -566,33 +566,33 @@  discard block
 block discarded – undo
566 566
 		 * Get the totals of the group.
567 567
 		 * @var GetPaid_Form_Item $item
568 568
 		 */
569
-		foreach ( $items as $item ) {
569
+		foreach ($items as $item) {
570 570
 
571
-			$subscription_totals[ $subscription_key ]['items'][ $item->get_id() ]  = $item->prepare_data_for_saving();
572
-			$subscription_totals[ $subscription_key ]['item_id']                 = $item->get_id();
573
-			$subscription_totals[ $subscription_key ]['period']                  = $item->get_recurring_period( true );
574
-			$subscription_totals[ $subscription_key ]['interval']                = $item->get_recurring_interval();
575
-			$subscription_totals[ $subscription_key ]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
-			$subscription_totals[ $subscription_key ]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
-			$subscription_totals[ $subscription_key ]['recurring_limit']         = $item->get_recurring_limit();
571
+			$subscription_totals[$subscription_key]['items'][$item->get_id()] = $item->prepare_data_for_saving();
572
+			$subscription_totals[$subscription_key]['item_id']                 = $item->get_id();
573
+			$subscription_totals[$subscription_key]['period']                  = $item->get_recurring_period(true);
574
+			$subscription_totals[$subscription_key]['interval']                = $item->get_recurring_interval();
575
+			$subscription_totals[$subscription_key]['initial_total']          += $item->get_sub_total() + $item->item_tax - $item->item_discount;
576
+			$subscription_totals[$subscription_key]['recurring_total']        += $item->get_recurring_sub_total() + $item->item_tax - $item->recurring_item_discount;
577
+			$subscription_totals[$subscription_key]['recurring_limit']         = $item->get_recurring_limit();
578 578
 
579 579
 			// Calculate the next renewal date.
580
-			$period       = $item->get_recurring_period( true );
580
+			$period       = $item->get_recurring_period(true);
581 581
 			$interval     = $item->get_recurring_interval();
582 582
 
583 583
 			// If the subscription item has a trial period...
584
-			if ( $item->has_free_trial() ) {
585
-				$period   = $item->get_trial_period( true );
584
+			if ($item->has_free_trial()) {
585
+				$period   = $item->get_trial_period(true);
586 586
 				$interval = $item->get_trial_interval();
587
-				$subscription_totals[ $subscription_key ]['trialling'] = $interval . ' ' . $period;
587
+				$subscription_totals[$subscription_key]['trialling'] = $interval . ' ' . $period;
588 588
 			}
589 589
 
590
-			$subscription_totals[ $subscription_key ]['renews_on'] = date( 'Y-m-d H:i:s', strtotime( "+$interval $period", current_time( 'timestamp' ) ) );
590
+			$subscription_totals[$subscription_key]['renews_on'] = date('Y-m-d H:i:s', strtotime("+$interval $period", current_time('timestamp')));
591 591
 
592 592
 		}
593 593
 }
594 594
 
595
-	return apply_filters( 'getpaid_calculate_subscription_totals', $subscription_totals, $invoice );
595
+	return apply_filters('getpaid_calculate_subscription_totals', $subscription_totals, $invoice);
596 596
 }
597 597
 
598 598
 /**
@@ -601,18 +601,18 @@  discard block
 block discarded – undo
601 601
  * @param WPInv_Invoice|GetPaid_Payment_Form_Submission|GetPaid_Payment_Form $invoice
602 602
  * @return array
603 603
  */
604
-function getpaid_should_group_subscriptions( $invoice ) {
604
+function getpaid_should_group_subscriptions($invoice) {
605 605
 
606 606
 	$recurring_items = 0;
607 607
 
608
-	foreach ( $invoice->get_items() as $item ) {
608
+	foreach ($invoice->get_items() as $item) {
609 609
 
610
-		if ( $item->is_recurring() ) {
611
-			$recurring_items ++;
610
+		if ($item->is_recurring()) {
611
+			$recurring_items++;
612 612
 		}
613 613
 }
614 614
 
615
-	return apply_filters( 'getpaid_should_group_subscriptions', $recurring_items > 1, $invoice );
615
+	return apply_filters('getpaid_should_group_subscriptions', $recurring_items > 1, $invoice);
616 616
 }
617 617
 
618 618
 /**
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
  * @param int|false $subscription_id
623 623
  * @return int
624 624
  */
625
-function getpaid_count_subscription_invoices( $parent_invoice_id, $subscription_id = false ) {
625
+function getpaid_count_subscription_invoices($parent_invoice_id, $subscription_id = false) {
626 626
 	global $wpdb;
627 627
 
628 628
 	$parent_invoice_id = (int) $parent_invoice_id;
629 629
 
630
-	if ( false === $subscription_id || ! (bool) get_post_meta( $parent_invoice_id, '_wpinv_subscription_id', true ) ) {
630
+	if (false === $subscription_id || !(bool) get_post_meta($parent_invoice_id, '_wpinv_subscription_id', true)) {
631 631
 
632 632
 		return (int) $wpdb->get_var(
633 633
 			$wpdb->prepare(
@@ -649,10 +649,10 @@  discard block
 block discarded – undo
649 649
 
650 650
 	$count = 0;
651 651
 
652
-	foreach ( wp_parse_id_list( $invoice_ids ) as $invoice_id ) {
652
+	foreach (wp_parse_id_list($invoice_ids) as $invoice_id) {
653 653
 
654
-		if ( $invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta( $invoice_id, '_wpinv_subscription_id', true ) ) {
655
-			$count ++;
654
+		if ($invoice_id == $parent_invoice_id || $subscription_id == (int) get_post_meta($invoice_id, '_wpinv_subscription_id', true)) {
655
+			$count++;
656 656
 			continue;
657 657
 		}
658 658
 }
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 3 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -963,7 +963,7 @@
 block discarded – undo
963 963
 
964 964
 		if ( $discount->exists() && $discount->is_recurring() ) {
965 965
 			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
-		}  else {
966
+		} else {
967 967
 			// Unset discount code.
968 968
 			$invoice->set_discount_code( '' );
969 969
 
Please login to merge, or discard this patch.
Indentation   +1036 added lines, -1036 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class WPInv_Subscription extends GetPaid_Data {
17 17
 
18
-	/**
19
-	 * Which data store to load.
20
-	 *
21
-	 * @var string
22
-	 */
23
-	protected $data_store_name = 'subscription';
24
-
25
-	/**
26
-	 * This is the name of this object type.
27
-	 *
28
-	 * @var string
29
-	 */
30
-	protected $object_type = 'subscription';
31
-
32
-	/**
33
-	 * Item Data array. This is the core item data exposed in APIs.
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array(
39
-		'customer_id'       => 0,
40
-		'frequency'         => 1,
41
-		'period'            => 'D',
42
-		'initial_amount'    => null,
43
-		'recurring_amount'  => null,
44
-		'bill_times'        => 0,
45
-		'transaction_id'    => '',
46
-		'parent_payment_id' => null,
47
-		'product_id'        => 0,
48
-		'created'           => '0000-00-00 00:00:00',
49
-		'expiration'        => '0000-00-00 00:00:00',
50
-		'trial_period'      => '',
51
-		'status'            => 'pending',
52
-		'profile_id'        => '',
53
-		'gateway'           => '',
54
-		'customer'          => '',
55
-	);
56
-
57
-	/**
58
-	 * Stores the status transition information.
59
-	 *
60
-	 * @since 1.0.19
61
-	 * @var bool
62
-	 */
63
-	protected $status_transition = false;
64
-
65
-	/**
66
-	 * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
-	 *
68
-	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
-	 * @param  bool $deprecated
70
-	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
72
-
73
-		parent::__construct( $subscription );
74
-
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
83
-		} else {
84
-			$this->set_object_read( true );
85
-		}
86
-
87
-		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
-
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
92
-		}
93
-
94
-	}
95
-
96
-	/**
97
-	 * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
-	 *
99
-	 *
100
-	 * @static
101
-	 * @param string $value
102
-	 * @param string $field Either invoice_id, transaction_id or profile_id.
103
-	 * @since 1.0.19
104
-	 * @return int
105
-	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
18
+    /**
19
+     * Which data store to load.
20
+     *
21
+     * @var string
22
+     */
23
+    protected $data_store_name = 'subscription';
24
+
25
+    /**
26
+     * This is the name of this object type.
27
+     *
28
+     * @var string
29
+     */
30
+    protected $object_type = 'subscription';
31
+
32
+    /**
33
+     * Item Data array. This is the core item data exposed in APIs.
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array(
39
+        'customer_id'       => 0,
40
+        'frequency'         => 1,
41
+        'period'            => 'D',
42
+        'initial_amount'    => null,
43
+        'recurring_amount'  => null,
44
+        'bill_times'        => 0,
45
+        'transaction_id'    => '',
46
+        'parent_payment_id' => null,
47
+        'product_id'        => 0,
48
+        'created'           => '0000-00-00 00:00:00',
49
+        'expiration'        => '0000-00-00 00:00:00',
50
+        'trial_period'      => '',
51
+        'status'            => 'pending',
52
+        'profile_id'        => '',
53
+        'gateway'           => '',
54
+        'customer'          => '',
55
+    );
56
+
57
+    /**
58
+     * Stores the status transition information.
59
+     *
60
+     * @since 1.0.19
61
+     * @var bool
62
+     */
63
+    protected $status_transition = false;
64
+
65
+    /**
66
+     * Get the subscription if ID is passed, otherwise the subscription is new and empty.
67
+     *
68
+     * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69
+     * @param  bool $deprecated
70
+     */
71
+    function __construct( $subscription = 0, $deprecated = false ) {
72
+
73
+        parent::__construct( $subscription );
74
+
75
+        if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
+            $this->set_id( $subscription );
77
+        } elseif ( $subscription instanceof self ) {
78
+            $this->set_id( $subscription->get_id() );
79
+        } elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
+            $this->set_id( $subscription_id );
81
+        } elseif ( ! empty( $subscription->id ) ) {
82
+            $this->set_id( $subscription->id );
83
+        } else {
84
+            $this->set_object_read( true );
85
+        }
86
+
87
+        // Load the datastore.
88
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
89
+
90
+        if ( $this->get_id() > 0 ) {
91
+            $this->data_store->read( $this );
92
+        }
93
+
94
+    }
95
+
96
+    /**
97
+     * Given an invoice id, profile id, transaction id, it returns the subscription's id.
98
+     *
99
+     *
100
+     * @static
101
+     * @param string $value
102
+     * @param string $field Either invoice_id, transaction_id or profile_id.
103
+     * @since 1.0.19
104
+     * @return int
105
+     */
106
+    public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
107 107
         global $wpdb;
108 108
 
109
-		// Trim the value.
110
-		$value = trim( $value );
109
+        // Trim the value.
110
+        $value = trim( $value );
111 111
 
112
-		if ( empty( $value ) ) {
113
-			return 0;
114
-		}
112
+        if ( empty( $value ) ) {
113
+            return 0;
114
+        }
115 115
 
116
-		if ( 'invoice_id' == $field ) {
117
-			$field = 'parent_payment_id';
118
-		}
116
+        if ( 'invoice_id' == $field ) {
117
+            $field = 'parent_payment_id';
118
+        }
119 119
 
120 120
         // Valid fields.
121 121
         $fields = array(
122
-			'parent_payment_id',
123
-			'transaction_id',
124
-			'profile_id',
125
-		);
126
-
127
-		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
-			return 0;
130
-		}
131
-
132
-		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
135
-			return $subscription_id;
136
-		}
122
+            'parent_payment_id',
123
+            'transaction_id',
124
+            'profile_id',
125
+        );
126
+
127
+        // Ensure a field has been passed.
128
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
129
+            return 0;
130
+        }
131
+
132
+        // Maybe retrieve from the cache.
133
+        $subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
+        if ( ! empty( $subscription_id ) ) {
135
+            return $subscription_id;
136
+        }
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
@@ -141,42 +141,42 @@  discard block
 block discarded – undo
141 141
             $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
145
-			return 0;
146
-		}
144
+        if ( empty( $subscription_id ) ) {
145
+            return 0;
146
+        }
147 147
 
148
-		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
148
+        // Update the cache with our data.
149
+        wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
150 150
 
151
-		return $subscription_id;
152
-	}
151
+        return $subscription_id;
152
+    }
153 153
 
154
-	/**
154
+    /**
155 155
      * Clears the subscription's cache.
156 156
      */
157 157
     public function clear_cache() {
158
-		$caches = array(
159
-			'getpaid_subscription_parent_payment_ids_to_subscription_ids' => $this->get_parent_payment_id(),
160
-			'getpaid_subscription_transaction_ids_to_subscription_ids'    => $this->get_transaction_id(),
161
-			'getpaid_subscription_profile_ids_to_subscription_ids'        => $this->get_profile_id(),
162
-			'getpaid_subscriptions'                                       => $this->get_id(),
163
-		);
164
-
165
-		foreach ( $caches as $cache => $value ) {
166
-			if ( '' !== $value && false !== $value ) {
167
-				wp_cache_delete( $value, $cache );
168
-			}
169
-		}
170
-	}
171
-
172
-	/**
158
+        $caches = array(
159
+            'getpaid_subscription_parent_payment_ids_to_subscription_ids' => $this->get_parent_payment_id(),
160
+            'getpaid_subscription_transaction_ids_to_subscription_ids'    => $this->get_transaction_id(),
161
+            'getpaid_subscription_profile_ids_to_subscription_ids'        => $this->get_profile_id(),
162
+            'getpaid_subscriptions'                                       => $this->get_id(),
163
+        );
164
+
165
+        foreach ( $caches as $cache => $value ) {
166
+            if ( '' !== $value && false !== $value ) {
167
+                wp_cache_delete( $value, $cache );
168
+            }
169
+        }
170
+    }
171
+
172
+    /**
173 173
      * Checks if a subscription key is set.
174 174
      */
175 175
     public function _isset( $key ) {
176 176
         return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
177
-	}
177
+    }
178 178
 
179
-	/*
179
+    /*
180 180
 	|--------------------------------------------------------------------------
181 181
 	| CRUD methods
182 182
 	|--------------------------------------------------------------------------
@@ -185,57 +185,57 @@  discard block
 block discarded – undo
185 185
 	|
186 186
     */
187 187
 
188
-	/*
188
+    /*
189 189
 	|--------------------------------------------------------------------------
190 190
 	| Getters
191 191
 	|--------------------------------------------------------------------------
192 192
 	*/
193 193
 
194
-	/**
195
-	 * Get customer id.
196
-	 *
197
-	 * @since 1.0.19
198
-	 * @param  string $context View or edit context.
199
-	 * @return int
200
-	 */
201
-	public function get_customer_id( $context = 'view' ) {
202
-		return (int) $this->get_prop( 'customer_id', $context );
203
-	}
204
-
205
-	/**
206
-	 * Get customer information.
207
-	 *
208
-	 * @since 1.0.19
209
-	 * @param  string $context View or edit context.
210
-	 * @return WP_User|false WP_User object on success, false on failure.
211
-	 */
212
-	public function get_customer( $context = 'view' ) {
213
-		return get_userdata( $this->get_customer_id( $context ) );
214
-	}
215
-
216
-	/**
217
-	 * Get parent invoice id.
218
-	 *
219
-	 * @since 1.0.19
220
-	 * @param  string $context View or edit context.
221
-	 * @return int
222
-	 */
223
-	public function get_parent_invoice_id( $context = 'view' ) {
224
-		return (int) $this->get_prop( 'parent_payment_id', $context );
225
-	}
226
-
227
-	/**
228
-	 * Alias for self::get_parent_invoice_id().
229
-	 *
230
-	 * @since 1.0.19
231
-	 * @param  string $context View or edit context.
232
-	 * @return int
233
-	 */
194
+    /**
195
+     * Get customer id.
196
+     *
197
+     * @since 1.0.19
198
+     * @param  string $context View or edit context.
199
+     * @return int
200
+     */
201
+    public function get_customer_id( $context = 'view' ) {
202
+        return (int) $this->get_prop( 'customer_id', $context );
203
+    }
204
+
205
+    /**
206
+     * Get customer information.
207
+     *
208
+     * @since 1.0.19
209
+     * @param  string $context View or edit context.
210
+     * @return WP_User|false WP_User object on success, false on failure.
211
+     */
212
+    public function get_customer( $context = 'view' ) {
213
+        return get_userdata( $this->get_customer_id( $context ) );
214
+    }
215
+
216
+    /**
217
+     * Get parent invoice id.
218
+     *
219
+     * @since 1.0.19
220
+     * @param  string $context View or edit context.
221
+     * @return int
222
+     */
223
+    public function get_parent_invoice_id( $context = 'view' ) {
224
+        return (int) $this->get_prop( 'parent_payment_id', $context );
225
+    }
226
+
227
+    /**
228
+     * Alias for self::get_parent_invoice_id().
229
+     *
230
+     * @since 1.0.19
231
+     * @param  string $context View or edit context.
232
+     * @return int
233
+     */
234 234
     public function get_parent_payment_id( $context = 'view' ) {
235 235
         return $this->get_parent_invoice_id( $context );
236
-	}
236
+    }
237 237
 
238
-	/**
238
+    /**
239 239
      * Alias for self::get_parent_invoice_id().
240 240
      *
241 241
      * @since  1.0.0
@@ -245,390 +245,390 @@  discard block
 block discarded – undo
245 245
         return $this->get_parent_invoice_id( $context );
246 246
     }
247 247
 
248
-	/**
249
-	 * Get parent invoice.
250
-	 *
251
-	 * @since 1.0.19
252
-	 * @param  string $context View or edit context.
253
-	 * @return WPInv_Invoice
254
-	 */
255
-	public function get_parent_invoice( $context = 'view' ) {
256
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
257
-	}
258
-
259
-	/**
260
-	 * Alias for self::get_parent_invoice().
261
-	 *
262
-	 * @since 1.0.19
263
-	 * @param  string $context View or edit context.
264
-	 * @return WPInv_Invoice
265
-	 */
248
+    /**
249
+     * Get parent invoice.
250
+     *
251
+     * @since 1.0.19
252
+     * @param  string $context View or edit context.
253
+     * @return WPInv_Invoice
254
+     */
255
+    public function get_parent_invoice( $context = 'view' ) {
256
+        return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
257
+    }
258
+
259
+    /**
260
+     * Alias for self::get_parent_invoice().
261
+     *
262
+     * @since 1.0.19
263
+     * @param  string $context View or edit context.
264
+     * @return WPInv_Invoice
265
+     */
266 266
     public function get_parent_payment( $context = 'view' ) {
267 267
         return $this->get_parent_invoice( $context );
268
-	}
269
-
270
-	/**
271
-	 * Get subscription's product id.
272
-	 *
273
-	 * @since 1.0.19
274
-	 * @param  string $context View or edit context.
275
-	 * @return int
276
-	 */
277
-	public function get_product_id( $context = 'view' ) {
278
-		return (int) $this->get_prop( 'product_id', $context );
279
-	}
280
-
281
-	/**
282
-	 * Get the subscription product.
283
-	 *
284
-	 * @since 1.0.19
285
-	 * @param  string $context View or edit context.
286
-	 * @return WPInv_Item
287
-	 */
288
-	public function get_product( $context = 'view' ) {
289
-		return new WPInv_Item( $this->get_product_id( $context ) );
290
-	}
291
-
292
-	/**
293
-	 * Get parent invoice's gateway.
294
-	 *
295
-	 * Here for backwards compatibility.
296
-	 *
297
-	 * @since 1.0.19
298
-	 * @param  string $context View or edit context.
299
-	 * @return string
300
-	 */
301
-	public function get_gateway( $context = 'view' ) {
302
-		return $this->get_parent_invoice( $context )->get_gateway();
303
-	}
304
-
305
-	/**
306
-	 * Get the period of a renewal.
307
-	 *
308
-	 * @since 1.0.19
309
-	 * @param  string $context View or edit context.
310
-	 * @return string
311
-	 */
312
-	public function get_period( $context = 'view' ) {
313
-		return $this->get_prop( 'period', $context );
314
-	}
315
-
316
-	/**
317
-	 * Get number of periods each renewal is valid for.
318
-	 *
319
-	 * @since 1.0.19
320
-	 * @param  string $context View or edit context.
321
-	 * @return int
322
-	 */
323
-	public function get_frequency( $context = 'view' ) {
324
-		return (int) $this->get_prop( 'frequency', $context );
325
-	}
326
-
327
-	/**
328
-	 * Get the initial amount for the subscription.
329
-	 *
330
-	 * @since 1.0.19
331
-	 * @param  string $context View or edit context.
332
-	 * @return float
333
-	 */
334
-	public function get_initial_amount( $context = 'view' ) {
335
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
336
-	}
337
-
338
-	/**
339
-	 * Get the recurring amount for the subscription.
340
-	 *
341
-	 * @since 1.0.19
342
-	 * @param  string $context View or edit context.
343
-	 * @return float
344
-	 */
345
-	public function get_recurring_amount( $context = 'view' ) {
346
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
347
-	}
348
-
349
-	/**
350
-	 * Get number of times that this subscription can be renewed.
351
-	 *
352
-	 * @since 1.0.19
353
-	 * @param  string $context View or edit context.
354
-	 * @return int
355
-	 */
356
-	public function get_bill_times( $context = 'view' ) {
357
-		return (int) $this->get_prop( 'bill_times', $context );
358
-	}
359
-
360
-	/**
361
-	 * Get transaction id of this subscription's parent invoice.
362
-	 *
363
-	 * @since 1.0.19
364
-	 * @param  string $context View or edit context.
365
-	 * @return string
366
-	 */
367
-	public function get_transaction_id( $context = 'view' ) {
368
-		return $this->get_prop( 'transaction_id', $context );
369
-	}
370
-
371
-	/**
372
-	 * Get the date that the subscription was created.
373
-	 *
374
-	 * @since 1.0.19
375
-	 * @param  string $context View or edit context.
376
-	 * @return string
377
-	 */
378
-	public function get_created( $context = 'view' ) {
379
-		return $this->get_prop( 'created', $context );
380
-	}
381
-
382
-	/**
383
-	 * Alias for self::get_created().
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @param  string $context View or edit context.
387
-	 * @return string
388
-	 */
389
-	public function get_date_created( $context = 'view' ) {
390
-		return $this->get_created( $context );
391
-	}
392
-
393
-	/**
394
-	 * Retrieves the creation date in a timestamp
395
-	 *
396
-	 * @since  1.0.0
397
-	 * @return int
398
-	 */
399
-	public function get_time_created() {
400
-		$created = $this->get_date_created();
401
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
402
-	}
403
-
404
-	/**
405
-	 * Get GMT date when the subscription was created.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @param  string $context View or edit context.
409
-	 * @return string
410
-	 */
411
-	public function get_date_created_gmt( $context = 'view' ) {
268
+    }
269
+
270
+    /**
271
+     * Get subscription's product id.
272
+     *
273
+     * @since 1.0.19
274
+     * @param  string $context View or edit context.
275
+     * @return int
276
+     */
277
+    public function get_product_id( $context = 'view' ) {
278
+        return (int) $this->get_prop( 'product_id', $context );
279
+    }
280
+
281
+    /**
282
+     * Get the subscription product.
283
+     *
284
+     * @since 1.0.19
285
+     * @param  string $context View or edit context.
286
+     * @return WPInv_Item
287
+     */
288
+    public function get_product( $context = 'view' ) {
289
+        return new WPInv_Item( $this->get_product_id( $context ) );
290
+    }
291
+
292
+    /**
293
+     * Get parent invoice's gateway.
294
+     *
295
+     * Here for backwards compatibility.
296
+     *
297
+     * @since 1.0.19
298
+     * @param  string $context View or edit context.
299
+     * @return string
300
+     */
301
+    public function get_gateway( $context = 'view' ) {
302
+        return $this->get_parent_invoice( $context )->get_gateway();
303
+    }
304
+
305
+    /**
306
+     * Get the period of a renewal.
307
+     *
308
+     * @since 1.0.19
309
+     * @param  string $context View or edit context.
310
+     * @return string
311
+     */
312
+    public function get_period( $context = 'view' ) {
313
+        return $this->get_prop( 'period', $context );
314
+    }
315
+
316
+    /**
317
+     * Get number of periods each renewal is valid for.
318
+     *
319
+     * @since 1.0.19
320
+     * @param  string $context View or edit context.
321
+     * @return int
322
+     */
323
+    public function get_frequency( $context = 'view' ) {
324
+        return (int) $this->get_prop( 'frequency', $context );
325
+    }
326
+
327
+    /**
328
+     * Get the initial amount for the subscription.
329
+     *
330
+     * @since 1.0.19
331
+     * @param  string $context View or edit context.
332
+     * @return float
333
+     */
334
+    public function get_initial_amount( $context = 'view' ) {
335
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
336
+    }
337
+
338
+    /**
339
+     * Get the recurring amount for the subscription.
340
+     *
341
+     * @since 1.0.19
342
+     * @param  string $context View or edit context.
343
+     * @return float
344
+     */
345
+    public function get_recurring_amount( $context = 'view' ) {
346
+        return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
347
+    }
348
+
349
+    /**
350
+     * Get number of times that this subscription can be renewed.
351
+     *
352
+     * @since 1.0.19
353
+     * @param  string $context View or edit context.
354
+     * @return int
355
+     */
356
+    public function get_bill_times( $context = 'view' ) {
357
+        return (int) $this->get_prop( 'bill_times', $context );
358
+    }
359
+
360
+    /**
361
+     * Get transaction id of this subscription's parent invoice.
362
+     *
363
+     * @since 1.0.19
364
+     * @param  string $context View or edit context.
365
+     * @return string
366
+     */
367
+    public function get_transaction_id( $context = 'view' ) {
368
+        return $this->get_prop( 'transaction_id', $context );
369
+    }
370
+
371
+    /**
372
+     * Get the date that the subscription was created.
373
+     *
374
+     * @since 1.0.19
375
+     * @param  string $context View or edit context.
376
+     * @return string
377
+     */
378
+    public function get_created( $context = 'view' ) {
379
+        return $this->get_prop( 'created', $context );
380
+    }
381
+
382
+    /**
383
+     * Alias for self::get_created().
384
+     *
385
+     * @since 1.0.19
386
+     * @param  string $context View or edit context.
387
+     * @return string
388
+     */
389
+    public function get_date_created( $context = 'view' ) {
390
+        return $this->get_created( $context );
391
+    }
392
+
393
+    /**
394
+     * Retrieves the creation date in a timestamp
395
+     *
396
+     * @since  1.0.0
397
+     * @return int
398
+     */
399
+    public function get_time_created() {
400
+        $created = $this->get_date_created();
401
+        return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
402
+    }
403
+
404
+    /**
405
+     * Get GMT date when the subscription was created.
406
+     *
407
+     * @since 1.0.19
408
+     * @param  string $context View or edit context.
409
+     * @return string
410
+     */
411
+    public function get_date_created_gmt( $context = 'view' ) {
412 412
         $date = $this->get_date_created( $context );
413 413
 
414 414
         if ( $date ) {
415 415
             $date = get_gmt_from_date( $date );
416 416
         }
417
-		return $date;
418
-	}
419
-
420
-	/**
421
-	 * Get the date that the subscription will renew.
422
-	 *
423
-	 * @since 1.0.19
424
-	 * @param  string $context View or edit context.
425
-	 * @return string
426
-	 */
427
-	public function get_next_renewal_date( $context = 'view' ) {
428
-		return $this->get_prop( 'expiration', $context );
429
-	}
430
-
431
-	/**
432
-	 * Alias for self::get_next_renewal_date().
433
-	 *
434
-	 * @since 1.0.19
435
-	 * @param  string $context View or edit context.
436
-	 * @return string
437
-	 */
438
-	public function get_expiration( $context = 'view' ) {
439
-		return $this->get_next_renewal_date( $context );
440
-	}
441
-
442
-	/**
443
-	 * Retrieves the expiration date in a timestamp
444
-	 *
445
-	 * @since  1.0.0
446
-	 * @return int
447
-	 */
448
-	public function get_expiration_time() {
449
-		$expiration = $this->get_expiration();
450
-
451
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
-			return current_time( 'timestamp' );
453
-		}
454
-
455
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
457
-	}
458
-
459
-	/**
460
-	 * Get GMT date when the subscription will renew.
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
417
+        return $date;
418
+    }
419
+
420
+    /**
421
+     * Get the date that the subscription will renew.
422
+     *
423
+     * @since 1.0.19
424
+     * @param  string $context View or edit context.
425
+     * @return string
426
+     */
427
+    public function get_next_renewal_date( $context = 'view' ) {
428
+        return $this->get_prop( 'expiration', $context );
429
+    }
430
+
431
+    /**
432
+     * Alias for self::get_next_renewal_date().
433
+     *
434
+     * @since 1.0.19
435
+     * @param  string $context View or edit context.
436
+     * @return string
437
+     */
438
+    public function get_expiration( $context = 'view' ) {
439
+        return $this->get_next_renewal_date( $context );
440
+    }
441
+
442
+    /**
443
+     * Retrieves the expiration date in a timestamp
444
+     *
445
+     * @since  1.0.0
446
+     * @return int
447
+     */
448
+    public function get_expiration_time() {
449
+        $expiration = $this->get_expiration();
450
+
451
+        if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
+            return current_time( 'timestamp' );
453
+        }
454
+
455
+        $expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
+        return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
457
+    }
458
+
459
+    /**
460
+     * Get GMT date when the subscription will renew.
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_next_renewal_date_gmt( $context = 'view' ) {
467 467
         $date = $this->get_next_renewal_date( $context );
468 468
 
469 469
         if ( $date ) {
470 470
             $date = get_gmt_from_date( $date );
471 471
         }
472
-		return $date;
473
-	}
474
-
475
-	/**
476
-	 * Get the subscription's trial period.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_trial_period( $context = 'view' ) {
483
-		return $this->get_prop( 'trial_period', $context );
484
-	}
485
-
486
-	/**
487
-	 * Get the subscription's status.
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_status( $context = 'view' ) {
494
-		return $this->get_prop( 'status', $context );
495
-	}
496
-
497
-	/**
498
-	 * Get the subscription's profile id.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_profile_id( $context = 'view' ) {
505
-		return $this->get_prop( 'profile_id', $context );
506
-	}
507
-
508
-	/*
472
+        return $date;
473
+    }
474
+
475
+    /**
476
+     * Get the subscription's trial period.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_trial_period( $context = 'view' ) {
483
+        return $this->get_prop( 'trial_period', $context );
484
+    }
485
+
486
+    /**
487
+     * Get the subscription's status.
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_status( $context = 'view' ) {
494
+        return $this->get_prop( 'status', $context );
495
+    }
496
+
497
+    /**
498
+     * Get the subscription's profile id.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_profile_id( $context = 'view' ) {
505
+        return $this->get_prop( 'profile_id', $context );
506
+    }
507
+
508
+    /*
509 509
 	|--------------------------------------------------------------------------
510 510
 	| Setters
511 511
 	|--------------------------------------------------------------------------
512 512
 	*/
513 513
 
514
-	/**
515
-	 * Set customer id.
516
-	 *
517
-	 * @since 1.0.19
518
-	 * @param  int $value The customer's id.
519
-	 */
520
-	public function set_customer_id( $value ) {
521
-		$this->set_prop( 'customer_id', (int) $value );
522
-	}
523
-
524
-	/**
525
-	 * Set parent invoice id.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  int $value The parent invoice id.
529
-	 */
530
-	public function set_parent_invoice_id( $value ) {
531
-		$this->set_prop( 'parent_payment_id', (int) $value );
532
-	}
533
-
534
-	/**
535
-	 * Alias for self::set_parent_invoice_id().
536
-	 *
537
-	 * @since 1.0.19
538
-	 * @param  int $value The parent invoice id.
539
-	 */
540
-    public function set_parent_payment_id( $value ) {
541
-        $this->set_parent_invoice_id( $value );
542
-	}
514
+    /**
515
+     * Set customer id.
516
+     *
517
+     * @since 1.0.19
518
+     * @param  int $value The customer's id.
519
+     */
520
+    public function set_customer_id( $value ) {
521
+        $this->set_prop( 'customer_id', (int) $value );
522
+    }
523
+
524
+    /**
525
+     * Set parent invoice id.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  int $value The parent invoice id.
529
+     */
530
+    public function set_parent_invoice_id( $value ) {
531
+        $this->set_prop( 'parent_payment_id', (int) $value );
532
+    }
533
+
534
+    /**
535
+     * Alias for self::set_parent_invoice_id().
536
+     *
537
+     * @since 1.0.19
538
+     * @param  int $value The parent invoice id.
539
+     */
540
+    public function set_parent_payment_id( $value ) {
541
+        $this->set_parent_invoice_id( $value );
542
+    }
543
+
544
+    /**
545
+     * Alias for self::set_parent_invoice_id().
546
+     *
547
+     * @since 1.0.19
548
+     * @param  int $value The parent invoice id.
549
+     */
550
+    public function set_original_payment_id( $value ) {
551
+        $this->set_parent_invoice_id( $value );
552
+    }
553
+
554
+    /**
555
+     * Set subscription's product id.
556
+     *
557
+     * @since 1.0.19
558
+     * @param  int $value The subscription product id.
559
+     */
560
+    public function set_product_id( $value ) {
561
+        $this->set_prop( 'product_id', (int) $value );
562
+    }
563
+
564
+    /**
565
+     * Set the period of a renewal.
566
+     *
567
+     * @since 1.0.19
568
+     * @param  string $value The renewal period.
569
+     */
570
+    public function set_period( $value ) {
571
+        $this->set_prop( 'period', $value );
572
+    }
573
+
574
+    /**
575
+     * Set number of periods each renewal is valid for.
576
+     *
577
+     * @since 1.0.19
578
+     * @param  int $value The subscription frequency.
579
+     */
580
+    public function set_frequency( $value ) {
581
+        $value = empty( $value ) ? 1 : (int) $value;
582
+        $this->set_prop( 'frequency', absint( $value ) );
583
+    }
584
+
585
+    /**
586
+     * Set the initial amount for the subscription.
587
+     *
588
+     * @since 1.0.19
589
+     * @param  float $value The initial subcription amount.
590
+     */
591
+    public function set_initial_amount( $value ) {
592
+        $this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
593
+    }
594
+
595
+    /**
596
+     * Set the recurring amount for the subscription.
597
+     *
598
+     * @since 1.0.19
599
+     * @param  float $value The recurring subcription amount.
600
+     */
601
+    public function set_recurring_amount( $value ) {
602
+        $this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
603
+    }
604
+
605
+    /**
606
+     * Set number of times that this subscription can be renewed.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  int $value Bill times.
610
+     */
611
+    public function set_bill_times( $value ) {
612
+        $this->set_prop( 'bill_times', (int) $value );
613
+    }
614
+
615
+    /**
616
+     * Get transaction id of this subscription's parent invoice.
617
+     *
618
+     * @since 1.0.19
619
+     * @param string $value Bill times.
620
+     */
621
+    public function set_transaction_id( $value ) {
622
+        $this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
623
+    }
543 624
 
544
-	/**
545
-     * Alias for self::set_parent_invoice_id().
625
+    /**
626
+     * Set date when this subscription started.
546 627
      *
547 628
      * @since 1.0.19
548
-	 * @param  int $value The parent invoice id.
629
+     * @param string $value strtotime compliant date.
549 630
      */
550
-    public function set_original_payment_id( $value ) {
551
-        $this->set_parent_invoice_id( $value );
552
-	}
553
-
554
-	/**
555
-	 * Set subscription's product id.
556
-	 *
557
-	 * @since 1.0.19
558
-	 * @param  int $value The subscription product id.
559
-	 */
560
-	public function set_product_id( $value ) {
561
-		$this->set_prop( 'product_id', (int) $value );
562
-	}
563
-
564
-	/**
565
-	 * Set the period of a renewal.
566
-	 *
567
-	 * @since 1.0.19
568
-	 * @param  string $value The renewal period.
569
-	 */
570
-	public function set_period( $value ) {
571
-		$this->set_prop( 'period', $value );
572
-	}
573
-
574
-	/**
575
-	 * Set number of periods each renewal is valid for.
576
-	 *
577
-	 * @since 1.0.19
578
-	 * @param  int $value The subscription frequency.
579
-	 */
580
-	public function set_frequency( $value ) {
581
-		$value = empty( $value ) ? 1 : (int) $value;
582
-		$this->set_prop( 'frequency', absint( $value ) );
583
-	}
584
-
585
-	/**
586
-	 * Set the initial amount for the subscription.
587
-	 *
588
-	 * @since 1.0.19
589
-	 * @param  float $value The initial subcription amount.
590
-	 */
591
-	public function set_initial_amount( $value ) {
592
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
593
-	}
594
-
595
-	/**
596
-	 * Set the recurring amount for the subscription.
597
-	 *
598
-	 * @since 1.0.19
599
-	 * @param  float $value The recurring subcription amount.
600
-	 */
601
-	public function set_recurring_amount( $value ) {
602
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
603
-	}
604
-
605
-	/**
606
-	 * Set number of times that this subscription can be renewed.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  int $value Bill times.
610
-	 */
611
-	public function set_bill_times( $value ) {
612
-		$this->set_prop( 'bill_times', (int) $value );
613
-	}
614
-
615
-	/**
616
-	 * Get transaction id of this subscription's parent invoice.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @param string $value Bill times.
620
-	 */
621
-	public function set_transaction_id( $value ) {
622
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
623
-	}
624
-
625
-	/**
626
-	 * Set date when this subscription started.
627
-	 *
628
-	 * @since 1.0.19
629
-	 * @param string $value strtotime compliant date.
630
-	 */
631
-	public function set_created( $value ) {
631
+    public function set_created( $value ) {
632 632
         $date = strtotime( $value );
633 633
 
634 634
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -636,93 +636,93 @@  discard block
 block discarded – undo
636 636
             return;
637 637
         }
638 638
 
639
-		$this->set_prop( 'created', '' );
639
+        $this->set_prop( 'created', '' );
640 640
 
641
-	}
641
+    }
642 642
 
643
-	/**
644
-	 * Alias for self::set_created().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param string $value strtotime compliant date.
648
-	 */
649
-	public function set_date_created( $value ) {
650
-		$this->set_created( $value );
643
+    /**
644
+     * Alias for self::set_created().
645
+     *
646
+     * @since 1.0.19
647
+     * @param string $value strtotime compliant date.
648
+     */
649
+    public function set_date_created( $value ) {
650
+        $this->set_created( $value );
651 651
     }
652 652
 
653
-	/**
654
-	 * Set the date that the subscription will renew.
655
-	 *
656
-	 * @since 1.0.19
657
-	 * @param string $value strtotime compliant date.
658
-	 */
659
-	public function set_next_renewal_date( $value ) {
660
-		$date = strtotime( $value );
653
+    /**
654
+     * Set the date that the subscription will renew.
655
+     *
656
+     * @since 1.0.19
657
+     * @param string $value strtotime compliant date.
658
+     */
659
+    public function set_next_renewal_date( $value ) {
660
+        $date = strtotime( $value );
661 661
 
662 662
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
663 663
             $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) );
664 664
             return;
665
-		}
666
-
667
-		$this->set_prop( 'expiration', '' );
668
-
669
-	}
670
-
671
-	/**
672
-	 * Alias for self::set_next_renewal_date().
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param string $value strtotime compliant date.
676
-	 */
677
-	public function set_expiration( $value ) {
678
-		$this->set_next_renewal_date( $value );
679
-    }
680
-
681
-	/**
682
-	 * Set the subscription's trial period.
683
-	 *
684
-	 * @since 1.0.19
685
-	 * @param string $value trial period e.g 1 year.
686
-	 */
687
-	public function set_trial_period( $value ) {
688
-		$this->set_prop( 'trial_period', $value );
689
-	}
690
-
691
-	/**
692
-	 * Set the subscription's status.
693
-	 *
694
-	 * @since 1.0.19
695
-	 * @param string $new_status    New subscription status.
696
-	 */
697
-	public function set_status( $new_status ) {
698
-
699
-		// Abort if this is not a valid status;
700
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
701
-			return;
702
-		}
703
-
704
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
-		if ( true === $this->object_read && $old_status !== $new_status ) {
706
-			$this->status_transition = array(
707
-				'from' => $old_status,
708
-				'to'   => $new_status,
709
-			);
710
-		}
711
-
712
-		$this->set_prop( 'status', $new_status );
713
-	}
714
-
715
-	/**
716
-	 * Set the subscription's (remote) profile id.
717
-	 *
718
-	 * @since 1.0.19
719
-	 * @param  string $value the remote profile id.
720
-	 */
721
-	public function set_profile_id( $value ) {
722
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
723
-	}
724
-
725
-	/*
665
+        }
666
+
667
+        $this->set_prop( 'expiration', '' );
668
+
669
+    }
670
+
671
+    /**
672
+     * Alias for self::set_next_renewal_date().
673
+     *
674
+     * @since 1.0.19
675
+     * @param string $value strtotime compliant date.
676
+     */
677
+    public function set_expiration( $value ) {
678
+        $this->set_next_renewal_date( $value );
679
+    }
680
+
681
+    /**
682
+     * Set the subscription's trial period.
683
+     *
684
+     * @since 1.0.19
685
+     * @param string $value trial period e.g 1 year.
686
+     */
687
+    public function set_trial_period( $value ) {
688
+        $this->set_prop( 'trial_period', $value );
689
+    }
690
+
691
+    /**
692
+     * Set the subscription's status.
693
+     *
694
+     * @since 1.0.19
695
+     * @param string $new_status    New subscription status.
696
+     */
697
+    public function set_status( $new_status ) {
698
+
699
+        // Abort if this is not a valid status;
700
+        if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
701
+            return;
702
+        }
703
+
704
+        $old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
+        if ( true === $this->object_read && $old_status !== $new_status ) {
706
+            $this->status_transition = array(
707
+                'from' => $old_status,
708
+                'to'   => $new_status,
709
+            );
710
+        }
711
+
712
+        $this->set_prop( 'status', $new_status );
713
+    }
714
+
715
+    /**
716
+     * Set the subscription's (remote) profile id.
717
+     *
718
+     * @since 1.0.19
719
+     * @param  string $value the remote profile id.
720
+     */
721
+    public function set_profile_id( $value ) {
722
+        $this->set_prop( 'profile_id', sanitize_text_field( $value ) );
723
+    }
724
+
725
+    /*
726 726
 	|--------------------------------------------------------------------------
727 727
 	| Boolean methods
728 728
 	|--------------------------------------------------------------------------
@@ -731,55 +731,55 @@  discard block
 block discarded – undo
731 731
 	|
732 732
 	*/
733 733
 
734
-	/**
734
+    /**
735 735
      * Checks if the subscription has a given status.
736
-	 *
737
-	 * @param string|array String or array of strings to check for.
738
-	 * @return bool
736
+     *
737
+     * @param string|array String or array of strings to check for.
738
+     * @return bool
739 739
      */
740 740
     public function has_status( $status ) {
741 741
         return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
742
-	}
742
+    }
743 743
 
744
-	/**
744
+    /**
745 745
      * Checks if the subscription has a trial period.
746
-	 *
747
-	 * @return bool
746
+     *
747
+     * @return bool
748 748
      */
749 749
     public function has_trial_period() {
750
-		$period = $this->get_trial_period();
750
+        $period = $this->get_trial_period();
751 751
         return ! empty( $period );
752
-	}
753
-
754
-	/**
755
-	 * Is the subscription active?
756
-	 *
757
-	 * @return bool
758
-	 */
759
-	public function is_active() {
760
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
761
-	}
762
-
763
-	/**
764
-	 * Is the subscription expired?
765
-	 *
766
-	 * @return bool
767
-	 */
768
-	public function is_expired() {
769
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
770
-	}
771
-
772
-	/**
773
-	 * Is this the last renewals?
774
-	 *
775
-	 * @return bool
776
-	 */
777
-	public function is_last_renewal() {
778
-		$max_bills = $this->get_bill_times();
779
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
780
-	}
781
-
782
-	/*
752
+    }
753
+
754
+    /**
755
+     * Is the subscription active?
756
+     *
757
+     * @return bool
758
+     */
759
+    public function is_active() {
760
+        return $this->has_status( 'active trialling' ) && ! $this->is_expired();
761
+    }
762
+
763
+    /**
764
+     * Is the subscription expired?
765
+     *
766
+     * @return bool
767
+     */
768
+    public function is_expired() {
769
+        return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
770
+    }
771
+
772
+    /**
773
+     * Is this the last renewals?
774
+     *
775
+     * @return bool
776
+     */
777
+    public function is_last_renewal() {
778
+        $max_bills = $this->get_bill_times();
779
+        return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
780
+    }
781
+
782
+    /*
783 783
 	|--------------------------------------------------------------------------
784 784
 	| Additional methods
785 785
 	|--------------------------------------------------------------------------
@@ -788,27 +788,27 @@  discard block
 block discarded – undo
788 788
 	|
789 789
 	*/
790 790
 
791
-	/**
792
-	 * Backwards compatibilty.
793
-	 */
794
-	public function create( $data = array() ) {
791
+    /**
792
+     * Backwards compatibilty.
793
+     */
794
+    public function create( $data = array() ) {
795 795
 
796
-		// Set the properties.
797
-		if ( is_array( $data ) ) {
798
-			$this->set_props( $data );
799
-		}
796
+        // Set the properties.
797
+        if ( is_array( $data ) ) {
798
+            $this->set_props( $data );
799
+        }
800 800
 
801
-		// Save the item.
802
-		return $this->save();
801
+        // Save the item.
802
+        return $this->save();
803 803
 
804
-	}
804
+    }
805 805
 
806
-	/**
807
-	 * Backwards compatibilty.
808
-	 */
809
-	public function update( $args = array() ) {
810
-		return $this->create( $args );
811
-	}
806
+    /**
807
+     * Backwards compatibilty.
808
+     */
809
+    public function update( $args = array() ) {
810
+        return $this->create( $args );
811
+    }
812 812
 
813 813
     /**
814 814
      * Retrieve renewal payments for a subscription
@@ -818,22 +818,22 @@  discard block
 block discarded – undo
818 818
      */
819 819
     public function get_child_payments( $hide_pending = true ) {
820 820
 
821
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
821
+        $statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
822 822
 
823
-		if ( ! $hide_pending ) {
824
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
825
-		}
823
+        if ( ! $hide_pending ) {
824
+            $statuses = array_keys( wpinv_get_invoice_statuses() );
825
+        }
826 826
 
827 827
         return get_posts(
828
-			array(
829
-            	'post_parent' => $this->get_parent_payment_id(),
830
-            	'numberposts' => -1,
831
-            	'post_status' => $statuses,
832
-            	'orderby'     => 'ID',
833
-            	'order'       => 'ASC',
834
-            	'post_type'   => 'wpi_invoice',
835
-			)
836
-		);
828
+            array(
829
+                'post_parent' => $this->get_parent_payment_id(),
830
+                'numberposts' => -1,
831
+                'post_status' => $statuses,
832
+                'orderby'     => 'ID',
833
+                'order'       => 'ASC',
834
+                'post_type'   => 'wpi_invoice',
835
+            )
836
+        );
837 837
     }
838 838
 
839 839
     /**
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
      * @return int
844 844
      */
845 845
     public function get_total_payments() {
846
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
846
+        return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
847 847
     }
848 848
 
849 849
     /**
@@ -867,202 +867,202 @@  discard block
 block discarded – undo
867 867
      *
868 868
      * @since  2.4
869 869
      * @param  array $args Array of values for the payment, including amount and transaction ID
870
-	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
870
+     * @param  WPInv_Invoice $invoice If adding an existing invoice.
871 871
      * @return bool
872 872
      */
873 873
     public function add_payment( $args = array(), $invoice = false ) {
874 874
 
875
-		// Process each payment once.
875
+        // Process each payment once.
876 876
         if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
877 877
             return false;
878 878
         }
879 879
 
880
-		// Are we creating a new invoice?
881
-		if ( empty( $invoice ) ) {
882
-			$invoice = $this->create_payment( false );
880
+        // Are we creating a new invoice?
881
+        if ( empty( $invoice ) ) {
882
+            $invoice = $this->create_payment( false );
883 883
 
884
-			if ( empty( $invoice ) ) {
885
-				return false;
886
-			}
887
-		}
884
+            if ( empty( $invoice ) ) {
885
+                return false;
886
+            }
887
+        }
888 888
 
889
-		// Maybe set a transaction id.
890
-		if ( ! empty( $args['transaction_id'] ) ) {
891
-			$invoice->set_transaction_id( $args['transaction_id'] );
892
-		}
889
+        // Maybe set a transaction id.
890
+        if ( ! empty( $args['transaction_id'] ) ) {
891
+            $invoice->set_transaction_id( $args['transaction_id'] );
892
+        }
893 893
 
894
-		// Set the completed date.
895
-		$invoice->set_completed_date( current_time( 'mysql' ) );
894
+        // Set the completed date.
895
+        $invoice->set_completed_date( current_time( 'mysql' ) );
896 896
 
897
-		// And the gateway.
898
-		if ( ! empty( $args['gateway'] ) ) {
899
-			$invoice->set_gateway( $args['gateway'] );
900
-		}
897
+        // And the gateway.
898
+        if ( ! empty( $args['gateway'] ) ) {
899
+            $invoice->set_gateway( $args['gateway'] );
900
+        }
901 901
 
902
-		$invoice->set_status( 'wpi-renewal' );
903
-		$invoice->save();
902
+        $invoice->set_status( 'wpi-renewal' );
903
+        $invoice->save();
904 904
 
905
-		if ( ! $invoice->exists() ) {
906
-			return false;
907
-		}
905
+        if ( ! $invoice->exists() ) {
906
+            return false;
907
+        }
908 908
 
909
-		return $this->after_add_payment( $invoice );
910
-	}
909
+        return $this->after_add_payment( $invoice );
910
+    }
911 911
 
912 912
     public function after_add_payment( $invoice ) {
913 913
 
914
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
914
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
916 916
         do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
917 917
 
918 918
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
919 919
 
920 920
         return $invoice->get_id();
921
-	}
921
+    }
922 922
 
923
-	/**
923
+    /**
924 924
      * Creates a new invoice and returns it.
925 925
      *
926 926
      * @since  1.0.19
927
-	 * @param bool $save Whether we should save the invoice.
927
+     * @param bool $save Whether we should save the invoice.
928 928
      * @return WPInv_Invoice|bool
929 929
      */
930 930
     public function create_payment( $save = true ) {
931 931
 
932
-		$parent_invoice = $this->get_parent_payment();
933
-
934
-		if ( ! $parent_invoice->exists() ) {
935
-			return false;
936
-		}
937
-
938
-		// Duplicate the parent invoice.
939
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
940
-		$invoice->set_parent_id( $parent_invoice->get_id() );
941
-		$invoice->set_subscription_id( $this->get_id() );
942
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
943
-
944
-		// Set invoice items.
945
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
947
-		$invoice_items      = array();
948
-
949
-		foreach ( $invoice->get_items() as $item ) {
950
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
951
-				$invoice_items[] = $item;
952
-			}
953
-		}
954
-
955
-		$invoice->set_items( $invoice_items );
956
-
957
-		if ( ! empty( $subscription_group['fees'] ) ) {
958
-			$invoice->set_fees( $subscription_group['fees'] );
959
-		}
960
-
961
-		// Maybe recalculate discount (Pre-GetPaid Fix).
962
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
963
-
964
-		if ( $discount->exists() && $discount->is_recurring() ) {
965
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
-		}  else {
967
-			// Unset discount code.
968
-			$invoice->set_discount_code( '' );
969
-
970
-			$invoice->remove_discount( 'discount_code' );
971
-		}
972
-
973
-		$invoice->recalculate_total();
974
-		$invoice->set_status( 'wpi-pending' );
975
-
976
-		if ( ! $save ) {
977
-			return $invoice;
978
-		}
979
-
980
-		$invoice->save();
981
-
982
-		return $invoice->exists() ? $invoice : false;
983
-    }
984
-
985
-	/**
986
-	 * Renews or completes a subscription
987
-	 *
988
-	 * @since  1.0.0
989
-	 * @return int The subscription's id
990
-	 */
991
-	public function renew( $calculate_from = null, $_new_expiration = null ) {
992
-		// Complete subscription if applicable
993
-		if ( $this->is_last_renewal() ) {
994
-			return $this->complete();
995
-		}
996
-
997
-		if ( ! empty( $_new_expiration ) ) {
998
-			$new_expiration = $_new_expiration;
999
-		} else {
1000
-			// Calculate new expiration
1001
-			$frequency      = $this->get_frequency();
1002
-			$period         = $this->get_period();
1003
-			$calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
1004
-			$new_expiration = strtotime( "+ $frequency $period", $calculate_from );
1005
-			$new_expiration = date( 'Y-m-d H:i:s', $new_expiration );
1006
-		}
1007
-
1008
-		$this->set_expiration( $new_expiration );
1009
-		$this->set_status( 'active' );
1010
-		$this->save();
1011
-
1012
-		do_action( 'getpaid_subscription_renewed', $this );
1013
-
1014
-		return $this->get_id();
1015
-	}
1016
-
1017
-	/**
1018
-	 * Marks a subscription as completed
1019
-	 *
1020
-	 * Subscription is completed when the number of payments matches the billing_times field
1021
-	 *
1022
-	 * @since  1.0.0
1023
-	 * @return int|bool Subscription id or false if the subscription is cancelled.
1024
-	 */
1025
-	public function complete() {
1026
-
1027
-		// Only mark a subscription as complete if it's not already cancelled.
1028
-		if ( $this->has_status( 'cancelled' ) ) {
1029
-			return false;
1030
-		}
1031
-
1032
-		$this->set_status( 'completed' );
1033
-		return $this->save();
1034
-
1035
-	}
1036
-
1037
-	/**
1038
-	 * Marks a subscription as expired
1039
-	 *
1040
-	 * @since  1.0.0
1041
-	 * @param  bool $check_expiration
1042
-	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1043
-	 */
1044
-	public function expire( $check_expiration = false ) {
1045
-
1046
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1047
-			// Do not mark as expired since real expiration date is in the future
1048
-			return false;
1049
-		}
1050
-
1051
-		$this->set_status( 'expired' );
1052
-		return $this->save();
1053
-
1054
-	}
1055
-
1056
-	/**
1057
-	 * Marks a subscription as failing
1058
-	 *
1059
-	 * @since  2.4.2
1060
-	 * @return int Subscription id.
1061
-	 */
1062
-	public function failing() {
1063
-		$this->set_status( 'failing' );
1064
-		return $this->save();
1065
-	}
932
+        $parent_invoice = $this->get_parent_payment();
933
+
934
+        if ( ! $parent_invoice->exists() ) {
935
+            return false;
936
+        }
937
+
938
+        // Duplicate the parent invoice.
939
+        $invoice = getpaid_duplicate_invoice( $parent_invoice );
940
+        $invoice->set_parent_id( $parent_invoice->get_id() );
941
+        $invoice->set_subscription_id( $this->get_id() );
942
+        $invoice->set_remote_subscription_id( $this->get_profile_id() );
943
+
944
+        // Set invoice items.
945
+        $subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
+        $allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
947
+        $invoice_items      = array();
948
+
949
+        foreach ( $invoice->get_items() as $item ) {
950
+            if ( in_array( $item->get_id(), $allowed_items ) ) {
951
+                $invoice_items[] = $item;
952
+            }
953
+        }
954
+
955
+        $invoice->set_items( $invoice_items );
956
+
957
+        if ( ! empty( $subscription_group['fees'] ) ) {
958
+            $invoice->set_fees( $subscription_group['fees'] );
959
+        }
960
+
961
+        // Maybe recalculate discount (Pre-GetPaid Fix).
962
+        $discount = new WPInv_Discount( $invoice->get_discount_code() );
963
+
964
+        if ( $discount->exists() && $discount->is_recurring() ) {
965
+            $invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
+        }  else {
967
+            // Unset discount code.
968
+            $invoice->set_discount_code( '' );
969
+
970
+            $invoice->remove_discount( 'discount_code' );
971
+        }
972
+
973
+        $invoice->recalculate_total();
974
+        $invoice->set_status( 'wpi-pending' );
975
+
976
+        if ( ! $save ) {
977
+            return $invoice;
978
+        }
979
+
980
+        $invoice->save();
981
+
982
+        return $invoice->exists() ? $invoice : false;
983
+    }
984
+
985
+    /**
986
+     * Renews or completes a subscription
987
+     *
988
+     * @since  1.0.0
989
+     * @return int The subscription's id
990
+     */
991
+    public function renew( $calculate_from = null, $_new_expiration = null ) {
992
+        // Complete subscription if applicable
993
+        if ( $this->is_last_renewal() ) {
994
+            return $this->complete();
995
+        }
996
+
997
+        if ( ! empty( $_new_expiration ) ) {
998
+            $new_expiration = $_new_expiration;
999
+        } else {
1000
+            // Calculate new expiration
1001
+            $frequency      = $this->get_frequency();
1002
+            $period         = $this->get_period();
1003
+            $calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
1004
+            $new_expiration = strtotime( "+ $frequency $period", $calculate_from );
1005
+            $new_expiration = date( 'Y-m-d H:i:s', $new_expiration );
1006
+        }
1007
+
1008
+        $this->set_expiration( $new_expiration );
1009
+        $this->set_status( 'active' );
1010
+        $this->save();
1011
+
1012
+        do_action( 'getpaid_subscription_renewed', $this );
1013
+
1014
+        return $this->get_id();
1015
+    }
1016
+
1017
+    /**
1018
+     * Marks a subscription as completed
1019
+     *
1020
+     * Subscription is completed when the number of payments matches the billing_times field
1021
+     *
1022
+     * @since  1.0.0
1023
+     * @return int|bool Subscription id or false if the subscription is cancelled.
1024
+     */
1025
+    public function complete() {
1026
+
1027
+        // Only mark a subscription as complete if it's not already cancelled.
1028
+        if ( $this->has_status( 'cancelled' ) ) {
1029
+            return false;
1030
+        }
1031
+
1032
+        $this->set_status( 'completed' );
1033
+        return $this->save();
1034
+
1035
+    }
1036
+
1037
+    /**
1038
+     * Marks a subscription as expired
1039
+     *
1040
+     * @since  1.0.0
1041
+     * @param  bool $check_expiration
1042
+     * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1043
+     */
1044
+    public function expire( $check_expiration = false ) {
1045
+
1046
+        if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1047
+            // Do not mark as expired since real expiration date is in the future
1048
+            return false;
1049
+        }
1050
+
1051
+        $this->set_status( 'expired' );
1052
+        return $this->save();
1053
+
1054
+    }
1055
+
1056
+    /**
1057
+     * Marks a subscription as failing
1058
+     *
1059
+     * @since  2.4.2
1060
+     * @return int Subscription id.
1061
+     */
1062
+    public function failing() {
1063
+        $this->set_status( 'failing' );
1064
+        return $this->save();
1065
+    }
1066 1066
 
1067 1067
     /**
1068 1068
      * Marks a subscription as cancelled
@@ -1071,19 +1071,19 @@  discard block
 block discarded – undo
1071 1071
      * @return int Subscription id.
1072 1072
      */
1073 1073
     public function cancel() {
1074
-		$this->set_status( 'cancelled' );
1075
-		return $this->save();
1074
+        $this->set_status( 'cancelled' );
1075
+        return $this->save();
1076 1076
     }
1077 1077
 
1078
-	/**
1079
-	 * Determines if a subscription can be cancelled both locally and with a payment processor.
1080
-	 *
1081
-	 * @since  1.0.0
1082
-	 * @return bool
1083
-	 */
1084
-	public function can_cancel() {
1085
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1086
-	}
1078
+    /**
1079
+     * Determines if a subscription can be cancelled both locally and with a payment processor.
1080
+     *
1081
+     * @since  1.0.0
1082
+     * @return bool
1083
+     */
1084
+    public function can_cancel() {
1085
+        return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1086
+    }
1087 1087
 
1088 1088
     /**
1089 1089
      * Returns an array of subscription statuses that can be cancelled
@@ -1096,109 +1096,109 @@  discard block
 block discarded – undo
1096 1096
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1097 1097
     }
1098 1098
 
1099
-	/**
1100
-	 * Retrieves the URL to cancel subscription
1101
-	 *
1102
-	 * @since  1.0.0
1103
-	 * @return string
1104
-	 */
1105
-	public function get_cancel_url() {
1106
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1107
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1108
-	}
1109
-
1110
-	/**
1111
-	 * Retrieves the URL to view a subscription
1112
-	 *
1113
-	 * @since  1.0.19
1114
-	 * @return string
1115
-	 */
1116
-	public function get_view_url() {
1117
-
1118
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1119
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1120
-
1121
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1122
-	}
1123
-
1124
-	/**
1125
-	 * Determines if subscription can be manually renewed
1126
-	 *
1127
-	 * This method is filtered by payment gateways in order to return true on subscriptions
1128
-	 * that can be renewed manually
1129
-	 *
1130
-	 * @since  2.5
1131
-	 * @return bool
1132
-	 */
1133
-	public function can_renew() {
1134
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1135
-	}
1136
-
1137
-	/**
1138
-	 * Retrieves the URL to renew a subscription
1139
-	 *
1140
-	 * @since  2.5
1141
-	 * @return string
1142
-	 */
1143
-	public function get_renew_url() {
1144
-		$url = wp_nonce_url(
1099
+    /**
1100
+     * Retrieves the URL to cancel subscription
1101
+     *
1102
+     * @since  1.0.0
1103
+     * @return string
1104
+     */
1105
+    public function get_cancel_url() {
1106
+        $url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1107
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1108
+    }
1109
+
1110
+    /**
1111
+     * Retrieves the URL to view a subscription
1112
+     *
1113
+     * @since  1.0.19
1114
+     * @return string
1115
+     */
1116
+    public function get_view_url() {
1117
+
1118
+        $url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1119
+        $url = add_query_arg( 'subscription', $this->get_id(), $url );
1120
+
1121
+        return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1122
+    }
1123
+
1124
+    /**
1125
+     * Determines if subscription can be manually renewed
1126
+     *
1127
+     * This method is filtered by payment gateways in order to return true on subscriptions
1128
+     * that can be renewed manually
1129
+     *
1130
+     * @since  2.5
1131
+     * @return bool
1132
+     */
1133
+    public function can_renew() {
1134
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1135
+    }
1136
+
1137
+    /**
1138
+     * Retrieves the URL to renew a subscription
1139
+     *
1140
+     * @since  2.5
1141
+     * @return string
1142
+     */
1143
+    public function get_renew_url() {
1144
+        $url = wp_nonce_url(
1145 1145
             add_query_arg(
1146 1146
                 array(
1147
-					'getpaid-action' => 'renew_subscription',
1148
-					'sub_id'         => $this->get_id,
1147
+                    'getpaid-action' => 'renew_subscription',
1148
+                    'sub_id'         => $this->get_id,
1149 1149
                 )
1150 1150
             ),
1151 1151
             'getpaid-nonce'
1152 1152
         );
1153
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1154
-	}
1155
-
1156
-	/**
1157
-	 * Determines if subscription can have their payment method updated
1158
-	 *
1159
-	 * @since  1.0.0
1160
-	 * @return bool
1161
-	 */
1162
-	public function can_update() {
1163
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1164
-	}
1165
-
1166
-	/**
1167
-	 * Retrieves the URL to update subscription
1168
-	 *
1169
-	 * @since  1.0.0
1170
-	 * @return string
1171
-	 */
1172
-	public function get_update_url() {
1173
-		$url = add_query_arg(
1153
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1154
+    }
1155
+
1156
+    /**
1157
+     * Determines if subscription can have their payment method updated
1158
+     *
1159
+     * @since  1.0.0
1160
+     * @return bool
1161
+     */
1162
+    public function can_update() {
1163
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
1164
+    }
1165
+
1166
+    /**
1167
+     * Retrieves the URL to update subscription
1168
+     *
1169
+     * @since  1.0.0
1170
+     * @return string
1171
+     */
1172
+    public function get_update_url() {
1173
+        $url = add_query_arg(
1174 1174
             array(
1175
-				'action'          => 'update',
1176
-				'subscription_id' => $this->get_id(),
1175
+                'action'          => 'update',
1176
+                'subscription_id' => $this->get_id(),
1177 1177
             )
1178 1178
         );
1179
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1180
-	}
1181
-
1182
-	/**
1183
-	 * Retrieves the subscription status label
1184
-	 *
1185
-	 * @since  1.0.0
1186
-	 * @return string
1187
-	 */
1188
-	public function get_status_label() {
1189
-		return getpaid_get_subscription_status_label( $this->get_status() );
1190
-	}
1191
-
1192
-	/**
1193
-	 * Retrieves the subscription status class
1194
-	 *
1195
-	 * @since  1.0.19
1196
-	 * @return string
1197
-	 */
1198
-	public function get_status_class() {
1199
-		$statuses = getpaid_get_subscription_status_classes();
1200
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1201
-	}
1179
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1180
+    }
1181
+
1182
+    /**
1183
+     * Retrieves the subscription status label
1184
+     *
1185
+     * @since  1.0.0
1186
+     * @return string
1187
+     */
1188
+    public function get_status_label() {
1189
+        return getpaid_get_subscription_status_label( $this->get_status() );
1190
+    }
1191
+
1192
+    /**
1193
+     * Retrieves the subscription status class
1194
+     *
1195
+     * @since  1.0.19
1196
+     * @return string
1197
+     */
1198
+    public function get_status_class() {
1199
+        $statuses = getpaid_get_subscription_status_classes();
1200
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1201
+    }
1202 1202
 
1203 1203
     /**
1204 1204
      * Retrieves the subscription status label
@@ -1208,11 +1208,11 @@  discard block
 block discarded – undo
1208 1208
      */
1209 1209
     public function get_status_label_html() {
1210 1210
 
1211
-		$status_label = sanitize_text_field( $this->get_status_label() );
1212
-		$class        = esc_attr( $this->get_status_class() );
1213
-		$status       = sanitize_html_class( $this->get_status() );
1211
+        $status_label = sanitize_text_field( $this->get_status_label() );
1212
+        $class        = esc_attr( $this->get_status_class() );
1213
+        $status       = sanitize_html_class( $this->get_status() );
1214 1214
 
1215
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1215
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1216 1216
     }
1217 1217
 
1218 1218
     /**
@@ -1223,75 +1223,75 @@  discard block
 block discarded – undo
1223 1223
      * @return bool
1224 1224
      */
1225 1225
     public function payment_exists( $txn_id = '' ) {
1226
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1226
+        $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1227 1227
         return ! empty( $invoice_id );
1228
-	}
1229
-
1230
-	/**
1231
-	 * Handle the status transition.
1232
-	 */
1233
-	protected function status_transition() {
1234
-		$status_transition = $this->status_transition;
1235
-
1236
-		// Reset status transition variable.
1237
-		$this->status_transition = false;
1238
-
1239
-		if ( $status_transition ) {
1240
-			try {
1241
-
1242
-				// Fire a hook for the status change.
1243
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1244
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1245
-
1246
-				if ( ! empty( $status_transition['from'] ) ) {
1247
-
1248
-					/* translators: 1: old subscription status 2: new subscription status */
1249
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1250
-
1251
-					// Note the transition occurred.
1252
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1253
-
1254
-					// Fire another hook.
1255
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1256
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1257
-
1258
-				} else {
1259
-					/* translators: %s: new invoice status */
1260
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1261
-
1262
-					// Note the transition occurred.
1263
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1264
-
1265
-				}
1266
-			} catch ( Exception $e ) {
1267
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1268
-			}
1269
-		}
1270
-
1271
-	}
1272
-
1273
-	/**
1274
-	 * Save data to the database.
1275
-	 *
1276
-	 * @since 1.0.19
1277
-	 * @return int subscription ID
1278
-	 */
1279
-	public function save() {
1280
-		parent::save();
1281
-		$this->status_transition();
1282
-		return $this->get_id();
1283
-	}
1284
-
1285
-	/**
1286
-	 * Activates a subscription.
1287
-	 *
1288
-	 * @since 1.0.19
1289
-	 * @return int subscription ID
1290
-	 */
1291
-	public function activate() {
1292
-		$status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1293
-		$this->set_status( $status );
1294
-		return $this->save();
1295
-	}
1228
+    }
1229
+
1230
+    /**
1231
+     * Handle the status transition.
1232
+     */
1233
+    protected function status_transition() {
1234
+        $status_transition = $this->status_transition;
1235
+
1236
+        // Reset status transition variable.
1237
+        $this->status_transition = false;
1238
+
1239
+        if ( $status_transition ) {
1240
+            try {
1241
+
1242
+                // Fire a hook for the status change.
1243
+                do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1244
+                do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1245
+
1246
+                if ( ! empty( $status_transition['from'] ) ) {
1247
+
1248
+                    /* translators: 1: old subscription status 2: new subscription status */
1249
+                    $transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1250
+
1251
+                    // Note the transition occurred.
1252
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1253
+
1254
+                    // Fire another hook.
1255
+                    do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1256
+                    do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1257
+
1258
+                } else {
1259
+                    /* translators: %s: new invoice status */
1260
+                    $transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1261
+
1262
+                    // Note the transition occurred.
1263
+                    $this->get_parent_payment()->add_note( $transition_note, false, false, true );
1264
+
1265
+                }
1266
+            } catch ( Exception $e ) {
1267
+                $this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1268
+            }
1269
+        }
1270
+
1271
+    }
1272
+
1273
+    /**
1274
+     * Save data to the database.
1275
+     *
1276
+     * @since 1.0.19
1277
+     * @return int subscription ID
1278
+     */
1279
+    public function save() {
1280
+        parent::save();
1281
+        $this->status_transition();
1282
+        return $this->get_id();
1283
+    }
1284
+
1285
+    /**
1286
+     * Activates a subscription.
1287
+     *
1288
+     * @since 1.0.19
1289
+     * @return int subscription ID
1290
+     */
1291
+    public function activate() {
1292
+        $status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1293
+        $this->set_status( $status );
1294
+        return $this->save();
1295
+    }
1296 1296
 
1297 1297
 }
Please login to merge, or discard this patch.
Spacing   +239 added lines, -239 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * The Subscription Class
@@ -68,27 +68,27 @@  discard block
 block discarded – undo
68 68
 	 * @param  int|string|object|WPInv_Subscription $subscription Subscription id, profile_id, or object to read.
69 69
 	 * @param  bool $deprecated
70 70
 	 */
71
-	function __construct( $subscription = 0, $deprecated = false ) {
71
+	function __construct($subscription = 0, $deprecated = false) {
72 72
 
73
-		parent::__construct( $subscription );
73
+		parent::__construct($subscription);
74 74
 
75
-		if ( ! $deprecated && ! empty( $subscription ) && is_numeric( $subscription ) ) {
76
-			$this->set_id( $subscription );
77
-		} elseif ( $subscription instanceof self ) {
78
-			$this->set_id( $subscription->get_id() );
79
-		} elseif ( $deprecated && $subscription_id = self::get_subscription_id_by_field( $subscription, 'profile_id' ) ) {
80
-			$this->set_id( $subscription_id );
81
-		} elseif ( ! empty( $subscription->id ) ) {
82
-			$this->set_id( $subscription->id );
75
+		if (!$deprecated && !empty($subscription) && is_numeric($subscription)) {
76
+			$this->set_id($subscription);
77
+		} elseif ($subscription instanceof self) {
78
+			$this->set_id($subscription->get_id());
79
+		} elseif ($deprecated && $subscription_id = self::get_subscription_id_by_field($subscription, 'profile_id')) {
80
+			$this->set_id($subscription_id);
81
+		} elseif (!empty($subscription->id)) {
82
+			$this->set_id($subscription->id);
83 83
 		} else {
84
-			$this->set_object_read( true );
84
+			$this->set_object_read(true);
85 85
 		}
86 86
 
87 87
 		// Load the datastore.
88
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
88
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
89 89
 
90
-		if ( $this->get_id() > 0 ) {
91
-			$this->data_store->read( $this );
90
+		if ($this->get_id() > 0) {
91
+			$this->data_store->read($this);
92 92
 		}
93 93
 
94 94
 	}
@@ -103,17 +103,17 @@  discard block
 block discarded – undo
103 103
 	 * @since 1.0.19
104 104
 	 * @return int
105 105
 	 */
106
-	public static function get_subscription_id_by_field( $value, $field = 'profile_id' ) {
106
+	public static function get_subscription_id_by_field($value, $field = 'profile_id') {
107 107
         global $wpdb;
108 108
 
109 109
 		// Trim the value.
110
-		$value = trim( $value );
110
+		$value = trim($value);
111 111
 
112
-		if ( empty( $value ) ) {
112
+		if (empty($value)) {
113 113
 			return 0;
114 114
 		}
115 115
 
116
-		if ( 'invoice_id' == $field ) {
116
+		if ('invoice_id' == $field) {
117 117
 			$field = 'parent_payment_id';
118 118
 		}
119 119
 
@@ -125,28 +125,28 @@  discard block
 block discarded – undo
125 125
 		);
126 126
 
127 127
 		// Ensure a field has been passed.
128
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
128
+		if (empty($field) || !in_array($field, $fields)) {
129 129
 			return 0;
130 130
 		}
131 131
 
132 132
 		// Maybe retrieve from the cache.
133
-		$subscription_id   = wp_cache_get( $value, "getpaid_subscription_{$field}s_to_subscription_ids" );
134
-		if ( ! empty( $subscription_id ) ) {
133
+		$subscription_id = wp_cache_get($value, "getpaid_subscription_{$field}s_to_subscription_ids");
134
+		if (!empty($subscription_id)) {
135 135
 			return $subscription_id;
136 136
 		}
137 137
 
138 138
         // Fetch from the db.
139 139
         $table            = $wpdb->prefix . 'wpinv_subscriptions';
140 140
         $subscription_id  = (int) $wpdb->get_var(
141
-            $wpdb->prepare( "SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
141
+            $wpdb->prepare("SELECT `id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
142 142
         );
143 143
 
144
-		if ( empty( $subscription_id ) ) {
144
+		if (empty($subscription_id)) {
145 145
 			return 0;
146 146
 		}
147 147
 
148 148
 		// Update the cache with our data.
149
-		wp_cache_set( $value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids" );
149
+		wp_cache_set($value, $subscription_id, "getpaid_subscription_{$field}s_to_subscription_ids");
150 150
 
151 151
 		return $subscription_id;
152 152
 	}
@@ -162,9 +162,9 @@  discard block
 block discarded – undo
162 162
 			'getpaid_subscriptions'                                       => $this->get_id(),
163 163
 		);
164 164
 
165
-		foreach ( $caches as $cache => $value ) {
166
-			if ( '' !== $value && false !== $value ) {
167
-				wp_cache_delete( $value, $cache );
165
+		foreach ($caches as $cache => $value) {
166
+			if ('' !== $value && false !== $value) {
167
+				wp_cache_delete($value, $cache);
168 168
 			}
169 169
 		}
170 170
 	}
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
      * Checks if a subscription key is set.
174 174
      */
175
-    public function _isset( $key ) {
176
-        return isset( $this->data[ $key ] ) || method_exists( $this, "get_$key" );
175
+    public function _isset($key) {
176
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
177 177
 	}
178 178
 
179 179
 	/*
@@ -198,8 +198,8 @@  discard block
 block discarded – undo
198 198
 	 * @param  string $context View or edit context.
199 199
 	 * @return int
200 200
 	 */
201
-	public function get_customer_id( $context = 'view' ) {
202
-		return (int) $this->get_prop( 'customer_id', $context );
201
+	public function get_customer_id($context = 'view') {
202
+		return (int) $this->get_prop('customer_id', $context);
203 203
 	}
204 204
 
205 205
 	/**
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param  string $context View or edit context.
210 210
 	 * @return WP_User|false WP_User object on success, false on failure.
211 211
 	 */
212
-	public function get_customer( $context = 'view' ) {
213
-		return get_userdata( $this->get_customer_id( $context ) );
212
+	public function get_customer($context = 'view') {
213
+		return get_userdata($this->get_customer_id($context));
214 214
 	}
215 215
 
216 216
 	/**
@@ -220,8 +220,8 @@  discard block
 block discarded – undo
220 220
 	 * @param  string $context View or edit context.
221 221
 	 * @return int
222 222
 	 */
223
-	public function get_parent_invoice_id( $context = 'view' ) {
224
-		return (int) $this->get_prop( 'parent_payment_id', $context );
223
+	public function get_parent_invoice_id($context = 'view') {
224
+		return (int) $this->get_prop('parent_payment_id', $context);
225 225
 	}
226 226
 
227 227
 	/**
@@ -231,8 +231,8 @@  discard block
 block discarded – undo
231 231
 	 * @param  string $context View or edit context.
232 232
 	 * @return int
233 233
 	 */
234
-    public function get_parent_payment_id( $context = 'view' ) {
235
-        return $this->get_parent_invoice_id( $context );
234
+    public function get_parent_payment_id($context = 'view') {
235
+        return $this->get_parent_invoice_id($context);
236 236
 	}
237 237
 
238 238
 	/**
@@ -241,8 +241,8 @@  discard block
 block discarded – undo
241 241
      * @since  1.0.0
242 242
      * @return int
243 243
      */
244
-    public function get_original_payment_id( $context = 'view' ) {
245
-        return $this->get_parent_invoice_id( $context );
244
+    public function get_original_payment_id($context = 'view') {
245
+        return $this->get_parent_invoice_id($context);
246 246
     }
247 247
 
248 248
 	/**
@@ -252,8 +252,8 @@  discard block
 block discarded – undo
252 252
 	 * @param  string $context View or edit context.
253 253
 	 * @return WPInv_Invoice
254 254
 	 */
255
-	public function get_parent_invoice( $context = 'view' ) {
256
-		return new WPInv_Invoice( $this->get_parent_invoice_id( $context ) );
255
+	public function get_parent_invoice($context = 'view') {
256
+		return new WPInv_Invoice($this->get_parent_invoice_id($context));
257 257
 	}
258 258
 
259 259
 	/**
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 	 * @param  string $context View or edit context.
264 264
 	 * @return WPInv_Invoice
265 265
 	 */
266
-    public function get_parent_payment( $context = 'view' ) {
267
-        return $this->get_parent_invoice( $context );
266
+    public function get_parent_payment($context = 'view') {
267
+        return $this->get_parent_invoice($context);
268 268
 	}
269 269
 
270 270
 	/**
@@ -274,8 +274,8 @@  discard block
 block discarded – undo
274 274
 	 * @param  string $context View or edit context.
275 275
 	 * @return int
276 276
 	 */
277
-	public function get_product_id( $context = 'view' ) {
278
-		return (int) $this->get_prop( 'product_id', $context );
277
+	public function get_product_id($context = 'view') {
278
+		return (int) $this->get_prop('product_id', $context);
279 279
 	}
280 280
 
281 281
 	/**
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param  string $context View or edit context.
286 286
 	 * @return WPInv_Item
287 287
 	 */
288
-	public function get_product( $context = 'view' ) {
289
-		return new WPInv_Item( $this->get_product_id( $context ) );
288
+	public function get_product($context = 'view') {
289
+		return new WPInv_Item($this->get_product_id($context));
290 290
 	}
291 291
 
292 292
 	/**
@@ -298,8 +298,8 @@  discard block
 block discarded – undo
298 298
 	 * @param  string $context View or edit context.
299 299
 	 * @return string
300 300
 	 */
301
-	public function get_gateway( $context = 'view' ) {
302
-		return $this->get_parent_invoice( $context )->get_gateway();
301
+	public function get_gateway($context = 'view') {
302
+		return $this->get_parent_invoice($context)->get_gateway();
303 303
 	}
304 304
 
305 305
 	/**
@@ -309,8 +309,8 @@  discard block
 block discarded – undo
309 309
 	 * @param  string $context View or edit context.
310 310
 	 * @return string
311 311
 	 */
312
-	public function get_period( $context = 'view' ) {
313
-		return $this->get_prop( 'period', $context );
312
+	public function get_period($context = 'view') {
313
+		return $this->get_prop('period', $context);
314 314
 	}
315 315
 
316 316
 	/**
@@ -320,8 +320,8 @@  discard block
 block discarded – undo
320 320
 	 * @param  string $context View or edit context.
321 321
 	 * @return int
322 322
 	 */
323
-	public function get_frequency( $context = 'view' ) {
324
-		return (int) $this->get_prop( 'frequency', $context );
323
+	public function get_frequency($context = 'view') {
324
+		return (int) $this->get_prop('frequency', $context);
325 325
 	}
326 326
 
327 327
 	/**
@@ -331,8 +331,8 @@  discard block
 block discarded – undo
331 331
 	 * @param  string $context View or edit context.
332 332
 	 * @return float
333 333
 	 */
334
-	public function get_initial_amount( $context = 'view' ) {
335
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'initial_amount', $context ) );
334
+	public function get_initial_amount($context = 'view') {
335
+		return (float) wpinv_sanitize_amount($this->get_prop('initial_amount', $context));
336 336
 	}
337 337
 
338 338
 	/**
@@ -342,8 +342,8 @@  discard block
 block discarded – undo
342 342
 	 * @param  string $context View or edit context.
343 343
 	 * @return float
344 344
 	 */
345
-	public function get_recurring_amount( $context = 'view' ) {
346
-		return (float) wpinv_sanitize_amount( $this->get_prop( 'recurring_amount', $context ) );
345
+	public function get_recurring_amount($context = 'view') {
346
+		return (float) wpinv_sanitize_amount($this->get_prop('recurring_amount', $context));
347 347
 	}
348 348
 
349 349
 	/**
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 * @param  string $context View or edit context.
354 354
 	 * @return int
355 355
 	 */
356
-	public function get_bill_times( $context = 'view' ) {
357
-		return (int) $this->get_prop( 'bill_times', $context );
356
+	public function get_bill_times($context = 'view') {
357
+		return (int) $this->get_prop('bill_times', $context);
358 358
 	}
359 359
 
360 360
 	/**
@@ -364,8 +364,8 @@  discard block
 block discarded – undo
364 364
 	 * @param  string $context View or edit context.
365 365
 	 * @return string
366 366
 	 */
367
-	public function get_transaction_id( $context = 'view' ) {
368
-		return $this->get_prop( 'transaction_id', $context );
367
+	public function get_transaction_id($context = 'view') {
368
+		return $this->get_prop('transaction_id', $context);
369 369
 	}
370 370
 
371 371
 	/**
@@ -375,8 +375,8 @@  discard block
 block discarded – undo
375 375
 	 * @param  string $context View or edit context.
376 376
 	 * @return string
377 377
 	 */
378
-	public function get_created( $context = 'view' ) {
379
-		return $this->get_prop( 'created', $context );
378
+	public function get_created($context = 'view') {
379
+		return $this->get_prop('created', $context);
380 380
 	}
381 381
 
382 382
 	/**
@@ -386,8 +386,8 @@  discard block
 block discarded – undo
386 386
 	 * @param  string $context View or edit context.
387 387
 	 * @return string
388 388
 	 */
389
-	public function get_date_created( $context = 'view' ) {
390
-		return $this->get_created( $context );
389
+	public function get_date_created($context = 'view') {
390
+		return $this->get_created($context);
391 391
 	}
392 392
 
393 393
 	/**
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
 	 */
399 399
 	public function get_time_created() {
400 400
 		$created = $this->get_date_created();
401
-		return empty( $created ) ? current_time( 'timestamp' ) : strtotime( $created, current_time( 'timestamp' ) );
401
+		return empty($created) ? current_time('timestamp') : strtotime($created, current_time('timestamp'));
402 402
 	}
403 403
 
404 404
 	/**
@@ -408,11 +408,11 @@  discard block
 block discarded – undo
408 408
 	 * @param  string $context View or edit context.
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_date_created_gmt( $context = 'view' ) {
412
-        $date = $this->get_date_created( $context );
411
+	public function get_date_created_gmt($context = 'view') {
412
+        $date = $this->get_date_created($context);
413 413
 
414
-        if ( $date ) {
415
-            $date = get_gmt_from_date( $date );
414
+        if ($date) {
415
+            $date = get_gmt_from_date($date);
416 416
         }
417 417
 		return $date;
418 418
 	}
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	 * @param  string $context View or edit context.
425 425
 	 * @return string
426 426
 	 */
427
-	public function get_next_renewal_date( $context = 'view' ) {
428
-		return $this->get_prop( 'expiration', $context );
427
+	public function get_next_renewal_date($context = 'view') {
428
+		return $this->get_prop('expiration', $context);
429 429
 	}
430 430
 
431 431
 	/**
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 	 * @param  string $context View or edit context.
436 436
 	 * @return string
437 437
 	 */
438
-	public function get_expiration( $context = 'view' ) {
439
-		return $this->get_next_renewal_date( $context );
438
+	public function get_expiration($context = 'view') {
439
+		return $this->get_next_renewal_date($context);
440 440
 	}
441 441
 
442 442
 	/**
@@ -448,12 +448,12 @@  discard block
 block discarded – undo
448 448
 	public function get_expiration_time() {
449 449
 		$expiration = $this->get_expiration();
450 450
 
451
-		if ( empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
452
-			return current_time( 'timestamp' );
451
+		if (empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
452
+			return current_time('timestamp');
453 453
 		}
454 454
 
455
-		$expiration = strtotime( $expiration, current_time( 'timestamp' ) );
456
-		return $expiration < current_time( 'timestamp' ) ? current_time( 'timestamp' ) : $expiration;
455
+		$expiration = strtotime($expiration, current_time('timestamp'));
456
+		return $expiration < current_time('timestamp') ? current_time('timestamp') : $expiration;
457 457
 	}
458 458
 
459 459
 	/**
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_next_renewal_date_gmt( $context = 'view' ) {
467
-        $date = $this->get_next_renewal_date( $context );
466
+	public function get_next_renewal_date_gmt($context = 'view') {
467
+        $date = $this->get_next_renewal_date($context);
468 468
 
469
-        if ( $date ) {
470
-            $date = get_gmt_from_date( $date );
469
+        if ($date) {
470
+            $date = get_gmt_from_date($date);
471 471
         }
472 472
 		return $date;
473 473
 	}
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_trial_period( $context = 'view' ) {
483
-		return $this->get_prop( 'trial_period', $context );
482
+	public function get_trial_period($context = 'view') {
483
+		return $this->get_prop('trial_period', $context);
484 484
 	}
485 485
 
486 486
 	/**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_status( $context = 'view' ) {
494
-		return $this->get_prop( 'status', $context );
493
+	public function get_status($context = 'view') {
494
+		return $this->get_prop('status', $context);
495 495
 	}
496 496
 
497 497
 	/**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_profile_id( $context = 'view' ) {
505
-		return $this->get_prop( 'profile_id', $context );
504
+	public function get_profile_id($context = 'view') {
505
+		return $this->get_prop('profile_id', $context);
506 506
 	}
507 507
 
508 508
 	/*
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	 * @since 1.0.19
518 518
 	 * @param  int $value The customer's id.
519 519
 	 */
520
-	public function set_customer_id( $value ) {
521
-		$this->set_prop( 'customer_id', (int) $value );
520
+	public function set_customer_id($value) {
521
+		$this->set_prop('customer_id', (int) $value);
522 522
 	}
523 523
 
524 524
 	/**
@@ -527,8 +527,8 @@  discard block
 block discarded – undo
527 527
 	 * @since 1.0.19
528 528
 	 * @param  int $value The parent invoice id.
529 529
 	 */
530
-	public function set_parent_invoice_id( $value ) {
531
-		$this->set_prop( 'parent_payment_id', (int) $value );
530
+	public function set_parent_invoice_id($value) {
531
+		$this->set_prop('parent_payment_id', (int) $value);
532 532
 	}
533 533
 
534 534
 	/**
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @since 1.0.19
538 538
 	 * @param  int $value The parent invoice id.
539 539
 	 */
540
-    public function set_parent_payment_id( $value ) {
541
-        $this->set_parent_invoice_id( $value );
540
+    public function set_parent_payment_id($value) {
541
+        $this->set_parent_invoice_id($value);
542 542
 	}
543 543
 
544 544
 	/**
@@ -547,8 +547,8 @@  discard block
 block discarded – undo
547 547
      * @since 1.0.19
548 548
 	 * @param  int $value The parent invoice id.
549 549
      */
550
-    public function set_original_payment_id( $value ) {
551
-        $this->set_parent_invoice_id( $value );
550
+    public function set_original_payment_id($value) {
551
+        $this->set_parent_invoice_id($value);
552 552
 	}
553 553
 
554 554
 	/**
@@ -557,8 +557,8 @@  discard block
 block discarded – undo
557 557
 	 * @since 1.0.19
558 558
 	 * @param  int $value The subscription product id.
559 559
 	 */
560
-	public function set_product_id( $value ) {
561
-		$this->set_prop( 'product_id', (int) $value );
560
+	public function set_product_id($value) {
561
+		$this->set_prop('product_id', (int) $value);
562 562
 	}
563 563
 
564 564
 	/**
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	 * @since 1.0.19
568 568
 	 * @param  string $value The renewal period.
569 569
 	 */
570
-	public function set_period( $value ) {
571
-		$this->set_prop( 'period', $value );
570
+	public function set_period($value) {
571
+		$this->set_prop('period', $value);
572 572
 	}
573 573
 
574 574
 	/**
@@ -577,9 +577,9 @@  discard block
 block discarded – undo
577 577
 	 * @since 1.0.19
578 578
 	 * @param  int $value The subscription frequency.
579 579
 	 */
580
-	public function set_frequency( $value ) {
581
-		$value = empty( $value ) ? 1 : (int) $value;
582
-		$this->set_prop( 'frequency', absint( $value ) );
580
+	public function set_frequency($value) {
581
+		$value = empty($value) ? 1 : (int) $value;
582
+		$this->set_prop('frequency', absint($value));
583 583
 	}
584 584
 
585 585
 	/**
@@ -588,8 +588,8 @@  discard block
 block discarded – undo
588 588
 	 * @since 1.0.19
589 589
 	 * @param  float $value The initial subcription amount.
590 590
 	 */
591
-	public function set_initial_amount( $value ) {
592
-		$this->set_prop( 'initial_amount', wpinv_sanitize_amount( $value ) );
591
+	public function set_initial_amount($value) {
592
+		$this->set_prop('initial_amount', wpinv_sanitize_amount($value));
593 593
 	}
594 594
 
595 595
 	/**
@@ -598,8 +598,8 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 * @param  float $value The recurring subcription amount.
600 600
 	 */
601
-	public function set_recurring_amount( $value ) {
602
-		$this->set_prop( 'recurring_amount', wpinv_sanitize_amount( $value ) );
601
+	public function set_recurring_amount($value) {
602
+		$this->set_prop('recurring_amount', wpinv_sanitize_amount($value));
603 603
 	}
604 604
 
605 605
 	/**
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 * @since 1.0.19
609 609
 	 * @param  int $value Bill times.
610 610
 	 */
611
-	public function set_bill_times( $value ) {
612
-		$this->set_prop( 'bill_times', (int) $value );
611
+	public function set_bill_times($value) {
612
+		$this->set_prop('bill_times', (int) $value);
613 613
 	}
614 614
 
615 615
 	/**
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	 * @since 1.0.19
619 619
 	 * @param string $value Bill times.
620 620
 	 */
621
-	public function set_transaction_id( $value ) {
622
-		$this->set_prop( 'transaction_id', sanitize_text_field( $value ) );
621
+	public function set_transaction_id($value) {
622
+		$this->set_prop('transaction_id', sanitize_text_field($value));
623 623
 	}
624 624
 
625 625
 	/**
@@ -628,15 +628,15 @@  discard block
 block discarded – undo
628 628
 	 * @since 1.0.19
629 629
 	 * @param string $value strtotime compliant date.
630 630
 	 */
631
-	public function set_created( $value ) {
632
-        $date = strtotime( $value );
631
+	public function set_created($value) {
632
+        $date = strtotime($value);
633 633
 
634
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
635
-            $this->set_prop( 'created', gmdate( 'Y-m-d H:i:s', $date ) );
634
+        if ($date && $value !== '0000-00-00 00:00:00') {
635
+            $this->set_prop('created', gmdate('Y-m-d H:i:s', $date));
636 636
             return;
637 637
         }
638 638
 
639
-		$this->set_prop( 'created', '' );
639
+		$this->set_prop('created', '');
640 640
 
641 641
 	}
642 642
 
@@ -646,8 +646,8 @@  discard block
 block discarded – undo
646 646
 	 * @since 1.0.19
647 647
 	 * @param string $value strtotime compliant date.
648 648
 	 */
649
-	public function set_date_created( $value ) {
650
-		$this->set_created( $value );
649
+	public function set_date_created($value) {
650
+		$this->set_created($value);
651 651
     }
652 652
 
653 653
 	/**
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 	 * @since 1.0.19
657 657
 	 * @param string $value strtotime compliant date.
658 658
 	 */
659
-	public function set_next_renewal_date( $value ) {
660
-		$date = strtotime( $value );
659
+	public function set_next_renewal_date($value) {
660
+		$date = strtotime($value);
661 661
 
662
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
663
-            $this->set_prop( 'expiration', gmdate( 'Y-m-d H:i:s', $date ) );
662
+        if ($date && $value !== '0000-00-00 00:00:00') {
663
+            $this->set_prop('expiration', gmdate('Y-m-d H:i:s', $date));
664 664
             return;
665 665
 		}
666 666
 
667
-		$this->set_prop( 'expiration', '' );
667
+		$this->set_prop('expiration', '');
668 668
 
669 669
 	}
670 670
 
@@ -674,8 +674,8 @@  discard block
 block discarded – undo
674 674
 	 * @since 1.0.19
675 675
 	 * @param string $value strtotime compliant date.
676 676
 	 */
677
-	public function set_expiration( $value ) {
678
-		$this->set_next_renewal_date( $value );
677
+	public function set_expiration($value) {
678
+		$this->set_next_renewal_date($value);
679 679
     }
680 680
 
681 681
 	/**
@@ -684,8 +684,8 @@  discard block
 block discarded – undo
684 684
 	 * @since 1.0.19
685 685
 	 * @param string $value trial period e.g 1 year.
686 686
 	 */
687
-	public function set_trial_period( $value ) {
688
-		$this->set_prop( 'trial_period', $value );
687
+	public function set_trial_period($value) {
688
+		$this->set_prop('trial_period', $value);
689 689
 	}
690 690
 
691 691
 	/**
@@ -694,22 +694,22 @@  discard block
 block discarded – undo
694 694
 	 * @since 1.0.19
695 695
 	 * @param string $new_status    New subscription status.
696 696
 	 */
697
-	public function set_status( $new_status ) {
697
+	public function set_status($new_status) {
698 698
 
699 699
 		// Abort if this is not a valid status;
700
-		if ( ! array_key_exists( $new_status, getpaid_get_subscription_statuses() ) ) {
700
+		if (!array_key_exists($new_status, getpaid_get_subscription_statuses())) {
701 701
 			return;
702 702
 		}
703 703
 
704
-		$old_status = ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $this->get_status();
705
-		if ( true === $this->object_read && $old_status !== $new_status ) {
704
+		$old_status = !empty($this->status_transition['from']) ? $this->status_transition['from'] : $this->get_status();
705
+		if (true === $this->object_read && $old_status !== $new_status) {
706 706
 			$this->status_transition = array(
707 707
 				'from' => $old_status,
708 708
 				'to'   => $new_status,
709 709
 			);
710 710
 		}
711 711
 
712
-		$this->set_prop( 'status', $new_status );
712
+		$this->set_prop('status', $new_status);
713 713
 	}
714 714
 
715 715
 	/**
@@ -718,8 +718,8 @@  discard block
 block discarded – undo
718 718
 	 * @since 1.0.19
719 719
 	 * @param  string $value the remote profile id.
720 720
 	 */
721
-	public function set_profile_id( $value ) {
722
-		$this->set_prop( 'profile_id', sanitize_text_field( $value ) );
721
+	public function set_profile_id($value) {
722
+		$this->set_prop('profile_id', sanitize_text_field($value));
723 723
 	}
724 724
 
725 725
 	/*
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	 * @param string|array String or array of strings to check for.
738 738
 	 * @return bool
739 739
      */
740
-    public function has_status( $status ) {
741
-        return in_array( $this->get_status(), wpinv_clean( wpinv_parse_list( $status ) ) );
740
+    public function has_status($status) {
741
+        return in_array($this->get_status(), wpinv_clean(wpinv_parse_list($status)));
742 742
 	}
743 743
 
744 744
 	/**
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      */
749 749
     public function has_trial_period() {
750 750
 		$period = $this->get_trial_period();
751
-        return ! empty( $period );
751
+        return !empty($period);
752 752
 	}
753 753
 
754 754
 	/**
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 	 * @return bool
758 758
 	 */
759 759
 	public function is_active() {
760
-		return $this->has_status( 'active trialling' ) && ! $this->is_expired();
760
+		return $this->has_status('active trialling') && !$this->is_expired();
761 761
 	}
762 762
 
763 763
 	/**
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
 	 * @return bool
767 767
 	 */
768 768
 	public function is_expired() {
769
-		return $this->has_status( 'expired' ) || ( $this->has_status( 'active cancelled trialling' ) && $this->get_expiration_time() < current_time( 'timestamp' ) );
769
+		return $this->has_status('expired') || ($this->has_status('active cancelled trialling') && $this->get_expiration_time() < current_time('timestamp'));
770 770
 	}
771 771
 
772 772
 	/**
@@ -776,7 +776,7 @@  discard block
 block discarded – undo
776 776
 	 */
777 777
 	public function is_last_renewal() {
778 778
 		$max_bills = $this->get_bill_times();
779
-		return ! empty( $max_bills ) && $max_bills <= $this->get_times_billed();
779
+		return !empty($max_bills) && $max_bills <= $this->get_times_billed();
780 780
 	}
781 781
 
782 782
 	/*
@@ -791,11 +791,11 @@  discard block
 block discarded – undo
791 791
 	/**
792 792
 	 * Backwards compatibilty.
793 793
 	 */
794
-	public function create( $data = array() ) {
794
+	public function create($data = array()) {
795 795
 
796 796
 		// Set the properties.
797
-		if ( is_array( $data ) ) {
798
-			$this->set_props( $data );
797
+		if (is_array($data)) {
798
+			$this->set_props($data);
799 799
 		}
800 800
 
801 801
 		// Save the item.
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 	/**
807 807
 	 * Backwards compatibilty.
808 808
 	 */
809
-	public function update( $args = array() ) {
810
-		return $this->create( $args );
809
+	public function update($args = array()) {
810
+		return $this->create($args);
811 811
 	}
812 812
 
813 813
     /**
@@ -816,12 +816,12 @@  discard block
 block discarded – undo
816 816
      * @since  1.0.0
817 817
      * @return WP_Post[]
818 818
      */
819
-    public function get_child_payments( $hide_pending = true ) {
819
+    public function get_child_payments($hide_pending = true) {
820 820
 
821
-		$statuses = array( 'publish', 'wpi-processing', 'wpi-renewal' );
821
+		$statuses = array('publish', 'wpi-processing', 'wpi-renewal');
822 822
 
823
-		if ( ! $hide_pending ) {
824
-			$statuses = array_keys( wpinv_get_invoice_statuses() );
823
+		if (!$hide_pending) {
824
+			$statuses = array_keys(wpinv_get_invoice_statuses());
825 825
 		}
826 826
 
827 827
         return get_posts(
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
      * @return int
844 844
      */
845 845
     public function get_total_payments() {
846
-		return getpaid_count_subscription_invoices( $this->get_parent_invoice_id(), $this->get_id() );
846
+		return getpaid_count_subscription_invoices($this->get_parent_invoice_id(), $this->get_id());
847 847
     }
848 848
 
849 849
     /**
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
     public function get_times_billed() {
856 856
         $times_billed = $this->get_total_payments();
857 857
 
858
-        if ( (float) $this->get_initial_amount() == 0 && $times_billed > 0 ) {
858
+        if ((float) $this->get_initial_amount() == 0 && $times_billed > 0) {
859 859
             $times_billed--;
860 860
         }
861 861
 
@@ -870,52 +870,52 @@  discard block
 block discarded – undo
870 870
 	 * @param  WPInv_Invoice $invoice If adding an existing invoice.
871 871
      * @return bool
872 872
      */
873
-    public function add_payment( $args = array(), $invoice = false ) {
873
+    public function add_payment($args = array(), $invoice = false) {
874 874
 
875 875
 		// Process each payment once.
876
-        if ( ! empty( $args['transaction_id'] ) && $this->payment_exists( $args['transaction_id'] ) ) {
876
+        if (!empty($args['transaction_id']) && $this->payment_exists($args['transaction_id'])) {
877 877
             return false;
878 878
         }
879 879
 
880 880
 		// Are we creating a new invoice?
881
-		if ( empty( $invoice ) ) {
882
-			$invoice = $this->create_payment( false );
881
+		if (empty($invoice)) {
882
+			$invoice = $this->create_payment(false);
883 883
 
884
-			if ( empty( $invoice ) ) {
884
+			if (empty($invoice)) {
885 885
 				return false;
886 886
 			}
887 887
 		}
888 888
 
889 889
 		// Maybe set a transaction id.
890
-		if ( ! empty( $args['transaction_id'] ) ) {
891
-			$invoice->set_transaction_id( $args['transaction_id'] );
890
+		if (!empty($args['transaction_id'])) {
891
+			$invoice->set_transaction_id($args['transaction_id']);
892 892
 		}
893 893
 
894 894
 		// Set the completed date.
895
-		$invoice->set_completed_date( current_time( 'mysql' ) );
895
+		$invoice->set_completed_date(current_time('mysql'));
896 896
 
897 897
 		// And the gateway.
898
-		if ( ! empty( $args['gateway'] ) ) {
899
-			$invoice->set_gateway( $args['gateway'] );
898
+		if (!empty($args['gateway'])) {
899
+			$invoice->set_gateway($args['gateway']);
900 900
 		}
901 901
 
902
-		$invoice->set_status( 'wpi-renewal' );
902
+		$invoice->set_status('wpi-renewal');
903 903
 		$invoice->save();
904 904
 
905
-		if ( ! $invoice->exists() ) {
905
+		if (!$invoice->exists()) {
906 906
 			return false;
907 907
 		}
908 908
 
909
-		return $this->after_add_payment( $invoice );
909
+		return $this->after_add_payment($invoice);
910 910
 	}
911 911
 
912
-    public function after_add_payment( $invoice ) {
912
+    public function after_add_payment($invoice) {
913 913
 
914
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
915
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
916
-        do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id() );
914
+		do_action('getpaid_after_create_subscription_renewal_invoice', $invoice, $this);
915
+		do_action('wpinv_recurring_add_subscription_payment', $invoice, $this);
916
+        do_action('wpinv_recurring_record_payment', $invoice->get_id(), $this->get_parent_invoice_id(), $invoice->get_recurring_total(), $invoice->get_transaction_id());
917 917
 
918
-        update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
918
+        update_post_meta($invoice->get_id(), '_wpinv_subscription_id', $this->id);
919 919
 
920 920
         return $invoice->get_id();
921 921
 	}
@@ -927,53 +927,53 @@  discard block
 block discarded – undo
927 927
 	 * @param bool $save Whether we should save the invoice.
928 928
      * @return WPInv_Invoice|bool
929 929
      */
930
-    public function create_payment( $save = true ) {
930
+    public function create_payment($save = true) {
931 931
 
932 932
 		$parent_invoice = $this->get_parent_payment();
933 933
 
934
-		if ( ! $parent_invoice->exists() ) {
934
+		if (!$parent_invoice->exists()) {
935 935
 			return false;
936 936
 		}
937 937
 
938 938
 		// Duplicate the parent invoice.
939
-		$invoice = getpaid_duplicate_invoice( $parent_invoice );
940
-		$invoice->set_parent_id( $parent_invoice->get_id() );
941
-		$invoice->set_subscription_id( $this->get_id() );
942
-		$invoice->set_remote_subscription_id( $this->get_profile_id() );
939
+		$invoice = getpaid_duplicate_invoice($parent_invoice);
940
+		$invoice->set_parent_id($parent_invoice->get_id());
941
+		$invoice->set_subscription_id($this->get_id());
942
+		$invoice->set_remote_subscription_id($this->get_profile_id());
943 943
 
944 944
 		// Set invoice items.
945
-		$subscription_group = getpaid_get_invoice_subscription_group( $parent_invoice->get_id(), $this->get_id() );
946
-		$allowed_items      = empty( $subscription_group ) ? array( $this->get_product_id() ) : array_keys( $subscription_group['items'] );
945
+		$subscription_group = getpaid_get_invoice_subscription_group($parent_invoice->get_id(), $this->get_id());
946
+		$allowed_items      = empty($subscription_group) ? array($this->get_product_id()) : array_keys($subscription_group['items']);
947 947
 		$invoice_items      = array();
948 948
 
949
-		foreach ( $invoice->get_items() as $item ) {
950
-			if ( in_array( $item->get_id(), $allowed_items ) ) {
949
+		foreach ($invoice->get_items() as $item) {
950
+			if (in_array($item->get_id(), $allowed_items)) {
951 951
 				$invoice_items[] = $item;
952 952
 			}
953 953
 		}
954 954
 
955
-		$invoice->set_items( $invoice_items );
955
+		$invoice->set_items($invoice_items);
956 956
 
957
-		if ( ! empty( $subscription_group['fees'] ) ) {
958
-			$invoice->set_fees( $subscription_group['fees'] );
957
+		if (!empty($subscription_group['fees'])) {
958
+			$invoice->set_fees($subscription_group['fees']);
959 959
 		}
960 960
 
961 961
 		// Maybe recalculate discount (Pre-GetPaid Fix).
962
-		$discount = new WPInv_Discount( $invoice->get_discount_code() );
962
+		$discount = new WPInv_Discount($invoice->get_discount_code());
963 963
 
964
-		if ( $discount->exists() && $discount->is_recurring() ) {
965
-			$invoice->add_discount( getpaid_calculate_invoice_discount( $invoice, $discount ) );
966
-		}  else {
964
+		if ($discount->exists() && $discount->is_recurring()) {
965
+			$invoice->add_discount(getpaid_calculate_invoice_discount($invoice, $discount));
966
+		} else {
967 967
 			// Unset discount code.
968
-			$invoice->set_discount_code( '' );
968
+			$invoice->set_discount_code('');
969 969
 
970
-			$invoice->remove_discount( 'discount_code' );
970
+			$invoice->remove_discount('discount_code');
971 971
 		}
972 972
 
973 973
 		$invoice->recalculate_total();
974
-		$invoice->set_status( 'wpi-pending' );
974
+		$invoice->set_status('wpi-pending');
975 975
 
976
-		if ( ! $save ) {
976
+		if (!$save) {
977 977
 			return $invoice;
978 978
 		}
979 979
 
@@ -988,28 +988,28 @@  discard block
 block discarded – undo
988 988
 	 * @since  1.0.0
989 989
 	 * @return int The subscription's id
990 990
 	 */
991
-	public function renew( $calculate_from = null, $_new_expiration = null ) {
991
+	public function renew($calculate_from = null, $_new_expiration = null) {
992 992
 		// Complete subscription if applicable
993
-		if ( $this->is_last_renewal() ) {
993
+		if ($this->is_last_renewal()) {
994 994
 			return $this->complete();
995 995
 		}
996 996
 
997
-		if ( ! empty( $_new_expiration ) ) {
997
+		if (!empty($_new_expiration)) {
998 998
 			$new_expiration = $_new_expiration;
999 999
 		} else {
1000 1000
 			// Calculate new expiration
1001 1001
 			$frequency      = $this->get_frequency();
1002 1002
 			$period         = $this->get_period();
1003
-			$calculate_from = empty( $calculate_from ) ? $this->get_expiration_time() : $calculate_from;
1004
-			$new_expiration = strtotime( "+ $frequency $period", $calculate_from );
1005
-			$new_expiration = date( 'Y-m-d H:i:s', $new_expiration );
1003
+			$calculate_from = empty($calculate_from) ? $this->get_expiration_time() : $calculate_from;
1004
+			$new_expiration = strtotime("+ $frequency $period", $calculate_from);
1005
+			$new_expiration = date('Y-m-d H:i:s', $new_expiration);
1006 1006
 		}
1007 1007
 
1008
-		$this->set_expiration( $new_expiration );
1009
-		$this->set_status( 'active' );
1008
+		$this->set_expiration($new_expiration);
1009
+		$this->set_status('active');
1010 1010
 		$this->save();
1011 1011
 
1012
-		do_action( 'getpaid_subscription_renewed', $this );
1012
+		do_action('getpaid_subscription_renewed', $this);
1013 1013
 
1014 1014
 		return $this->get_id();
1015 1015
 	}
@@ -1025,11 +1025,11 @@  discard block
 block discarded – undo
1025 1025
 	public function complete() {
1026 1026
 
1027 1027
 		// Only mark a subscription as complete if it's not already cancelled.
1028
-		if ( $this->has_status( 'cancelled' ) ) {
1028
+		if ($this->has_status('cancelled')) {
1029 1029
 			return false;
1030 1030
 		}
1031 1031
 
1032
-		$this->set_status( 'completed' );
1032
+		$this->set_status('completed');
1033 1033
 		return $this->save();
1034 1034
 
1035 1035
 	}
@@ -1041,14 +1041,14 @@  discard block
 block discarded – undo
1041 1041
 	 * @param  bool $check_expiration
1042 1042
 	 * @return int|bool Subscription id or false if $check_expiration is true and expiration date is in the future.
1043 1043
 	 */
1044
-	public function expire( $check_expiration = false ) {
1044
+	public function expire($check_expiration = false) {
1045 1045
 
1046
-		if ( $check_expiration && $this->get_expiration_time() > current_time( 'timestamp' ) ) {
1046
+		if ($check_expiration && $this->get_expiration_time() > current_time('timestamp')) {
1047 1047
 			// Do not mark as expired since real expiration date is in the future
1048 1048
 			return false;
1049 1049
 		}
1050 1050
 
1051
-		$this->set_status( 'expired' );
1051
+		$this->set_status('expired');
1052 1052
 		return $this->save();
1053 1053
 
1054 1054
 	}
@@ -1060,7 +1060,7 @@  discard block
 block discarded – undo
1060 1060
 	 * @return int Subscription id.
1061 1061
 	 */
1062 1062
 	public function failing() {
1063
-		$this->set_status( 'failing' );
1063
+		$this->set_status('failing');
1064 1064
 		return $this->save();
1065 1065
 	}
1066 1066
 
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
      * @return int Subscription id.
1072 1072
      */
1073 1073
     public function cancel() {
1074
-		$this->set_status( 'cancelled' );
1074
+		$this->set_status('cancelled');
1075 1075
 		return $this->save();
1076 1076
     }
1077 1077
 
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
 	 * @return bool
1083 1083
 	 */
1084 1084
 	public function can_cancel() {
1085
-		return apply_filters( 'wpinv_subscription_can_cancel', $this->has_status( $this->get_cancellable_statuses() ), $this );
1085
+		return apply_filters('wpinv_subscription_can_cancel', $this->has_status($this->get_cancellable_statuses()), $this);
1086 1086
 	}
1087 1087
 
1088 1088
     /**
@@ -1093,7 +1093,7 @@  discard block
 block discarded – undo
1093 1093
      * @return      array
1094 1094
      */
1095 1095
     public function get_cancellable_statuses() {
1096
-        return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
1096
+        return apply_filters('wpinv_recurring_cancellable_statuses', array('active', 'trialling', 'failing'));
1097 1097
     }
1098 1098
 
1099 1099
 	/**
@@ -1103,8 +1103,8 @@  discard block
 block discarded – undo
1103 1103
 	 * @return string
1104 1104
 	 */
1105 1105
 	public function get_cancel_url() {
1106
-		$url = getpaid_get_authenticated_action_url( 'subscription_cancel', $this->get_view_url() );
1107
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
1106
+		$url = getpaid_get_authenticated_action_url('subscription_cancel', $this->get_view_url());
1107
+		return apply_filters('wpinv_subscription_cancel_url', $url, $this);
1108 1108
 	}
1109 1109
 
1110 1110
 	/**
@@ -1115,10 +1115,10 @@  discard block
 block discarded – undo
1115 1115
 	 */
1116 1116
 	public function get_view_url() {
1117 1117
 
1118
-		$url = getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) );
1119
-		$url = add_query_arg( 'subscription', $this->get_id(), $url );
1118
+		$url = getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')));
1119
+		$url = add_query_arg('subscription', $this->get_id(), $url);
1120 1120
 
1121
-		return apply_filters( 'getpaid_get_subscription_view_url', $url, $this );
1121
+		return apply_filters('getpaid_get_subscription_view_url', $url, $this);
1122 1122
 	}
1123 1123
 
1124 1124
 	/**
@@ -1131,7 +1131,7 @@  discard block
 block discarded – undo
1131 1131
 	 * @return bool
1132 1132
 	 */
1133 1133
 	public function can_renew() {
1134
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
1134
+		return apply_filters('wpinv_subscription_can_renew', true, $this);
1135 1135
 	}
1136 1136
 
1137 1137
 	/**
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
             ),
1151 1151
             'getpaid-nonce'
1152 1152
         );
1153
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
1153
+		return apply_filters('wpinv_subscription_renew_url', $url, $this);
1154 1154
 	}
1155 1155
 
1156 1156
 	/**
@@ -1160,7 +1160,7 @@  discard block
 block discarded – undo
1160 1160
 	 * @return bool
1161 1161
 	 */
1162 1162
 	public function can_update() {
1163
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
1163
+		return apply_filters('wpinv_subscription_can_update', false, $this);
1164 1164
 	}
1165 1165
 
1166 1166
 	/**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 				'subscription_id' => $this->get_id(),
1177 1177
             )
1178 1178
         );
1179
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
1179
+		return apply_filters('wpinv_subscription_update_url', $url, $this);
1180 1180
 	}
1181 1181
 
1182 1182
 	/**
@@ -1186,7 +1186,7 @@  discard block
 block discarded – undo
1186 1186
 	 * @return string
1187 1187
 	 */
1188 1188
 	public function get_status_label() {
1189
-		return getpaid_get_subscription_status_label( $this->get_status() );
1189
+		return getpaid_get_subscription_status_label($this->get_status());
1190 1190
 	}
1191 1191
 
1192 1192
 	/**
@@ -1197,7 +1197,7 @@  discard block
 block discarded – undo
1197 1197
 	 */
1198 1198
 	public function get_status_class() {
1199 1199
 		$statuses = getpaid_get_subscription_status_classes();
1200
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'bg-dark';
1200
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'bg-dark';
1201 1201
 	}
1202 1202
 
1203 1203
     /**
@@ -1208,9 +1208,9 @@  discard block
 block discarded – undo
1208 1208
      */
1209 1209
     public function get_status_label_html() {
1210 1210
 
1211
-		$status_label = sanitize_text_field( $this->get_status_label() );
1212
-		$class        = esc_attr( $this->get_status_class() );
1213
-		$status       = sanitize_html_class( $this->get_status() );
1211
+		$status_label = sanitize_text_field($this->get_status_label());
1212
+		$class        = esc_attr($this->get_status_class());
1213
+		$status       = sanitize_html_class($this->get_status());
1214 1214
 
1215 1215
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
1216 1216
     }
@@ -1222,9 +1222,9 @@  discard block
 block discarded – undo
1222 1222
      * @param  string $txn_id The transaction ID from the merchant processor
1223 1223
      * @return bool
1224 1224
      */
1225
-    public function payment_exists( $txn_id = '' ) {
1226
-		$invoice_id = WPInv_Invoice::get_invoice_id_by_field( $txn_id, 'transaction_id' );
1227
-        return ! empty( $invoice_id );
1225
+    public function payment_exists($txn_id = '') {
1226
+		$invoice_id = WPInv_Invoice::get_invoice_id_by_field($txn_id, 'transaction_id');
1227
+        return !empty($invoice_id);
1228 1228
 	}
1229 1229
 
1230 1230
 	/**
@@ -1236,35 +1236,35 @@  discard block
 block discarded – undo
1236 1236
 		// Reset status transition variable.
1237 1237
 		$this->status_transition = false;
1238 1238
 
1239
-		if ( $status_transition ) {
1239
+		if ($status_transition) {
1240 1240
 			try {
1241 1241
 
1242 1242
 				// Fire a hook for the status change.
1243
-				do_action( 'wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
1244
-				do_action( 'getpaid_subscription_' . $status_transition['to'], $this, $status_transition );
1243
+				do_action('wpinv_subscription_' . $status_transition['to'], $this->get_id(), $this, $status_transition);
1244
+				do_action('getpaid_subscription_' . $status_transition['to'], $this, $status_transition);
1245 1245
 
1246
-				if ( ! empty( $status_transition['from'] ) ) {
1246
+				if (!empty($status_transition['from'])) {
1247 1247
 
1248 1248
 					/* translators: 1: old subscription status 2: new subscription status */
1249
-					$transition_note = sprintf( __( 'Subscription status changed from %1$s to %2$s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['from'] ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1249
+					$transition_note = sprintf(__('Subscription status changed from %1$s to %2$s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['from']), getpaid_get_subscription_status_label($status_transition['to']));
1250 1250
 
1251 1251
 					// Note the transition occurred.
1252
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1252
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1253 1253
 
1254 1254
 					// Fire another hook.
1255
-					do_action( 'getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
1256
-					do_action( 'getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to'] );
1255
+					do_action('getpaid_subscription_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this);
1256
+					do_action('getpaid_subscription_status_changed', $this, $status_transition['from'], $status_transition['to']);
1257 1257
 
1258 1258
 				} else {
1259 1259
 					/* translators: %s: new invoice status */
1260
-					$transition_note = sprintf( __( 'Subscription status set to %s.', 'invoicing' ), getpaid_get_subscription_status_label( $status_transition['to'] ) );
1260
+					$transition_note = sprintf(__('Subscription status set to %s.', 'invoicing'), getpaid_get_subscription_status_label($status_transition['to']));
1261 1261
 
1262 1262
 					// Note the transition occurred.
1263
-					$this->get_parent_payment()->add_note( $transition_note, false, false, true );
1263
+					$this->get_parent_payment()->add_note($transition_note, false, false, true);
1264 1264
 
1265 1265
 				}
1266
-			} catch ( Exception $e ) {
1267
-				$this->get_parent_payment()->add_note( __( 'Error during subscription status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
1266
+			} catch (Exception $e) {
1267
+				$this->get_parent_payment()->add_note(__('Error during subscription status transition.', 'invoicing') . ' ' . $e->getMessage());
1268 1268
 			}
1269 1269
 		}
1270 1270
 
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
 	 */
1291 1291
 	public function activate() {
1292 1292
 		$status = $this->has_trial_period() && 'trialling' === $this->get_status() ? 'trialling' : 'active';
1293
-		$this->set_status( $status );
1293
+		$this->set_status($status);
1294 1294
 		return $this->save();
1295 1295
 	}
1296 1296
 
Please login to merge, or discard this patch.
vendor/ayecode/wp-super-duper/wp-super-duper.php 3 patches
Braces   +42 added lines, -44 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 			if(!empty($this->options['nested-block'])){
61 61
 				if(empty($this->options['output_types'])){
62 62
 					$this->options['output_types'] = array('shortcode','block');
63
-				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
63
+				} elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64 64
 					unset($this->options['output_types'][$key]);
65 65
 				}
66 66
 			}
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 				<?php
717 717
 				if(! empty( $insert_shortcode_function )){
718 718
 					echo $insert_shortcode_function;
719
-				}else{
719
+				} else{
720 720
 
721 721
 				/**
722 722
 				 * Function for super duper insert shortcode.
@@ -2240,7 +2240,7 @@  discard block
 block discarded – undo
2240 2240
 				$p_pl = 'ps-';
2241 2241
 				$p_pr = 'pe-';
2242 2242
 					<?php
2243
-				}else{
2243
+				} else{
2244 2244
 						?>
2245 2245
 				$aui_bs5 = false;
2246 2246
 				$p_ml = 'ml-';
@@ -2468,7 +2468,7 @@  discard block
 block discarded – undo
2468 2468
 					var InnerBlocks = blockEditor.InnerBlocks;
2469 2469
 
2470 2470
 					var term_query_type = '';
2471
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
2471
+					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";} else{echo "[]";} ?>;
2472 2472
 					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2473 2473
 					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2474 2474
 					const MediaUpload = wp.blockEditor.MediaUpload;
@@ -2525,9 +2525,9 @@  discard block
 block discarded – undo
2525 2525
 						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2526 2526
 						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2527 2527
 							// no preview if set to false
2528
-						}elseif( !empty( $example_args ) ){
2528
+						} elseif( !empty( $example_args ) ){
2529 2529
 							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2530
-						}elseif( !empty( $this->options['example'] ) ){
2530
+						} elseif( !empty( $this->options['example'] ) ){
2531 2531
 							unset($this->options['example']['viewportWidth']);
2532 2532
 							unset($this->options['example']['innerBlocks']);
2533 2533
 							$example_atts = $this->array_to_attributes( $this->options['example'] );
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 							if(!empty($example_parts)){
2545 2545
 								echo "example : {".implode(',', $example_parts)."},";
2546 2546
 							}
2547
-						}else{
2547
+						} else{
2548 2548
 							echo 'example : {viewportWidth: 500},';
2549 2549
 						}
2550 2550
 
@@ -2615,8 +2615,7 @@  discard block
 block discarded – undo
2615 2615
 
2616 2616
 									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2617 2617
 										continue;
2618
-									}
2619
-									elseif ( $args['type'] == 'checkbox' ) {
2618
+									} elseif ( $args['type'] == 'checkbox' ) {
2620 2619
 										$type    = 'boolean';
2621 2620
 										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2622 2621
 									} elseif ( $args['type'] == 'number' ) {
@@ -2752,7 +2751,7 @@  discard block
 block discarded – undo
2752 2751
 							<?php
2753 2752
 							if(!empty($this->options['block-edit-raw'])) {
2754 2753
 								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2755
-							}else{
2754
+							} else{
2756 2755
 							?>
2757 2756
 
2758 2757
 function hasSelectedInnerBlock(props) {
@@ -2887,7 +2886,7 @@  discard block
 block discarded – undo
2887 2886
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2888 2887
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2889 2888
 	echo 'const { deviceType } = "";';
2890
-}else{
2889
+} else{
2891 2890
 ?>
2892 2891
 /** Get device type const. */
2893 2892
 const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>';
@@ -2951,7 +2950,7 @@  discard block
 block discarded – undo
2951 2950
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2952 2951
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2953 2952
 										echo $post->ID;
2954
-									}else{echo '0';}?>,
2953
+									} else{echo '0';}?>,
2955 2954
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2956 2955
 									};
2957 2956
 
@@ -2971,7 +2970,7 @@  discard block
 block discarded – undo
2971 2970
 										is_fetching = false;
2972 2971
 										prev_attributes[props.clientId] = props.attributes;
2973 2972
 											 <?php
2974
-										}else{
2973
+										} else{
2975 2974
 										?>
2976 2975
 										props.setAttributes({content: env});
2977 2976
 										is_fetching = false;
@@ -3182,7 +3181,7 @@  discard block
 block discarded – undo
3182 3181
 //
3183 3182
 
3184 3183
 									}
3185
-									}else {
3184
+									} else {
3186 3185
 									?>
3187 3186
 									el(wp.components.PanelBody, {
3188 3187
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
@@ -3208,9 +3207,9 @@  discard block
 block discarded – undo
3208 3207
 								// If the user sets block-output array then build it
3209 3208
 								if ( ! empty( $this->options['block-output'] ) ) {
3210 3209
 								$this->block_element( $this->options['block-output'] );
3211
-							}elseif(!empty($this->options['block-edit-return'])){
3210
+							} elseif(!empty($this->options['block-edit-return'])){
3212 3211
 								   echo $this->options['block-edit-return'];
3213
-							}else{
3212
+							} else{
3214 3213
 								// if no block-output is set then we try and get the shortcode html output via ajax.
3215 3214
 								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3216 3215
 								?>
@@ -3322,9 +3321,9 @@  discard block
 block discarded – undo
3322 3321
 							   );
3323 3322
 								<?php
3324 3323
 
3325
-							}elseif(!empty($this->options['block-save-return'])){
3324
+							} elseif(!empty($this->options['block-save-return'])){
3326 3325
 								   echo 'return ' . $this->options['block-save-return'];
3327
-							}elseif(!empty($this->options['nested-block'])){
3326
+							} elseif(!empty($this->options['nested-block'])){
3328 3327
 								?>
3329 3328
 							  return el(
3330 3329
 								   '',
@@ -3334,13 +3333,13 @@  discard block
 block discarded – undo
3334 3333
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3335 3334
 							   );
3336 3335
 								<?php
3337
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3336
+							} elseif(!empty( $this->options['block-save-return'] ) ){
3338 3337
 								echo "return ". $this->options['block-edit-return'].";";
3339
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3338
+							} elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3340 3339
 							?>
3341 3340
 							return content;
3342 3341
 							<?php
3343
-							}else{
3342
+							} else{
3344 3343
 							?>
3345 3344
 							var block_wrap = 'div';
3346 3345
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -3391,9 +3390,9 @@  discard block
 block discarded – undo
3391 3390
 				$device_type_icon = '';
3392 3391
 				if($device_type=='Desktop'){
3393 3392
 					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3394
-				}elseif($device_type=='Tablet'){
3393
+				} elseif($device_type=='Tablet'){
3395 3394
 					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3396
-				}elseif($device_type=='Mobile'){
3395
+				} elseif($device_type=='Mobile'){
3397 3396
 					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3398 3397
 				}
3399 3398
 				echo $element_require;
@@ -3438,7 +3437,7 @@  discard block
 block discarded – undo
3438 3437
 
3439 3438
 					<?php
3440 3439
 					if(false){?></script><?php }
3441
-				}elseif(!empty($args['row']['close'])){
3440
+				} elseif(!empty($args['row']['close'])){
3442 3441
 					if(false){?><script><?php }?>
3443 3442
 						el(
3444 3443
 							'div',
@@ -3447,7 +3446,7 @@  discard block
 block discarded – undo
3447 3446
 							},
3448 3447
 					<?php
3449 3448
 					if(false){?></script><?php }
3450
-				}else{
3449
+				} else{
3451 3450
 					if(false){?><script><?php }?>
3452 3451
 						el(
3453 3452
 							'div',
@@ -3552,9 +3551,9 @@  discard block
 block discarded – undo
3552 3551
 			$device_type_icon = '';
3553 3552
 			if($device_type=='Desktop'){
3554 3553
 				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3555
-			}elseif($device_type=='Tablet'){
3554
+			} elseif($device_type=='Tablet'){
3556 3555
 				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3557
-			}elseif($device_type=='Mobile'){
3556
+			} elseif($device_type=='Mobile'){
3558 3557
 				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3559 3558
 			}
3560 3559
 
@@ -3617,7 +3616,7 @@  discard block
 block discarded – undo
3617 3616
 				$args['type'] == 'text';
3618 3617
 				// Save numbers as numbers and not strings
3619 3618
 				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3620
-			}else if ( $args['type'] == 'notice' ) {
3619
+			} else if ( $args['type'] == 'notice' ) {
3621 3620
 
3622 3621
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3623 3622
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3692,7 +3691,7 @@  discard block
 block discarded – undo
3692 3691
 							$key: value
3693 3692
 						});
3694 3693
 					},";
3695
-			}elseif ( $args['type'] == 'gradient' ) {
3694
+			} elseif ( $args['type'] == 'gradient' ) {
3696 3695
 				$type = 'GradientPicker';
3697 3696
 				$extra .= "gradients: [{
3698 3697
 			name: 'Vivid cyan blue to vivid purple',
@@ -3731,7 +3730,7 @@  discard block
 block discarded – undo
3731 3730
 			slug: 'cool-to-warm-spectrum',
3732 3731
 		}],";
3733 3732
 
3734
-			}elseif ( $args['type'] == 'image' ) {
3733
+			} elseif ( $args['type'] == 'image' ) {
3735 3734
 //                print_r($args);
3736 3735
 
3737 3736
 				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
@@ -3868,8 +3867,7 @@  discard block
 block discarded – undo
3868 3867
 				$onchange = "";
3869 3868
 
3870 3869
 				//$inside_elements = ",el('div',{},'file upload')";
3871
-			}
3872
-			elseif ( $args['type'] == 'checkbox' ) {
3870
+			} elseif ( $args['type'] == 'checkbox' ) {
3873 3871
 				$type = 'CheckboxControl';
3874 3872
 				$extra .= "checked: props.attributes.$key,";
3875 3873
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
@@ -3881,9 +3879,9 @@  discard block
 block discarded – undo
3881 3879
 
3882 3880
 				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3883 3881
 					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3884
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3882
+				} elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3885 3883
 					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3886
-				}else {
3884
+				} else {
3887 3885
 
3888 3886
 					if ( ! empty( $args['options'] ) ) {
3889 3887
 						$options .= "options: [";
@@ -4047,7 +4045,7 @@  discard block
 block discarded – undo
4047 4045
 				foreach ( $custom_attributes as $key => $val ) {
4048 4046
 					if(is_array($val)){
4049 4047
 						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4050
-					}else{
4048
+					} else{
4051 4049
 						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4052 4050
 					}
4053 4051
 				}
@@ -4088,7 +4086,7 @@  discard block
 block discarded – undo
4088 4086
 
4089 4087
 							if($new_args['element']=='InnerBlocks'){
4090 4088
 								echo "\n el( InnerBlocks, {";
4091
-							}elseif($new_args['element']=='innerBlocksProps'){
4089
+							} elseif($new_args['element']=='innerBlocksProps'){
4092 4090
 								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4093 4091
 							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4094 4092
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
@@ -4101,11 +4099,11 @@  discard block
 block discarded – undo
4101 4099
 							//    echo '###';
4102 4100
 
4103 4101
 							  //  echo '###';
4104
-							}elseif($new_args['element']=='BlocksProps'){
4102
+							} elseif($new_args['element']=='BlocksProps'){
4105 4103
 
4106 4104
 								if ( isset($new_args['if_inner_element']) ) {
4107 4105
 									$element = $new_args['if_inner_element'];
4108
-								}else {
4106
+								} else {
4109 4107
 									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4110 4108
 								}
4111 4109
 
@@ -4116,7 +4114,7 @@  discard block
 block discarded – undo
4116 4114
 
4117 4115
 							   // echo "} ),";
4118 4116
 
4119
-							}else{
4117
+							} else{
4120 4118
 								echo "\n el( '" . $new_args['element'] . "', {";
4121 4119
 							}
4122 4120
 
@@ -4141,7 +4139,7 @@  discard block
 block discarded – undo
4141 4139
 
4142 4140
 									if ( $new_key === 'content' ) {
4143 4141
 										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4144
-									}else if ( $new_key === 'if_content' ) {
4142
+									} else if ( $new_key === 'if_content' ) {
4145 4143
 										echo  $this->block_props_replace(  $new_value  );
4146 4144
 									}
4147 4145
 
@@ -4171,7 +4169,7 @@  discard block
 block discarded – undo
4171 4169
 
4172 4170
 							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4173 4171
 								echo "))";// end content
4174
-							}else{
4172
+							} else{
4175 4173
 								echo ")";// end content
4176 4174
 							}
4177 4175
 
@@ -4795,11 +4793,11 @@  discard block
 block discarded – undo
4795 4793
 		public function get_widget_icon($icon = 'box-top', $title = ''){
4796 4794
 			if($icon=='box-top'){
4797 4795
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4798
-			}elseif($icon=='box-right'){
4796
+			} elseif($icon=='box-right'){
4799 4797
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4800
-			}elseif($icon=='box-bottom'){
4798
+			} elseif($icon=='box-bottom'){
4801 4799
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4802
-			}elseif($icon=='box-left'){
4800
+			} elseif($icon=='box-left'){
4803 4801
 				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4804 4802
 			}
4805 4803
 		}
Please login to merge, or discard this patch.
Indentation   +2637 added lines, -2637 removed lines patch added patch discarded remove patch
@@ -1,147 +1,147 @@  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
-	define( 'SUPER_DUPER_VER', '1.2.16' );
9
-
10
-	/**
11
-	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
-	 *
13
-	 * Should not be called direct but extended instead.
14
-	 *
15
-	 * Class WP_Super_Duper
16
-	 * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
-	 * @ver 1.1.1
18
-	 */
19
-	class WP_Super_Duper extends WP_Widget {
20
-
21
-		public $version = SUPER_DUPER_VER;
22
-		public $font_awesome_icon_version = "5.11.2";
23
-		public $block_code;
24
-		public $options;
25
-		public $base_id;
26
-		public $settings_hash;
27
-		public $arguments = array();
28
-		public $instance = array();
29
-		private $class_name;
30
-
31
-		/**
32
-		 * The relative url to the current folder.
33
-		 *
34
-		 * @var string
35
-		 */
36
-		public $url = '';
37
-
38
-		/**
39
-		 * Take the array options and use them to build.
40
-		 */
41
-		public function __construct( $options ) {
42
-			global $sd_widgets;
43
-
44
-			$sd_widgets[ $options['base_id'] ] = array(
45
-				'name'       => $options['name'],
46
-				'class_name' => $options['class_name'],
47
-				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
-			);
49
-			$this->base_id                     = $options['base_id'];
50
-			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
54
-			$this->options = $options;
55
-
56
-			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
-
59
-			// nested blocks can't work as a widget
60
-			if(!empty($this->options['nested-block'])){
61
-				if(empty($this->options['output_types'])){
62
-					$this->options['output_types'] = array('shortcode','block');
63
-				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
-					unset($this->options['output_types'][$key]);
65
-				}
66
-			}
8
+    define( 'SUPER_DUPER_VER', '1.2.16' );
9
+
10
+    /**
11
+     * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
12
+     *
13
+     * Should not be called direct but extended instead.
14
+     *
15
+     * Class WP_Super_Duper
16
+     * @since 1.0.16 change log moved to file change-log.txt - CHANGED
17
+     * @ver 1.1.1
18
+     */
19
+    class WP_Super_Duper extends WP_Widget {
20
+
21
+        public $version = SUPER_DUPER_VER;
22
+        public $font_awesome_icon_version = "5.11.2";
23
+        public $block_code;
24
+        public $options;
25
+        public $base_id;
26
+        public $settings_hash;
27
+        public $arguments = array();
28
+        public $instance = array();
29
+        private $class_name;
67 30
 
68
-			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-				parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
-			}
31
+        /**
32
+         * The relative url to the current folder.
33
+         *
34
+         * @var string
35
+         */
36
+        public $url = '';
37
+
38
+        /**
39
+         * Take the array options and use them to build.
40
+         */
41
+        public function __construct( $options ) {
42
+            global $sd_widgets;
43
+
44
+            $sd_widgets[ $options['base_id'] ] = array(
45
+                'name'       => $options['name'],
46
+                'class_name' => $options['class_name'],
47
+                'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48
+            );
49
+            $this->base_id                     = $options['base_id'];
50
+            // lets filter the options before we do anything
51
+            $options       = apply_filters( "wp_super_duper_options", $options );
52
+            $options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
+            $options       = $this->add_name_from_key( $options );
54
+            $this->options = $options;
55
+
56
+            $this->base_id   = $options['base_id'];
57
+            $this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
58
+
59
+            // nested blocks can't work as a widget
60
+            if(!empty($this->options['nested-block'])){
61
+                if(empty($this->options['output_types'])){
62
+                    $this->options['output_types'] = array('shortcode','block');
63
+                }elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64
+                    unset($this->options['output_types'][$key]);
65
+                }
66
+            }
72 67
 
68
+            // init parent
69
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
+                parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
71
+            }
73 72
 
74
-			if ( isset( $options['class_name'] ) ) {
75
-				// register widget
76
-				$this->class_name = $options['class_name'];
77 73
 
78
-				// register shortcode, this needs to be done even for blocks and widgets
79
-				$this->register_shortcode();
74
+            if ( isset( $options['class_name'] ) ) {
75
+                // register widget
76
+                $this->class_name = $options['class_name'];
80 77
 
78
+                // register shortcode, this needs to be done even for blocks and widgets
79
+                $this->register_shortcode();
81 80
 
82
-				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
85
-				}
81
+
82
+                // Fusion Builder (avada) support
83
+                if ( function_exists( 'fusion_builder_map' ) ) {
84
+                    add_action( 'init', array( $this, 'register_fusion_element' ) );
85
+                }
86 86
 
87 87
                 // maybe load the Bricks transformer class
88 88
                 if( class_exists('\Bricks\Elements', false) ){
89
-					add_action( 'init', array( $this, 'load_bricks_element_class' ) );
89
+                    add_action( 'init', array( $this, 'load_bricks_element_class' ) );
90 90
                 }
91 91
 
92
-				// register block
93
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
-					add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
-				}
96
-			}
92
+                // register block
93
+                if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
+                    add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
95
+                }
96
+            }
97 97
 
98
-			// add the CSS and JS we need ONCE
99
-			global $sd_widget_scripts;
98
+            // add the CSS and JS we need ONCE
99
+            global $sd_widget_scripts;
100 100
 
101
-			if ( ! $sd_widget_scripts ) {
102
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
-				wp_add_inline_style( 'widgets', $this->widget_css() );
101
+            if ( ! $sd_widget_scripts ) {
102
+                wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
+                wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
+                wp_add_inline_style( 'widgets', $this->widget_css() );
105 105
 
106
-				// maybe add elementor editor styles
107
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
106
+                // maybe add elementor editor styles
107
+                add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
108 108
 
109
-				$sd_widget_scripts = true;
109
+                $sd_widget_scripts = true;
110 110
 
111
-				// add shortcode insert button once
112
-				add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
-				// generatepress theme sections compatibility
115
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
-				}
118
-				/* Load script on Divi theme builder page */
119
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
120
-					add_thickbox();
121
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
122
-				}
111
+                // add shortcode insert button once
112
+                add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
+                add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
114
+                // generatepress theme sections compatibility
115
+                if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
+                    add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
117
+                }
118
+                /* Load script on Divi theme builder page */
119
+                if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
120
+                    add_thickbox();
121
+                    add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
122
+                }
123 123
 
124
-				if ( $this->is_preview() ) {
125
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
126
-					// this makes the insert button work for elementor
127
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
128
-						$this,
129
-						'shortcode_insert_button_script'
130
-					) ); // for elementor
131
-				}
132
-				// this makes the insert button work for cornerstone
133
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
124
+                if ( $this->is_preview() ) {
125
+                    add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
126
+                    // this makes the insert button work for elementor
127
+                    add_action( 'elementor/editor/after_enqueue_scripts', array(
128
+                        $this,
129
+                        'shortcode_insert_button_script'
130
+                    ) ); // for elementor
131
+                }
132
+                // this makes the insert button work for cornerstone
133
+                add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
134 134
 
135
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
135
+                add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
+                add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
137 137
 
138
-				// add generator text to head
139
-				add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
-				add_action( 'wp_head', array( $this, 'generator' ), 99 );
141
-			}
138
+                // add generator text to head
139
+                add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
+                add_action( 'wp_head', array( $this, 'generator' ), 99 );
141
+            }
142 142
 
143
-			do_action( 'wp_super_duper_widget_init', $options, $this );
144
-		}
143
+            do_action( 'wp_super_duper_widget_init', $options, $this );
144
+        }
145 145
 
146 146
         /**
147 147
          * Load the Bricks conversion class if we are running Bricks.
@@ -151,163 +151,163 @@  discard block
 block discarded – undo
151 151
                     include_once __DIR__ . '/includes/class-super-duper-bricks-element.php';
152 152
         }
153 153
 
154
-		/**
155
-		 * The register widget function
156
-		 * @return void
157
-		 */
158
-		public function _register() {
159
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
160
-				parent::_register();
161
-			}
162
-		}
163
-
164
-		/**
165
-		 * Add our widget CSS to elementor editor.
166
-		 */
167
-		public function elementor_editor_styles() {
168
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
169
-		}
170
-
171
-		public function register_fusion_element() {
172
-
173
-			$options = $this->options;
174
-
175
-			if ( $this->base_id ) {
176
-
177
-				$params = $this->get_fusion_params();
178
-
179
-				$args = array(
180
-					'name'            => $options['name'],
181
-					'shortcode'       => $this->base_id,
182
-					'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
183
-					'allow_generator' => true,
184
-				);
185
-
186
-				if ( ! empty( $params ) ) {
187
-					$args['params'] = $params;
188
-				}
189
-
190
-				fusion_builder_map( $args );
191
-			}
154
+        /**
155
+         * The register widget function
156
+         * @return void
157
+         */
158
+        public function _register() {
159
+            if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
160
+                parent::_register();
161
+            }
162
+        }
192 163
 
193
-		}
164
+        /**
165
+         * Add our widget CSS to elementor editor.
166
+         */
167
+        public function elementor_editor_styles() {
168
+            wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
169
+        }
194 170
 
195
-		public function get_fusion_params() {
196
-			$params    = array();
197
-			$arguments = $this->get_arguments();
198
-
199
-			if ( ! empty( $arguments ) ) {
200
-				foreach ( $arguments as $key => $val ) {
201
-					$param = array();
202
-					// type
203
-					$param['type'] = str_replace(
204
-						array(
205
-							"text",
206
-							"number",
207
-							"email",
208
-							"color",
209
-							"checkbox"
210
-						),
211
-						array(
212
-							"textfield",
213
-							"textfield",
214
-							"textfield",
215
-							"colorpicker",
216
-							"select",
171
+        public function register_fusion_element() {
217 172
 
218
-						),
219
-						$val['type'] );
173
+            $options = $this->options;
220 174
 
221
-					// multiselect
222
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
223
-						$param['type']     = 'multiple_select';
224
-						$param['multiple'] = true;
225
-					}
175
+            if ( $this->base_id ) {
226 176
 
227
-					// heading
228
-					$param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
177
+                $params = $this->get_fusion_params();
229 178
 
230
-					// description
231
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
179
+                $args = array(
180
+                    'name'            => $options['name'],
181
+                    'shortcode'       => $this->base_id,
182
+                    'icon'            => $options['block-icon'] ? $options['block-icon'] : 'far fa-square',
183
+                    'allow_generator' => true,
184
+                );
232 185
 
233
-					// param_name
234
-					$param['param_name'] = $key;
186
+                if ( ! empty( $params ) ) {
187
+                    $args['params'] = $params;
188
+                }
235 189
 
236
-					// Default
237
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
190
+                fusion_builder_map( $args );
191
+            }
238 192
 
239
-					// Group
240
-					if ( isset( $val['group'] ) ) {
241
-						$param['group'] = $val['group'];
242
-					}
193
+        }
243 194
 
244
-					// value
245
-					if ( $val['type'] == 'checkbox' ) {
246
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
-							unset( $param['default'] );
248
-						}
249
-						$param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
252
-					} else {
253
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
254
-					}
195
+        public function get_fusion_params() {
196
+            $params    = array();
197
+            $arguments = $this->get_arguments();
198
+
199
+            if ( ! empty( $arguments ) ) {
200
+                foreach ( $arguments as $key => $val ) {
201
+                    $param = array();
202
+                    // type
203
+                    $param['type'] = str_replace(
204
+                        array(
205
+                            "text",
206
+                            "number",
207
+                            "email",
208
+                            "color",
209
+                            "checkbox"
210
+                        ),
211
+                        array(
212
+                            "textfield",
213
+                            "textfield",
214
+                            "textfield",
215
+                            "colorpicker",
216
+                            "select",
217
+
218
+                        ),
219
+                        $val['type'] );
220
+
221
+                    // multiselect
222
+                    if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
223
+                        $param['type']     = 'multiple_select';
224
+                        $param['multiple'] = true;
225
+                    }
226
+
227
+                    // heading
228
+                    $param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
229
+
230
+                    // description
231
+                    $param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
232
+
233
+                    // param_name
234
+                    $param['param_name'] = $key;
235
+
236
+                    // Default
237
+                    $param['default'] = isset( $val['default'] ) ? $val['default'] : '';
238
+
239
+                    // Group
240
+                    if ( isset( $val['group'] ) ) {
241
+                        $param['group'] = $val['group'];
242
+                    }
243
+
244
+                    // value
245
+                    if ( $val['type'] == 'checkbox' ) {
246
+                        if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
+                            unset( $param['default'] );
248
+                        }
249
+                        $param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
+                    } elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
+                        $param['value'] = isset( $val['options'] ) ? $val['options'] : array();
252
+                    } else {
253
+                        $param['value'] = isset( $val['default'] ) ? $val['default'] : '';
254
+                    }
255
+
256
+                    // setup the param
257
+                    $params[] = $param;
255 258
 
256
-					// setup the param
257
-					$params[] = $param;
259
+                }
260
+            }
258 261
 
259
-				}
260
-			}
261 262
 
263
+            return $params;
264
+        }
262 265
 
263
-			return $params;
264
-		}
266
+        /**
267
+         * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268
+         */
269
+        public static function maybe_cornerstone_builder() {
270
+            if ( did_action( 'cornerstone_before_boot_app' ) ) {
271
+                self::shortcode_insert_button_script();
272
+            }
273
+        }
265 274
 
266
-		/**
267
-		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268
-		 */
269
-		public static function maybe_cornerstone_builder() {
270
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
271
-				self::shortcode_insert_button_script();
272
-			}
273
-		}
275
+        /**
276
+         * A function to ge the shortcode builder picker html.
277
+         *
278
+         * @param string $editor_id
279
+         *
280
+         * @return string
281
+         */
282
+        public static function get_picker( $editor_id = '' ) {
274 283
 
275
-		/**
276
-		 * A function to ge the shortcode builder picker html.
277
-		 *
278
-		 * @param string $editor_id
279
-		 *
280
-		 * @return string
281
-		 */
282
-		public static function get_picker( $editor_id = '' ) {
283
-
284
-			ob_start();
285
-			if ( isset( $_POST['editor_id'] ) ) {
286
-				$editor_id = esc_attr( $_POST['editor_id'] );
287
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
288
-				$editor_id = 'main_content_content_vb_tiny_mce';
289
-			}
284
+            ob_start();
285
+            if ( isset( $_POST['editor_id'] ) ) {
286
+                $editor_id = esc_attr( $_POST['editor_id'] );
287
+            } elseif ( isset( $_REQUEST['et_fb'] ) ) {
288
+                $editor_id = 'main_content_content_vb_tiny_mce';
289
+            }
290 290
 
291
-			global $sd_widgets;
291
+            global $sd_widgets;
292 292
 
293 293
 //			print_r($sd_widgets);exit;
294
-			?>
294
+            ?>
295 295
 
296 296
 			<div class="sd-shortcode-left-wrap">
297 297
 				<?php
298
-				ksort( $sd_widgets );
299
-				//				print_r($sd_widgets);exit;
300
-				if ( ! empty( $sd_widgets ) ) {
301
-					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
-					echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
-					foreach ( $sd_widgets as $shortcode => $class ) {
304
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
306
-					}
307
-					echo "</select>";
298
+                ksort( $sd_widgets );
299
+                //				print_r($sd_widgets);exit;
300
+                if ( ! empty( $sd_widgets ) ) {
301
+                    echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
+                    echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
+                    foreach ( $sd_widgets as $shortcode => $class ) {
304
+                        if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
+                        echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
306
+                    }
307
+                    echo "</select>";
308 308
 
309
-				}
310
-				?>
309
+                }
310
+                ?>
311 311
 				<div class="sd-shortcode-settings"></div>
312 312
 
313 313
 			</div>
@@ -318,8 +318,8 @@  discard block
 block discarded – undo
318 318
 					<?php if ( $editor_id != '' ) { ?>
319 319
 						<button class="button sd-insert-shortcode-button"
320 320
 								onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
321
-									echo "'" . $editor_id . "'";
322
-								} ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
321
+                                    echo "'" . $editor_id . "'";
322
+                                } ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
323 323
 					<?php } ?>
324 324
 					<button class="button"
325 325
 							onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
@@ -327,150 +327,150 @@  discard block
 block discarded – undo
327 327
 			</div>
328 328
 			<?php
329 329
 
330
-			$html = ob_get_clean();
331
-
332
-			if ( wp_doing_ajax() ) {
333
-				echo $html;
334
-				$should_die = true;
330
+            $html = ob_get_clean();
335 331
 
336
-				// some builder get the editor via ajax so we should not die on those occasions
337
-				$dont_die = array(
338
-					'parent_tag',// WP Bakery
339
-					'avia_request' // enfold
340
-				);
341
-
342
-				foreach ( $dont_die as $request ) {
343
-					if ( isset( $_REQUEST[ $request ] ) ) {
344
-						$should_die = false;
345
-					}
346
-				}
332
+            if ( wp_doing_ajax() ) {
333
+                echo $html;
334
+                $should_die = true;
347 335
 
348
-				if ( $should_die ) {
349
-					wp_die();
350
-				}
336
+                // some builder get the editor via ajax so we should not die on those occasions
337
+                $dont_die = array(
338
+                    'parent_tag',// WP Bakery
339
+                    'avia_request' // enfold
340
+                );
351 341
 
352
-			} else {
353
-				return $html;
354
-			}
342
+                foreach ( $dont_die as $request ) {
343
+                    if ( isset( $_REQUEST[ $request ] ) ) {
344
+                        $should_die = false;
345
+                    }
346
+                }
355 347
 
356
-			return '';
348
+                if ( $should_die ) {
349
+                    wp_die();
350
+                }
357 351
 
358
-		}
352
+            } else {
353
+                return $html;
354
+            }
359 355
 
360
-		/**
361
-		 * Output the version in the header.
362
-		 */
363
-		public function generator() {
364
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
366
-
367
-			// Find source plugin/theme of SD
368
-			$source = array();
369
-			if ( strpos( $file, $plugins_dir ) !== false ) {
370
-				$source = explode( "/", plugin_basename( $file ) );
371
-			} else if ( function_exists( 'get_theme_root' ) ) {
372
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
373
-
374
-				if ( strpos( $file, $themes_dir ) !== false ) {
375
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
376
-				}
377
-			}
356
+            return '';
378 357
 
379
-			echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
380
-		}
358
+        }
381 359
 
382
-		/**
383
-		 * Get widget settings.
384
-		 *
385
-		 * @since 1.0.0
386
-		 */
387
-		public static function get_widget_settings() {
388
-			global $sd_widgets;
389
-
390
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
-			if ( ! $shortcode ) {
392
-				wp_die();
393
-			}
394
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
-			if ( ! $widget_args ) {
396
-				wp_die();
397
-			}
398
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
-			if ( ! $class_name ) {
400
-				wp_die();
401
-			}
360
+        /**
361
+         * Output the version in the header.
362
+         */
363
+        public function generator() {
364
+            $file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
+            $plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
366
+
367
+            // Find source plugin/theme of SD
368
+            $source = array();
369
+            if ( strpos( $file, $plugins_dir ) !== false ) {
370
+                $source = explode( "/", plugin_basename( $file ) );
371
+            } else if ( function_exists( 'get_theme_root' ) ) {
372
+                $themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
373
+
374
+                if ( strpos( $file, $themes_dir ) !== false ) {
375
+                    $source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
376
+                }
377
+            }
402 378
 
403
-			// invoke an instance method
404
-			$widget = new $class_name;
379
+            echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
380
+        }
405 381
 
406
-			ob_start();
407
-			$widget->form( array() );
408
-			$form = ob_get_clean();
409
-			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410
-			echo "<style>" . $widget->widget_css() . "</style>";
411
-			echo "<script>" . $widget->widget_js() . "</script>";
412
-			?>
382
+        /**
383
+         * Get widget settings.
384
+         *
385
+         * @since 1.0.0
386
+         */
387
+        public static function get_widget_settings() {
388
+            global $sd_widgets;
389
+
390
+            $shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
+            if ( ! $shortcode ) {
392
+                wp_die();
393
+            }
394
+            $widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
+            if ( ! $widget_args ) {
396
+                wp_die();
397
+            }
398
+            $class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
+            if ( ! $class_name ) {
400
+                wp_die();
401
+            }
402
+
403
+            // invoke an instance method
404
+            $widget = new $class_name;
405
+
406
+            ob_start();
407
+            $widget->form( array() );
408
+            $form = ob_get_clean();
409
+            echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410
+            echo "<style>" . $widget->widget_css() . "</style>";
411
+            echo "<script>" . $widget->widget_js() . "</script>";
412
+            ?>
413 413
 			<?php
414
-			wp_die();
415
-		}
416
-
417
-		/**
418
-		 * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
419
-		 *
420
-		 * @param string $editor_id Optional. Shortcode editor id. Default null.
421
-		 * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
422
-		 *
423
-		 *@since 1.0.0
424
-		 *
425
-		 */
426
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
427
-			global $sd_widgets, $shortcode_insert_button_once;
428
-			if ( $shortcode_insert_button_once ) {
429
-				return;
430
-			}
431
-			add_thickbox();
432
-
433
-
434
-			/**
435
-			 * Cornerstone makes us play dirty tricks :/
436
-			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437
-			 */
438
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
439
-				echo '<span id="insert-media-button">';
440
-			}
441
-
442
-			echo self::shortcode_button( 'this', 'true' );
443
-
444
-			// see opening note
445
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
-				echo '</span>'; // end #insert-media-button
447
-			}
448
-
449
-			// Add separate script for generatepress theme sections
450
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
451
-			} else {
452
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
453
-			}
414
+            wp_die();
415
+        }
454 416
 
455
-			$shortcode_insert_button_once = true;
456
-		}
417
+        /**
418
+         * Insert shortcode builder button to classic editor (not inside Gutenberg, not needed).
419
+         *
420
+         * @param string $editor_id Optional. Shortcode editor id. Default null.
421
+         * @param string $insert_shortcode_function Optional. Insert shortcode function. Default null.
422
+         *
423
+         *@since 1.0.0
424
+         *
425
+         */
426
+        public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
427
+            global $sd_widgets, $shortcode_insert_button_once;
428
+            if ( $shortcode_insert_button_once ) {
429
+                return;
430
+            }
431
+            add_thickbox();
432
+
433
+
434
+            /**
435
+             * Cornerstone makes us play dirty tricks :/
436
+             * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437
+             */
438
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
439
+                echo '<span id="insert-media-button">';
440
+            }
441
+
442
+            echo self::shortcode_button( 'this', 'true' );
443
+
444
+            // see opening note
445
+            if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
446
+                echo '</span>'; // end #insert-media-button
447
+            }
448
+
449
+            // Add separate script for generatepress theme sections
450
+            if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
451
+            } else {
452
+                self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
453
+            }
454
+
455
+            $shortcode_insert_button_once = true;
456
+        }
457 457
 
458
-		/**
459
-		 * Gets the shortcode insert button html.
460
-		 *
461
-		 * @param string $id
462
-		 * @param string $search_for_id
463
-		 *
464
-		 * @return mixed
465
-		 */
466
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
467
-			ob_start();
468
-			?>
458
+        /**
459
+         * Gets the shortcode insert button html.
460
+         *
461
+         * @param string $id
462
+         * @param string $search_for_id
463
+         *
464
+         * @return mixed
465
+         */
466
+        public static function shortcode_button( $id = '', $search_for_id = '' ) {
467
+            ob_start();
468
+            ?>
469 469
 			<span class="sd-lable-shortcode-inserter">
470 470
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
471
-				if ( $search_for_id ) {
472
-					echo "," . $search_for_id;
473
-				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
471
+                if ( $search_for_id ) {
472
+                    echo "," . $search_for_id;
473
+                } ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
474 474
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
475 475
 					<span style="vertical-align: middle;line-height: 18px;font-size: 20px;"
476 476
 						  class="dashicons dashicons-screenoptions"></span>
@@ -481,21 +481,21 @@  discard block
 block discarded – undo
481 481
 			</span>
482 482
 
483 483
 			<?php
484
-			$html = ob_get_clean();
484
+            $html = ob_get_clean();
485 485
 
486
-			// remove line breaks so we can use it in js
487
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
488
-		}
486
+            // remove line breaks so we can use it in js
487
+            return preg_replace( "/\r|\n/", "", trim( $html ) );
488
+        }
489 489
 
490
-		/**
491
-		 * Makes SD work with the siteOrigin page builder.
492
-		 *
493
-		 * @return mixed
494
-		 *@since 1.0.6
495
-		 */
496
-		public static function siteorigin_js() {
497
-			ob_start();
498
-			?>
490
+        /**
491
+         * Makes SD work with the siteOrigin page builder.
492
+         *
493
+         * @return mixed
494
+         *@since 1.0.6
495
+         */
496
+        public static function siteorigin_js() {
497
+            ob_start();
498
+            ?>
499 499
 			<script>
500 500
 				/**
501 501
 				 * Check a form to see what items should be shown or hidden.
@@ -571,29 +571,29 @@  discard block
 block discarded – undo
571 571
 				});
572 572
 			</script>
573 573
 			<?php
574
-			$output = ob_get_clean();
574
+            $output = ob_get_clean();
575 575
 
576
-			/*
576
+            /*
577 577
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
578 578
 			 */
579 579
 
580
-			return str_replace( array(
581
-				'<script>',
582
-				'</script>'
583
-			), '', $output );
584
-		}
580
+            return str_replace( array(
581
+                '<script>',
582
+                '</script>'
583
+            ), '', $output );
584
+        }
585 585
 
586
-		/**
587
-		 * Output the JS and CSS for the shortcode insert button.
588
-		 *
589
-		 * @param string $editor_id
590
-		 * @param string $insert_shortcode_function
591
-		 *
592
-		 *@since 1.0.6
593
-		 *
594
-		 */
595
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
596
-			?>
586
+        /**
587
+         * Output the JS and CSS for the shortcode insert button.
588
+         *
589
+         * @param string $editor_id
590
+         * @param string $insert_shortcode_function
591
+         *
592
+         *@since 1.0.6
593
+         *
594
+         */
595
+        public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
596
+            ?>
597 597
 			<style>
598 598
 				.sd-shortcode-left-wrap {
599 599
 					float: left;
@@ -721,35 +721,35 @@  discard block
 block discarded – undo
721 721
 				<?php } ?>
722 722
 			</style>
723 723
 			<?php
724
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
725
-				echo "<script>" . self::siteorigin_js() . "</script>";
726
-			}
727
-			?>
724
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
725
+                echo "<script>" . self::siteorigin_js() . "</script>";
726
+            }
727
+            ?>
728 728
 			<script>
729 729
 				<?php
730
-				if(! empty( $insert_shortcode_function )){
731
-					echo $insert_shortcode_function;
732
-				}else{
733
-
734
-				/**
735
-				 * Function for super duper insert shortcode.
736
-				 *
737
-				 * @since 1.0.0
738
-				 */
739
-				?>
730
+                if(! empty( $insert_shortcode_function )){
731
+                    echo $insert_shortcode_function;
732
+                }else{
733
+
734
+                /**
735
+                 * Function for super duper insert shortcode.
736
+                 *
737
+                 * @since 1.0.0
738
+                 */
739
+                ?>
740 740
 				function sd_insert_shortcode($editor_id) {
741 741
 					$shortcode = jQuery('#TB_ajaxContent #sd-shortcode-output').val();
742 742
 					if ($shortcode) {
743 743
 						if (!$editor_id) {
744 744
 							<?php
745
-							if ( isset( $_REQUEST['et_fb'] ) ) {
746
-								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
748
-								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749
-							} else {
750
-								echo '$editor_id = "#wp-content-editor-container textarea";';
751
-							}
752
-							?>
745
+                            if ( isset( $_REQUEST['et_fb'] ) ) {
746
+                                echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
+                            } elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
748
+                                echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749
+                            } else {
750
+                                echo '$editor_id = "#wp-content-editor-container textarea";';
751
+                            }
752
+                            ?>
753 753
 						} else {
754 754
 							$editor_id = '#' + $editor_id;
755 755
 						}
@@ -1063,18 +1063,18 @@  discard block
 block discarded – undo
1063 1063
 				}
1064 1064
 			</script>
1065 1065
 			<?php
1066
-		}
1066
+        }
1067 1067
 
1068
-		/**
1069
-		 * Gets some CSS for the widgets screen.
1070
-		 *
1071
-		 * @param bool $advanced If we should include advanced CSS.
1072
-		 *
1073
-		 * @return mixed
1074
-		 */
1075
-		public function widget_css( $advanced = true ) {
1076
-			ob_start();
1077
-			?>
1068
+        /**
1069
+         * Gets some CSS for the widgets screen.
1070
+         *
1071
+         * @param bool $advanced If we should include advanced CSS.
1072
+         *
1073
+         * @return mixed
1074
+         */
1075
+        public function widget_css( $advanced = true ) {
1076
+            ob_start();
1077
+            ?>
1078 1078
 			<style>
1079 1079
 				<?php if( $advanced ){ ?>
1080 1080
 				.sd-advanced-setting {
@@ -1114,26 +1114,26 @@  discard block
 block discarded – undo
1114 1114
 				.elementor-control .sd-argument select[multiple] option{padding:3px}
1115 1115
 			</style>
1116 1116
 			<?php
1117
-			$output = ob_get_clean();
1117
+            $output = ob_get_clean();
1118 1118
 
1119
-			/*
1119
+            /*
1120 1120
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1121 1121
 			 */
1122 1122
 
1123
-			return str_replace( array(
1124
-				'<style>',
1125
-				'</style>'
1126
-			), '', $output );
1127
-		}
1123
+            return str_replace( array(
1124
+                '<style>',
1125
+                '</style>'
1126
+            ), '', $output );
1127
+        }
1128 1128
 
1129
-		/**
1130
-		 * Gets some JS for the widgets screen.
1131
-		 *
1132
-		 * @return mixed
1133
-		 */
1134
-		public function widget_js() {
1135
-			ob_start();
1136
-			?>
1129
+        /**
1130
+         * Gets some JS for the widgets screen.
1131
+         *
1132
+         * @return mixed
1133
+         */
1134
+        public function widget_js() {
1135
+            ob_start();
1136
+            ?>
1137 1137
 			<script>
1138 1138
 
1139 1139
 				/**
@@ -1284,513 +1284,513 @@  discard block
 block discarded – undo
1284 1284
 				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1285 1285
 			</script>
1286 1286
 			<?php
1287
-			$output = ob_get_clean();
1287
+            $output = ob_get_clean();
1288 1288
 
1289
-			/*
1289
+            /*
1290 1290
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1291 1291
 			 */
1292 1292
 
1293
-			return str_replace( array(
1294
-				'<script>',
1295
-				'</script>'
1296
-			), '', $output );
1297
-		}
1293
+            return str_replace( array(
1294
+                '<script>',
1295
+                '</script>'
1296
+            ), '', $output );
1297
+        }
1298 1298
 
1299 1299
 
1300
-		/**
1301
-		 * Set the name from the argument key.
1302
-		 *
1303
-		 * @param $options
1304
-		 *
1305
-		 * @return mixed
1306
-		 */
1307
-		private function add_name_from_key( $options, $arguments = false ) {
1308
-			if ( ! empty( $options['arguments'] ) ) {
1309
-				foreach ( $options['arguments'] as $key => $val ) {
1310
-					$options['arguments'][ $key ]['name'] = $key;
1311
-				}
1312
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
-				foreach ( $options as $key => $val ) {
1314
-					$options[ $key ]['name'] = $key;
1315
-				}
1316
-			}
1300
+        /**
1301
+         * Set the name from the argument key.
1302
+         *
1303
+         * @param $options
1304
+         *
1305
+         * @return mixed
1306
+         */
1307
+        private function add_name_from_key( $options, $arguments = false ) {
1308
+            if ( ! empty( $options['arguments'] ) ) {
1309
+                foreach ( $options['arguments'] as $key => $val ) {
1310
+                    $options['arguments'][ $key ]['name'] = $key;
1311
+                }
1312
+            } elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
+                foreach ( $options as $key => $val ) {
1314
+                    $options[ $key ]['name'] = $key;
1315
+                }
1316
+            }
1317 1317
 
1318
-			return $options;
1319
-		}
1318
+            return $options;
1319
+        }
1320 1320
 
1321
-		/**
1322
-		 * Register the parent shortcode.
1323
-		 *
1324
-		 * @since 1.0.0
1325
-		 */
1326
-		public function register_shortcode() {
1327
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1329
-		}
1321
+        /**
1322
+         * Register the parent shortcode.
1323
+         *
1324
+         * @since 1.0.0
1325
+         */
1326
+        public function register_shortcode() {
1327
+            add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
+            add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1329
+        }
1330 1330
 
1331
-		/**
1332
-		 * Render the shortcode via ajax so we can return it to Gutenberg.
1333
-		 *
1334
-		 * @since 1.0.0
1335
-		 */
1336
-		public function render_shortcode() {
1337
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
-			if ( ! current_user_can( 'manage_options' ) ) {
1339
-				wp_die();
1340
-			}
1331
+        /**
1332
+         * Render the shortcode via ajax so we can return it to Gutenberg.
1333
+         *
1334
+         * @since 1.0.0
1335
+         */
1336
+        public function render_shortcode() {
1337
+            check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
+            if ( ! current_user_can( 'manage_options' ) ) {
1339
+                wp_die();
1340
+            }
1341
+
1342
+            // we might need the $post value here so lets set it.
1343
+            if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
+                $post_obj = get_post( absint( $_POST['post_id'] ) );
1345
+                if ( ! empty( $post_obj ) && empty( $post ) ) {
1346
+                    global $post;
1347
+                    $post = $post_obj;
1348
+                }
1349
+            }
1350
+
1351
+            if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1352
+                $is_preview = $this->is_preview();
1353
+                $shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
+                $attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355
+                $attributes       = '';
1356
+                if ( ! empty( $attributes_array ) ) {
1357
+                    foreach ( $attributes_array as $key => $value ) {
1358
+                        if ( is_array( $value ) ) {
1359
+                            $value = implode( ",", $value );
1360
+                        }
1361
+
1362
+                        if ( ! empty( $value ) ) {
1363
+                            $value = wp_unslash( $value );
1364
+
1365
+                            // Encode [ and ].
1366
+                            if ( $is_preview ) {
1367
+                                $value = $this->encode_shortcodes( $value );
1368
+                            }
1369
+                        }
1370
+                        $attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1371
+                    }
1372
+                }
1341 1373
 
1342
-			// we might need the $post value here so lets set it.
1343
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1345
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1346
-					global $post;
1347
-					$post = $post_obj;
1348
-				}
1349
-			}
1374
+                $shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1350 1375
 
1351
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1352
-				$is_preview = $this->is_preview();
1353
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355
-				$attributes       = '';
1356
-				if ( ! empty( $attributes_array ) ) {
1357
-					foreach ( $attributes_array as $key => $value ) {
1358
-						if ( is_array( $value ) ) {
1359
-							$value = implode( ",", $value );
1360
-						}
1376
+                $content = do_shortcode( $shortcode );
1361 1377
 
1362
-						if ( ! empty( $value ) ) {
1363
-							$value = wp_unslash( $value );
1378
+                // Decode [ and ].
1379
+                if ( ! empty( $content ) && $is_preview ) {
1380
+                    $content = $this->decode_shortcodes( $content );
1381
+                }
1364 1382
 
1365
-							// Encode [ and ].
1366
-							if ( $is_preview ) {
1367
-								$value = $this->encode_shortcodes( $value );
1368
-							}
1369
-						}
1370
-						$attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1371
-					}
1372
-				}
1383
+                echo $content;
1384
+            }
1385
+            wp_die();
1386
+        }
1373 1387
 
1374
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1388
+        /**
1389
+         * Output the shortcode.
1390
+         *
1391
+         * @param array $args
1392
+         * @param string $content
1393
+         *
1394
+         * @return string
1395
+         */
1396
+        public function shortcode_output( $args = array(), $content = '' ) {
1397
+            $_instance = $args;
1398
+
1399
+            $args = $this->argument_values( $args );
1400
+
1401
+            // add extra argument so we know its a output to gutenberg
1402
+            //$args
1403
+            $args = $this->string_to_bool( $args );
1404
+
1405
+            // if we have a enclosed shortcode we add it to the special `html` argument
1406
+            if ( ! empty( $content ) ) {
1407
+                $args['html'] = $content;
1408
+            }
1409
+
1410
+            if ( ! $this->is_preview() ) {
1411
+                /**
1412
+                 * Filters the settings for a particular widget args.
1413
+                 *
1414
+                 * @param array          $args      The current widget instance's settings.
1415
+                 * @param WP_Super_Duper $widget    The current widget settings.
1416
+                 * @param array          $_instance An array of default widget arguments.
1417
+                 *
1418
+                 *@since 1.0.28
1419
+                 *
1420
+                 */
1421
+                $args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1422
+
1423
+                if ( ! is_array( $args ) ) {
1424
+                    return $args;
1425
+                }
1426
+            }
1427
+
1428
+            $class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
+            $class .= " sdel-".$this->get_instance_hash();
1430
+
1431
+            $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
+            $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1433
+
1434
+            $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
+            $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1436
+
1437
+            $shortcode_args = array();
1438
+            $output         = '';
1439
+            $no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
+            if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1441
+                $no_wrap = true;
1442
+            }
1443
+            $main_content = $this->output( $args, $shortcode_args, $content );
1444
+            if ( $main_content && ! $no_wrap ) {
1445
+                // wrap the shortcode in a div with the same class as the widget
1446
+                $output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
+                if ( ! empty( $args['title'] ) ) {
1448
+                    // if its a shortcode and there is a title try to grab the title wrappers
1449
+                    $shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
+                    if ( empty( $instance ) ) {
1451
+                        global $wp_registered_sidebars;
1452
+                        if ( ! empty( $wp_registered_sidebars ) ) {
1453
+                            foreach ( $wp_registered_sidebars as $sidebar ) {
1454
+                                if ( ! empty( $sidebar['before_title'] ) ) {
1455
+                                    $shortcode_args['before_title'] = $sidebar['before_title'];
1456
+                                    $shortcode_args['after_title']  = $sidebar['after_title'];
1457
+                                    break;
1458
+                                }
1459
+                            }
1460
+                        }
1461
+                    }
1462
+                    $output .= $this->output_title( $shortcode_args, $args );
1463
+                }
1464
+                $output .= $main_content;
1465
+                $output .= '</div>';
1466
+            } elseif ( $main_content && $no_wrap ) {
1467
+                $output .= $main_content;
1468
+            }
1469
+
1470
+            // if preview show a placeholder if empty
1471
+            if ( $this->is_preview() && $output == '' ) {
1472
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1473
+            }
1474
+
1475
+            return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
+        }
1375 1477
 
1376
-				$content = do_shortcode( $shortcode );
1478
+        /**
1479
+         * Placeholder text to show if output is empty and we are on a preview/builder page.
1480
+         *
1481
+         * @param string $name
1482
+         *
1483
+         * @return string
1484
+         */
1485
+        public function preview_placeholder_text( $name = '' ) {
1486
+            return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1487
+        }
1377 1488
 
1378
-				// Decode [ and ].
1379
-				if ( ! empty( $content ) && $is_preview ) {
1380
-					$content = $this->decode_shortcodes( $content );
1381
-				}
1489
+        /**
1490
+         * Sometimes booleans values can be turned to strings, so we fix that.
1491
+         *
1492
+         * @param $options
1493
+         *
1494
+         * @return mixed
1495
+         */
1496
+        public function string_to_bool( $options ) {
1497
+            // convert bool strings to booleans
1498
+            foreach ( $options as $key => $val ) {
1499
+                if ( $val == 'false' ) {
1500
+                    $options[ $key ] = false;
1501
+                } elseif ( $val == 'true' ) {
1502
+                    $options[ $key ] = true;
1503
+                }
1504
+            }
1382 1505
 
1383
-				echo $content;
1384
-			}
1385
-			wp_die();
1386
-		}
1506
+            return $options;
1507
+        }
1387 1508
 
1388
-		/**
1389
-		 * Output the shortcode.
1390
-		 *
1391
-		 * @param array $args
1392
-		 * @param string $content
1393
-		 *
1394
-		 * @return string
1395
-		 */
1396
-		public function shortcode_output( $args = array(), $content = '' ) {
1397
-			$_instance = $args;
1398
-
1399
-			$args = $this->argument_values( $args );
1400
-
1401
-			// add extra argument so we know its a output to gutenberg
1402
-			//$args
1403
-			$args = $this->string_to_bool( $args );
1404
-
1405
-			// if we have a enclosed shortcode we add it to the special `html` argument
1406
-			if ( ! empty( $content ) ) {
1407
-				$args['html'] = $content;
1408
-			}
1509
+        /**
1510
+         * Get the argument values that are also filterable.
1511
+         *
1512
+         * @param $instance
1513
+         *
1514
+         * @return array
1515
+         *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516
+         *
1517
+         */
1518
+        public function argument_values( $instance ) {
1519
+            $argument_values = array();
1520
+
1521
+            // set widget instance
1522
+            $this->instance = $instance;
1523
+
1524
+            if ( empty( $this->arguments ) ) {
1525
+                $this->arguments = $this->get_arguments();
1526
+            }
1527
+
1528
+            if ( ! empty( $this->arguments ) ) {
1529
+                foreach ( $this->arguments as $key => $args ) {
1530
+                    // set the input name from the key
1531
+                    $args['name'] = $key;
1532
+                    //
1533
+                    $argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
+                    if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1535
+                        // don't set default for an empty checkbox
1536
+                    } elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
+                        $argument_values[ $key ] = $args['default'];
1538
+                    }
1539
+                }
1540
+            }
1409 1541
 
1410
-			if ( ! $this->is_preview() ) {
1411
-				/**
1412
-				 * Filters the settings for a particular widget args.
1413
-				 *
1414
-				 * @param array          $args      The current widget instance's settings.
1415
-				 * @param WP_Super_Duper $widget    The current widget settings.
1416
-				 * @param array          $_instance An array of default widget arguments.
1417
-				 *
1418
-				 *@since 1.0.28
1419
-				 *
1420
-				 */
1421
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1542
+            return $argument_values;
1543
+        }
1422 1544
 
1423
-				if ( ! is_array( $args ) ) {
1424
-					return $args;
1425
-				}
1426
-			}
1545
+        /**
1546
+         * Set arguments in super duper.
1547
+         *
1548
+         * @return array Set arguments.
1549
+         *@since 1.0.0
1550
+         *
1551
+         */
1552
+        public function set_arguments() {
1553
+            return $this->arguments;
1554
+        }
1427 1555
 
1428
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
-			$class .= " sdel-".$this->get_instance_hash();
1556
+        /**
1557
+         * Get arguments in super duper.
1558
+         *
1559
+         * @return array Get arguments.
1560
+         *@since 1.0.0
1561
+         *
1562
+         */
1563
+        public function get_arguments() {
1564
+            if ( empty( $this->arguments ) ) {
1565
+                $this->arguments = $this->set_arguments();
1566
+            }
1430 1567
 
1431
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1568
+            $this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
+            $this->arguments = $this->add_name_from_key( $this->arguments, true );
1433 1570
 
1434
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1571
+            return $this->arguments;
1572
+        }
1436 1573
 
1437
-			$shortcode_args = array();
1438
-			$output         = '';
1439
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1441
-				$no_wrap = true;
1442
-			}
1443
-			$main_content = $this->output( $args, $shortcode_args, $content );
1444
-			if ( $main_content && ! $no_wrap ) {
1445
-				// wrap the shortcode in a div with the same class as the widget
1446
-				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
-				if ( ! empty( $args['title'] ) ) {
1448
-					// if its a shortcode and there is a title try to grab the title wrappers
1449
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
-					if ( empty( $instance ) ) {
1451
-						global $wp_registered_sidebars;
1452
-						if ( ! empty( $wp_registered_sidebars ) ) {
1453
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1454
-								if ( ! empty( $sidebar['before_title'] ) ) {
1455
-									$shortcode_args['before_title'] = $sidebar['before_title'];
1456
-									$shortcode_args['after_title']  = $sidebar['after_title'];
1457
-									break;
1458
-								}
1459
-							}
1460
-						}
1461
-					}
1462
-					$output .= $this->output_title( $shortcode_args, $args );
1463
-				}
1464
-				$output .= $main_content;
1465
-				$output .= '</div>';
1466
-			} elseif ( $main_content && $no_wrap ) {
1467
-				$output .= $main_content;
1468
-			}
1574
+        /**
1575
+         * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1576
+         *
1577
+         * @param array $args
1578
+         * @param array $widget_args
1579
+         * @param string $content
1580
+         */
1581
+        public function output( $args = array(), $widget_args = array(), $content = '' ) {
1469 1582
 
1470
-			// if preview show a placeholder if empty
1471
-			if ( $this->is_preview() && $output == '' ) {
1472
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1473
-			}
1583
+        }
1474 1584
 
1475
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1476
-		}
1585
+        /**
1586
+         * Add the dynamic block code inline when the wp-block in enqueued.
1587
+         */
1588
+        public function register_block() {
1589
+            wp_add_inline_script( 'wp-blocks', $this->block() );
1590
+            if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
+                wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1592
+            }
1593
+        }
1477 1594
 
1478
-		/**
1479
-		 * Placeholder text to show if output is empty and we are on a preview/builder page.
1480
-		 *
1481
-		 * @param string $name
1482
-		 *
1483
-		 * @return string
1484
-		 */
1485
-		public function preview_placeholder_text( $name = '' ) {
1486
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1487
-		}
1595
+        /**
1596
+         * Check if we need to show advanced options.
1597
+         *
1598
+         * @return bool
1599
+         */
1600
+        public function block_show_advanced() {
1488 1601
 
1489
-		/**
1490
-		 * Sometimes booleans values can be turned to strings, so we fix that.
1491
-		 *
1492
-		 * @param $options
1493
-		 *
1494
-		 * @return mixed
1495
-		 */
1496
-		public function string_to_bool( $options ) {
1497
-			// convert bool strings to booleans
1498
-			foreach ( $options as $key => $val ) {
1499
-				if ( $val == 'false' ) {
1500
-					$options[ $key ] = false;
1501
-				} elseif ( $val == 'true' ) {
1502
-					$options[ $key ] = true;
1503
-				}
1504
-			}
1602
+            $show      = false;
1603
+            $arguments = $this->get_arguments();
1505 1604
 
1506
-			return $options;
1507
-		}
1605
+            if ( ! empty( $arguments ) ) {
1606
+                foreach ( $arguments as $argument ) {
1607
+                    if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1608
+                        $show = true;
1609
+                        break; // no need to continue if we know we have it
1610
+                    }
1611
+                }
1612
+            }
1508 1613
 
1509
-		/**
1510
-		 * Get the argument values that are also filterable.
1511
-		 *
1512
-		 * @param $instance
1513
-		 *
1514
-		 * @return array
1515
-		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516
-		 *
1517
-		 */
1518
-		public function argument_values( $instance ) {
1519
-			$argument_values = array();
1520
-
1521
-			// set widget instance
1522
-			$this->instance = $instance;
1523
-
1524
-			if ( empty( $this->arguments ) ) {
1525
-				$this->arguments = $this->get_arguments();
1526
-			}
1614
+            return $show;
1615
+        }
1527 1616
 
1528
-			if ( ! empty( $this->arguments ) ) {
1529
-				foreach ( $this->arguments as $key => $args ) {
1530
-					// set the input name from the key
1531
-					$args['name'] = $key;
1532
-					//
1533
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1535
-						// don't set default for an empty checkbox
1536
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
-						$argument_values[ $key ] = $args['default'];
1538
-					}
1539
-				}
1540
-			}
1617
+        /**
1618
+         * Get the url path to the current folder.
1619
+         *
1620
+         * @return string
1621
+         */
1622
+        public function get_url() {
1623
+            $url = $this->url;
1541 1624
 
1542
-			return $argument_values;
1543
-		}
1625
+            if ( ! $url ) {
1626
+                $content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
+                $content_url = untrailingslashit( WP_CONTENT_URL );
1544 1628
 
1545
-		/**
1546
-		 * Set arguments in super duper.
1547
-		 *
1548
-		 * @return array Set arguments.
1549
-		 *@since 1.0.0
1550
-		 *
1551
-		 */
1552
-		public function set_arguments() {
1553
-			return $this->arguments;
1554
-		}
1629
+                // Replace http:// to https://.
1630
+                if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
+                    $content_url = str_replace( 'http://', 'https://', $content_url );
1632
+                }
1555 1633
 
1556
-		/**
1557
-		 * Get arguments in super duper.
1558
-		 *
1559
-		 * @return array Get arguments.
1560
-		 *@since 1.0.0
1561
-		 *
1562
-		 */
1563
-		public function get_arguments() {
1564
-			if ( empty( $this->arguments ) ) {
1565
-				$this->arguments = $this->set_arguments();
1566
-			}
1634
+                // Check if we are inside a plugin
1635
+                $file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
+                $url = str_replace( $content_dir, $content_url, $file_dir );
1637
+                $url = trailingslashit( $url );
1638
+                $this->url = $url;
1639
+            }
1567 1640
 
1568
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1641
+            return $url;
1642
+        }
1570 1643
 
1571
-			return $this->arguments;
1572
-		}
1644
+        /**
1645
+         * Get the url path to the current folder.
1646
+         *
1647
+         * @return string
1648
+         */
1649
+        public function get_url_old() {
1573 1650
 
1574
-		/**
1575
-		 * This is the main output class for all 3 items, widget, shortcode and block, it is extended in the calling class.
1576
-		 *
1577
-		 * @param array $args
1578
-		 * @param array $widget_args
1579
-		 * @param string $content
1580
-		 */
1581
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1651
+            $url = $this->url;
1582 1652
 
1583
-		}
1653
+            if ( ! $url ) {
1654
+                // check if we are inside a plugin
1655
+                $file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1584 1656
 
1585
-		/**
1586
-		 * Add the dynamic block code inline when the wp-block in enqueued.
1587
-		 */
1588
-		public function register_block() {
1589
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1590
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1592
-			}
1593
-		}
1657
+                $dir_parts = explode( "/wp-content/", $file_dir );
1658
+                $url_parts = explode( "/wp-content/", plugins_url() );
1594 1659
 
1595
-		/**
1596
-		 * Check if we need to show advanced options.
1597
-		 *
1598
-		 * @return bool
1599
-		 */
1600
-		public function block_show_advanced() {
1601
-
1602
-			$show      = false;
1603
-			$arguments = $this->get_arguments();
1604
-
1605
-			if ( ! empty( $arguments ) ) {
1606
-				foreach ( $arguments as $argument ) {
1607
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1608
-						$show = true;
1609
-						break; // no need to continue if we know we have it
1610
-					}
1611
-				}
1612
-			}
1660
+                if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
+                    $url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1662
+                    $this->url = $url;
1663
+                }
1664
+            }
1613 1665
 
1614
-			return $show;
1615
-		}
1616 1666
 
1617
-		/**
1618
-		 * Get the url path to the current folder.
1619
-		 *
1620
-		 * @return string
1621
-		 */
1622
-		public function get_url() {
1623
-			$url = $this->url;
1624
-
1625
-			if ( ! $url ) {
1626
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1628
-
1629
-				// Replace http:// to https://.
1630
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1632
-				}
1667
+            return $url;
1668
+        }
1633 1669
 
1634
-				// Check if we are inside a plugin
1635
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1637
-				$url = trailingslashit( $url );
1638
-				$this->url = $url;
1639
-			}
1670
+        /**
1671
+         * Generate the block icon.
1672
+         *
1673
+         * Enables the use of Font Awesome icons.
1674
+         *
1675
+         * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1676
+         *
1677
+         * @param $icon
1678
+         *
1679
+         * @return string
1680
+         *@since 1.1.0
1681
+         */
1682
+        public function get_block_icon( $icon ) {
1683
+
1684
+            // check if we have a Font Awesome icon
1685
+            $fa_type = '';
1686
+            if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1687
+                $fa_type = 'solid';
1688
+            } elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1689
+                $fa_type = 'regular';
1690
+            } elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1691
+                $fa_type = 'brands';
1692
+            } else {
1693
+                $icon = "'" . $icon . "'";
1694
+            }
1695
+
1696
+            // set the icon if we found one
1697
+            if ( $fa_type ) {
1698
+                $fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1699
+                $icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700
+            }
1701
+
1702
+            return $icon;
1703
+        }
1640 1704
 
1641
-			return $url;
1642
-		}
1705
+        public function group_arguments( $arguments ) {
1706
+            if ( ! empty( $arguments ) ) {
1707
+                $temp_arguments = array();
1708
+                $general        = __( "General", 'ayecode-connect' );
1709
+                $add_sections   = false;
1710
+                foreach ( $arguments as $key => $args ) {
1711
+                    if ( isset( $args['group'] ) ) {
1712
+                        $temp_arguments[ $args['group'] ][ $key ] = $args;
1713
+                        $add_sections                             = true;
1714
+                    } else {
1715
+                        $temp_arguments[ $general ][ $key ] = $args;
1716
+                    }
1717
+                }
1643 1718
 
1644
-		/**
1645
-		 * Get the url path to the current folder.
1646
-		 *
1647
-		 * @return string
1648
-		 */
1649
-		public function get_url_old() {
1650
-
1651
-			$url = $this->url;
1652
-
1653
-			if ( ! $url ) {
1654
-				// check if we are inside a plugin
1655
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1656
-
1657
-				$dir_parts = explode( "/wp-content/", $file_dir );
1658
-				$url_parts = explode( "/wp-content/", plugins_url() );
1659
-
1660
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1662
-					$this->url = $url;
1663
-				}
1664
-			}
1665
-
1666
-
1667
-			return $url;
1668
-		}
1669
-
1670
-		/**
1671
-		 * Generate the block icon.
1672
-		 *
1673
-		 * Enables the use of Font Awesome icons.
1674
-		 *
1675
-		 * @note xlink:href is actually deprecated but href is not supported by all so we use both.
1676
-		 *
1677
-		 * @param $icon
1678
-		 *
1679
-		 * @return string
1680
-		 *@since 1.1.0
1681
-		 */
1682
-		public function get_block_icon( $icon ) {
1683
-
1684
-			// check if we have a Font Awesome icon
1685
-			$fa_type = '';
1686
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1687
-				$fa_type = 'solid';
1688
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1689
-				$fa_type = 'regular';
1690
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1691
-				$fa_type = 'brands';
1692
-			} else {
1693
-				$icon = "'" . $icon . "'";
1694
-			}
1695
-
1696
-			// set the icon if we found one
1697
-			if ( $fa_type ) {
1698
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1699
-				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700
-			}
1701
-
1702
-			return $icon;
1703
-		}
1719
+                // only add sections if more than one
1720
+                if ( $add_sections ) {
1721
+                    $arguments = $temp_arguments;
1722
+                }
1723
+            }
1704 1724
 
1705
-		public function group_arguments( $arguments ) {
1706
-			if ( ! empty( $arguments ) ) {
1707
-				$temp_arguments = array();
1708
-				$general        = __( "General", 'ayecode-connect' );
1709
-				$add_sections   = false;
1710
-				foreach ( $arguments as $key => $args ) {
1711
-					if ( isset( $args['group'] ) ) {
1712
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1713
-						$add_sections                             = true;
1714
-					} else {
1715
-						$temp_arguments[ $general ][ $key ] = $args;
1716
-					}
1717
-				}
1725
+            return $arguments;
1726
+        }
1718 1727
 
1719
-				// only add sections if more than one
1720
-				if ( $add_sections ) {
1721
-					$arguments = $temp_arguments;
1722
-				}
1723
-			}
1728
+        /**
1729
+         * Parse used group tabs.
1730
+         *
1731
+         * @since 1.1.17
1732
+         */
1733
+        public function group_block_tabs( $tabs, $arguments ) {
1734
+            if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1735
+                $has_sections = false;
1736
+
1737
+                foreach ( $this->arguments as $key => $args ) {
1738
+                    if ( isset( $args['group'] ) ) {
1739
+                        $has_sections = true;
1740
+                        break;
1741
+                    }
1742
+                }
1724 1743
 
1725
-			return $arguments;
1726
-		}
1744
+                if ( ! $has_sections ) {
1745
+                    return $tabs;
1746
+                }
1727 1747
 
1728
-		/**
1729
-		 * Parse used group tabs.
1730
-		 *
1731
-		 * @since 1.1.17
1732
-		 */
1733
-		public function group_block_tabs( $tabs, $arguments ) {
1734
-			if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1735
-				$has_sections = false;
1736
-
1737
-				foreach ( $this->arguments as $key => $args ) {
1738
-					if ( isset( $args['group'] ) ) {
1739
-						$has_sections = true;
1740
-						break;
1741
-					}
1742
-				}
1748
+                $new_tabs = array();
1743 1749
 
1744
-				if ( ! $has_sections ) {
1745
-					return $tabs;
1746
-				}
1750
+                foreach ( $tabs as $tab_key => $tab ) {
1751
+                    $new_groups = array();
1747 1752
 
1748
-				$new_tabs = array();
1753
+                    if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
+                        foreach ( $tab['groups'] as $group ) {
1755
+                            if ( isset( $arguments[ $group ] ) ) {
1756
+                                $new_groups[] = $group;
1757
+                            }
1758
+                        }
1759
+                    }
1749 1760
 
1750
-				foreach ( $tabs as $tab_key => $tab ) {
1751
-					$new_groups = array();
1761
+                    if ( ! empty( $new_groups ) ) {
1762
+                        $tab['groups'] = $new_groups;
1752 1763
 
1753
-					if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
-						foreach ( $tab['groups'] as $group ) {
1755
-							if ( isset( $arguments[ $group ] ) ) {
1756
-								$new_groups[] = $group;
1757
-							}
1758
-						}
1759
-					}
1764
+                        $new_tabs[ $tab_key ] = $tab;
1765
+                    }
1766
+                }
1760 1767
 
1761
-					if ( ! empty( $new_groups ) ) {
1762
-						$tab['groups'] = $new_groups;
1768
+                $tabs = $new_tabs;
1769
+            }
1763 1770
 
1764
-						$new_tabs[ $tab_key ] = $tab;
1765
-					}
1766
-				}
1771
+            return $tabs;
1772
+        }
1767 1773
 
1768
-				$tabs = $new_tabs;
1769
-			}
1774
+        /**
1775
+         * Output the JS for building the dynamic Guntenberg block.
1776
+         *
1777
+         * @return mixed
1778
+         *@since 1.0.9 Save numbers as numbers and not strings.
1779
+         * @since 1.1.0 Font Awesome classes can be used for icons.
1780
+         * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1781
+         */
1782
+        public function block() {
1783
+            global $sd_is_js_functions_loaded, $aui_bs5;
1770 1784
 
1771
-			return $tabs;
1772
-		}
1785
+            $show_advanced = $this->block_show_advanced();
1773 1786
 
1774
-		/**
1775
-		 * Output the JS for building the dynamic Guntenberg block.
1776
-		 *
1777
-		 * @return mixed
1778
-		 *@since 1.0.9 Save numbers as numbers and not strings.
1779
-		 * @since 1.1.0 Font Awesome classes can be used for icons.
1780
-		 * @since 1.0.4 Added block_wrap property which will set the block wrapping output element ie: div, span, p or empty for no wrap.
1781
-		 */
1782
-		public function block() {
1783
-			global $sd_is_js_functions_loaded, $aui_bs5;
1784
-
1785
-			$show_advanced = $this->block_show_advanced();
1786
-
1787
-			ob_start();
1788
-			?>
1787
+            ob_start();
1788
+            ?>
1789 1789
 			<script>
1790 1790
 			<?php
1791
-			if ( ! $sd_is_js_functions_loaded ) {
1792
-				$sd_is_js_functions_loaded = true;
1793
-			?>
1791
+            if ( ! $sd_is_js_functions_loaded ) {
1792
+                $sd_is_js_functions_loaded = true;
1793
+            ?>
1794 1794
 function sd_show_view_options($this){
1795 1795
 	if(jQuery($this).html().length){
1796 1796
 		jQuery($this).html('');
@@ -2244,8 +2244,8 @@  discard block
 block discarded – undo
2244 2244
 				$classes = [];
2245 2245
 
2246 2246
 				<?php
2247
-				if($aui_bs5){
2248
-					?>
2247
+                if($aui_bs5){
2248
+                    ?>
2249 2249
 				$aui_bs5 = true;
2250 2250
 				$p_ml = 'ms-';
2251 2251
 				$p_mr = 'me-';
@@ -2253,8 +2253,8 @@  discard block
 block discarded – undo
2253 2253
 				$p_pl = 'ps-';
2254 2254
 				$p_pr = 'pe-';
2255 2255
 					<?php
2256
-				}else{
2257
-						?>
2256
+                }else{
2257
+                        ?>
2258 2258
 				$aui_bs5 = false;
2259 2259
 				$p_ml = 'ml-';
2260 2260
 				$p_mr = 'mr-';
@@ -2262,8 +2262,8 @@  discard block
 block discarded – undo
2262 2262
 				$p_pl = 'pl-';
2263 2263
 				$p_pr = 'pr-';
2264 2264
 					<?php
2265
-				}
2266
-				?>
2265
+                }
2266
+                ?>
2267 2267
 
2268 2268
 				// margins
2269 2269
 				if ( $args['mt'] !== undefined && $args['mt'] !== '' ) { $classes.push( "mt-" + $args['mt'] );  $mt = $args['mt']; }else{$mt = null;}
@@ -2447,12 +2447,12 @@  discard block
 block discarded – undo
2447 2447
 			<?php
2448 2448
 
2449 2449
 
2450
-			}
2450
+            }
2451 2451
 
2452
-			if(method_exists($this,'block_global_js')){
2453
-					echo $this->block_global_js();
2454
-			}
2455
-			?>
2452
+            if(method_exists($this,'block_global_js')){
2453
+                    echo $this->block_global_js();
2454
+            }
2455
+            ?>
2456 2456
 
2457 2457
 jQuery(function() {
2458 2458
 
@@ -2505,13 +2505,13 @@  discard block
 block discarded – undo
2505 2505
 						icon: <?php echo $this->get_block_icon( $this->options['block-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/.
2506 2506
 						supports: {
2507 2507
 							<?php
2508
-							if(!isset($this->options['block-supports']['renaming'])){
2509
-								$this->options['block-supports']['renaming'] = false;
2510
-							}
2511
-							if ( isset( $this->options['block-supports'] ) ) {
2512
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2513
-							}
2514
-							?>
2508
+                            if(!isset($this->options['block-supports']['renaming'])){
2509
+                                $this->options['block-supports']['renaming'] = false;
2510
+                            }
2511
+                            if ( isset( $this->options['block-supports'] ) ) {
2512
+                                echo $this->array_to_attributes( $this->options['block-supports'] );
2513
+                            }
2514
+                            ?>
2515 2515
 						},
2516 2516
 						__experimentalLabel( attributes, { context } ) {
2517 2517
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
@@ -2521,174 +2521,174 @@  discard block
 block discarded – undo
2521 2521
 						},
2522 2522
 						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.
2523 2523
 						<?php if ( isset( $this->options['block-keywords'] ) ) {
2524
-						echo "keywords : " . $this->options['block-keywords'] . ",";
2525
-						}
2526
-
2527
-
2528
-						// block hover preview.
2529
-						$example_args = array();
2530
-						if(!empty($this->arguments)){
2531
-							foreach($this->arguments as $key => $a_args){
2532
-								if(isset($a_args['example'])){
2533
-									$example_args[$key] = $a_args['example'];
2534
-								}
2535
-							}
2536
-						}
2537
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2538
-						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2539
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2540
-							// no preview if set to false
2541
-						}elseif( !empty( $example_args ) ){
2542
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2543
-						}elseif( !empty( $this->options['example'] ) ){
2544
-							unset($this->options['example']['viewportWidth']);
2545
-							unset($this->options['example']['innerBlocks']);
2546
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2547
-							$example_parts = array();
2548
-							if($example_atts){
2549
-								$example_parts[] = rtrim($example_atts,",");
2550
-							}
2551
-							if($viewport_width){
2552
-								$example_parts[] = $viewport_width;
2553
-							}
2554
-							if($example_inner_blocks){
2555
-								$example_parts[] = $example_inner_blocks;
2556
-							}
2557
-							if(!empty($example_parts)){
2558
-								echo "example : {".implode(',', $example_parts)."},";
2559
-							}
2560
-						}else{
2561
-							echo 'example : {viewportWidth: 500},';
2562
-						}
2563
-
2564
-
2565
-
2566
-						// limit to parent
2567
-						if( !empty( $this->options['parent'] ) ){
2568
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2569
-						}
2570
-
2571
-						// limit allowed blocks
2572
-						if( !empty( $this->options['allowed-blocks'] ) ){
2573
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2574
-						}
2575
-
2576
-						// maybe set no_wrap
2577
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2578
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2579
-							$no_wrap = true;
2580
-						}
2581
-						if ( $no_wrap ) {
2582
-							$this->options['block-wrap'] = '';
2583
-						}
2584
-
2585
-						// maybe load the drag/drop functions.
2586
-						$img_drag_drop = false;
2587
-
2588
-						$show_alignment = false;
2589
-						// align feature
2590
-						/*echo "supports: {";
2524
+                        echo "keywords : " . $this->options['block-keywords'] . ",";
2525
+                        }
2526
+
2527
+
2528
+                        // block hover preview.
2529
+                        $example_args = array();
2530
+                        if(!empty($this->arguments)){
2531
+                            foreach($this->arguments as $key => $a_args){
2532
+                                if(isset($a_args['example'])){
2533
+                                    $example_args[$key] = $a_args['example'];
2534
+                                }
2535
+                            }
2536
+                        }
2537
+                        $viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2538
+                        $example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2539
+                        if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2540
+                            // no preview if set to false
2541
+                        }elseif( !empty( $example_args ) ){
2542
+                            echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2543
+                        }elseif( !empty( $this->options['example'] ) ){
2544
+                            unset($this->options['example']['viewportWidth']);
2545
+                            unset($this->options['example']['innerBlocks']);
2546
+                            $example_atts = $this->array_to_attributes( $this->options['example'] );
2547
+                            $example_parts = array();
2548
+                            if($example_atts){
2549
+                                $example_parts[] = rtrim($example_atts,",");
2550
+                            }
2551
+                            if($viewport_width){
2552
+                                $example_parts[] = $viewport_width;
2553
+                            }
2554
+                            if($example_inner_blocks){
2555
+                                $example_parts[] = $example_inner_blocks;
2556
+                            }
2557
+                            if(!empty($example_parts)){
2558
+                                echo "example : {".implode(',', $example_parts)."},";
2559
+                            }
2560
+                        }else{
2561
+                            echo 'example : {viewportWidth: 500},';
2562
+                        }
2563
+
2564
+
2565
+
2566
+                        // limit to parent
2567
+                        if( !empty( $this->options['parent'] ) ){
2568
+                            echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2569
+                        }
2570
+
2571
+                        // limit allowed blocks
2572
+                        if( !empty( $this->options['allowed-blocks'] ) ){
2573
+                            echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2574
+                        }
2575
+
2576
+                        // maybe set no_wrap
2577
+                        $no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2578
+                        if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2579
+                            $no_wrap = true;
2580
+                        }
2581
+                        if ( $no_wrap ) {
2582
+                            $this->options['block-wrap'] = '';
2583
+                        }
2584
+
2585
+                        // maybe load the drag/drop functions.
2586
+                        $img_drag_drop = false;
2587
+
2588
+                        $show_alignment = false;
2589
+                        // align feature
2590
+                        /*echo "supports: {";
2591 2591
 						echo "	align: true,";
2592 2592
 						echo "  html: false";
2593 2593
 						echo "},";*/
2594 2594
 
2595 2595
 
2596
-							echo "attributes : {";
2597
-
2598
-							if ( $show_advanced ) {
2599
-								echo "show_advanced: {";
2600
-								echo "	type: 'boolean',";
2601
-								echo "  default: false,";
2602
-								echo "},";
2603
-							}
2604
-
2605
-							// block wrap element
2606
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2607
-								echo "block_wrap: {";
2608
-								echo "	type: 'string',";
2609
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2610
-								echo "},";
2611
-							}
2612
-
2613
-
2614
-							if ( ! empty( $this->arguments ) ) {
2615
-
2616
-								foreach ( $this->arguments as $key => $args ) {
2617
-
2618
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2619
-										$img_drag_drop = true;
2620
-									}
2621
-
2622
-									// set if we should show alignment
2623
-									if ( $key == 'alignment' ) {
2624
-										$show_alignment = true;
2625
-									}
2626
-
2627
-									$extra = '';
2628
-
2629
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2630
-										continue;
2631
-									}
2632
-									elseif ( $args['type'] == 'checkbox' ) {
2633
-										$type    = 'boolean';
2634
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2635
-									} elseif ( $args['type'] == 'number' ) {
2636
-										$type    = 'number';
2637
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2638
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2639
-										$type = 'array';
2640
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2641
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2642
-										} else {
2643
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2644
-										}
2645
-									} elseif ( $args['type'] == 'tagselect' ) {
2646
-										$type    = 'array';
2647
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2648
-									} elseif ( $args['type'] == 'multiselect' ) {
2649
-										$type    = 'array';
2650
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2651
-									} elseif ( $args['type'] == 'image_xy' ) {
2652
-										$type    = 'object';
2653
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2654
-									} elseif ( $args['type'] == 'image' ) {
2655
-										$type    = 'string';
2656
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2657
-
2658
-										// add a field for ID
2659
-	//                                    echo $key . "_id : {";
2660
-	//                                    echo "type : 'number',";
2661
-	//                                    echo "},";
2662
-	//                                    echo $key . "_xy : {";
2663
-	//                                    echo "type : 'object',";
2664
-	//                                    echo "},";
2665
-
2666
-									} else {
2667
-										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2668
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2669
-
2670
-									}
2671
-									echo $key . " : {";
2672
-									echo "type : '$type',";
2673
-									echo "default : $default,";
2674
-									echo "},";
2675
-								}
2676
-							}
2677
-
2678
-							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2679
-							echo "sd_shortcode : {type : 'string',default: ''},";
2680
-
2681
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2682
-								echo "sd_shortcode_close : {type : 'string',default: ''},";
2683
-							}
2684
-
2685
-							echo "className: { type: 'string', default: '' },";
2686
-
2687
-							echo "},";
2688
-
2689
-
2690
-
2691
-						?>
2596
+                            echo "attributes : {";
2597
+
2598
+                            if ( $show_advanced ) {
2599
+                                echo "show_advanced: {";
2600
+                                echo "	type: 'boolean',";
2601
+                                echo "  default: false,";
2602
+                                echo "},";
2603
+                            }
2604
+
2605
+                            // block wrap element
2606
+                            if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2607
+                                echo "block_wrap: {";
2608
+                                echo "	type: 'string',";
2609
+                                echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2610
+                                echo "},";
2611
+                            }
2612
+
2613
+
2614
+                            if ( ! empty( $this->arguments ) ) {
2615
+
2616
+                                foreach ( $this->arguments as $key => $args ) {
2617
+
2618
+                                    if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2619
+                                        $img_drag_drop = true;
2620
+                                    }
2621
+
2622
+                                    // set if we should show alignment
2623
+                                    if ( $key == 'alignment' ) {
2624
+                                        $show_alignment = true;
2625
+                                    }
2626
+
2627
+                                    $extra = '';
2628
+
2629
+                                    if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2630
+                                        continue;
2631
+                                    }
2632
+                                    elseif ( $args['type'] == 'checkbox' ) {
2633
+                                        $type    = 'boolean';
2634
+                                        $default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2635
+                                    } elseif ( $args['type'] == 'number' ) {
2636
+                                        $type    = 'number';
2637
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2638
+                                    } elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2639
+                                        $type = 'array';
2640
+                                        if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2641
+                                            $default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2642
+                                        } else {
2643
+                                            $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2644
+                                        }
2645
+                                    } elseif ( $args['type'] == 'tagselect' ) {
2646
+                                        $type    = 'array';
2647
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2648
+                                    } elseif ( $args['type'] == 'multiselect' ) {
2649
+                                        $type    = 'array';
2650
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2651
+                                    } elseif ( $args['type'] == 'image_xy' ) {
2652
+                                        $type    = 'object';
2653
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2654
+                                    } elseif ( $args['type'] == 'image' ) {
2655
+                                        $type    = 'string';
2656
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2657
+
2658
+                                        // add a field for ID
2659
+    //                                    echo $key . "_id : {";
2660
+    //                                    echo "type : 'number',";
2661
+    //                                    echo "},";
2662
+    //                                    echo $key . "_xy : {";
2663
+    //                                    echo "type : 'object',";
2664
+    //                                    echo "},";
2665
+
2666
+                                    } else {
2667
+                                        $type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2668
+                                        $default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2669
+
2670
+                                    }
2671
+                                    echo $key . " : {";
2672
+                                    echo "type : '$type',";
2673
+                                    echo "default : $default,";
2674
+                                    echo "},";
2675
+                                }
2676
+                            }
2677
+
2678
+                            echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2679
+                            echo "sd_shortcode : {type : 'string',default: ''},";
2680
+
2681
+                            if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2682
+                                echo "sd_shortcode_close : {type : 'string',default: ''},";
2683
+                            }
2684
+
2685
+                            echo "className: { type: 'string', default: '' },";
2686
+
2687
+                            echo "},";
2688
+
2689
+
2690
+
2691
+                        ?>
2692 2692
 
2693 2693
 						// The "edit" property must be a valid function.
2694 2694
 						edit: function (props) {
@@ -2763,10 +2763,10 @@  discard block
 block discarded – undo
2763 2763
 							}
2764 2764
 
2765 2765
 							<?php
2766
-							if(!empty($this->options['block-edit-raw'])) {
2767
-								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2768
-							}else{
2769
-							?>
2766
+                            if(!empty($this->options['block-edit-raw'])) {
2767
+                                echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2768
+                            }else{
2769
+                            ?>
2770 2770
 
2771 2771
 function hasSelectedInnerBlock(props) {
2772 2772
 	const select = wp.data.select('core/editor');
@@ -2788,9 +2788,9 @@  discard block
 block discarded – undo
2788 2788
 
2789 2789
 	var $value = '';
2790 2790
 	<?php
2791
-	// if we have a post_type and a category then link them
2792
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2793
-	?>
2791
+    // if we have a post_type and a category then link them
2792
+    if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2793
+    ?>
2794 2794
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2795 2795
 		$pt = props.attributes.post_type;
2796 2796
 		if(post_type_rest_slugs.length){
@@ -2803,11 +2803,11 @@  discard block
 block discarded – undo
2803 2803
 			term_query_type = $pt;
2804 2804
 		}
2805 2805
 <?php
2806
-	$cat_path = '';
2807
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2808
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2809
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2810
-	}
2806
+    $cat_path = '';
2807
+    if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2808
+        $cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2809
+        $cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2810
+    }
2811 2811
 ?>
2812 2812
 		/* taxonomies */
2813 2813
 		if($value && 'post_type' in prev_attributes[props.clientId] && 'category' in prev_attributes[props.clientId] && run){
@@ -2899,7 +2899,7 @@  discard block
 block discarded – undo
2899 2899
 <?php
2900 2900
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2901 2901
 if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2902
-	echo 'const { deviceType } = "";';
2902
+    echo 'const { deviceType } = "";';
2903 2903
 }else{
2904 2904
 ?>
2905 2905
 /** Get device type const. */
@@ -2963,8 +2963,8 @@  discard block
 block discarded – undo
2963 2963
 										'attributes': props.attributes,
2964 2964
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2965 2965
 										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2966
-										echo $post->ID;
2967
-									}else{echo '0';}?>,
2966
+                                        echo $post->ID;
2967
+                                    }else{echo '0';}?>,
2968 2968
 										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2969 2969
 									};
2970 2970
 
@@ -2978,20 +2978,20 @@  discard block
 block discarded – undo
2978 2978
 										}
2979 2979
 
2980 2980
 										 <?php
2981
-										if(!empty($this->options['nested-block'])){
2982
-											?>
2981
+                                        if(!empty($this->options['nested-block'])){
2982
+                                            ?>
2983 2983
 											// props.setAttributes({content: env});
2984 2984
 										is_fetching = false;
2985 2985
 										prev_attributes[props.clientId] = props.attributes;
2986 2986
 											 <?php
2987
-										}else{
2988
-										?>
2987
+                                        }else{
2988
+                                        ?>
2989 2989
 										props.setAttributes({content: env});
2990 2990
 										is_fetching = false;
2991 2991
 										prev_attributes[props.clientId] = props.attributes;
2992 2992
 										<?php
2993
-										}
2994
-										?>
2993
+                                        }
2994
+                                        ?>
2995 2995
 
2996 2996
 
2997 2997
 										// if AUI is active call the js init function
@@ -3010,31 +3010,31 @@  discard block
 block discarded – undo
3010 3010
 							}
3011 3011
 
3012 3012
 							<?php
3013
-							if(!empty($this->options['block-edit-js'])) {
3014
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3015
-							}
3013
+                            if(!empty($this->options['block-edit-js'])) {
3014
+                                echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3015
+                            }
3016 3016
 
3017 3017
 
3018 3018
 
3019 3019
 
3020
-							if(empty($this->options['block-save-return'])){
3021
-							?>
3020
+                            if(empty($this->options['block-save-return'])){
3021
+                            ?>
3022 3022
 								///////////////////////////////////////////////////////////////////////
3023 3023
 
3024 3024
 									 // build the shortcode.
3025 3025
 								shortcode = "[<?php echo $this->options['base_id'];?>";
3026 3026
 								<?php
3027 3027
 
3028
-								if(! empty( $this->arguments )){
3028
+                                if(! empty( $this->arguments )){
3029 3029
 
3030
-								foreach($this->arguments as $key => $args){
3031
-								   // if($args['type']=='tabs'){continue;}
3030
+                                foreach($this->arguments as $key => $args){
3031
+                                    // if($args['type']=='tabs'){continue;}
3032 3032
 
3033
-								   // don't add metadata arguments
3034
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3035
-									   continue;
3036
-								   }
3037
-								?>
3033
+                                    // don't add metadata arguments
3034
+                                    if (substr($key, 0, 9 ) === 'metadata_') {
3035
+                                        continue;
3036
+                                    }
3037
+                                ?>
3038 3038
 								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3039 3039
 									if ('<?php echo esc_attr( $key );?>' == 'html') {
3040 3040
 									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
@@ -3045,10 +3045,10 @@  discard block
 block discarded – undo
3045 3045
 									}
3046 3046
 								}
3047 3047
 								<?php
3048
-								}
3049
-								}
3048
+                                }
3049
+                                }
3050 3050
 
3051
-								?>
3051
+                                ?>
3052 3052
 								shortcode += "]";
3053 3053
 
3054 3054
 								if(shortcode){
@@ -3060,17 +3060,17 @@  discard block
 block discarded – undo
3060 3060
 
3061 3061
 
3062 3062
 									<?php
3063
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3064
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3065
-									}
3066
-									?>
3063
+                                    if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3064
+                                        echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3065
+                                    }
3066
+                                    ?>
3067 3067
 								}
3068 3068
 
3069 3069
 
3070 3070
 							///////////////////////////////////////////////////////////////////////
3071 3071
 							<?php
3072
-							} // end nested block check
3073
-							?>
3072
+                            } // end nested block check
3073
+                            ?>
3074 3074
 
3075 3075
 							return [
3076 3076
 
@@ -3094,10 +3094,10 @@  discard block
 block discarded – undo
3094 3094
 
3095 3095
 									<?php
3096 3096
 
3097
-									if(! empty( $this->arguments )){
3097
+                                    if(! empty( $this->arguments )){
3098 3098
 
3099
-									if ( $show_advanced ) {
3100
-									?>
3099
+                                    if ( $show_advanced ) {
3100
+                                    ?>
3101 3101
 									el('div', {
3102 3102
 											style: {'padding-left': '16px','padding-right': '16px'}
3103 3103
 										},
@@ -3114,119 +3114,119 @@  discard block
 block discarded – undo
3114 3114
 									)
3115 3115
 									,
3116 3116
 									<?php
3117
-									}
3118
-
3119
-									$arguments = $this->group_arguments( $this->arguments );
3120
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3121
-
3122
-									// Do we have sections?
3123
-									$has_sections = $arguments == $this->arguments ? false : true;
3124
-
3125
-									if($has_sections){
3126
-									$panel_count = 0;
3127
-									$open_tab = '';
3128
-
3129
-									$open_tab_groups = array();
3130
-									$used_tabs = array();
3131
-
3132
-									foreach ( $arguments as $key => $args ) {
3133
-										$close_tab = false;
3134
-										$close_tabs = false;
3135
-
3136
-										 if ( ! empty( $block_group_tabs ) ) {
3137
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3138
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3139
-													$open_tab_groups[] = $key;
3140
-
3141
-													if ( $open_tab != $tab_name ) {
3142
-														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3143
-														$tab_args['tab']['open'] = true;
3144
-
3145
-														$this->block_tab_start( '', $tab_args );
3146
-														$open_tab = $tab_name;
3147
-														$used_tabs[] = $tab_name;
3148
-													}
3149
-
3150
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3151
-														$close_tab = true;
3152
-														$open_tab_groups = array();
3153
-
3154
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3155
-															$close_tabs = true;
3156
-														}
3157
-													}
3158
-												}
3159
-											}
3160
-										}
3161
-										?>
3117
+                                    }
3118
+
3119
+                                    $arguments = $this->group_arguments( $this->arguments );
3120
+                                    $block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3121
+
3122
+                                    // Do we have sections?
3123
+                                    $has_sections = $arguments == $this->arguments ? false : true;
3124
+
3125
+                                    if($has_sections){
3126
+                                    $panel_count = 0;
3127
+                                    $open_tab = '';
3128
+
3129
+                                    $open_tab_groups = array();
3130
+                                    $used_tabs = array();
3131
+
3132
+                                    foreach ( $arguments as $key => $args ) {
3133
+                                        $close_tab = false;
3134
+                                        $close_tabs = false;
3135
+
3136
+                                            if ( ! empty( $block_group_tabs ) ) {
3137
+                                            foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3138
+                                                if ( in_array( $key, $tab_args['groups'] ) ) {
3139
+                                                    $open_tab_groups[] = $key;
3140
+
3141
+                                                    if ( $open_tab != $tab_name ) {
3142
+                                                        $tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3143
+                                                        $tab_args['tab']['open'] = true;
3144
+
3145
+                                                        $this->block_tab_start( '', $tab_args );
3146
+                                                        $open_tab = $tab_name;
3147
+                                                        $used_tabs[] = $tab_name;
3148
+                                                    }
3149
+
3150
+                                                    if ( $open_tab_groups == $tab_args['groups'] ) {
3151
+                                                        $close_tab = true;
3152
+                                                        $open_tab_groups = array();
3153
+
3154
+                                                        if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3155
+                                                            $close_tabs = true;
3156
+                                                        }
3157
+                                                    }
3158
+                                                }
3159
+                                            }
3160
+                                        }
3161
+                                        ?>
3162 3162
 										el(wp.components.PanelBody, {
3163 3163
 												title: '<?php esc_attr_e( $key ); ?>',
3164 3164
 												initialOpen: <?php if ( $panel_count ) {
3165
-												echo "false";
3166
-											} else {
3167
-												echo "true";
3168
-											}?>
3165
+                                                echo "false";
3166
+                                            } else {
3167
+                                                echo "true";
3168
+                                            }?>
3169 3169
 											},
3170 3170
 											<?php
3171
-											foreach ( $args as $k => $a ) {
3172
-												$this->block_tab_start( $k, $a );
3173
-												$this->block_row_start( $k, $a );
3174
-												$this->build_block_arguments( $k, $a );
3175
-												$this->block_row_end( $k, $a );
3176
-												$this->block_tab_end( $k, $a );
3177
-											}
3178
-											?>
3171
+                                            foreach ( $args as $k => $a ) {
3172
+                                                $this->block_tab_start( $k, $a );
3173
+                                                $this->block_row_start( $k, $a );
3174
+                                                $this->build_block_arguments( $k, $a );
3175
+                                                $this->block_row_end( $k, $a );
3176
+                                                $this->block_tab_end( $k, $a );
3177
+                                            }
3178
+                                            ?>
3179 3179
 										),
3180 3180
 										<?php
3181
-										$panel_count ++;
3181
+                                        $panel_count ++;
3182 3182
 
3183
-										if($close_tab || $close_tabs){
3184
-											$tab_args = array(
3185
-												'tab'	=> array(
3186
-													'tabs_close' => $close_tabs,
3187
-												'close' => true,
3188
-												)
3183
+                                        if($close_tab || $close_tabs){
3184
+                                            $tab_args = array(
3185
+                                                'tab'	=> array(
3186
+                                                    'tabs_close' => $close_tabs,
3187
+                                                'close' => true,
3188
+                                                )
3189 3189
 
3190
-											);
3191
-											$this->block_tab_end( '', $tab_args );
3190
+                                            );
3191
+                                            $this->block_tab_end( '', $tab_args );
3192 3192
 //											echo '###close'; print_r($tab_args);
3193
-											$panel_count = 0;
3194
-										}
3193
+                                            $panel_count = 0;
3194
+                                        }
3195 3195
 //
3196 3196
 
3197
-									}
3198
-									}else {
3199
-									?>
3197
+                                    }
3198
+                                    }else {
3199
+                                    ?>
3200 3200
 									el(wp.components.PanelBody, {
3201 3201
 											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3202 3202
 											initialOpen: true
3203 3203
 										},
3204 3204
 										<?php
3205
-										foreach ( $this->arguments as $key => $args ) {
3206
-											$this->block_row_start( $key, $args );
3207
-											$this->build_block_arguments( $key, $args );
3208
-											$this->block_row_end( $key, $args );
3209
-										}
3210
-										?>
3205
+                                        foreach ( $this->arguments as $key => $args ) {
3206
+                                            $this->block_row_start( $key, $args );
3207
+                                            $this->build_block_arguments( $key, $args );
3208
+                                            $this->block_row_end( $key, $args );
3209
+                                        }
3210
+                                        ?>
3211 3211
 									),
3212 3212
 									<?php
3213
-									}
3213
+                                    }
3214 3214
 
3215
-									}
3216
-									?>
3215
+                                    }
3216
+                                    ?>
3217 3217
 
3218 3218
 								),
3219 3219
 
3220 3220
 								<?php
3221
-								// If the user sets block-output array then build it
3222
-								if ( ! empty( $this->options['block-output'] ) ) {
3223
-								$this->block_element( $this->options['block-output'] );
3224
-							}elseif(!empty($this->options['block-edit-return'])){
3225
-								   echo $this->options['block-edit-return'];
3226
-							}else{
3227
-								// if no block-output is set then we try and get the shortcode html output via ajax.
3228
-								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3229
-								?>
3221
+                                // If the user sets block-output array then build it
3222
+                                if ( ! empty( $this->options['block-output'] ) ) {
3223
+                                $this->block_element( $this->options['block-output'] );
3224
+                            }elseif(!empty($this->options['block-edit-return'])){
3225
+                                    echo $this->options['block-edit-return'];
3226
+                            }else{
3227
+                                // if no block-output is set then we try and get the shortcode html output via ajax.
3228
+                                $block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3229
+                                ?>
3230 3230
 								el('<?php echo esc_attr($block_edit_wrap_tag); ?>', wp.blockEditor.useBlockProps({
3231 3231
 									dangerouslySetInnerHTML: {__html: onChangeContent()},
3232 3232
 									className: props.className,
@@ -3234,13 +3234,13 @@  discard block
 block discarded – undo
3234 3234
 									style: {'minHeight': '30px'}
3235 3235
 								}))
3236 3236
 								<?php
3237
-								}
3238
-								?>
3237
+                                }
3238
+                                ?>
3239 3239
 							]; // end return
3240 3240
 
3241 3241
 							<?php
3242
-							} // end block-edit-raw else
3243
-							?>
3242
+                            } // end block-edit-raw else
3243
+                            ?>
3244 3244
 						},
3245 3245
 
3246 3246
 						// The "save" property must be specified and must be a valid function.
@@ -3254,16 +3254,16 @@  discard block
 block discarded – undo
3254 3254
 							$html = '';
3255 3255
 							<?php
3256 3256
 
3257
-							if(! empty( $this->arguments )){
3257
+                            if(! empty( $this->arguments )){
3258 3258
 
3259
-							foreach($this->arguments as $key => $args){
3260
-							   // if($args['type']=='tabs'){continue;}
3259
+                            foreach($this->arguments as $key => $args){
3260
+                                // if($args['type']=='tabs'){continue;}
3261 3261
 
3262
-							   // don't add metadata arguments
3263
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3264
-								   continue;
3265
-							   }
3266
-							?>
3262
+                                // don't add metadata arguments
3263
+                                if (substr($key, 0, 9 ) === 'metadata_') {
3264
+                                    continue;
3265
+                                }
3266
+                            ?>
3267 3267
 							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3268 3268
 								if ('<?php echo esc_attr( $key );?>' == 'html') {
3269 3269
 									$html = attr.<?php echo esc_attr( $key );?>;
@@ -3274,10 +3274,10 @@  discard block
 block discarded – undo
3274 3274
 								}
3275 3275
 							}
3276 3276
 							<?php
3277
-							}
3278
-							}
3277
+                            }
3278
+                            }
3279 3279
 
3280
-							?>
3280
+                            ?>
3281 3281
 							content += "]";
3282 3282
 							 content = '';
3283 3283
 
@@ -3287,7 +3287,7 @@  discard block
 block discarded – undo
3287 3287
 //                                $html = 'el( InnerBlocks.Content )';
3288 3288
 //                                <?php
3289 3289
 //                            }
3290
-							?>
3290
+                            ?>
3291 3291
 							// if has html element
3292 3292
 							if ($html) {
3293 3293
 								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
@@ -3320,12 +3320,12 @@  discard block
 block discarded – undo
3320 3320
 //                                <x?php
3321 3321
 //							}else
3322 3322
 
3323
-							if(!empty($this->options['block-output'])){
3323
+                            if(!empty($this->options['block-output'])){
3324 3324
 //                               echo "return";
3325 3325
 //                               $this->block_element( $this->options['block-output'], true );
3326 3326
 //                               echo ";";
3327 3327
 
3328
-							   ?>
3328
+                                ?>
3329 3329
 							  return el(
3330 3330
 								   '',
3331 3331
 								   {},
@@ -3335,10 +3335,10 @@  discard block
 block discarded – undo
3335 3335
 							   );
3336 3336
 								<?php
3337 3337
 
3338
-							}elseif(!empty($this->options['block-save-return'])){
3339
-								   echo 'return ' . $this->options['block-save-return'];
3340
-							}elseif(!empty($this->options['nested-block'])){
3341
-								?>
3338
+                            }elseif(!empty($this->options['block-save-return'])){
3339
+                                    echo 'return ' . $this->options['block-save-return'];
3340
+                            }elseif(!empty($this->options['nested-block'])){
3341
+                                ?>
3342 3342
 							  return el(
3343 3343
 								   '',
3344 3344
 								   {},
@@ -3347,22 +3347,22 @@  discard block
 block discarded – undo
3347 3347
 								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3348 3348
 							   );
3349 3349
 								<?php
3350
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3351
-								echo "return ". $this->options['block-edit-return'].";";
3352
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3353
-							?>
3350
+                            }elseif(!empty( $this->options['block-save-return'] ) ){
3351
+                                echo "return ". $this->options['block-edit-return'].";";
3352
+                            }elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3353
+                            ?>
3354 3354
 							return content;
3355 3355
 							<?php
3356
-							}else{
3357
-							?>
3356
+                            }else{
3357
+                            ?>
3358 3358
 							var block_wrap = 'div';
3359 3359
 							if (attr.hasOwnProperty("block_wrap")) {
3360 3360
 								block_wrap = attr.block_wrap;
3361 3361
 							}
3362 3362
 							return el(block_wrap, wp.blockEditor.useBlockProps.save( {dangerouslySetInnerHTML: {__html: content}, className: align} ));
3363 3363
 							<?php
3364
-							}
3365
-							?>
3364
+                            }
3365
+                            ?>
3366 3366
 
3367 3367
 
3368 3368
 						}
@@ -3376,43 +3376,43 @@  discard block
 block discarded – undo
3376 3376
 				});
3377 3377
 			</script>
3378 3378
 			<?php
3379
-			$output = ob_get_clean();
3379
+            $output = ob_get_clean();
3380 3380
 
3381
-			/*
3381
+            /*
3382 3382
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3383 3383
 			 */
3384 3384
 
3385
-			return str_replace( array(
3386
-				'<script>',
3387
-				'</script>'
3388
-			), '', $output );
3389
-		}
3385
+            return str_replace( array(
3386
+                '<script>',
3387
+                '</script>'
3388
+            ), '', $output );
3389
+        }
3390 3390
 
3391 3391
 
3392 3392
 
3393
-		public function block_row_start($key, $args){
3393
+        public function block_row_start($key, $args){
3394 3394
 
3395
-			// check for row
3396
-			if(!empty($args['row'])){
3395
+            // check for row
3396
+            if(!empty($args['row'])){
3397 3397
 
3398
-				if(!empty($args['row']['open'])){
3398
+                if(!empty($args['row']['open'])){
3399 3399
 
3400
-				// element require
3401
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3402
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3403
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3404
-				$device_type_icon = '';
3405
-				if($device_type=='Desktop'){
3406
-					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3407
-				}elseif($device_type=='Tablet'){
3408
-					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3409
-				}elseif($device_type=='Mobile'){
3410
-					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3411
-				}
3412
-				echo $element_require;
3413
-				echo $device_type_require;
3400
+                // element require
3401
+                $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3402
+                $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3403
+                $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3404
+                $device_type_icon = '';
3405
+                if($device_type=='Desktop'){
3406
+                    $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3407
+                }elseif($device_type=='Tablet'){
3408
+                    $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3409
+                }elseif($device_type=='Mobile'){
3410
+                    $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3411
+                }
3412
+                echo $element_require;
3413
+                echo $device_type_require;
3414 3414
 
3415
-					if(false){?><script><?php }?>
3415
+                    if(false){?><script><?php }?>
3416 3416
 						el('div', {
3417 3417
 								className: 'bsui components-base-control',
3418 3418
 							},
@@ -3425,8 +3425,8 @@  discard block
 block discarded – undo
3425 3425
 								<?php if($device_type_icon){ ?>
3426 3426
 									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3427 3427
 								<?php
3428
-								}
3429
-								?>
3428
+                                }
3429
+                                ?>
3430 3430
 
3431 3431
 
3432 3432
 							),
@@ -3450,51 +3450,51 @@  discard block
 block discarded – undo
3450 3450
 									},
3451 3451
 
3452 3452
 					<?php
3453
-					if(false){?></script><?php }
3454
-				}elseif(!empty($args['row']['close'])){
3455
-					if(false){?><script><?php }?>
3453
+                    if(false){?></script><?php }
3454
+                }elseif(!empty($args['row']['close'])){
3455
+                    if(false){?><script><?php }?>
3456 3456
 						el(
3457 3457
 							'div',
3458 3458
 							{
3459 3459
 								className: 'col pl-0 ps-0',
3460 3460
 							},
3461 3461
 					<?php
3462
-					if(false){?></script><?php }
3463
-				}else{
3464
-					if(false){?><script><?php }?>
3462
+                    if(false){?></script><?php }
3463
+                }else{
3464
+                    if(false){?><script><?php }?>
3465 3465
 						el(
3466 3466
 							'div',
3467 3467
 							{
3468 3468
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3469 3469
 							},
3470 3470
 					<?php
3471
-					if(false){?></script><?php }
3472
-				}
3471
+                    if(false){?></script><?php }
3472
+                }
3473 3473
 
3474
-			}
3474
+            }
3475 3475
 
3476
-		}
3476
+        }
3477 3477
 
3478
-		public function block_row_end($key, $args){
3478
+        public function block_row_end($key, $args){
3479 3479
 
3480
-			if(!empty($args['row'])){
3481
-				// maybe close
3482
-				if(!empty($args['row']['close'])){
3483
-					echo "))";
3484
-				}
3480
+            if(!empty($args['row'])){
3481
+                // maybe close
3482
+                if(!empty($args['row']['close'])){
3483
+                    echo "))";
3484
+                }
3485 3485
 
3486
-				echo "),";
3487
-			}
3488
-		}
3486
+                echo "),";
3487
+            }
3488
+        }
3489 3489
 
3490
-		public function block_tab_start($key, $args){
3490
+        public function block_tab_start($key, $args){
3491 3491
 
3492
-			// check for row
3493
-			if(!empty($args['tab'])){
3492
+            // check for row
3493
+            if(!empty($args['tab'])){
3494 3494
 
3495
-				if(!empty($args['tab']['tabs_open'])){
3495
+                if(!empty($args['tab']['tabs_open'])){
3496 3496
 
3497
-					if(false){?><script><?php }?>
3497
+                    if(false){?><script><?php }?>
3498 3498
 
3499 3499
 el('div',{className: 'bsui'},
3500 3500
 
@@ -3507,12 +3507,12 @@  discard block
 block discarded – undo
3507 3507
 										tabs: [
3508 3508
 
3509 3509
 					<?php
3510
-					if(false){?></script><?php }
3511
-				}
3510
+                    if(false){?></script><?php }
3511
+                }
3512 3512
 
3513
-				if(!empty($args['tab']['open'])){
3513
+                if(!empty($args['tab']['open'])){
3514 3514
 
3515
-					if(false){?><script><?php }?>
3515
+                    if(false){?><script><?php }?>
3516 3516
 							{
3517 3517
 												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3518 3518
 												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
@@ -3521,93 +3521,93 @@  discard block
 block discarded – undo
3521 3521
 									className: 'components-base-control__help mb-0',
3522 3522
 									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3523 3523
 								}),<?php }
3524
-					if(false){?></script><?php }
3525
-				}
3524
+                    if(false){?></script><?php }
3525
+                }
3526 3526
 
3527
-			}
3527
+            }
3528 3528
 
3529
-		}
3529
+        }
3530 3530
 
3531
-		public function block_tab_end($key, $args){
3531
+        public function block_tab_end($key, $args){
3532 3532
 
3533
-			if(!empty($args['tab'])){
3534
-				// maybe close
3535
-				if(!empty($args['tab']['close'])){
3536
-					echo ")}, /* tab close */";
3537
-				}
3533
+            if(!empty($args['tab'])){
3534
+                // maybe close
3535
+                if(!empty($args['tab']['close'])){
3536
+                    echo ")}, /* tab close */";
3537
+                }
3538 3538
 
3539
-				if(!empty($args['tab']['tabs_close'])){
3540
-					if(false){?><script><?php }?>
3539
+                if(!empty($args['tab']['tabs_close'])){
3540
+                    if(false){?><script><?php }?>
3541 3541
 						]}, ( tab ) => {
3542 3542
 								return tab.content;
3543 3543
 							}
3544 3544
 						)), /* tabs close */
3545 3545
 					<?php if(false){ ?></script><?php }
3546
-				}
3547
-			}
3548
-		}
3549
-
3550
-		public function build_block_arguments( $key, $args ) {
3551
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3552
-			$options           = '';
3553
-			$extra             = '';
3554
-			$require           = '';
3555
-			$inside_elements   = '';
3556
-			$after_elements	   = '';
3557
-
3558
-			// `content` is a protected and special argument
3559
-			if ( $key == 'content' ) {
3560
-				return;
3561
-			}
3562
-
3563
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3564
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3565
-			$device_type_icon = '';
3566
-			if($device_type=='Desktop'){
3567
-				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3568
-			}elseif($device_type=='Tablet'){
3569
-				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3570
-			}elseif($device_type=='Mobile'){
3571
-				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3572
-			}
3573
-
3574
-			// icon
3575
-			$icon = '';
3576
-			if( !empty( $args['icon'] ) ){
3577
-				$icon .= "el('div', {";
3578
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3579
-									$icon .= "className: 'text-center',";
3580
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3581
-								$icon .= "}),";
3582
-
3583
-				// blank title as its added to the icon.
3584
-				$args['title'] = '';
3585
-			}
3586
-
3587
-			// require advanced
3588
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3589
-
3590
-			// element require
3591
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3592
-
3546
+                }
3547
+            }
3548
+        }
3593 3549
 
3594
-			$onchange  = "props.setAttributes({ $key: $key } )";
3595
-			$onchangecomplete  = "";
3596
-			$value     = "props.attributes.$key";
3597
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3598
-			if ( in_array( $args['type'], $text_type ) ) {
3599
-				$type = 'TextControl';
3600
-				// Save numbers as numbers and not strings
3601
-				if ( $args['type'] == 'number' ) {
3602
-					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3603
-				}
3550
+        public function build_block_arguments( $key, $args ) {
3551
+            $custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3552
+            $options           = '';
3553
+            $extra             = '';
3554
+            $require           = '';
3555
+            $inside_elements   = '';
3556
+            $after_elements	   = '';
3557
+
3558
+            // `content` is a protected and special argument
3559
+            if ( $key == 'content' ) {
3560
+                return;
3561
+            }
3562
+
3563
+            $device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3564
+            $device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3565
+            $device_type_icon = '';
3566
+            if($device_type=='Desktop'){
3567
+                $device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3568
+            }elseif($device_type=='Tablet'){
3569
+                $device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3570
+            }elseif($device_type=='Mobile'){
3571
+                $device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3572
+            }
3573
+
3574
+            // icon
3575
+            $icon = '';
3576
+            if( !empty( $args['icon'] ) ){
3577
+                $icon .= "el('div', {";
3578
+                                    $icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3579
+                                    $icon .= "className: 'text-center',";
3580
+                                    $icon .= "title: '".addslashes( $args['title'] )."',";
3581
+                                $icon .= "}),";
3582
+
3583
+                // blank title as its added to the icon.
3584
+                $args['title'] = '';
3585
+            }
3586
+
3587
+            // require advanced
3588
+            $require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3589
+
3590
+            // element require
3591
+            $element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3592
+
3593
+
3594
+            $onchange  = "props.setAttributes({ $key: $key } )";
3595
+            $onchangecomplete  = "";
3596
+            $value     = "props.attributes.$key";
3597
+            $text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3598
+            if ( in_array( $args['type'], $text_type ) ) {
3599
+                $type = 'TextControl';
3600
+                // Save numbers as numbers and not strings
3601
+                if ( $args['type'] == 'number' ) {
3602
+                    $onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3603
+                }
3604 3604
 
3605
-				if (substr($key, 0, 9 ) === 'metadata_') {
3606
-					$real_key = str_replace('metadata_','', $key );
3607
-					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3608
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3609
-				}
3610
-			}
3605
+                if (substr($key, 0, 9 ) === 'metadata_') {
3606
+                    $real_key = str_replace('metadata_','', $key );
3607
+                    $onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3608
+                    $value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3609
+                }
3610
+            }
3611 3611
 //			else if ( $args['type'] == 'popup' ) {
3612 3612
 //				$type = 'TextControl';
3613 3613
 //				$args['type'] == 'text';
@@ -3625,21 +3625,21 @@  discard block
 block discarded – undo
3625 3625
 //
3626 3626
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3627 3627
 //			}
3628
-			else if ( $args['type'] == 'styleid' ) {
3629
-				$type = 'TextControl';
3630
-				$args['type'] == 'text';
3631
-				// Save numbers as numbers and not strings
3632
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3633
-			}else if ( $args['type'] == 'notice' ) {
3634
-
3635
-				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3636
-				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3637
-
3638
-				$notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3639
-				echo $notice_message ? $element_require . $notice : '';
3640
-				return;
3641
-			}
3642
-			/*
3628
+            else if ( $args['type'] == 'styleid' ) {
3629
+                $type = 'TextControl';
3630
+                $args['type'] == 'text';
3631
+                // Save numbers as numbers and not strings
3632
+                $value     = "props.attributes.$key ? props.attributes.$key : ''";
3633
+            }else if ( $args['type'] == 'notice' ) {
3634
+
3635
+                $notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3636
+                $notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
3637
+
3638
+                $notice = "el('div',{className:'bsui'},el(wp.components.Notice, {status: '$notice_status',isDismissible: false,className: 'm-0 pr-0 pe-0 mb-3'},el('div',{dangerouslySetInnerHTML: {__html: '$notice_message'}}))),";
3639
+                echo $notice_message ? $element_require . $notice : '';
3640
+                return;
3641
+            }
3642
+            /*
3643 3643
 			 * https://www.wptricks.com/question/set-current-tab-on-a-gutenberg-tabpanel-component-from-outside-that-component/ es5 layout
3644 3644
 						elseif($args['type']=='tabs'){
3645 3645
 							?>
@@ -3692,22 +3692,22 @@  discard block
 block discarded – undo
3692 3692
 							return;
3693 3693
 						}
3694 3694
 */
3695
-			elseif ( $args['type'] == 'color' ) {
3696
-				$type = 'ColorPicker';
3697
-				$onchange = "";
3698
-				$extra = "color: $value,";
3699
-				if(!empty($args['disable_alpha'])){
3700
-					$extra .= "disableAlpha: true,";
3701
-				}
3702
-				$onchangecomplete = "onChangeComplete: function($key) {
3695
+            elseif ( $args['type'] == 'color' ) {
3696
+                $type = 'ColorPicker';
3697
+                $onchange = "";
3698
+                $extra = "color: $value,";
3699
+                if(!empty($args['disable_alpha'])){
3700
+                    $extra .= "disableAlpha: true,";
3701
+                }
3702
+                $onchangecomplete = "onChangeComplete: function($key) {
3703 3703
 				value =  $key.rgb.a && $key.rgb.a < 1 ? \"rgba(\"+$key.rgb.r+\",\"+$key.rgb.g+\",\"+$key.rgb.b+\",\"+$key.rgb.a+\")\" : $key.hex;
3704 3704
 						props.setAttributes({
3705 3705
 							$key: value
3706 3706
 						});
3707 3707
 					},";
3708
-			}elseif ( $args['type'] == 'gradient' ) {
3709
-				$type = 'GradientPicker';
3710
-				$extra .= "gradients: [{
3708
+            }elseif ( $args['type'] == 'gradient' ) {
3709
+                $type = 'GradientPicker';
3710
+                $extra .= "gradients: [{
3711 3711
 			name: 'Vivid cyan blue to vivid purple',
3712 3712
 			gradient:
3713 3713
 				'linear-gradient(135deg,rgba(6,147,227,1) 0%,rgb(155,81,224) 100%)',
@@ -3744,10 +3744,10 @@  discard block
 block discarded – undo
3744 3744
 			slug: 'cool-to-warm-spectrum',
3745 3745
 		}],";
3746 3746
 
3747
-			}elseif ( $args['type'] == 'image' ) {
3747
+            }elseif ( $args['type'] == 'image' ) {
3748 3748
 //                print_r($args);
3749 3749
 
3750
-				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3750
+                $img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
3751 3751
 							url:  props.attributes.{$key}_use_featured === true ? 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiID8+CjxzdmcgYmFzZVByb2ZpbGU9InRpbnkiIGhlaWdodD0iNDAwIiB2ZXJzaW9uPSIxLjIiIHdpZHRoPSI0MDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6ZXY9Imh0dHA6Ly93d3cudzMub3JnLzIwMDEveG1sLWV2ZW50cyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxkZWZzIC8+PHJlY3QgZmlsbD0iI2QzZDNkMyIgaGVpZ2h0PSI0MDAiIHdpZHRoPSI0MDAiIHg9IjAiIHk9IjAiIC8+PGxpbmUgc3Ryb2tlPSJ3aGl0ZSIgc3Ryb2tlLXdpZHRoPSIxMCIgeDE9IjAiIHgyPSI0MDAiIHkxPSIwIiB5Mj0iNDAwIiAvPjxsaW5lIHN0cm9rZT0id2hpdGUiIHN0cm9rZS13aWR0aD0iMTAiIHgxPSIwIiB4Mj0iNDAwIiB5MT0iNDAwIiB5Mj0iMCIgLz48cmVjdCBmaWxsPSIjZDNkM2QzIiBoZWlnaHQ9IjUwIiB3aWR0aD0iMjE4LjAiIHg9IjkxLjAiIHk9IjE3NS4wIiAvPjx0ZXh0IGZpbGw9IndoaXRlIiBmb250LXNpemU9IjMwIiBmb250LXdlaWdodD0iYm9sZCIgdGV4dC1hbmNob3I9Im1pZGRsZSIgeD0iMjAwLjAiIHk9IjIwNy41Ij5QTEFDRUhPTERFUjwvdGV4dD48L3N2Zz4='  : props.attributes.$key,
3752 3752
 							value: props.attributes.{$key}_xy.x !== undefined && props.attributes.{$key}_xy.x >= 0 ? props.attributes.{$key}_xy  : {x: 0.5,y: 0.5,},
3753 3753
 //                            value: props.attributes.{$key}_xy,
@@ -3768,16 +3768,16 @@  discard block
 block discarded – undo
3768 3768
 						}), ";
3769 3769
 
3770 3770
 
3771
-				$value = '""';
3772
-				$type = 'MediaUpload';
3773
-				$extra .= "onSelect: function(media){
3771
+                $value = '""';
3772
+                $type = 'MediaUpload';
3773
+                $extra .= "onSelect: function(media){
3774 3774
 					  return props.setAttributes({
3775 3775
 						  $key: media.url,
3776 3776
 						  {$key}_id: media.id
3777 3777
 						});
3778 3778
 					  },";
3779
-				   $extra .= "type: 'image',";
3780
-				   $extra .= "render: function (obj) {
3779
+                    $extra .= "type: 'image',";
3780
+                    $extra .= "render: function (obj) {
3781 3781
 						return el( 'div',{},
3782 3782
 						( !props.attributes.$key && !props.attributes.{$key}_use_featured ) && el( wp.components.Button, {
3783 3783
 						  className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
@@ -3803,11 +3803,11 @@  discard block
 block discarded – undo
3803 3803
 
3804 3804
 
3805 3805
 					  }";
3806
-				$onchange = "";
3806
+                $onchange = "";
3807 3807
 
3808
-				//$inside_elements = ",el('div',{},'file upload')";
3809
-			} else if ( $args['type'] == 'images' ) {
3810
-				$img_preview = "props.attributes.$key && (function() {
3808
+                //$inside_elements = ",el('div',{},'file upload')";
3809
+            } else if ( $args['type'] == 'images' ) {
3810
+                $img_preview = "props.attributes.$key && (function() {
3811 3811
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3812 3812
 	let images = [];
3813 3813
 	uploads.map((upload, index) => (
@@ -3834,9 +3834,9 @@  discard block
 block discarded – undo
3834 3834
 })(),";
3835 3835
 
3836 3836
 
3837
-				$value = '""';
3838
-				$type = 'MediaUpload';
3839
-				$extra .= "onSelect: function(media){
3837
+                $value = '""';
3838
+                $type = 'MediaUpload';
3839
+                $extra .= "onSelect: function(media){
3840 3840
 	let slim_images = props.attributes.$key ? JSON.parse('['+props.attributes.$key+']') : [];
3841 3841
 	if(media.length){
3842 3842
 		for (var i=0; i < media.length; i++) {
@@ -3849,9 +3849,9 @@  discard block
 block discarded – undo
3849 3849
 	}
3850 3850
 	return props.setAttributes({ $key: slimImagesV});
3851 3851
 },";
3852
-				$extra .= "type: 'image',";
3853
-				$extra .= "multiple: true,";
3854
-				$extra .= "render: function (obj) {
3852
+                $extra .= "type: 'image',";
3853
+                $extra .= "multiple: true,";
3854
+                $extra .= "render: function (obj) {
3855 3855
 	/* Init the sort */
3856 3856
 	enableDragSort('sd-sortable');
3857 3857
 	return el( 'div',{},
@@ -3878,40 +3878,40 @@  discard block
 block discarded – undo
3878 3878
 		)
3879 3879
 	)
3880 3880
 }";
3881
-				$onchange = "";
3882
-
3883
-				//$inside_elements = ",el('div',{},'file upload')";
3884
-			}
3885
-			elseif ( $args['type'] == 'checkbox' ) {
3886
-				$type = 'CheckboxControl';
3887
-				$extra .= "checked: props.attributes.$key,";
3888
-				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3889
-			} elseif ( $args['type'] == 'textarea' ) {
3890
-				$type = 'TextareaControl';
3891
-
3892
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3893
-				$type = 'SelectControl';
3894
-
3895
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3896
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3897
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3898
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3899
-				}else {
3900
-
3901
-					if ( ! empty( $args['options'] ) ) {
3902
-						$options .= "options: [";
3903
-						foreach ( $args['options'] as $option_val => $option_label ) {
3904
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3905
-						}
3906
-						$options .= "],";
3907
-					}
3908
-				}
3909
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3910
-					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3911
-				}
3881
+                $onchange = "";
3882
+
3883
+                //$inside_elements = ",el('div',{},'file upload')";
3884
+            }
3885
+            elseif ( $args['type'] == 'checkbox' ) {
3886
+                $type = 'CheckboxControl';
3887
+                $extra .= "checked: props.attributes.$key,";
3888
+                $onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3889
+            } elseif ( $args['type'] == 'textarea' ) {
3890
+                $type = 'TextareaControl';
3891
+
3892
+            } elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3893
+                $type = 'SelectControl';
3894
+
3895
+                if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3896
+                    $options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3897
+                }elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3898
+                    $options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3899
+                }else {
3900
+
3901
+                    if ( ! empty( $args['options'] ) ) {
3902
+                        $options .= "options: [";
3903
+                        foreach ( $args['options'] as $option_val => $option_label ) {
3904
+                            $options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3905
+                        }
3906
+                        $options .= "],";
3907
+                    }
3908
+                }
3909
+                if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3910
+                    $extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3911
+                }
3912 3912
 
3913
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3914
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3913
+                if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3914
+                    $after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3915 3915
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3916 3916
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3917 3917
 									  onClick: function(){
@@ -3922,8 +3922,8 @@  discard block
 block discarded – undo
3922 3922
 									},
3923 3923
 									'Clear'
3924 3924
 							),";
3925
-				}
3926
-			} elseif ( $args['type'] == 'tagselect' ) {
3925
+                }
3926
+            } elseif ( $args['type'] == 'tagselect' ) {
3927 3927
 //				$type = 'FormTokenField';
3928 3928
 //
3929 3929
 //				if ( ! empty( $args['options'] ) ) {
@@ -3958,20 +3958,20 @@  discard block
 block discarded – undo
3958 3958
 //				$value     = "[]";
3959 3959
 //				$extra .= ' __experimentalExpandOnFocus: true,';
3960 3960
 
3961
-			} else if ( $args['type'] == 'alignment' ) {
3962
-				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3963
-			} else if ( $args['type'] == 'margins' ) {
3964
-
3965
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
3966
-				$type = 'TextControl';
3967
-				$value = "(props.attributes.$key ? props.attributes.$key : '')";
3968
-				$args['type'] = 'text';
3969
-				$options .= 'disabled:true,';
3970
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
3971
-				$bsvc_body = $this->block_visibility_fields( $args );
3972
-				// @TODO reset button
3973
-				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
3974
-				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
3961
+            } else if ( $args['type'] == 'alignment' ) {
3962
+                $type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3963
+            } else if ( $args['type'] == 'margins' ) {
3964
+
3965
+            } else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
3966
+                $type = 'TextControl';
3967
+                $value = "(props.attributes.$key ? props.attributes.$key : '')";
3968
+                $args['type'] = 'text';
3969
+                $options .= 'disabled:true,';
3970
+                $bsvc_title = esc_attr( addslashes( $args['title'] ) );
3971
+                $bsvc_body = $this->block_visibility_fields( $args );
3972
+                // @TODO reset button
3973
+                $bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
3974
+                $after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
3975 3975
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
3976 3976
 						onClick: function() {
3977 3977
 							var sValue = props.attributes." . $key . ";
@@ -3997,39 +3997,39 @@  discard block
 block discarded – undo
3997 3997
 					},
3998 3998
 					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
3999 3999
 				) ),";
4000
-			} else {
4001
-				return;// if we have not implemented the control then don't break the JS.
4002
-			}
4003
-
4004
-			// color input does not show the labels so we add them
4005
-			if($args['type']=='color'){
4006
-				// add show only if advanced
4007
-				echo $require_advanced;
4008
-				// add setting require if defined
4009
-				echo $element_require;
4010
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4011
-			}
4012
-
4013
-			// add show only if advanced
4014
-			echo $require_advanced;
4015
-			// add setting require if defined
4016
-			echo $element_require;
4017
-			echo $device_type_require;
4018
-
4019
-			// icon
4020
-			echo $icon;
4021
-			?>
4000
+            } else {
4001
+                return;// if we have not implemented the control then don't break the JS.
4002
+            }
4003
+
4004
+            // color input does not show the labels so we add them
4005
+            if($args['type']=='color'){
4006
+                // add show only if advanced
4007
+                echo $require_advanced;
4008
+                // add setting require if defined
4009
+                echo $element_require;
4010
+                echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4011
+            }
4012
+
4013
+            // add show only if advanced
4014
+            echo $require_advanced;
4015
+            // add setting require if defined
4016
+            echo $element_require;
4017
+            echo $device_type_require;
4018
+
4019
+            // icon
4020
+            echo $icon;
4021
+            ?>
4022 4022
 			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4023 4023
 			label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4024
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4024
+            } else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4025 4025
 			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4026 4026
 			value: <?php echo $value; ?>,
4027 4027
 			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4028
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4029
-			} ?>
4028
+                echo "type: '" . addslashes( $args['type'] ) . "',";
4029
+            } ?>
4030 4030
 			<?php if ( ! empty( $args['placeholder'] ) ) {
4031
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4032
-			} ?>
4031
+                echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4032
+            } ?>
4033 4033
 			<?php echo $options; ?>
4034 4034
 			<?php echo $extra; ?>
4035 4035
 			<?php echo $custom_attributes; ?>
@@ -4041,1266 +4041,1266 @@  discard block
 block discarded – undo
4041 4041
 			<?php } ?>
4042 4042
 		} <?php echo $inside_elements; ?> ),
4043 4043
 			<?php
4044
-			echo $after_elements;
4045
-		}
4044
+            echo $after_elements;
4045
+        }
4046 4046
 
4047
-		/**
4048
-		 * Convert an array of attributes to block string.
4049
-		 *
4050
-		 * @param $custom_attributes
4051
-		 *
4052
-		 * @return string
4053
-		 *@todo there is prob a faster way to do this, also we could add some validation here.
4054
-		 *
4055
-		 */
4056
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4057
-			$attributes = '';
4058
-			if ( ! empty( $custom_attributes ) ) {
4059
-
4060
-				foreach ( $custom_attributes as $key => $val ) {
4061
-					if(is_array($val)){
4062
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4063
-					}else{
4064
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4065
-					}
4066
-				}
4047
+        /**
4048
+         * Convert an array of attributes to block string.
4049
+         *
4050
+         * @param $custom_attributes
4051
+         *
4052
+         * @return string
4053
+         *@todo there is prob a faster way to do this, also we could add some validation here.
4054
+         *
4055
+         */
4056
+        public function array_to_attributes( $custom_attributes, $html = false ) {
4057
+            $attributes = '';
4058
+            if ( ! empty( $custom_attributes ) ) {
4059
+
4060
+                foreach ( $custom_attributes as $key => $val ) {
4061
+                    if(is_array($val)){
4062
+                        $attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4063
+                    }else{
4064
+                        $attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4065
+                    }
4066
+                }
4067 4067
 
4068
-			}
4068
+            }
4069 4069
 
4070
-			return $attributes;
4071
-		}
4070
+            return $attributes;
4071
+        }
4072 4072
 
4073 4073
 
4074 4074
 
4075
-		/**
4076
-		 * A self looping function to create the output for JS block elements.
4077
-		 *
4078
-		 * This is what is output in the WP Editor visual view.
4079
-		 *
4080
-		 * @param $args
4081
-		 */
4082
-		public function block_element( $args, $save = false ) {
4075
+        /**
4076
+         * A self looping function to create the output for JS block elements.
4077
+         *
4078
+         * This is what is output in the WP Editor visual view.
4079
+         *
4080
+         * @param $args
4081
+         */
4082
+        public function block_element( $args, $save = false ) {
4083 4083
 
4084 4084
 //            print_r($args);echo '###';exit;
4085 4085
 
4086
-			if ( ! empty( $args ) ) {
4087
-				foreach ( $args as $element => $new_args ) {
4086
+            if ( ! empty( $args ) ) {
4087
+                foreach ( $args as $element => $new_args ) {
4088 4088
 
4089
-					if ( is_array( $new_args ) ) { // its an element
4089
+                    if ( is_array( $new_args ) ) { // its an element
4090 4090
 
4091 4091
 
4092
-						if ( isset( $new_args['element'] ) ) {
4092
+                        if ( isset( $new_args['element'] ) ) {
4093 4093
 
4094
-							if ( isset( $new_args['element_require'] ) ) {
4095
-								echo str_replace( array(
4096
-										"'+",
4097
-										"+'"
4098
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4099
-								unset( $new_args['element_require'] );
4100
-							}
4094
+                            if ( isset( $new_args['element_require'] ) ) {
4095
+                                echo str_replace( array(
4096
+                                        "'+",
4097
+                                        "+'"
4098
+                                    ), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4099
+                                unset( $new_args['element_require'] );
4100
+                            }
4101 4101
 
4102
-							if($new_args['element']=='InnerBlocks'){
4103
-								echo "\n el( InnerBlocks, {";
4104
-							}elseif($new_args['element']=='innerBlocksProps'){
4105
-								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4106
-							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4102
+                            if($new_args['element']=='InnerBlocks'){
4103
+                                echo "\n el( InnerBlocks, {";
4104
+                            }elseif($new_args['element']=='innerBlocksProps'){
4105
+                                $element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4106
+                                //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4107 4107
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4108
-								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4109
-								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4110
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4111
-
4112
-								echo "} ), {";
4113
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4114
-							//    echo '###';
4115
-
4116
-							  //  echo '###';
4117
-							}elseif($new_args['element']=='BlocksProps'){
4118
-
4119
-								if ( isset($new_args['if_inner_element']) ) {
4120
-									$element = $new_args['if_inner_element'];
4121
-								}else {
4122
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4123
-								}
4124
-
4125
-								unset($new_args['inner_element']);
4126
-								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4127
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4128
-
4129
-
4130
-							   // echo "} ),";
4131
-
4132
-							}else{
4133
-								echo "\n el( '" . $new_args['element'] . "', {";
4134
-							}
4135
-
4136
-
4137
-							// get the attributes
4138
-							foreach ( $new_args as $new_key => $new_value ) {
4139
-
4140
-
4141
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4142
-									// do nothing
4143
-								} else {
4144
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4145
-								}
4146
-							}
4147
-
4148
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4149
-
4150
-							// get the content
4151
-							$first_item = 0;
4152
-							foreach ( $new_args as $new_key => $new_value ) {
4153
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4154
-
4155
-									if ( $new_key === 'content' ) {
4156
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4157
-									}else if ( $new_key === 'if_content' ) {
4158
-										echo  $this->block_props_replace(  $new_value  );
4159
-									}
4160
-
4161
-									if ( is_array( $new_value ) ) {
4162
-
4163
-										if ( isset( $new_value['element_require'] ) ) {
4164
-											echo str_replace( array(
4165
-													"'+",
4166
-													"+'"
4167
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4168
-											unset( $new_value['element_require'] );
4169
-										}
4170
-
4171
-										if ( isset( $new_value['element_repeat'] ) ) {
4172
-											$x = 1;
4173
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4174
-												$this->block_element( array( '' => $new_value ),$save );
4175
-												$x ++;
4176
-											}
4177
-										} else {
4178
-											$this->block_element( array( '' => $new_value ),$save );
4179
-										}
4180
-									}
4181
-									$first_item ++;
4182
-								}
4183
-							}
4184
-
4185
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4186
-								echo "))";// end content
4187
-							}else{
4188
-								echo ")";// end content
4189
-							}
4190
-
4191
-
4192
-							echo ", \n";
4193
-
4194
-						}
4195
-					} else {
4196
-
4197
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4198
-							$extra = '';
4199
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4200
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4201
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4202
-							}
4203
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4204
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4205
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4206
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4108
+                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4109
+                                echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4110
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4111
+
4112
+                                echo "} ), {";
4113
+                                echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4114
+                            //    echo '###';
4115
+
4116
+                                //  echo '###';
4117
+                            }elseif($new_args['element']=='BlocksProps'){
4118
+
4119
+                                if ( isset($new_args['if_inner_element']) ) {
4120
+                                    $element = $new_args['if_inner_element'];
4121
+                                }else {
4122
+                                    $element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4123
+                                }
4124
+
4125
+                                unset($new_args['inner_element']);
4126
+                                echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4127
+                                echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4128
+
4129
+
4130
+                                // echo "} ),";
4131
+
4132
+                            }else{
4133
+                                echo "\n el( '" . $new_args['element'] . "', {";
4134
+                            }
4135
+
4136
+
4137
+                            // get the attributes
4138
+                            foreach ( $new_args as $new_key => $new_value ) {
4139
+
4140
+
4141
+                                if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4142
+                                    // do nothing
4143
+                                } else {
4144
+                                    echo $this->block_element( array( $new_key => $new_value ),$save );
4145
+                                }
4146
+                            }
4147
+
4148
+                            echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4149
+
4150
+                            // get the content
4151
+                            $first_item = 0;
4152
+                            foreach ( $new_args as $new_key => $new_value ) {
4153
+                                if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4154
+
4155
+                                    if ( $new_key === 'content' ) {
4156
+                                        echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4157
+                                    }else if ( $new_key === 'if_content' ) {
4158
+                                        echo  $this->block_props_replace(  $new_value  );
4159
+                                    }
4160
+
4161
+                                    if ( is_array( $new_value ) ) {
4162
+
4163
+                                        if ( isset( $new_value['element_require'] ) ) {
4164
+                                            echo str_replace( array(
4165
+                                                    "'+",
4166
+                                                    "+'"
4167
+                                                ), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4168
+                                            unset( $new_value['element_require'] );
4169
+                                        }
4170
+
4171
+                                        if ( isset( $new_value['element_repeat'] ) ) {
4172
+                                            $x = 1;
4173
+                                            while ( $x <= absint( $new_value['element_repeat'] ) ) {
4174
+                                                $this->block_element( array( '' => $new_value ),$save );
4175
+                                                $x ++;
4176
+                                            }
4177
+                                        } else {
4178
+                                            $this->block_element( array( '' => $new_value ),$save );
4179
+                                        }
4180
+                                    }
4181
+                                    $first_item ++;
4182
+                                }
4183
+                            }
4184
+
4185
+                            if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4186
+                                echo "))";// end content
4187
+                            }else{
4188
+                                echo ")";// end content
4189
+                            }
4190
+
4191
+
4192
+                            echo ", \n";
4193
+
4194
+                        }
4195
+                    } else {
4196
+
4197
+                        if ( substr( $element, 0, 3 ) === "if_" ) {
4198
+                            $extra = '';
4199
+                            if( strpos($new_args, '[%WrapClass%]') !== false ){
4200
+                                $new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4201
+                                $new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4202
+                            }
4203
+                            echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4204
+                        } elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4205
+                            $new_args = str_replace('[%WrapStyle%]','',$new_args);
4206
+                            echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4207 4207
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4208
-						} elseif ( $element == 'style' ) {
4209
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4210
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4211
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4212
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4213
-						} elseif ( $element == 'template' && $new_args ) {
4214
-							echo $element . ": $new_args,";
4215
-						} else {
4216
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4217
-						}
4218
-
4219
-					}
4220
-				}
4221
-			}
4222
-		}
4223
-
4224
-		/**
4225
-		 * Replace block attributes placeholders with the proper naming.
4226
-		 *
4227
-		 * @param $string
4228
-		 *
4229
-		 * @return mixed
4230
-		 */
4231
-		public function block_props_replace( $string, $no_wrap = false ) {
4232
-			if ( $no_wrap ) {
4233
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4234
-			} else {
4235
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4236
-			}
4237
-
4238
-			return $string;
4239
-		}
4240
-
4241
-		/**
4242
-		 * Outputs the content of the widget
4243
-		 *
4244
-		 * @param array $args
4245
-		 * @param array $instance
4246
-		 */
4247
-		public function widget( $args, $instance ) {
4248
-			if ( ! is_array( $args ) ) {
4249
-				$args = array();
4250
-			}
4251
-
4252
-			// Get the filtered values
4253
-			$argument_values = $this->argument_values( $instance );
4254
-			$argument_values = $this->string_to_bool( $argument_values );
4255
-			$output          = $this->output( $argument_values, $args );
4256
-
4257
-			$no_wrap = false;
4258
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4259
-				$no_wrap = true;
4260
-			}
4261
-
4262
-			ob_start();
4263
-			if ( $output && ! $no_wrap ) {
4264
-
4265
-				$class_original = $this->options['widget_ops']['classname'];
4266
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4267
-
4268
-				// Before widget
4269
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4270
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4271
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4272
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4273
-
4274
-				// After widget
4275
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4276
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4277
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4278
-
4279
-				echo $before_widget;
4280
-				// elementor strips the widget wrapping div so we check for and add it back if needed
4281
-				if ( $this->is_elementor_widget_output() ) {
4282
-					// Filter class & attrs for elementor widget output.
4283
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4284
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4285
-
4286
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4287
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4288
-
4289
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4290
-				}
4291
-				echo $this->output_title( $args, $instance );
4292
-				echo $output;
4293
-				if ( $this->is_elementor_widget_output() ) {
4294
-					echo "</span>";
4295
-				}
4296
-				echo $after_widget;
4297
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4298
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4299
-				echo $output;
4300
-			} elseif ( $output && $no_wrap ) {
4301
-				echo $output;
4302
-			}
4303
-			$output = ob_get_clean();
4304
-
4305
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4208
+                        } elseif ( $element == 'style' ) {
4209
+                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4210
+                        } elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4211
+                            $new_args = str_replace('[%WrapClass%]','',$new_args);
4212
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4213
+                        } elseif ( $element == 'template' && $new_args ) {
4214
+                            echo $element . ": $new_args,";
4215
+                        } else {
4216
+                            echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4217
+                        }
4218
+
4219
+                    }
4220
+                }
4221
+            }
4222
+        }
4306 4223
 
4307
-			echo $output;
4308
-		}
4224
+        /**
4225
+         * Replace block attributes placeholders with the proper naming.
4226
+         *
4227
+         * @param $string
4228
+         *
4229
+         * @return mixed
4230
+         */
4231
+        public function block_props_replace( $string, $no_wrap = false ) {
4232
+            if ( $no_wrap ) {
4233
+                $string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4234
+            } else {
4235
+                $string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4236
+            }
4237
+
4238
+            return $string;
4239
+        }
4309 4240
 
4310
-		/**
4311
-		 * Tests if the current output is inside a elementor container.
4312
-		 *
4313
-		 * @return bool
4314
-		 *@since 1.0.4
4315
-		 */
4316
-		public function is_elementor_widget_output() {
4317
-			$result = false;
4318
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4319
-				$result = true;
4320
-			}
4241
+        /**
4242
+         * Outputs the content of the widget
4243
+         *
4244
+         * @param array $args
4245
+         * @param array $instance
4246
+         */
4247
+        public function widget( $args, $instance ) {
4248
+            if ( ! is_array( $args ) ) {
4249
+                $args = array();
4250
+            }
4251
+
4252
+            // Get the filtered values
4253
+            $argument_values = $this->argument_values( $instance );
4254
+            $argument_values = $this->string_to_bool( $argument_values );
4255
+            $output          = $this->output( $argument_values, $args );
4256
+
4257
+            $no_wrap = false;
4258
+            if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4259
+                $no_wrap = true;
4260
+            }
4261
+
4262
+            ob_start();
4263
+            if ( $output && ! $no_wrap ) {
4264
+
4265
+                $class_original = $this->options['widget_ops']['classname'];
4266
+                $class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4267
+
4268
+                // Before widget
4269
+                $before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4270
+                $before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4271
+                $before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4272
+                $before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4273
+
4274
+                // After widget
4275
+                $after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4276
+                $after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4277
+                $after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4278
+
4279
+                echo $before_widget;
4280
+                // elementor strips the widget wrapping div so we check for and add it back if needed
4281
+                if ( $this->is_elementor_widget_output() ) {
4282
+                    // Filter class & attrs for elementor widget output.
4283
+                    $class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4284
+                    $class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4285
+
4286
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4287
+                    $attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4288
+
4289
+                    echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4290
+                }
4291
+                echo $this->output_title( $args, $instance );
4292
+                echo $output;
4293
+                if ( $this->is_elementor_widget_output() ) {
4294
+                    echo "</span>";
4295
+                }
4296
+                echo $after_widget;
4297
+            } elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4298
+                $output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4299
+                echo $output;
4300
+            } elseif ( $output && $no_wrap ) {
4301
+                echo $output;
4302
+            }
4303
+            $output = ob_get_clean();
4304
+
4305
+            $output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4306
+
4307
+            echo $output;
4308
+        }
4321 4309
 
4322
-			return $result;
4323
-		}
4310
+        /**
4311
+         * Tests if the current output is inside a elementor container.
4312
+         *
4313
+         * @return bool
4314
+         *@since 1.0.4
4315
+         */
4316
+        public function is_elementor_widget_output() {
4317
+            $result = false;
4318
+            if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4319
+                $result = true;
4320
+            }
4324 4321
 
4325
-		/**
4326
-		 * Tests if the current output is inside a elementor preview.
4327
-		 *
4328
-		 * @return bool
4329
-		 *@since 1.0.4
4330
-		 */
4331
-		public function is_elementor_preview() {
4332
-			$result = false;
4333
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4334
-				$result = true;
4335
-			}
4322
+            return $result;
4323
+        }
4336 4324
 
4337
-			return $result;
4338
-		}
4325
+        /**
4326
+         * Tests if the current output is inside a elementor preview.
4327
+         *
4328
+         * @return bool
4329
+         *@since 1.0.4
4330
+         */
4331
+        public function is_elementor_preview() {
4332
+            $result = false;
4333
+            if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4334
+                $result = true;
4335
+            }
4339 4336
 
4340
-		/**
4341
-		 * Tests if the current output is inside a Divi preview.
4342
-		 *
4343
-		 * @return bool
4344
-		 *@since 1.0.6
4345
-		 */
4346
-		public function is_divi_preview() {
4347
-			$result = false;
4348
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4349
-				$result = true;
4350
-			}
4337
+            return $result;
4338
+        }
4351 4339
 
4352
-			return $result;
4353
-		}
4340
+        /**
4341
+         * Tests if the current output is inside a Divi preview.
4342
+         *
4343
+         * @return bool
4344
+         *@since 1.0.6
4345
+         */
4346
+        public function is_divi_preview() {
4347
+            $result = false;
4348
+            if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4349
+                $result = true;
4350
+            }
4354 4351
 
4355
-		/**
4356
-		 * Tests if the current output is inside a Beaver builder preview.
4357
-		 *
4358
-		 * @return bool
4359
-		 *@since 1.0.6
4360
-		 */
4361
-		public function is_beaver_preview() {
4362
-			$result = false;
4363
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4364
-				$result = true;
4365
-			}
4352
+            return $result;
4353
+        }
4366 4354
 
4367
-			return $result;
4368
-		}
4355
+        /**
4356
+         * Tests if the current output is inside a Beaver builder preview.
4357
+         *
4358
+         * @return bool
4359
+         *@since 1.0.6
4360
+         */
4361
+        public function is_beaver_preview() {
4362
+            $result = false;
4363
+            if ( isset( $_REQUEST['fl_builder'] ) ) {
4364
+                $result = true;
4365
+            }
4369 4366
 
4370
-		/**
4371
-		 * Tests if the current output is inside a siteorigin builder preview.
4372
-		 *
4373
-		 * @return bool
4374
-		 *@since 1.0.6
4375
-		 */
4376
-		public function is_siteorigin_preview() {
4377
-			$result = false;
4378
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4379
-				$result = true;
4380
-			}
4367
+            return $result;
4368
+        }
4381 4369
 
4382
-			return $result;
4383
-		}
4370
+        /**
4371
+         * Tests if the current output is inside a siteorigin builder preview.
4372
+         *
4373
+         * @return bool
4374
+         *@since 1.0.6
4375
+         */
4376
+        public function is_siteorigin_preview() {
4377
+            $result = false;
4378
+            if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4379
+                $result = true;
4380
+            }
4384 4381
 
4385
-		/**
4386
-		 * Tests if the current output is inside a cornerstone builder preview.
4387
-		 *
4388
-		 * @return bool
4389
-		 *@since 1.0.8
4390
-		 */
4391
-		public function is_cornerstone_preview() {
4392
-			$result = false;
4393
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4394
-				$result = true;
4395
-			}
4382
+            return $result;
4383
+        }
4396 4384
 
4397
-			return $result;
4398
-		}
4385
+        /**
4386
+         * Tests if the current output is inside a cornerstone builder preview.
4387
+         *
4388
+         * @return bool
4389
+         *@since 1.0.8
4390
+         */
4391
+        public function is_cornerstone_preview() {
4392
+            $result = false;
4393
+            if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4394
+                $result = true;
4395
+            }
4399 4396
 
4400
-		/**
4401
-		 * Tests if the current output is inside a fusion builder preview.
4402
-		 *
4403
-		 * @return bool
4404
-		 *@since 1.1.0
4405
-		 */
4406
-		public function is_fusion_preview() {
4407
-			$result = false;
4408
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4409
-				$result = true;
4410
-			}
4397
+            return $result;
4398
+        }
4411 4399
 
4412
-			return $result;
4413
-		}
4400
+        /**
4401
+         * Tests if the current output is inside a fusion builder preview.
4402
+         *
4403
+         * @return bool
4404
+         *@since 1.1.0
4405
+         */
4406
+        public function is_fusion_preview() {
4407
+            $result = false;
4408
+            if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4409
+                $result = true;
4410
+            }
4414 4411
 
4415
-		/**
4416
-		 * Tests if the current output is inside a Oxygen builder preview.
4417
-		 *
4418
-		 * @return bool
4419
-		 *@since 1.0.18
4420
-		 */
4421
-		public function is_oxygen_preview() {
4422
-			$result = false;
4423
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4424
-				$result = true;
4425
-			}
4412
+            return $result;
4413
+        }
4426 4414
 
4427
-			return $result;
4428
-		}
4415
+        /**
4416
+         * Tests if the current output is inside a Oxygen builder preview.
4417
+         *
4418
+         * @return bool
4419
+         *@since 1.0.18
4420
+         */
4421
+        public function is_oxygen_preview() {
4422
+            $result = false;
4423
+            if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4424
+                $result = true;
4425
+            }
4429 4426
 
4430
-		/**
4431
-		 * Check for Kallyas theme Zion builder preview.
4432
-		 *
4433
-		 * @since 1.1.22
4434
-		 *
4435
-		 * @return bool True when preview page otherwise false.
4436
-		 */
4437
-		public function is_kallyas_zion_preview() {
4438
-			$result = false;
4439
-
4440
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4441
-				$result = true;
4442
-			}
4427
+            return $result;
4428
+        }
4443 4429
 
4444
-			return $result;
4445
-		}
4430
+        /**
4431
+         * Check for Kallyas theme Zion builder preview.
4432
+         *
4433
+         * @since 1.1.22
4434
+         *
4435
+         * @return bool True when preview page otherwise false.
4436
+         */
4437
+        public function is_kallyas_zion_preview() {
4438
+            $result = false;
4446 4439
 
4447
-		/**
4448
-		 * Check for Bricks theme builder preview.
4449
-		 *
4450
-		 * @since 1.1.31
4451
-		 *
4452
-		 * @return bool True when preview page otherwise false.
4453
-		 */
4454
-		public function is_bricks_preview() {
4455
-			$result = false;
4456
-
4457
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4458
-				$result = true;
4459
-			}
4440
+            if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4441
+                $result = true;
4442
+            }
4460 4443
 
4461
-			return $result;
4462
-		}
4444
+            return $result;
4445
+        }
4463 4446
 
4464
-		/**
4465
-		 * General function to check if we are in a preview situation.
4466
-		 *
4467
-		 * @return bool
4468
-		 *@since 1.0.6
4469
-		 */
4470
-		public function is_preview() {
4471
-			$preview = false;
4472
-			if ( $this->is_divi_preview() ) {
4473
-				$preview = true;
4474
-			} elseif ( $this->is_elementor_preview() ) {
4475
-				$preview = true;
4476
-			} elseif ( $this->is_beaver_preview() ) {
4477
-				$preview = true;
4478
-			} elseif ( $this->is_siteorigin_preview() ) {
4479
-				$preview = true;
4480
-			} elseif ( $this->is_cornerstone_preview() ) {
4481
-				$preview = true;
4482
-			} elseif ( $this->is_fusion_preview() ) {
4483
-				$preview = true;
4484
-			} elseif ( $this->is_oxygen_preview() ) {
4485
-				$preview = true;
4486
-			} elseif( $this->is_kallyas_zion_preview() ) {
4487
-				$preview = true;
4488
-			} elseif( $this->is_block_content_call() ) {
4489
-				$preview = true;
4490
-			} elseif( $this->is_bricks_preview() ) {
4491
-				$preview = true;
4492
-			}
4447
+        /**
4448
+         * Check for Bricks theme builder preview.
4449
+         *
4450
+         * @since 1.1.31
4451
+         *
4452
+         * @return bool True when preview page otherwise false.
4453
+         */
4454
+        public function is_bricks_preview() {
4455
+            $result = false;
4493 4456
 
4494
-			return $preview;
4495
-		}
4457
+            if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4458
+                $result = true;
4459
+            }
4496 4460
 
4497
-		/**
4498
-		 * Output the super title.
4499
-		 *
4500
-		 * @param $args
4501
-		 * @param array $instance
4502
-		 *
4503
-		 * @return string
4504
-		 */
4505
-		public function output_title( $args, $instance = array() ) {
4506
-			$output = '';
4507
-			if ( ! empty( $instance['title'] ) ) {
4508
-				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4509
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4510
-
4511
-				if ( empty( $instance['widget_title_tag'] ) ) {
4512
-					if ( ! isset( $args['before_title'] ) ) {
4513
-						$args['before_title'] = '';
4514
-					}
4461
+            return $result;
4462
+        }
4515 4463
 
4516
-					if ( ! isset( $args['after_title'] ) ) {
4517
-						$args['after_title'] = '';
4518
-					}
4464
+        /**
4465
+         * General function to check if we are in a preview situation.
4466
+         *
4467
+         * @return bool
4468
+         *@since 1.0.6
4469
+         */
4470
+        public function is_preview() {
4471
+            $preview = false;
4472
+            if ( $this->is_divi_preview() ) {
4473
+                $preview = true;
4474
+            } elseif ( $this->is_elementor_preview() ) {
4475
+                $preview = true;
4476
+            } elseif ( $this->is_beaver_preview() ) {
4477
+                $preview = true;
4478
+            } elseif ( $this->is_siteorigin_preview() ) {
4479
+                $preview = true;
4480
+            } elseif ( $this->is_cornerstone_preview() ) {
4481
+                $preview = true;
4482
+            } elseif ( $this->is_fusion_preview() ) {
4483
+                $preview = true;
4484
+            } elseif ( $this->is_oxygen_preview() ) {
4485
+                $preview = true;
4486
+            } elseif( $this->is_kallyas_zion_preview() ) {
4487
+                $preview = true;
4488
+            } elseif( $this->is_block_content_call() ) {
4489
+                $preview = true;
4490
+            } elseif( $this->is_bricks_preview() ) {
4491
+                $preview = true;
4492
+            }
4493
+
4494
+            return $preview;
4495
+        }
4519 4496
 
4520
-					$output = $args['before_title'] . $title . $args['after_title'];
4521
-				} else {
4522
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4523
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4524
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4525
-
4526
-					// classes
4527
-					$title_classes = array();
4528
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4529
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4530
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4531
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4532
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4533
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4534
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4535
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4536
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4537
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4538
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4539
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4540
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4541
-
4542
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4543
-					$output = "<$title_tag class='$class' >$title</$title_tag>";
4544
-				}
4497
+        /**
4498
+         * Output the super title.
4499
+         *
4500
+         * @param $args
4501
+         * @param array $instance
4502
+         *
4503
+         * @return string
4504
+         */
4505
+        public function output_title( $args, $instance = array() ) {
4506
+            $output = '';
4507
+            if ( ! empty( $instance['title'] ) ) {
4508
+                /** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4509
+                $title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4510
+
4511
+                if ( empty( $instance['widget_title_tag'] ) ) {
4512
+                    if ( ! isset( $args['before_title'] ) ) {
4513
+                        $args['before_title'] = '';
4514
+                    }
4515
+
4516
+                    if ( ! isset( $args['after_title'] ) ) {
4517
+                        $args['after_title'] = '';
4518
+                    }
4519
+
4520
+                    $output = $args['before_title'] . $title . $args['after_title'];
4521
+                } else {
4522
+                    $tag 			= esc_attr( $instance['widget_title_tag'] );
4523
+                    $allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4524
+                    $title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4525
+
4526
+                    // classes
4527
+                    $title_classes = array();
4528
+                    $title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4529
+                    $title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4530
+                    $title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4531
+                    $title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4532
+                    $title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4533
+                    $title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4534
+                    $title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4535
+                    $title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4536
+                    $title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4537
+                    $title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4538
+                    $title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4539
+                    $title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4540
+                    $title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4541
+
4542
+                    $class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4543
+                    $output = "<$title_tag class='$class' >$title</$title_tag>";
4544
+                }
4545 4545
 
4546
-			}
4546
+            }
4547 4547
 
4548
-			return $output;
4549
-		}
4548
+            return $output;
4549
+        }
4550 4550
 
4551
-		/**
4552
-		 * Outputs the options form inputs for the widget.
4553
-		 *
4554
-		 * @param array $instance The widget options.
4555
-		 */
4556
-		public function form( $instance ) {
4551
+        /**
4552
+         * Outputs the options form inputs for the widget.
4553
+         *
4554
+         * @param array $instance The widget options.
4555
+         */
4556
+        public function form( $instance ) {
4557 4557
 
4558
-			// set widget instance
4559
-			$this->instance = $instance;
4558
+            // set widget instance
4559
+            $this->instance = $instance;
4560 4560
 
4561
-			// set it as a SD widget
4562
-			echo $this->widget_advanced_toggle();
4561
+            // set it as a SD widget
4562
+            echo $this->widget_advanced_toggle();
4563 4563
 
4564
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4565
-			$arguments_raw = $this->get_arguments();
4564
+            echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4565
+            $arguments_raw = $this->get_arguments();
4566 4566
 
4567
-			if ( is_array( $arguments_raw ) ) {
4567
+            if ( is_array( $arguments_raw ) ) {
4568 4568
 
4569
-				$arguments = $this->group_arguments( $arguments_raw );
4569
+                $arguments = $this->group_arguments( $arguments_raw );
4570 4570
 
4571
-				// Do we have sections?
4572
-				$has_sections = $arguments == $arguments_raw ? false : true;
4571
+                // Do we have sections?
4572
+                $has_sections = $arguments == $arguments_raw ? false : true;
4573 4573
 
4574 4574
 
4575
-				if ( $has_sections ) {
4576
-					$panel_count = 0;
4577
-					foreach ( $arguments as $key => $args ) {
4575
+                if ( $has_sections ) {
4576
+                    $panel_count = 0;
4577
+                    foreach ( $arguments as $key => $args ) {
4578 4578
 
4579
-						?>
4579
+                        ?>
4580 4580
 						<script>
4581 4581
 							//							jQuery(this).find("i").toggleClass("fas fa-chevron-up fas fa-chevron-down");jQuery(this).next().toggle();
4582 4582
 						</script>
4583 4583
 						<?php
4584 4584
 
4585
-						$hide       = $panel_count ? ' style="display:none;" ' : '';
4586
-						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4587
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4588
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4585
+                        $hide       = $panel_count ? ' style="display:none;" ' : '';
4586
+                        $icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4587
+                        echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4588
+                        echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4589 4589
 
4590
-						foreach ( $args as $k => $a ) {
4590
+                        foreach ( $args as $k => $a ) {
4591 4591
 
4592
-							$this->widget_inputs_row_start($k, $a);
4593
-							$this->widget_inputs( $a, $instance );
4594
-							$this->widget_inputs_row_end($k, $a);
4592
+                            $this->widget_inputs_row_start($k, $a);
4593
+                            $this->widget_inputs( $a, $instance );
4594
+                            $this->widget_inputs_row_end($k, $a);
4595 4595
 
4596
-						}
4596
+                        }
4597 4597
 
4598
-						echo "</div>";
4598
+                        echo "</div>";
4599 4599
 
4600
-						$panel_count ++;
4600
+                        $panel_count ++;
4601 4601
 
4602
-					}
4603
-				} else {
4604
-					foreach ( $arguments as $key => $args ) {
4605
-						$this->widget_inputs_row_start($key, $args);
4606
-						$this->widget_inputs( $args, $instance );
4607
-						$this->widget_inputs_row_end($key, $args);
4608
-					}
4609
-				}
4602
+                    }
4603
+                } else {
4604
+                    foreach ( $arguments as $key => $args ) {
4605
+                        $this->widget_inputs_row_start($key, $args);
4606
+                        $this->widget_inputs( $args, $instance );
4607
+                        $this->widget_inputs_row_end($key, $args);
4608
+                    }
4609
+                }
4610 4610
 
4611
-			}
4612
-		}
4611
+            }
4612
+        }
4613 4613
 
4614
-		public function widget_inputs_row_start( $key, $args ) {
4615
-			if ( ! empty( $args['row'] ) ) {
4616
-				// Maybe open
4617
-				if ( ! empty( $args['row']['open'] ) ) {
4618
-					?>
4614
+        public function widget_inputs_row_start( $key, $args ) {
4615
+            if ( ! empty( $args['row'] ) ) {
4616
+                // Maybe open
4617
+                if ( ! empty( $args['row']['open'] ) ) {
4618
+                    ?>
4619 4619
 					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4620 4620
 					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4621 4621
 					<?php
4622
-						if ( isset( $args['row']['icon'] ) ) {
4623
-							$args['row']['icon'] = '';
4624
-						}
4625
-
4626
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4627
-							$args['row']['device_type'] = $args['device_type'];
4628
-						}
4629
-					?>
4622
+                        if ( isset( $args['row']['icon'] ) ) {
4623
+                            $args['row']['icon'] = '';
4624
+                        }
4625
+
4626
+                        if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4627
+                            $args['row']['device_type'] = $args['device_type'];
4628
+                        }
4629
+                    ?>
4630 4630
 					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4631 4631
 					<?php } ?>
4632 4632
 					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4633 4633
 					<div class='col pr-2'>
4634 4634
 					<?php
4635
-				} else if ( ! empty( $args['row']['close'] ) ) {
4636
-					echo "<div class='col pl-0 ps-0'>";
4637
-				} else {
4638
-					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4639
-				}
4640
-			}
4641
-		}
4642
-
4643
-		public function widget_inputs_row_end( $key, $args ) {
4644
-			if ( ! empty( $args['row'] ) ) {
4645
-				// Maybe close
4646
-				if ( ! empty( $args['row']['close'] ) ) {
4647
-					echo "</div></div>";
4648
-				}
4649
-				echo "</div>";
4650
-			}
4651
-		}
4652
-
4653
-		/**
4654
-		 * Get the hidden input that when added makes the advanced button show on widget settings.
4655
-		 *
4656
-		 * @return string
4657
-		 */
4658
-		public function widget_advanced_toggle() {
4659
-
4660
-			$output = '';
4661
-			if ( $this->block_show_advanced() ) {
4662
-				$val = 1;
4663
-			} else {
4664
-				$val = 0;
4665
-			}
4635
+                } else if ( ! empty( $args['row']['close'] ) ) {
4636
+                    echo "<div class='col pl-0 ps-0'>";
4637
+                } else {
4638
+                    echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
4639
+                }
4640
+            }
4641
+        }
4666 4642
 
4667
-			$output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4643
+        public function widget_inputs_row_end( $key, $args ) {
4644
+            if ( ! empty( $args['row'] ) ) {
4645
+                // Maybe close
4646
+                if ( ! empty( $args['row']['close'] ) ) {
4647
+                    echo "</div></div>";
4648
+                }
4649
+                echo "</div>";
4650
+            }
4651
+        }
4668 4652
 
4669
-			return $output;
4670
-		}
4653
+        /**
4654
+         * Get the hidden input that when added makes the advanced button show on widget settings.
4655
+         *
4656
+         * @return string
4657
+         */
4658
+        public function widget_advanced_toggle() {
4671 4659
 
4672
-		/**
4673
-		 * Convert require element.
4674
-		 *
4675
-		 * @param string $input Input element.
4676
-		 *
4677
-		 * @return string $output
4678
-		 *@since 1.0.0
4679
-		 *
4680
-		 */
4681
-		public function convert_element_require( $input ) {
4682
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4683
-
4684
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4685
-				"jQuery(form).find('[data-argument=\"",
4686
-				"\"]').find('input,select,textarea').val()",
4687
-				"\"]').find('input:checked').val()"
4688
-			), $input ) );
4689
-
4690
-			return $output;
4691
-		}
4660
+            $output = '';
4661
+            if ( $this->block_show_advanced() ) {
4662
+                $val = 1;
4663
+            } else {
4664
+                $val = 0;
4665
+            }
4692 4666
 
4693
-		/**
4694
-		 * Builds the inputs for the widget options.
4695
-		 *
4696
-		 * @param $args
4697
-		 * @param $instance
4698
-		 */
4699
-		public function widget_inputs( $args, $instance ) {
4700
-
4701
-			$class             = "";
4702
-			$element_require   = "";
4703
-			$custom_attributes = "";
4704
-
4705
-			// get value
4706
-			if ( isset( $instance[ $args['name'] ] ) ) {
4707
-				$value = $instance[ $args['name'] ];
4708
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4709
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4710
-			} else {
4711
-				$value = '';
4712
-			}
4667
+            $output .= "<input type='hidden'  class='sd-show-advanced' value='$val' />";
4713 4668
 
4714
-			// get placeholder
4715
-			if ( ! empty( $args['placeholder'] ) ) {
4716
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4717
-			} else {
4718
-				$placeholder = '';
4719
-			}
4669
+            return $output;
4670
+        }
4720 4671
 
4721
-			// get if advanced
4722
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4723
-				$class .= " sd-advanced-setting ";
4724
-			}
4672
+        /**
4673
+         * Convert require element.
4674
+         *
4675
+         * @param string $input Input element.
4676
+         *
4677
+         * @return string $output
4678
+         *@since 1.0.0
4679
+         *
4680
+         */
4681
+        public function convert_element_require( $input ) {
4682
+            $input = str_replace( "'", '"', $input );// we only want double quotes
4725 4683
 
4726
-			// element_require
4727
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4728
-				$element_require = $args['element_require'];
4729
-			}
4684
+            $output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4685
+                "jQuery(form).find('[data-argument=\"",
4686
+                "\"]').find('input,select,textarea').val()",
4687
+                "\"]').find('input:checked').val()"
4688
+            ), $input ) );
4730 4689
 
4731
-			// custom_attributes
4732
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4733
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4734
-			}
4690
+            return $output;
4691
+        }
4735 4692
 
4736
-			// before wrapper
4737
-			?>
4693
+        /**
4694
+         * Builds the inputs for the widget options.
4695
+         *
4696
+         * @param $args
4697
+         * @param $instance
4698
+         */
4699
+        public function widget_inputs( $args, $instance ) {
4700
+
4701
+            $class             = "";
4702
+            $element_require   = "";
4703
+            $custom_attributes = "";
4704
+
4705
+            // get value
4706
+            if ( isset( $instance[ $args['name'] ] ) ) {
4707
+                $value = $instance[ $args['name'] ];
4708
+            } elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4709
+                $value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4710
+            } else {
4711
+                $value = '';
4712
+            }
4713
+
4714
+            // get placeholder
4715
+            if ( ! empty( $args['placeholder'] ) ) {
4716
+                $placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4717
+            } else {
4718
+                $placeholder = '';
4719
+            }
4720
+
4721
+            // get if advanced
4722
+            if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4723
+                $class .= " sd-advanced-setting ";
4724
+            }
4725
+
4726
+            // element_require
4727
+            if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4728
+                $element_require = $args['element_require'];
4729
+            }
4730
+
4731
+            // custom_attributes
4732
+            if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4733
+                $custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4734
+            }
4735
+
4736
+            // before wrapper
4737
+            ?>
4738 4738
 			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4739 4739
 			<?php
4740
-			switch ( $args['type'] ) {
4741
-				//array('text','password','number','email','tel','url','color')
4742
-				case "text":
4743
-				case "password":
4744
-				case "number":
4745
-				case "email":
4746
-				case "tel":
4747
-				case "url":
4748
-				case "color":
4749
-					?>
4740
+            switch ( $args['type'] ) {
4741
+                //array('text','password','number','email','tel','url','color')
4742
+                case "text":
4743
+                case "password":
4744
+                case "number":
4745
+                case "email":
4746
+                case "tel":
4747
+                case "url":
4748
+                case "color":
4749
+                    ?>
4750 4750
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4751 4751
 					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>">
4752 4752
 					<?php
4753 4753
 
4754
-					break;
4755
-				case "select":
4756
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4757
-					if ( $multiple ) {
4758
-						if ( empty( $value ) ) {
4759
-							$value = array();
4760
-						}
4761
-					}
4762
-					?>
4754
+                    break;
4755
+                case "select":
4756
+                    $multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4757
+                    if ( $multiple ) {
4758
+                        if ( empty( $value ) ) {
4759
+                            $value = array();
4760
+                        }
4761
+                    }
4762
+                    ?>
4763 4763
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4764 4764
 					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>"
4765 4765
 						<?php if ( $multiple ) {
4766
-							echo "multiple";
4767
-						} //@todo not implemented yet due to gutenberg not supporting it
4768
-						?>>
4766
+                            echo "multiple";
4767
+                        } //@todo not implemented yet due to gutenberg not supporting it
4768
+                        ?>>
4769 4769
 						<?php
4770 4770
 
4771
-						if ( ! empty( $args['options'] ) ) {
4772
-							foreach ( $args['options'] as $val => $label ) {
4773
-								if ( $multiple ) {
4774
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4775
-								} else {
4776
-									$selected = selected( $value, $val, false );
4777
-								}
4778
-								echo "<option value='$val' " . $selected . ">$label</option>";
4779
-							}
4780
-						}
4781
-						?>
4771
+                        if ( ! empty( $args['options'] ) ) {
4772
+                            foreach ( $args['options'] as $val => $label ) {
4773
+                                if ( $multiple ) {
4774
+                                    $selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4775
+                                } else {
4776
+                                    $selected = selected( $value, $val, false );
4777
+                                }
4778
+                                echo "<option value='$val' " . $selected . ">$label</option>";
4779
+                            }
4780
+                        }
4781
+                        ?>
4782 4782
 					</select>
4783 4783
 					<?php
4784
-					break;
4785
-				case "checkbox":
4786
-					?>
4784
+                    break;
4785
+                case "checkbox":
4786
+                    ?>
4787 4787
 					<input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1">
4788 4788
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4789 4789
 					<?php
4790
-					break;
4791
-				case "textarea":
4792
-					?>
4790
+                    break;
4791
+                case "textarea":
4792
+                    ?>
4793 4793
 					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4794 4794
 					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea>
4795 4795
 					<?php
4796 4796
 
4797
-					break;
4798
-				case "hidden":
4799
-					?>
4797
+                    break;
4798
+                case "hidden":
4799
+                    ?>
4800 4800
 					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>">
4801 4801
 					<?php
4802
-					break;
4803
-				default:
4804
-					echo "No input type found!"; // @todo we need to add more input types.
4805
-			}
4806
-			// after wrapper
4807
-			?></p><?php
4808
-		}
4802
+                    break;
4803
+                default:
4804
+                    echo "No input type found!"; // @todo we need to add more input types.
4805
+            }
4806
+            // after wrapper
4807
+            ?></p><?php
4808
+        }
4809 4809
 
4810
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4811
-			if($icon=='box-top'){
4812
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4813
-			}elseif($icon=='box-right'){
4814
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4815
-			}elseif($icon=='box-bottom'){
4816
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4817
-			}elseif($icon=='box-left'){
4818
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4819
-			}
4820
-		}
4810
+        public function get_widget_icon($icon = 'box-top', $title = ''){
4811
+            if($icon=='box-top'){
4812
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4813
+            }elseif($icon=='box-right'){
4814
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4815
+            }elseif($icon=='box-bottom'){
4816
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4817
+            }elseif($icon=='box-left'){
4818
+                return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4819
+            }
4820
+        }
4821 4821
 
4822
-		/**
4823
-		 * Get the widget input description html.
4824
-		 *
4825
-		 * @param $args
4826
-		 *
4827
-		 * @return string
4828
-		 * @todo, need to make its own tooltip script
4829
-		 */
4830
-		public function widget_field_desc( $args ) {
4831
-
4832
-			$description = '';
4833
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4834
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4835
-					$description = $this->desc_tip( $args['desc'] );
4836
-				} else {
4837
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4838
-				}
4839
-			}
4822
+        /**
4823
+         * Get the widget input description html.
4824
+         *
4825
+         * @param $args
4826
+         *
4827
+         * @return string
4828
+         * @todo, need to make its own tooltip script
4829
+         */
4830
+        public function widget_field_desc( $args ) {
4831
+
4832
+            $description = '';
4833
+            if ( isset( $args['desc'] ) && $args['desc'] ) {
4834
+                if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4835
+                    $description = $this->desc_tip( $args['desc'] );
4836
+                } else {
4837
+                    $description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4838
+                }
4839
+            }
4840 4840
 
4841
-			return $description;
4842
-		}
4841
+            return $description;
4842
+        }
4843 4843
 
4844
-		/**
4845
-		 * Get the widget input title html.
4846
-		 *
4847
-		 * @param $args
4848
-		 *
4849
-		 * @return string
4850
-		 */
4851
-		public function widget_field_title( $args ) {
4852
-			$title = '';
4853
-
4854
-			if ( isset( $args['title'] ) && $args['title'] ) {
4855
-				if ( ! empty( $args['device_type'] ) ) {
4856
-					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4857
-				}
4844
+        /**
4845
+         * Get the widget input title html.
4846
+         *
4847
+         * @param $args
4848
+         *
4849
+         * @return string
4850
+         */
4851
+        public function widget_field_title( $args ) {
4852
+            $title = '';
4858 4853
 
4859
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4860
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4861
-				} else {
4862
-					$title = esc_attr( $args['title'] );
4863
-				}
4864
-			}
4854
+            if ( isset( $args['title'] ) && $args['title'] ) {
4855
+                if ( ! empty( $args['device_type'] ) ) {
4856
+                    $args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4857
+                }
4865 4858
 
4866
-			return $title;
4867
-		}
4859
+                if ( isset( $args['icon'] ) && $args['icon'] ) {
4860
+                    $title = self::get_widget_icon( $args['icon'], $args['title']  );
4861
+                } else {
4862
+                    $title = esc_attr( $args['title'] );
4863
+                }
4864
+            }
4868 4865
 
4869
-		/**
4870
-		 * Get the tool tip html.
4871
-		 *
4872
-		 * @param $tip
4873
-		 * @param bool $allow_html
4874
-		 *
4875
-		 * @return string
4876
-		 */
4877
-		function desc_tip( $tip, $allow_html = false ) {
4878
-			if ( $allow_html ) {
4879
-				$tip = $this->sanitize_tooltip( $tip );
4880
-			} else {
4881
-				$tip = esc_attr( $tip );
4882
-			}
4866
+            return $title;
4867
+        }
4883 4868
 
4884
-			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4885
-		}
4869
+        /**
4870
+         * Get the tool tip html.
4871
+         *
4872
+         * @param $tip
4873
+         * @param bool $allow_html
4874
+         *
4875
+         * @return string
4876
+         */
4877
+        function desc_tip( $tip, $allow_html = false ) {
4878
+            if ( $allow_html ) {
4879
+                $tip = $this->sanitize_tooltip( $tip );
4880
+            } else {
4881
+                $tip = esc_attr( $tip );
4882
+            }
4883
+
4884
+            return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
4885
+        }
4886 4886
 
4887
-		/**
4888
-		 * Sanitize a string destined to be a tooltip.
4889
-		 *
4890
-		 * @param string $var
4891
-		 *
4892
-		 * @return string
4893
-		 */
4894
-		public function sanitize_tooltip( $var ) {
4895
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4896
-				'br'     => array(),
4897
-				'em'     => array(),
4898
-				'strong' => array(),
4899
-				'small'  => array(),
4900
-				'span'   => array(),
4901
-				'ul'     => array(),
4902
-				'li'     => array(),
4903
-				'ol'     => array(),
4904
-				'p'      => array(),
4905
-			) ) );
4906
-		}
4887
+        /**
4888
+         * Sanitize a string destined to be a tooltip.
4889
+         *
4890
+         * @param string $var
4891
+         *
4892
+         * @return string
4893
+         */
4894
+        public function sanitize_tooltip( $var ) {
4895
+            return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4896
+                'br'     => array(),
4897
+                'em'     => array(),
4898
+                'strong' => array(),
4899
+                'small'  => array(),
4900
+                'span'   => array(),
4901
+                'ul'     => array(),
4902
+                'li'     => array(),
4903
+                'ol'     => array(),
4904
+                'p'      => array(),
4905
+            ) ) );
4906
+        }
4907 4907
 
4908
-		/**
4909
-		 * Processing widget options on save
4910
-		 *
4911
-		 * @param array $new_instance The new options
4912
-		 * @param array $old_instance The previous options
4913
-		 *
4914
-		 * @return array
4915
-		 * @todo we should add some sanitation here.
4916
-		 */
4917
-		public function update( $new_instance, $old_instance ) {
4918
-
4919
-			//save the widget
4920
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4921
-
4922
-			// set widget instance
4923
-			$this->instance = $instance;
4924
-
4925
-			if ( empty( $this->arguments ) ) {
4926
-				$this->get_arguments();
4927
-			}
4908
+        /**
4909
+         * Processing widget options on save
4910
+         *
4911
+         * @param array $new_instance The new options
4912
+         * @param array $old_instance The previous options
4913
+         *
4914
+         * @return array
4915
+         * @todo we should add some sanitation here.
4916
+         */
4917
+        public function update( $new_instance, $old_instance ) {
4928 4918
 
4929
-			// check for checkboxes
4930
-			if ( ! empty( $this->arguments ) ) {
4931
-				foreach ( $this->arguments as $argument ) {
4932
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4933
-						$instance[ $argument['name'] ] = '0';
4934
-					}
4935
-				}
4936
-			}
4919
+            //save the widget
4920
+            $instance = array_merge( (array) $old_instance, (array) $new_instance );
4937 4921
 
4938
-			return $instance;
4939
-		}
4922
+            // set widget instance
4923
+            $this->instance = $instance;
4940 4924
 
4941
-		/**
4942
-		 * Checks if the current call is a ajax call to get the block content.
4943
-		 *
4944
-		 * This can be used in your widget to return different content as the block content.
4945
-		 *
4946
-		 * @return bool
4947
-		 *@since 1.0.3
4948
-		 */
4949
-		public function is_block_content_call() {
4950
-			$result = false;
4951
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4952
-				$result = true;
4953
-			}
4925
+            if ( empty( $this->arguments ) ) {
4926
+                $this->get_arguments();
4927
+            }
4954 4928
 
4955
-			return $result;
4956
-		}
4929
+            // check for checkboxes
4930
+            if ( ! empty( $this->arguments ) ) {
4931
+                foreach ( $this->arguments as $argument ) {
4932
+                    if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4933
+                        $instance[ $argument['name'] ] = '0';
4934
+                    }
4935
+                }
4936
+            }
4957 4937
 
4958
-		/**
4959
-		 * Get an instance hash that will be unique to the type and settings.
4960
-		 *
4961
-		 * @return string
4962
-		 *@since 1.0.20
4963
-		 */
4964
-		public function get_instance_hash(){
4965
-			$instance_string = $this->base_id.serialize($this->instance);
4966
-			return hash('crc32b',$instance_string);
4967
-		}
4938
+            return $instance;
4939
+        }
4968 4940
 
4969
-		/**
4970
-		 * Generate and return inline styles from CSS rules that will match the unique class of the instance.
4971
-		 *
4972
-		 * @param array $rules
4973
-		 *
4974
-		 * @return string
4975
-		 *@since 1.0.20
4976
-		 */
4977
-		public function get_instance_style($rules = array()){
4978
-			$css = '';
4979
-
4980
-			if(!empty($rules)){
4981
-				$rules = array_unique($rules);
4982
-				$instance_hash = $this->get_instance_hash();
4983
-				$css .= "<style>";
4984
-				foreach($rules as $rule){
4985
-					$css .= ".sdel-$instance_hash $rule";
4986
-				}
4987
-				$css .= "</style>";
4988
-			}
4941
+        /**
4942
+         * Checks if the current call is a ajax call to get the block content.
4943
+         *
4944
+         * This can be used in your widget to return different content as the block content.
4945
+         *
4946
+         * @return bool
4947
+         *@since 1.0.3
4948
+         */
4949
+        public function is_block_content_call() {
4950
+            $result = false;
4951
+            if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4952
+                $result = true;
4953
+            }
4989 4954
 
4990
-			return $css;
4991
-		}
4955
+            return $result;
4956
+        }
4957
+
4958
+        /**
4959
+         * Get an instance hash that will be unique to the type and settings.
4960
+         *
4961
+         * @return string
4962
+         *@since 1.0.20
4963
+         */
4964
+        public function get_instance_hash(){
4965
+            $instance_string = $this->base_id.serialize($this->instance);
4966
+            return hash('crc32b',$instance_string);
4967
+        }
4968
+
4969
+        /**
4970
+         * Generate and return inline styles from CSS rules that will match the unique class of the instance.
4971
+         *
4972
+         * @param array $rules
4973
+         *
4974
+         * @return string
4975
+         *@since 1.0.20
4976
+         */
4977
+        public function get_instance_style($rules = array()){
4978
+            $css = '';
4979
+
4980
+            if(!empty($rules)){
4981
+                $rules = array_unique($rules);
4982
+                $instance_hash = $this->get_instance_hash();
4983
+                $css .= "<style>";
4984
+                foreach($rules as $rule){
4985
+                    $css .= ".sdel-$instance_hash $rule";
4986
+                }
4987
+                $css .= "</style>";
4988
+            }
4989
+
4990
+            return $css;
4991
+        }
4992 4992
 
4993
-		/**
4994
-		 * Encode shortcodes tags.
4995
-		 *
4996
-		 * @param string $content Content to search for shortcode tags.
4997
-		 *
4993
+        /**
4994
+         * Encode shortcodes tags.
4995
+         *
4996
+         * @param string $content Content to search for shortcode tags.
4997
+         *
4998 4998
 *@return string Content with shortcode tags removed.
4999
-		 *@since 1.0.28
5000
-		 *
5001
-		 */
5002
-		public function encode_shortcodes( $content ) {
5003
-			// Avoids existing encoded tags.
5004
-			$trans   = array(
5005
-				'&#91;' => '&#091;',
5006
-				'&#93;' => '&#093;',
5007
-				'&amp;#91;' => '&#091;',
5008
-				'&amp;#93;' => '&#093;',
5009
-				'&lt;' => '&0lt;',
5010
-				'&gt;' => '&0gt;',
5011
-				'&amp;lt;' => '&0lt;',
5012
-				'&amp;gt;' => '&0gt;',
5013
-			);
5014
-
5015
-			$content = strtr( $content, $trans );
5016
-
5017
-			$trans   = array(
5018
-				'[' => '&#91;',
5019
-				']' => '&#93;',
5020
-				'<' => '&lt;',
5021
-				'>' => '&gt;',
5022
-				'"' => '&quot;',
5023
-				"'" => '&#39;',
5024
-			);
5025
-
5026
-			$content = strtr( $content, $trans );
5027
-
5028
-			return $content;
5029
-		}
4999
+         *@since 1.0.28
5000
+         *
5001
+         */
5002
+        public function encode_shortcodes( $content ) {
5003
+            // Avoids existing encoded tags.
5004
+            $trans   = array(
5005
+                '&#91;' => '&#091;',
5006
+                '&#93;' => '&#093;',
5007
+                '&amp;#91;' => '&#091;',
5008
+                '&amp;#93;' => '&#093;',
5009
+                '&lt;' => '&0lt;',
5010
+                '&gt;' => '&0gt;',
5011
+                '&amp;lt;' => '&0lt;',
5012
+                '&amp;gt;' => '&0gt;',
5013
+            );
5014
+
5015
+            $content = strtr( $content, $trans );
5016
+
5017
+            $trans   = array(
5018
+                '[' => '&#91;',
5019
+                ']' => '&#93;',
5020
+                '<' => '&lt;',
5021
+                '>' => '&gt;',
5022
+                '"' => '&quot;',
5023
+                "'" => '&#39;',
5024
+            );
5025
+
5026
+            $content = strtr( $content, $trans );
5027
+
5028
+            return $content;
5029
+        }
5030 5030
 
5031
-		/**
5032
-		 * Remove encoded shortcod tags.
5033
-		 *
5034
-		 * @param string $content Content to search for shortcode tags.
5035
-		 *
5031
+        /**
5032
+         * Remove encoded shortcod tags.
5033
+         *
5034
+         * @param string $content Content to search for shortcode tags.
5035
+         *
5036 5036
 *@return string Content with decoded shortcode tags.
5037
-		 *@since 1.0.28
5038
-		 *
5039
-		 */
5040
-		public function decode_shortcodes( $content ) {
5041
-			$trans   = array(
5042
-				'&#91;' => '[',
5043
-				'&#93;' => ']',
5044
-				'&amp;#91;' => '[',
5045
-				'&amp;#93;' => ']',
5046
-				'&lt;' => '<',
5047
-				'&gt;' => '>',
5048
-				'&amp;lt;' => '<',
5049
-				'&amp;gt;' => '>',
5050
-				'&quot;' => '"',
5051
-				'&apos;' => "'",
5052
-			);
5053
-
5054
-			$content = strtr( $content, $trans );
5055
-
5056
-			$trans   = array(
5057
-				'&#091;' => '&#91;',
5058
-				'&#093;' => '&#93;',
5059
-				'&amp;#091;' => '&#91;',
5060
-				'&amp;#093;' => '&#93;',
5061
-				'&0lt;' => '&lt;',
5062
-				'&0gt;' => '&gt;',
5063
-				'&amp;0lt;' => '&lt;',
5064
-				'&amp;0gt;' => '&gt;',
5065
-			);
5066
-
5067
-			$content = strtr( $content, $trans );
5068
-
5069
-			return $content;
5070
-		}
5071
-
5072
-		public function block_visibility_fields( $args ) {
5073
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5074
-			$content = '<div class="bs-vc-rule-template d-none">';
5075
-				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5076
-					$content .= '<div class="row">';
5077
-						$content .= '<div class="col-sm-12">';
5078
-							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5079
-							$content .= aui()->select(
5080
-								array(
5081
-									'id'          => 'bsvc_rule_BSVCINDEX',
5082
-									'name'        => 'bsvc_rule_BSVCINDEX',
5083
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5084
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5085
-									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5086
-									'options'     => sd_visibility_rules_options(),
5087
-									'default'     => '',
5088
-									'value'       => '',
5089
-									'label_type'  => '',
5090
-									'select2'     => false,
5091
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5092
-									'extra_attributes' => array(
5093
-										'data-minimum-results-for-search' => '-1'
5094
-									)
5095
-								)
5096
-							);
5097
-
5098
-						$content .= '</div>';
5099
-
5100
-						if ( class_exists( 'GeoDirectory' ) ) {
5101
-							$content .= '<div class="col-md-7 col-sm-12">';
5102
-
5103
-								$content .= aui()->select(
5104
-									array(
5105
-										'id'          => 'bsvc_gd_field_BSVCINDEX',
5106
-										'name'        => 'bsvc_gd_field_BSVCINDEX',
5107
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5108
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5109
-										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5110
-										'options'     => sd_visibility_gd_field_options(),
5111
-										'default'     => '',
5112
-										'value'       => '',
5113
-										'label_type'  => '',
5114
-										'select2'     => false,
5115
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5116
-										'extra_attributes' => array(
5117
-											'data-minimum-results-for-search' => '-1'
5118
-										)
5119
-									)
5120
-								);
5121
-
5122
-							$content .= '</div>';
5123
-							$content .= '<div class="col-md-5 col-sm-12">';
5124
-
5125
-								$content .= aui()->select(
5126
-									array(
5127
-										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5128
-										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5129
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5130
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5131
-										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5132
-										'options'     => sd_visibility_field_condition_options(),
5133
-										'default'     => '',
5134
-										'value'       => '',
5135
-										'label_type'  => '',
5136
-										'select2'     => false,
5137
-										'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5138
-										'extra_attributes' => array(
5139
-											'data-minimum-results-for-search' => '-1'
5140
-										)
5141
-									)
5142
-								);
5143
-
5144
-							$content .= '</div>';
5145
-							$content .= '<div class="col-sm-12">';
5146
-
5147
-								$content .= aui()->input(
5148
-									array(
5149
-										'type'            => 'text',
5150
-										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5151
-										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5152
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5153
-										'class'           => 'bsvc_gd_field_search form-control-sm',
5154
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5155
-										'label_type'      => '',
5156
-										'value'           => '',
5157
-										'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
5158
-									)
5159
-								);
5037
+         *@since 1.0.28
5038
+         *
5039
+         */
5040
+        public function decode_shortcodes( $content ) {
5041
+            $trans   = array(
5042
+                '&#91;' => '[',
5043
+                '&#93;' => ']',
5044
+                '&amp;#91;' => '[',
5045
+                '&amp;#93;' => ']',
5046
+                '&lt;' => '<',
5047
+                '&gt;' => '>',
5048
+                '&amp;lt;' => '<',
5049
+                '&amp;gt;' => '>',
5050
+                '&quot;' => '"',
5051
+                '&apos;' => "'",
5052
+            );
5053
+
5054
+            $content = strtr( $content, $trans );
5055
+
5056
+            $trans   = array(
5057
+                '&#091;' => '&#91;',
5058
+                '&#093;' => '&#93;',
5059
+                '&amp;#091;' => '&#91;',
5060
+                '&amp;#093;' => '&#93;',
5061
+                '&0lt;' => '&lt;',
5062
+                '&0gt;' => '&gt;',
5063
+                '&amp;0lt;' => '&lt;',
5064
+                '&amp;0gt;' => '&gt;',
5065
+            );
5066
+
5067
+            $content = strtr( $content, $trans );
5068
+
5069
+            return $content;
5070
+        }
5160 5071
 
5161
-							$content .= '</div>';
5162
-						}
5072
+        public function block_visibility_fields( $args ) {
5073
+            $value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5074
+            $content = '<div class="bs-vc-rule-template d-none">';
5075
+                $content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5076
+                    $content .= '<div class="row">';
5077
+                        $content .= '<div class="col-sm-12">';
5078
+                            $content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5079
+                            $content .= aui()->select(
5080
+                                array(
5081
+                                    'id'          => 'bsvc_rule_BSVCINDEX',
5082
+                                    'name'        => 'bsvc_rule_BSVCINDEX',
5083
+                                    'label'       => __( 'Rule', 'ayecode-connect' ),
5084
+                                    'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5085
+                                    'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5086
+                                    'options'     => sd_visibility_rules_options(),
5087
+                                    'default'     => '',
5088
+                                    'value'       => '',
5089
+                                    'label_type'  => '',
5090
+                                    'select2'     => false,
5091
+                                    'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5092
+                                    'extra_attributes' => array(
5093
+                                        'data-minimum-results-for-search' => '-1'
5094
+                                    )
5095
+                                )
5096
+                            );
5097
+
5098
+                        $content .= '</div>';
5099
+
5100
+                        if ( class_exists( 'GeoDirectory' ) ) {
5101
+                            $content .= '<div class="col-md-7 col-sm-12">';
5102
+
5103
+                                $content .= aui()->select(
5104
+                                    array(
5105
+                                        'id'          => 'bsvc_gd_field_BSVCINDEX',
5106
+                                        'name'        => 'bsvc_gd_field_BSVCINDEX',
5107
+                                        'label'       => __( 'FIELD', 'ayecode-connect' ),
5108
+                                        'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5109
+                                        'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5110
+                                        'options'     => sd_visibility_gd_field_options(),
5111
+                                        'default'     => '',
5112
+                                        'value'       => '',
5113
+                                        'label_type'  => '',
5114
+                                        'select2'     => false,
5115
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5116
+                                        'extra_attributes' => array(
5117
+                                            'data-minimum-results-for-search' => '-1'
5118
+                                        )
5119
+                                    )
5120
+                                );
5121
+
5122
+                            $content .= '</div>';
5123
+                            $content .= '<div class="col-md-5 col-sm-12">';
5124
+
5125
+                                $content .= aui()->select(
5126
+                                    array(
5127
+                                        'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5128
+                                        'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5129
+                                        'label'       => __( 'CONDITION', 'ayecode-connect' ),
5130
+                                        'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5131
+                                        'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5132
+                                        'options'     => sd_visibility_field_condition_options(),
5133
+                                        'default'     => '',
5134
+                                        'value'       => '',
5135
+                                        'label_type'  => '',
5136
+                                        'select2'     => false,
5137
+                                        'element_require'  => '[%bsvc_rule_BSVCINDEX%]=="gd_field"',
5138
+                                        'extra_attributes' => array(
5139
+                                            'data-minimum-results-for-search' => '-1'
5140
+                                        )
5141
+                                    )
5142
+                                );
5143
+
5144
+                            $content .= '</div>';
5145
+                            $content .= '<div class="col-sm-12">';
5146
+
5147
+                                $content .= aui()->input(
5148
+                                    array(
5149
+                                        'type'            => 'text',
5150
+                                        'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5151
+                                        'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5152
+                                        'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5153
+                                        'class'           => 'bsvc_gd_field_search form-control-sm',
5154
+                                        'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5155
+                                        'label_type'      => '',
5156
+                                        'value'           => '',
5157
+                                        'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
5158
+                                    )
5159
+                                );
5160
+
5161
+                            $content .= '</div>';
5162
+                        }
5163
+
5164
+                    $content .= '</div>';
5165
+
5166
+                    $content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5167
+                        $role_options = sd_user_roles_options();
5168
+
5169
+                        $role_option_i = 0;
5170
+                        foreach ( $role_options as $role_option_key => $role_option_name ) {
5171
+                            $role_option_i++;
5172
+
5173
+                            $content .= '<div class="col-sm-6">';
5174
+                            $content .= aui()->input(
5175
+                                array(
5176
+                                    'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5177
+                                    'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5178
+                                    'type'             => 'checkbox',
5179
+                                    'label'            => $role_option_name,
5180
+                                    'label_type'       => 'hidden',
5181
+                                    'class'            => 'bsvc_user_roles',
5182
+                                    'value'            => $role_option_key,
5183
+                                    'switch'           => 'md',
5184
+                                    'no_wrap'          => true
5185
+                                )
5186
+                            );
5187
+                            $content .= '</div>';
5188
+                        }
5189
+                    $content .= '</div>';
5190
+                $content .= '</div>';
5191
+            $content .= '</div>';
5192
+            $content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5193
+            $content .= '<div class="bs-vc-rule-sets"></div>';
5194
+            $content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5195
+            $content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5196
+            $content .= aui()->select(
5197
+                array(
5198
+                    'id'          => 'bsvc_output',
5199
+                    'name'        => 'bsvc_output',
5200
+                    'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5201
+                    'placeholder' => __( 'Default Output', 'ayecode-connect' ),
5202
+                    'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5203
+                    'options'     => sd_visibility_output_options(),
5204
+                    'default'     => '',
5205
+                    'value'       => '',
5206
+                    'label_type'  => 'top',
5207
+                    'select2'     => false,
5208
+                    'extra_attributes' => array(
5209
+                        'data-minimum-results-for-search' => '-1'
5210
+                    )
5211
+                )
5212
+            );
5213
+
5214
+            $content .= '</div><div class="col-md-6 col-sm-12">';
5215
+
5216
+            $content .= aui()->select(
5217
+                array(
5218
+                    'id'              => 'bsvc_page',
5219
+                    'name'            => 'bsvc_page',
5220
+                    'label'           => __( 'Page Content', 'ayecode-connect' ),
5221
+                    'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5222
+                    'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5223
+                    'options'         => sd_template_page_options(),
5224
+                    'default'         => '',
5225
+                    'value'           => '',
5226
+                    'label_type'      => 'top',
5227
+                    'select2'         => false,
5228
+                    'element_require' => '[%bsvc_output%]=="page"'
5229
+                )
5230
+            );
5231
+
5232
+            $content .= aui()->select(
5233
+                array(
5234
+                    'id'          => 'bsvc_tmpl_part',
5235
+                    'name'        => 'bsvc_tmpl_part',
5236
+                    'label'       => __( 'Template Part', 'ayecode-connect' ),
5237
+                    'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5238
+                    'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5239
+                    'options'     => sd_template_part_options(),
5240
+                    'default'     => '',
5241
+                    'value'       => '',
5242
+                    'label_type'  => 'top',
5243
+                    'select2'     => false,
5244
+                    'element_require'  => '[%bsvc_output%]=="template_part"',
5245
+                    'extra_attributes' => array(
5246
+                        'data-minimum-results-for-search' => '-1'
5247
+                    )
5248
+                )
5249
+            );
5250
+
5251
+            $content .= aui()->select(
5252
+                array(
5253
+                    'id'               => 'bsvc_message_type',
5254
+                    'name'             => 'bsvc_message_type',
5255
+                    'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5256
+                    'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5257
+                    'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5258
+                    'options'          => sd_aui_colors(),
5259
+                    'default'          => '',
5260
+                    'value'            => '',
5261
+                    'label_type'       => 'top',
5262
+                    'select2'          => false,
5263
+                    'element_require'  => '[%bsvc_output%]=="message"',
5264
+                    'extra_attributes' => array(
5265
+                        'data-minimum-results-for-search' => '-1'
5266
+                    )
5267
+                )
5268
+            );
5269
+
5270
+            $content .= '</div><div class="col-sm-12">';
5271
+
5272
+            $content .= aui()->input(
5273
+                array(
5274
+                    'type'            => 'text',
5275
+                    'id'              => 'bsvc_message',
5276
+                    'name'            => 'bsvc_message',
5277
+                    'label'           => '',
5278
+                    'class'           => 'bsvc_message form-control-sm',
5279
+                    'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5280
+                    'label_type'      => '',
5281
+                    'value'           => '',
5282
+                    'form_group_class' => ' ',
5283
+                    'element_require' => '[%bsvc_output%]=="message"',
5284
+                )
5285
+            );
5286
+
5287
+            $content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5288
+
5289
+            return $content;
5290
+        }
5163 5291
 
5164
-					$content .= '</div>';
5165
-
5166
-					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5167
-						$role_options = sd_user_roles_options();
5168
-
5169
-						$role_option_i = 0;
5170
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5171
-							$role_option_i++;
5172
-
5173
-							$content .= '<div class="col-sm-6">';
5174
-							$content .= aui()->input(
5175
-								array(
5176
-									'id'               => 'bsvc_user_roles_BSVCINDEX_' . $role_option_i,
5177
-									'name'             => 'bsvc_user_roles_BSVCINDEX[]',
5178
-									'type'             => 'checkbox',
5179
-									'label'            => $role_option_name,
5180
-									'label_type'       => 'hidden',
5181
-									'class'            => 'bsvc_user_roles',
5182
-									'value'            => $role_option_key,
5183
-									'switch'           => 'md',
5184
-									'no_wrap'          => true
5185
-								)
5186
-							);
5187
-							$content .= '</div>';
5188
-						}
5189
-					$content .= '</div>';
5190
-				$content .= '</div>';
5191
-			$content .= '</div>';
5192
-			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5193
-			$content .= '<div class="bs-vc-rule-sets"></div>';
5194
-			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5195
-			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5196
-			$content .= aui()->select(
5197
-				array(
5198
-					'id'          => 'bsvc_output',
5199
-					'name'        => 'bsvc_output',
5200
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5201
-					'placeholder' => __( 'Default Output', 'ayecode-connect' ),
5202
-					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5203
-					'options'     => sd_visibility_output_options(),
5204
-					'default'     => '',
5205
-					'value'       => '',
5206
-					'label_type'  => 'top',
5207
-					'select2'     => false,
5208
-					'extra_attributes' => array(
5209
-						'data-minimum-results-for-search' => '-1'
5210
-					)
5211
-				)
5212
-			);
5213
-
5214
-			$content .= '</div><div class="col-md-6 col-sm-12">';
5215
-
5216
-			$content .= aui()->select(
5217
-				array(
5218
-					'id'              => 'bsvc_page',
5219
-					'name'            => 'bsvc_page',
5220
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5221
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5222
-					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5223
-					'options'         => sd_template_page_options(),
5224
-					'default'         => '',
5225
-					'value'           => '',
5226
-					'label_type'      => 'top',
5227
-					'select2'         => false,
5228
-					'element_require' => '[%bsvc_output%]=="page"'
5229
-				)
5230
-			);
5231
-
5232
-			$content .= aui()->select(
5233
-				array(
5234
-					'id'          => 'bsvc_tmpl_part',
5235
-					'name'        => 'bsvc_tmpl_part',
5236
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5237
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5238
-					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5239
-					'options'     => sd_template_part_options(),
5240
-					'default'     => '',
5241
-					'value'       => '',
5242
-					'label_type'  => 'top',
5243
-					'select2'     => false,
5244
-					'element_require'  => '[%bsvc_output%]=="template_part"',
5245
-					'extra_attributes' => array(
5246
-						'data-minimum-results-for-search' => '-1'
5247
-					)
5248
-				)
5249
-			);
5250
-
5251
-			$content .= aui()->select(
5252
-				array(
5253
-					'id'               => 'bsvc_message_type',
5254
-					'name'             => 'bsvc_message_type',
5255
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5256
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5257
-					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5258
-					'options'          => sd_aui_colors(),
5259
-					'default'          => '',
5260
-					'value'            => '',
5261
-					'label_type'       => 'top',
5262
-					'select2'          => false,
5263
-					'element_require'  => '[%bsvc_output%]=="message"',
5264
-					'extra_attributes' => array(
5265
-						'data-minimum-results-for-search' => '-1'
5266
-					)
5267
-				)
5268
-			);
5269
-
5270
-			$content .= '</div><div class="col-sm-12">';
5271
-
5272
-			$content .= aui()->input(
5273
-				array(
5274
-					'type'            => 'text',
5275
-					'id'              => 'bsvc_message',
5276
-					'name'            => 'bsvc_message',
5277
-					'label'           => '',
5278
-					'class'           => 'bsvc_message form-control-sm',
5279
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5280
-					'label_type'      => '',
5281
-					'value'           => '',
5282
-					'form_group_class' => ' ',
5283
-					'element_require' => '[%bsvc_output%]=="message"',
5284
-				)
5285
-			);
5286
-
5287
-			$content .= '</div></div></form><input type="hidden" id="bsvc_raw_value" name="bsvc_raw_value" value="' . $value . '">';
5288
-
5289
-			return $content;
5290
-		}
5292
+        /**
5293
+         * Handle media_buttons hook.
5294
+         *
5295
+         * @since 1.2.7
5296
+         */
5297
+        public function wp_media_buttons() {
5298
+            global $shortcode_insert_button_once;
5291 5299
 
5292
-		/**
5293
-		 * Handle media_buttons hook.
5294
-		 *
5295
-		 * @since 1.2.7
5296
-		 */
5297
-		public function wp_media_buttons() {
5298
-			global $shortcode_insert_button_once;
5299
-
5300
-			// Fix conflicts with UpSolution Core in header template edit element.
5301
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5302
-				$shortcode_insert_button_once = true;
5303
-			}
5304
-		}
5305
-	}
5300
+            // Fix conflicts with UpSolution Core in header template edit element.
5301
+            if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5302
+                $shortcode_insert_button_once = true;
5303
+            }
5304
+        }
5305
+    }
5306 5306
 }
Please login to merge, or discard this patch.
Spacing   +820 added lines, -820 removed lines patch added patch discarded remove patch
@@ -1,11 +1,11 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
6
-if ( ! class_exists( 'WP_Super_Duper' ) ) {
6
+if (!class_exists('WP_Super_Duper')) {
7 7
 
8
-	define( 'SUPER_DUPER_VER', '1.2.16' );
8
+	define('SUPER_DUPER_VER', '1.2.16');
9 9
 
10 10
 	/**
11 11
 	 * A Class to be able to create a Widget, Shortcode or Block to be able to output content for WordPress.
@@ -38,40 +38,40 @@  discard block
 block discarded – undo
38 38
 		/**
39 39
 		 * Take the array options and use them to build.
40 40
 		 */
41
-		public function __construct( $options ) {
41
+		public function __construct($options) {
42 42
 			global $sd_widgets;
43 43
 
44
-			$sd_widgets[ $options['base_id'] ] = array(
44
+			$sd_widgets[$options['base_id']] = array(
45 45
 				'name'       => $options['name'],
46 46
 				'class_name' => $options['class_name'],
47 47
 				'output_types' => !empty($options['output_types']) ? $options['output_types'] : array()
48 48
 			);
49
-			$this->base_id                     = $options['base_id'];
49
+			$this->base_id = $options['base_id'];
50 50
 			// lets filter the options before we do anything
51
-			$options       = apply_filters( "wp_super_duper_options", $options );
52
-			$options       = apply_filters( "wp_super_duper_options_{$this->base_id}", $options );
53
-			$options       = $this->add_name_from_key( $options );
51
+			$options       = apply_filters("wp_super_duper_options", $options);
52
+			$options       = apply_filters("wp_super_duper_options_{$this->base_id}", $options);
53
+			$options       = $this->add_name_from_key($options);
54 54
 			$this->options = $options;
55 55
 
56 56
 			$this->base_id   = $options['base_id'];
57
-			$this->arguments = isset( $options['arguments'] ) ? $options['arguments'] : array();
57
+			$this->arguments = isset($options['arguments']) ? $options['arguments'] : array();
58 58
 
59 59
 			// nested blocks can't work as a widget
60
-			if(!empty($this->options['nested-block'])){
61
-				if(empty($this->options['output_types'])){
62
-					$this->options['output_types'] = array('shortcode','block');
60
+			if (!empty($this->options['nested-block'])) {
61
+				if (empty($this->options['output_types'])) {
62
+					$this->options['output_types'] = array('shortcode', 'block');
63 63
 				}elseif (($key = array_search('widget', $this->options['output_types'])) !== false) {
64 64
 					unset($this->options['output_types'][$key]);
65 65
 				}
66 66
 			}
67 67
 
68 68
 			// init parent
69
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
70
-				parent::__construct( $options['base_id'], $options['name'], $options['widget_ops'] );
69
+			if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) {
70
+				parent::__construct($options['base_id'], $options['name'], $options['widget_ops']);
71 71
 			}
72 72
 
73 73
 
74
-			if ( isset( $options['class_name'] ) ) {
74
+			if (isset($options['class_name'])) {
75 75
 				// register widget
76 76
 				$this->class_name = $options['class_name'];
77 77
 
@@ -80,67 +80,67 @@  discard block
 block discarded – undo
80 80
 
81 81
 
82 82
 				// Fusion Builder (avada) support
83
-				if ( function_exists( 'fusion_builder_map' ) ) {
84
-					add_action( 'init', array( $this, 'register_fusion_element' ) );
83
+				if (function_exists('fusion_builder_map')) {
84
+					add_action('init', array($this, 'register_fusion_element'));
85 85
 				}
86 86
 
87 87
                 // maybe load the Bricks transformer class
88
-                if( class_exists('\Bricks\Elements', false) ){
89
-					add_action( 'init', array( $this, 'load_bricks_element_class' ) );
88
+                if (class_exists('\Bricks\Elements', false)) {
89
+					add_action('init', array($this, 'load_bricks_element_class'));
90 90
                 }
91 91
 
92 92
 				// register block
93
-				if(empty($this->options['output_types']) || in_array('block',$this->options['output_types'])){
94
-					add_action( 'admin_enqueue_scripts', array( $this, 'register_block' ) );
93
+				if (empty($this->options['output_types']) || in_array('block', $this->options['output_types'])) {
94
+					add_action('admin_enqueue_scripts', array($this, 'register_block'));
95 95
 				}
96 96
 			}
97 97
 
98 98
 			// add the CSS and JS we need ONCE
99 99
 			global $sd_widget_scripts;
100 100
 
101
-			if ( ! $sd_widget_scripts ) {
102
-				wp_add_inline_script( 'admin-widgets', $this->widget_js() );
103
-				wp_add_inline_script( 'customize-controls', $this->widget_js() );
104
-				wp_add_inline_style( 'widgets', $this->widget_css() );
101
+			if (!$sd_widget_scripts) {
102
+				wp_add_inline_script('admin-widgets', $this->widget_js());
103
+				wp_add_inline_script('customize-controls', $this->widget_js());
104
+				wp_add_inline_style('widgets', $this->widget_css());
105 105
 
106 106
 				// maybe add elementor editor styles
107
-				add_action( 'elementor/editor/after_enqueue_styles', array( $this, 'elementor_editor_styles' ) );
107
+				add_action('elementor/editor/after_enqueue_styles', array($this, 'elementor_editor_styles'));
108 108
 
109 109
 				$sd_widget_scripts = true;
110 110
 
111 111
 				// add shortcode insert button once
112
-				add_action( 'media_buttons', array( $this, 'wp_media_buttons' ), 1 );
113
-				add_action( 'media_buttons', array( $this, 'shortcode_insert_button' ) );
112
+				add_action('media_buttons', array($this, 'wp_media_buttons'), 1);
113
+				add_action('media_buttons', array($this, 'shortcode_insert_button'));
114 114
 				// generatepress theme sections compatibility
115
-				if ( function_exists( 'generate_sections_sections_metabox' ) ) {
116
-					add_action( 'generate_sections_metabox', array( $this, 'shortcode_insert_button_script' ) );
115
+				if (function_exists('generate_sections_sections_metabox')) {
116
+					add_action('generate_sections_metabox', array($this, 'shortcode_insert_button_script'));
117 117
 				}
118 118
 				/* Load script on Divi theme builder page */
119
-				if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) {
119
+				if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) {
120 120
 					add_thickbox();
121
-					add_action( 'admin_footer', array( $this, 'shortcode_insert_button_script' ) );
121
+					add_action('admin_footer', array($this, 'shortcode_insert_button_script'));
122 122
 				}
123 123
 
124
-				if ( $this->is_preview() ) {
125
-					add_action( 'wp_footer', array( $this, 'shortcode_insert_button_script' ) );
124
+				if ($this->is_preview()) {
125
+					add_action('wp_footer', array($this, 'shortcode_insert_button_script'));
126 126
 					// this makes the insert button work for elementor
127
-					add_action( 'elementor/editor/after_enqueue_scripts', array(
127
+					add_action('elementor/editor/after_enqueue_scripts', array(
128 128
 						$this,
129 129
 						'shortcode_insert_button_script'
130
-					) ); // for elementor
130
+					)); // for elementor
131 131
 				}
132 132
 				// this makes the insert button work for cornerstone
133
-				add_action( 'wp_print_footer_scripts', array( __CLASS__, 'maybe_cornerstone_builder' ) );
133
+				add_action('wp_print_footer_scripts', array(__CLASS__, 'maybe_cornerstone_builder'));
134 134
 
135
-				add_action( 'wp_ajax_super_duper_get_widget_settings', array( __CLASS__, 'get_widget_settings' ) );
136
-				add_action( 'wp_ajax_super_duper_get_picker', array( __CLASS__, 'get_picker' ) );
135
+				add_action('wp_ajax_super_duper_get_widget_settings', array(__CLASS__, 'get_widget_settings'));
136
+				add_action('wp_ajax_super_duper_get_picker', array(__CLASS__, 'get_picker'));
137 137
 
138 138
 				// add generator text to head
139
-				add_action( 'admin_head', array( $this, 'generator' ), 99 );
140
-				add_action( 'wp_head', array( $this, 'generator' ), 99 );
139
+				add_action('admin_head', array($this, 'generator'), 99);
140
+				add_action('wp_head', array($this, 'generator'), 99);
141 141
 			}
142 142
 
143
-			do_action( 'wp_super_duper_widget_init', $options, $this );
143
+			do_action('wp_super_duper_widget_init', $options, $this);
144 144
 		}
145 145
 
146 146
         /**
@@ -156,7 +156,7 @@  discard block
 block discarded – undo
156 156
 		 * @return void
157 157
 		 */
158 158
 		public function _register() {
159
-			if(empty($this->options['output_types']) || in_array('widget',$this->options['output_types'])){
159
+			if (empty($this->options['output_types']) || in_array('widget', $this->options['output_types'])) {
160 160
 				parent::_register();
161 161
 			}
162 162
 		}
@@ -165,14 +165,14 @@  discard block
 block discarded – undo
165 165
 		 * Add our widget CSS to elementor editor.
166 166
 		 */
167 167
 		public function elementor_editor_styles() {
168
-			wp_add_inline_style( 'elementor-editor', $this->widget_css( false ) );
168
+			wp_add_inline_style('elementor-editor', $this->widget_css(false));
169 169
 		}
170 170
 
171 171
 		public function register_fusion_element() {
172 172
 
173 173
 			$options = $this->options;
174 174
 
175
-			if ( $this->base_id ) {
175
+			if ($this->base_id) {
176 176
 
177 177
 				$params = $this->get_fusion_params();
178 178
 
@@ -183,11 +183,11 @@  discard block
 block discarded – undo
183 183
 					'allow_generator' => true,
184 184
 				);
185 185
 
186
-				if ( ! empty( $params ) ) {
186
+				if (!empty($params)) {
187 187
 					$args['params'] = $params;
188 188
 				}
189 189
 
190
-				fusion_builder_map( $args );
190
+				fusion_builder_map($args);
191 191
 			}
192 192
 
193 193
 		}
@@ -196,8 +196,8 @@  discard block
 block discarded – undo
196 196
 			$params    = array();
197 197
 			$arguments = $this->get_arguments();
198 198
 
199
-			if ( ! empty( $arguments ) ) {
200
-				foreach ( $arguments as $key => $val ) {
199
+			if (!empty($arguments)) {
200
+				foreach ($arguments as $key => $val) {
201 201
 					$param = array();
202 202
 					// type
203 203
 					$param['type'] = str_replace(
@@ -219,38 +219,38 @@  discard block
 block discarded – undo
219 219
 						$val['type'] );
220 220
 
221 221
 					// multiselect
222
-					if ( $val['type'] == 'multiselect' || ( ( $param['type'] == 'select' || $val['type'] == 'select' ) && ! empty( $val['multiple'] ) ) ) {
222
+					if ($val['type'] == 'multiselect' || (($param['type'] == 'select' || $val['type'] == 'select') && !empty($val['multiple']))) {
223 223
 						$param['type']     = 'multiple_select';
224 224
 						$param['multiple'] = true;
225 225
 					}
226 226
 
227 227
 					// heading
228
-					$param['heading'] = isset( $val['title'] ) ? $val['title'] : '';
228
+					$param['heading'] = isset($val['title']) ? $val['title'] : '';
229 229
 
230 230
 					// description
231
-					$param['description'] = isset( $val['desc'] ) ? $val['desc'] : '';
231
+					$param['description'] = isset($val['desc']) ? $val['desc'] : '';
232 232
 
233 233
 					// param_name
234 234
 					$param['param_name'] = $key;
235 235
 
236 236
 					// Default
237
-					$param['default'] = isset( $val['default'] ) ? $val['default'] : '';
237
+					$param['default'] = isset($val['default']) ? $val['default'] : '';
238 238
 
239 239
 					// Group
240
-					if ( isset( $val['group'] ) ) {
240
+					if (isset($val['group'])) {
241 241
 						$param['group'] = $val['group'];
242 242
 					}
243 243
 
244 244
 					// value
245
-					if ( $val['type'] == 'checkbox' ) {
246
-						if ( isset( $val['default'] ) && $val['default'] == '0' ) {
247
-							unset( $param['default'] );
245
+					if ($val['type'] == 'checkbox') {
246
+						if (isset($val['default']) && $val['default'] == '0') {
247
+							unset($param['default']);
248 248
 						}
249
-						$param['value'] = array( '0' => __( "No", 'ayecode-connect' ), '1' => __( "Yes", 'ayecode-connect' ) );
250
-					} elseif ( $param['type'] == 'select' || $param['type'] == 'multiple_select' ) {
251
-						$param['value'] = isset( $val['options'] ) ? $val['options'] : array();
249
+						$param['value'] = array('0' => __("No", 'ayecode-connect'), '1' => __("Yes", 'ayecode-connect'));
250
+					} elseif ($param['type'] == 'select' || $param['type'] == 'multiple_select') {
251
+						$param['value'] = isset($val['options']) ? $val['options'] : array();
252 252
 					} else {
253
-						$param['value'] = isset( $val['default'] ) ? $val['default'] : '';
253
+						$param['value'] = isset($val['default']) ? $val['default'] : '';
254 254
 					}
255 255
 
256 256
 					// setup the param
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 		 * Maybe insert the shortcode inserter button in the footer if we are in the cornerstone builder
268 268
 		 */
269 269
 		public static function maybe_cornerstone_builder() {
270
-			if ( did_action( 'cornerstone_before_boot_app' ) ) {
270
+			if (did_action('cornerstone_before_boot_app')) {
271 271
 				self::shortcode_insert_button_script();
272 272
 			}
273 273
 		}
@@ -279,12 +279,12 @@  discard block
 block discarded – undo
279 279
 		 *
280 280
 		 * @return string
281 281
 		 */
282
-		public static function get_picker( $editor_id = '' ) {
282
+		public static function get_picker($editor_id = '') {
283 283
 
284 284
 			ob_start();
285
-			if ( isset( $_POST['editor_id'] ) ) {
286
-				$editor_id = esc_attr( $_POST['editor_id'] );
287
-			} elseif ( isset( $_REQUEST['et_fb'] ) ) {
285
+			if (isset($_POST['editor_id'])) {
286
+				$editor_id = esc_attr($_POST['editor_id']);
287
+			} elseif (isset($_REQUEST['et_fb'])) {
288 288
 				$editor_id = 'main_content_content_vb_tiny_mce';
289 289
 			}
290 290
 
@@ -295,14 +295,14 @@  discard block
 block discarded – undo
295 295
 
296 296
 			<div class="sd-shortcode-left-wrap">
297 297
 				<?php
298
-				ksort( $sd_widgets );
298
+				ksort($sd_widgets);
299 299
 				//				print_r($sd_widgets);exit;
300
-				if ( ! empty( $sd_widgets ) ) {
300
+				if (!empty($sd_widgets)) {
301 301
 					echo '<select class="widefat" onchange="sd_get_shortcode_options(this);">';
302
-					echo "<option>" . __( 'Select shortcode', 'ayecode-connect' ) . "</option>";
303
-					foreach ( $sd_widgets as $shortcode => $class ) {
304
-						if(!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])){ continue; }
305
-						echo "<option value='" . esc_attr( $shortcode ) . "'>" . esc_attr( $shortcode ) . " (" . esc_attr( $class['name'] ) . ")</option>";
302
+					echo "<option>" . __('Select shortcode', 'ayecode-connect') . "</option>";
303
+					foreach ($sd_widgets as $shortcode => $class) {
304
+						if (!empty($class['output_types']) && !in_array('shortcode', $class['output_types'])) { continue; }
305
+						echo "<option value='" . esc_attr($shortcode) . "'>" . esc_attr($shortcode) . " (" . esc_attr($class['name']) . ")</option>";
306 306
 					}
307 307
 					echo "</select>";
308 308
 
@@ -315,37 +315,37 @@  discard block
 block discarded – undo
315 315
 			<div class="sd-shortcode-right-wrap">
316 316
 				<textarea id='sd-shortcode-output' disabled></textarea>
317 317
 				<div id='sd-shortcode-output-actions'>
318
-					<?php if ( $editor_id != '' ) { ?>
318
+					<?php if ($editor_id != '') { ?>
319 319
 						<button class="button sd-insert-shortcode-button"
320
-								onclick="sd_insert_shortcode(<?php if ( ! empty( $editor_id ) ) {
320
+								onclick="sd_insert_shortcode(<?php if (!empty($editor_id)) {
321 321
 									echo "'" . $editor_id . "'";
322
-								} ?>)"><?php _e( 'Insert shortcode', 'ayecode-connect' ); ?></button>
322
+								} ?>)"><?php _e('Insert shortcode', 'ayecode-connect'); ?></button>
323 323
 					<?php } ?>
324 324
 					<button class="button"
325
-							onclick="sd_copy_to_clipboard()"><?php _e( 'Copy shortcode' ); ?></button>
325
+							onclick="sd_copy_to_clipboard()"><?php _e('Copy shortcode'); ?></button>
326 326
 				</div>
327 327
 			</div>
328 328
 			<?php
329 329
 
330 330
 			$html = ob_get_clean();
331 331
 
332
-			if ( wp_doing_ajax() ) {
332
+			if (wp_doing_ajax()) {
333 333
 				echo $html;
334 334
 				$should_die = true;
335 335
 
336 336
 				// some builder get the editor via ajax so we should not die on those occasions
337 337
 				$dont_die = array(
338
-					'parent_tag',// WP Bakery
338
+					'parent_tag', // WP Bakery
339 339
 					'avia_request' // enfold
340 340
 				);
341 341
 
342
-				foreach ( $dont_die as $request ) {
343
-					if ( isset( $_REQUEST[ $request ] ) ) {
342
+				foreach ($dont_die as $request) {
343
+					if (isset($_REQUEST[$request])) {
344 344
 						$should_die = false;
345 345
 					}
346 346
 				}
347 347
 
348
-				if ( $should_die ) {
348
+				if ($should_die) {
349 349
 					wp_die();
350 350
 				}
351 351
 
@@ -361,22 +361,22 @@  discard block
 block discarded – undo
361 361
 		 * Output the version in the header.
362 362
 		 */
363 363
 		public function generator() {
364
-			$file = str_replace( array( "/", "\\" ), "/", realpath( __FILE__ ) );
365
-			$plugins_dir = str_replace( array( "/", "\\" ), "/", realpath( WP_PLUGIN_DIR ) );
364
+			$file = str_replace(array("/", "\\"), "/", realpath(__FILE__));
365
+			$plugins_dir = str_replace(array("/", "\\"), "/", realpath(WP_PLUGIN_DIR));
366 366
 
367 367
 			// Find source plugin/theme of SD
368 368
 			$source = array();
369
-			if ( strpos( $file, $plugins_dir ) !== false ) {
370
-				$source = explode( "/", plugin_basename( $file ) );
371
-			} else if ( function_exists( 'get_theme_root' ) ) {
372
-				$themes_dir = str_replace( array( "/", "\\" ), "/", realpath( get_theme_root() ) );
369
+			if (strpos($file, $plugins_dir) !== false) {
370
+				$source = explode("/", plugin_basename($file));
371
+			} else if (function_exists('get_theme_root')) {
372
+				$themes_dir = str_replace(array("/", "\\"), "/", realpath(get_theme_root()));
373 373
 
374
-				if ( strpos( $file, $themes_dir ) !== false ) {
375
-					$source = explode( "/", ltrim( str_replace( $themes_dir, "", $file ), "/" ) );
374
+				if (strpos($file, $themes_dir) !== false) {
375
+					$source = explode("/", ltrim(str_replace($themes_dir, "", $file), "/"));
376 376
 				}
377 377
 			}
378 378
 
379
-			echo '<meta name="generator" content="WP Super Duper v' . esc_attr( $this->version ) . '"' . ( ! empty( $source[0] ) ? ' data-sd-source="' . esc_attr( $source[0] ) . '"' : '' ) . ' />';
379
+			echo '<meta name="generator" content="WP Super Duper v' . esc_attr($this->version) . '"' . (!empty($source[0]) ? ' data-sd-source="' . esc_attr($source[0]) . '"' : '') . ' />';
380 380
 		}
381 381
 
382 382
 		/**
@@ -387,16 +387,16 @@  discard block
 block discarded – undo
387 387
 		public static function get_widget_settings() {
388 388
 			global $sd_widgets;
389 389
 
390
-			$shortcode = isset( $_REQUEST['shortcode'] ) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes( $_REQUEST['shortcode'] ) : '';
391
-			if ( ! $shortcode ) {
390
+			$shortcode = isset($_REQUEST['shortcode']) && $_REQUEST['shortcode'] ? sanitize_title_with_dashes($_REQUEST['shortcode']) : '';
391
+			if (!$shortcode) {
392 392
 				wp_die();
393 393
 			}
394
-			$widget_args = isset( $sd_widgets[ $shortcode ] ) ? $sd_widgets[ $shortcode ] : '';
395
-			if ( ! $widget_args ) {
394
+			$widget_args = isset($sd_widgets[$shortcode]) ? $sd_widgets[$shortcode] : '';
395
+			if (!$widget_args) {
396 396
 				wp_die();
397 397
 			}
398
-			$class_name = isset( $widget_args['class_name'] ) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
-			if ( ! $class_name ) {
398
+			$class_name = isset($widget_args['class_name']) && $widget_args['class_name'] ? $widget_args['class_name'] : '';
399
+			if (!$class_name) {
400 400
 				wp_die();
401 401
 			}
402 402
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 			$widget = new $class_name;
405 405
 
406 406
 			ob_start();
407
-			$widget->form( array() );
407
+			$widget->form(array());
408 408
 			$form = ob_get_clean();
409 409
 			echo "<form id='$shortcode'>" . $form . "<div class=\"widget-control-save\"></div></form>";
410 410
 			echo "<style>" . $widget->widget_css() . "</style>";
@@ -423,9 +423,9 @@  discard block
 block discarded – undo
423 423
 		 *@since 1.0.0
424 424
 		 *
425 425
 		 */
426
-		public static function shortcode_insert_button( $editor_id = '', $insert_shortcode_function = '' ) {
426
+		public static function shortcode_insert_button($editor_id = '', $insert_shortcode_function = '') {
427 427
 			global $sd_widgets, $shortcode_insert_button_once;
428
-			if ( $shortcode_insert_button_once ) {
428
+			if ($shortcode_insert_button_once) {
429 429
 				return;
430 430
 			}
431 431
 			add_thickbox();
@@ -435,21 +435,21 @@  discard block
 block discarded – undo
435 435
 			 * Cornerstone makes us play dirty tricks :/
436 436
 			 * All media_buttons are removed via JS unless they are two specific id's so we wrap our content in this ID so it is not removed.
437 437
 			 */
438
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
438
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
439 439
 				echo '<span id="insert-media-button">';
440 440
 			}
441 441
 
442
-			echo self::shortcode_button( 'this', 'true' );
442
+			echo self::shortcode_button('this', 'true');
443 443
 
444 444
 			// see opening note
445
-			if ( function_exists( 'cornerstone_plugin_init' ) && ! is_admin() ) {
445
+			if (function_exists('cornerstone_plugin_init') && !is_admin()) {
446 446
 				echo '</span>'; // end #insert-media-button
447 447
 			}
448 448
 
449 449
 			// Add separate script for generatepress theme sections
450
-			if ( function_exists( 'generate_sections_sections_metabox' ) && did_action( 'generate_sections_metabox' ) ) {
450
+			if (function_exists('generate_sections_sections_metabox') && did_action('generate_sections_metabox')) {
451 451
 			} else {
452
-				self::shortcode_insert_button_script( $editor_id, $insert_shortcode_function );
452
+				self::shortcode_insert_button_script($editor_id, $insert_shortcode_function);
453 453
 			}
454 454
 
455 455
 			$shortcode_insert_button_once = true;
@@ -463,12 +463,12 @@  discard block
 block discarded – undo
463 463
 		 *
464 464
 		 * @return mixed
465 465
 		 */
466
-		public static function shortcode_button( $id = '', $search_for_id = '' ) {
466
+		public static function shortcode_button($id = '', $search_for_id = '') {
467 467
 			ob_start();
468 468
 			?>
469 469
 			<span class="sd-lable-shortcode-inserter">
470 470
 				<a onclick="sd_ajax_get_picker(<?php echo $id;
471
-				if ( $search_for_id ) {
471
+				if ($search_for_id) {
472 472
 					echo "," . $search_for_id;
473 473
 				} ?>);" href="#TB_inline?width=100%&height=550&inlineId=super-duper-content-ajaxed"
474 474
 				   class="thickbox button super-duper-content-open" title="Add Shortcode">
@@ -484,7 +484,7 @@  discard block
 block discarded – undo
484 484
 			$html = ob_get_clean();
485 485
 
486 486
 			// remove line breaks so we can use it in js
487
-			return preg_replace( "/\r|\n/", "", trim( $html ) );
487
+			return preg_replace("/\r|\n/", "", trim($html));
488 488
 		}
489 489
 
490 490
 		/**
@@ -542,7 +542,7 @@  discard block
 block discarded – undo
542 542
 						jQuery($this).data('sd-widget-enabled', true);
543 543
 					}
544 544
 
545
-					var $button = '<button title="<?php _e( 'Advanced Settings', 'ayecode-connect' );?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
545
+					var $button = '<button title="<?php _e('Advanced Settings', 'ayecode-connect'); ?>" class="button button-primary right sd-advanced-button" onclick="sd_so_toggle_advanced(this);return false;"><i class="fas fa-sliders-h" aria-hidden="true"></i></button>';
546 546
 					var form = jQuery($this).parents('' + $selector + '');
547 547
 
548 548
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -577,10 +577,10 @@  discard block
 block discarded – undo
577 577
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
578 578
 			 */
579 579
 
580
-			return str_replace( array(
580
+			return str_replace(array(
581 581
 				'<script>',
582 582
 				'</script>'
583
-			), '', $output );
583
+			), '', $output);
584 584
 		}
585 585
 
586 586
 		/**
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 		 *@since 1.0.6
593 593
 		 *
594 594
 		 */
595
-		public static function shortcode_insert_button_script( $editor_id = '', $insert_shortcode_function = '' ) {
595
+		public static function shortcode_insert_button_script($editor_id = '', $insert_shortcode_function = '') {
596 596
 			?>
597 597
 			<style>
598 598
 				.sd-shortcode-left-wrap {
@@ -711,25 +711,25 @@  discard block
 block discarded – undo
711 711
 					width: 100%;
712 712
 				}
713 713
 
714
-				<?php if ( function_exists( 'generate_sections_sections_metabox' ) ) { ?>
714
+				<?php if (function_exists('generate_sections_sections_metabox')) { ?>
715 715
 				.generate-sections-modal #custom-media-buttons > .sd-lable-shortcode-inserter {
716 716
 					display: inline;
717 717
 				}
718 718
 				<?php } ?>
719
-				<?php if ( function_exists( 'et_builder_is_tb_admin_screen' ) && et_builder_is_tb_admin_screen() ) { ?>
719
+				<?php if (function_exists('et_builder_is_tb_admin_screen') && et_builder_is_tb_admin_screen()) { ?>
720 720
 				body.divi_page_et_theme_builder div#TB_window.gd-tb-window{z-index:9999999}
721 721
 				<?php } ?>
722 722
 			</style>
723 723
 			<?php
724
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
724
+			if (class_exists('SiteOrigin_Panels')) {
725 725
 				echo "<script>" . self::siteorigin_js() . "</script>";
726 726
 			}
727 727
 			?>
728 728
 			<script>
729 729
 				<?php
730
-				if(! empty( $insert_shortcode_function )){
730
+				if (!empty($insert_shortcode_function)) {
731 731
 					echo $insert_shortcode_function;
732
-				}else{
732
+				} else {
733 733
 
734 734
 				/**
735 735
 				 * Function for super duper insert shortcode.
@@ -742,9 +742,9 @@  discard block
 block discarded – undo
742 742
 					if ($shortcode) {
743 743
 						if (!$editor_id) {
744 744
 							<?php
745
-							if ( isset( $_REQUEST['et_fb'] ) ) {
745
+							if (isset($_REQUEST['et_fb'])) {
746 746
 								echo '$editor_id = "#main_content_content_vb_tiny_mce";';
747
-							} elseif ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) {
747
+							} elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') {
748 748
 								echo '$editor_id = "#elementor-controls .wp-editor-container textarea";';
749 749
 							} else {
750 750
 								echo '$editor_id = "#wp-content-editor-container textarea";';
@@ -827,11 +827,11 @@  discard block
 block discarded – undo
827 827
 							'shortcode': $short_code,
828 828
 							'attributes': 123,
829 829
 							'post_id': 321,
830
-							'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
830
+							'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
831 831
 						};
832 832
 
833 833
 						if (typeof ajaxurl === 'undefined') {
834
-							var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' );?>";
834
+							var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
835 835
 						}
836 836
 
837 837
 						jQuery.post(ajaxurl, data, function (response) {
@@ -1030,11 +1030,11 @@  discard block
 block discarded – undo
1030 1030
 					var data = {
1031 1031
 						'action': 'super_duper_get_picker',
1032 1032
 						'editor_id': $id,
1033
-						'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_picker' );?>'
1033
+						'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_picker'); ?>'
1034 1034
 					};
1035 1035
 
1036 1036
 					if (!ajaxurl) {
1037
-						var ajaxurl = "<?php echo admin_url( 'admin-ajax.php' ); ?>";
1037
+						var ajaxurl = "<?php echo admin_url('admin-ajax.php'); ?>";
1038 1038
 					}
1039 1039
 
1040 1040
 					jQuery.post(ajaxurl, data, function (response) {
@@ -1056,9 +1056,9 @@  discard block
 block discarded – undo
1056 1056
 				 */
1057 1057
 				function sd_shortcode_button($id) {
1058 1058
 					if ($id) {
1059
-						return '<?php echo self::shortcode_button( "\\''+\$id+'\\'" );?>';
1059
+						return '<?php echo self::shortcode_button("\\''+\$id+'\\'"); ?>';
1060 1060
 					} else {
1061
-						return '<?php echo self::shortcode_button();?>';
1061
+						return '<?php echo self::shortcode_button(); ?>';
1062 1062
 					}
1063 1063
 				}
1064 1064
 			</script>
@@ -1072,11 +1072,11 @@  discard block
 block discarded – undo
1072 1072
 		 *
1073 1073
 		 * @return mixed
1074 1074
 		 */
1075
-		public function widget_css( $advanced = true ) {
1075
+		public function widget_css($advanced = true) {
1076 1076
 			ob_start();
1077 1077
 			?>
1078 1078
 			<style>
1079
-				<?php if( $advanced ){ ?>
1079
+				<?php if ($advanced) { ?>
1080 1080
 				.sd-advanced-setting {
1081 1081
 					display: none;
1082 1082
 				}
@@ -1120,10 +1120,10 @@  discard block
 block discarded – undo
1120 1120
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1121 1121
 			 */
1122 1122
 
1123
-			return str_replace( array(
1123
+			return str_replace(array(
1124 1124
 				'<style>',
1125 1125
 				'</style>'
1126
-			), '', $output );
1126
+			), '', $output);
1127 1127
 		}
1128 1128
 
1129 1129
 		/**
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 						jQuery($this).data('sd-widget-enabled', true);
1191 1191
 					}
1192 1192
 
1193
-					var $button = '<button title="<?php _e( 'Advanced Settings', 'ayecode-connect' );?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1193
+					var $button = '<button title="<?php _e('Advanced Settings', 'ayecode-connect'); ?>" style="line-height: 28px;" class="button button-primary right sd-advanced-button" onclick="sd_toggle_advanced(this);return false;"><span class="dashicons dashicons-admin-settings" style="width: 28px;font-size: 28px;"></span></button>';
1194 1194
 					var form = $form ? $form : jQuery($this).parents('' + $selector + '');
1195 1195
 
1196 1196
 					if (jQuery($this).val() == '1' && jQuery(form).find('.sd-advanced-button').length == 0) {
@@ -1281,7 +1281,7 @@  discard block
 block discarded – undo
1281 1281
 					});
1282 1282
 
1283 1283
 				}
1284
-				<?php do_action( 'wp_super_duper_widget_js', $this ); ?>
1284
+				<?php do_action('wp_super_duper_widget_js', $this); ?>
1285 1285
 			</script>
1286 1286
 			<?php
1287 1287
 			$output = ob_get_clean();
@@ -1290,10 +1290,10 @@  discard block
 block discarded – undo
1290 1290
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
1291 1291
 			 */
1292 1292
 
1293
-			return str_replace( array(
1293
+			return str_replace(array(
1294 1294
 				'<script>',
1295 1295
 				'</script>'
1296
-			), '', $output );
1296
+			), '', $output);
1297 1297
 		}
1298 1298
 
1299 1299
 
@@ -1304,14 +1304,14 @@  discard block
 block discarded – undo
1304 1304
 		 *
1305 1305
 		 * @return mixed
1306 1306
 		 */
1307
-		private function add_name_from_key( $options, $arguments = false ) {
1308
-			if ( ! empty( $options['arguments'] ) ) {
1309
-				foreach ( $options['arguments'] as $key => $val ) {
1310
-					$options['arguments'][ $key ]['name'] = $key;
1307
+		private function add_name_from_key($options, $arguments = false) {
1308
+			if (!empty($options['arguments'])) {
1309
+				foreach ($options['arguments'] as $key => $val) {
1310
+					$options['arguments'][$key]['name'] = $key;
1311 1311
 				}
1312
-			} elseif ( $arguments && is_array( $options ) && ! empty( $options ) ) {
1313
-				foreach ( $options as $key => $val ) {
1314
-					$options[ $key ]['name'] = $key;
1312
+			} elseif ($arguments && is_array($options) && !empty($options)) {
1313
+				foreach ($options as $key => $val) {
1314
+					$options[$key]['name'] = $key;
1315 1315
 				}
1316 1316
 			}
1317 1317
 
@@ -1324,8 +1324,8 @@  discard block
 block discarded – undo
1324 1324
 		 * @since 1.0.0
1325 1325
 		 */
1326 1326
 		public function register_shortcode() {
1327
-			add_shortcode( $this->base_id, array( $this, 'shortcode_output' ) );
1328
-			add_action( 'wp_ajax_super_duper_output_shortcode', array( $this, 'render_shortcode' ) );
1327
+			add_shortcode($this->base_id, array($this, 'shortcode_output'));
1328
+			add_action('wp_ajax_super_duper_output_shortcode', array($this, 'render_shortcode'));
1329 1329
 		}
1330 1330
 
1331 1331
 		/**
@@ -1334,50 +1334,50 @@  discard block
 block discarded – undo
1334 1334
 		 * @since 1.0.0
1335 1335
 		 */
1336 1336
 		public function render_shortcode() {
1337
-			check_ajax_referer( 'super_duper_output_shortcode', '_ajax_nonce', true );
1338
-			if ( ! current_user_can( 'manage_options' ) ) {
1337
+			check_ajax_referer('super_duper_output_shortcode', '_ajax_nonce', true);
1338
+			if (!current_user_can('manage_options')) {
1339 1339
 				wp_die();
1340 1340
 			}
1341 1341
 
1342 1342
 			// we might need the $post value here so lets set it.
1343
-			if ( isset( $_POST['post_id'] ) && $_POST['post_id'] ) {
1344
-				$post_obj = get_post( absint( $_POST['post_id'] ) );
1345
-				if ( ! empty( $post_obj ) && empty( $post ) ) {
1343
+			if (isset($_POST['post_id']) && $_POST['post_id']) {
1344
+				$post_obj = get_post(absint($_POST['post_id']));
1345
+				if (!empty($post_obj) && empty($post)) {
1346 1346
 					global $post;
1347 1347
 					$post = $post_obj;
1348 1348
 				}
1349 1349
 			}
1350 1350
 
1351
-			if ( isset( $_POST['shortcode'] ) && $_POST['shortcode'] ) {
1351
+			if (isset($_POST['shortcode']) && $_POST['shortcode']) {
1352 1352
 				$is_preview = $this->is_preview();
1353
-				$shortcode_name   = sanitize_title_with_dashes( $_POST['shortcode'] );
1354
-				$attributes_array = isset( $_POST['attributes'] ) && $_POST['attributes'] ? $_POST['attributes'] : array();
1353
+				$shortcode_name   = sanitize_title_with_dashes($_POST['shortcode']);
1354
+				$attributes_array = isset($_POST['attributes']) && $_POST['attributes'] ? $_POST['attributes'] : array();
1355 1355
 				$attributes       = '';
1356
-				if ( ! empty( $attributes_array ) ) {
1357
-					foreach ( $attributes_array as $key => $value ) {
1358
-						if ( is_array( $value ) ) {
1359
-							$value = implode( ",", $value );
1356
+				if (!empty($attributes_array)) {
1357
+					foreach ($attributes_array as $key => $value) {
1358
+						if (is_array($value)) {
1359
+							$value = implode(",", $value);
1360 1360
 						}
1361 1361
 
1362
-						if ( ! empty( $value ) ) {
1363
-							$value = wp_unslash( $value );
1362
+						if (!empty($value)) {
1363
+							$value = wp_unslash($value);
1364 1364
 
1365 1365
 							// Encode [ and ].
1366
-							if ( $is_preview ) {
1367
-								$value = $this->encode_shortcodes( $value );
1366
+							if ($is_preview) {
1367
+								$value = $this->encode_shortcodes($value);
1368 1368
 							}
1369 1369
 						}
1370
-						$attributes .= " " . esc_attr( sanitize_title_with_dashes( $key ) ) . "='" . esc_attr( $value ) . "' ";
1370
+						$attributes .= " " . esc_attr(sanitize_title_with_dashes($key)) . "='" . esc_attr($value) . "' ";
1371 1371
 					}
1372 1372
 				}
1373 1373
 
1374
-				$shortcode = "[" . esc_attr( $shortcode_name ) . " " . $attributes . "]";
1374
+				$shortcode = "[" . esc_attr($shortcode_name) . " " . $attributes . "]";
1375 1375
 
1376
-				$content = do_shortcode( $shortcode );
1376
+				$content = do_shortcode($shortcode);
1377 1377
 
1378 1378
 				// Decode [ and ].
1379
-				if ( ! empty( $content ) && $is_preview ) {
1380
-					$content = $this->decode_shortcodes( $content );
1379
+				if (!empty($content) && $is_preview) {
1380
+					$content = $this->decode_shortcodes($content);
1381 1381
 				}
1382 1382
 
1383 1383
 				echo $content;
@@ -1393,21 +1393,21 @@  discard block
 block discarded – undo
1393 1393
 		 *
1394 1394
 		 * @return string
1395 1395
 		 */
1396
-		public function shortcode_output( $args = array(), $content = '' ) {
1396
+		public function shortcode_output($args = array(), $content = '') {
1397 1397
 			$_instance = $args;
1398 1398
 
1399
-			$args = $this->argument_values( $args );
1399
+			$args = $this->argument_values($args);
1400 1400
 
1401 1401
 			// add extra argument so we know its a output to gutenberg
1402 1402
 			//$args
1403
-			$args = $this->string_to_bool( $args );
1403
+			$args = $this->string_to_bool($args);
1404 1404
 
1405 1405
 			// if we have a enclosed shortcode we add it to the special `html` argument
1406
-			if ( ! empty( $content ) ) {
1406
+			if (!empty($content)) {
1407 1407
 				$args['html'] = $content;
1408 1408
 			}
1409 1409
 
1410
-			if ( ! $this->is_preview() ) {
1410
+			if (!$this->is_preview()) {
1411 1411
 				/**
1412 1412
 				 * Filters the settings for a particular widget args.
1413 1413
 				 *
@@ -1418,40 +1418,40 @@  discard block
 block discarded – undo
1418 1418
 				 *@since 1.0.28
1419 1419
 				 *
1420 1420
 				 */
1421
-				$args = apply_filters( 'wp_super_duper_widget_display_callback', $args, $this, $_instance );
1421
+				$args = apply_filters('wp_super_duper_widget_display_callback', $args, $this, $_instance);
1422 1422
 
1423
-				if ( ! is_array( $args ) ) {
1423
+				if (!is_array($args)) {
1424 1424
 					return $args;
1425 1425
 				}
1426 1426
 			}
1427 1427
 
1428
-			$class = isset( $this->options['widget_ops']['classname'] ) ? esc_attr( $this->options['widget_ops']['classname'] ) : '';
1429
-			$class .= " sdel-".$this->get_instance_hash();
1428
+			$class = isset($this->options['widget_ops']['classname']) ? esc_attr($this->options['widget_ops']['classname']) : '';
1429
+			$class .= " sdel-" . $this->get_instance_hash();
1430 1430
 
1431
-			$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
1432
-			$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
1431
+			$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
1432
+			$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
1433 1433
 
1434
-			$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
1435
-			$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
1434
+			$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
1435
+			$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
1436 1436
 
1437 1437
 			$shortcode_args = array();
1438 1438
 			$output         = '';
1439
-			$no_wrap        = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
1440
-			if ( isset( $args['no_wrap'] ) && $args['no_wrap'] ) {
1439
+			$no_wrap        = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
1440
+			if (isset($args['no_wrap']) && $args['no_wrap']) {
1441 1441
 				$no_wrap = true;
1442 1442
 			}
1443
-			$main_content = $this->output( $args, $shortcode_args, $content );
1444
-			if ( $main_content && ! $no_wrap ) {
1443
+			$main_content = $this->output($args, $shortcode_args, $content);
1444
+			if ($main_content && !$no_wrap) {
1445 1445
 				// wrap the shortcode in a div with the same class as the widget
1446 1446
 				$output .= '<div class="' . $class . '" ' . $attrs . '>';
1447
-				if ( ! empty( $args['title'] ) ) {
1447
+				if (!empty($args['title'])) {
1448 1448
 					// if its a shortcode and there is a title try to grab the title wrappers
1449
-					$shortcode_args = array( 'before_title' => '', 'after_title' => '' );
1450
-					if ( empty( $instance ) ) {
1449
+					$shortcode_args = array('before_title' => '', 'after_title' => '');
1450
+					if (empty($instance)) {
1451 1451
 						global $wp_registered_sidebars;
1452
-						if ( ! empty( $wp_registered_sidebars ) ) {
1453
-							foreach ( $wp_registered_sidebars as $sidebar ) {
1454
-								if ( ! empty( $sidebar['before_title'] ) ) {
1452
+						if (!empty($wp_registered_sidebars)) {
1453
+							foreach ($wp_registered_sidebars as $sidebar) {
1454
+								if (!empty($sidebar['before_title'])) {
1455 1455
 									$shortcode_args['before_title'] = $sidebar['before_title'];
1456 1456
 									$shortcode_args['after_title']  = $sidebar['after_title'];
1457 1457
 									break;
@@ -1459,20 +1459,20 @@  discard block
 block discarded – undo
1459 1459
 							}
1460 1460
 						}
1461 1461
 					}
1462
-					$output .= $this->output_title( $shortcode_args, $args );
1462
+					$output .= $this->output_title($shortcode_args, $args);
1463 1463
 				}
1464 1464
 				$output .= $main_content;
1465 1465
 				$output .= '</div>';
1466
-			} elseif ( $main_content && $no_wrap ) {
1466
+			} elseif ($main_content && $no_wrap) {
1467 1467
 				$output .= $main_content;
1468 1468
 			}
1469 1469
 
1470 1470
 			// if preview show a placeholder if empty
1471
-			if ( $this->is_preview() && $output == '' ) {
1472
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
1471
+			if ($this->is_preview() && $output == '') {
1472
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
1473 1473
 			}
1474 1474
 
1475
-			return apply_filters( 'wp_super_duper_widget_output', $output, $args, $shortcode_args, $this );
1475
+			return apply_filters('wp_super_duper_widget_output', $output, $args, $shortcode_args, $this);
1476 1476
 		}
1477 1477
 
1478 1478
 		/**
@@ -1482,8 +1482,8 @@  discard block
 block discarded – undo
1482 1482
 		 *
1483 1483
 		 * @return string
1484 1484
 		 */
1485
-		public function preview_placeholder_text( $name = '' ) {
1486
-			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf( __( 'Placeholder for: %s', 'ayecode-connect' ), $name ) . "</div>";
1485
+		public function preview_placeholder_text($name = '') {
1486
+			return "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" . wp_sprintf(__('Placeholder for: %s', 'ayecode-connect'), $name) . "</div>";
1487 1487
 		}
1488 1488
 
1489 1489
 		/**
@@ -1493,13 +1493,13 @@  discard block
 block discarded – undo
1493 1493
 		 *
1494 1494
 		 * @return mixed
1495 1495
 		 */
1496
-		public function string_to_bool( $options ) {
1496
+		public function string_to_bool($options) {
1497 1497
 			// convert bool strings to booleans
1498
-			foreach ( $options as $key => $val ) {
1499
-				if ( $val == 'false' ) {
1500
-					$options[ $key ] = false;
1501
-				} elseif ( $val == 'true' ) {
1502
-					$options[ $key ] = true;
1498
+			foreach ($options as $key => $val) {
1499
+				if ($val == 'false') {
1500
+					$options[$key] = false;
1501
+				} elseif ($val == 'true') {
1502
+					$options[$key] = true;
1503 1503
 				}
1504 1504
 			}
1505 1505
 
@@ -1515,26 +1515,26 @@  discard block
 block discarded – undo
1515 1515
 		 *@since 1.0.12 Don't set checkbox default value if the value is empty.
1516 1516
 		 *
1517 1517
 		 */
1518
-		public function argument_values( $instance ) {
1518
+		public function argument_values($instance) {
1519 1519
 			$argument_values = array();
1520 1520
 
1521 1521
 			// set widget instance
1522 1522
 			$this->instance = $instance;
1523 1523
 
1524
-			if ( empty( $this->arguments ) ) {
1524
+			if (empty($this->arguments)) {
1525 1525
 				$this->arguments = $this->get_arguments();
1526 1526
 			}
1527 1527
 
1528
-			if ( ! empty( $this->arguments ) ) {
1529
-				foreach ( $this->arguments as $key => $args ) {
1528
+			if (!empty($this->arguments)) {
1529
+				foreach ($this->arguments as $key => $args) {
1530 1530
 					// set the input name from the key
1531 1531
 					$args['name'] = $key;
1532 1532
 					//
1533
-					$argument_values[ $key ] = isset( $instance[ $key ] ) ? $instance[ $key ] : '';
1534
-					if ( $args['type'] == 'checkbox' && $argument_values[ $key ] == '' ) {
1533
+					$argument_values[$key] = isset($instance[$key]) ? $instance[$key] : '';
1534
+					if ($args['type'] == 'checkbox' && $argument_values[$key] == '') {
1535 1535
 						// don't set default for an empty checkbox
1536
-					} elseif ( $argument_values[ $key ] == '' && isset( $args['default'] ) ) {
1537
-						$argument_values[ $key ] = $args['default'];
1536
+					} elseif ($argument_values[$key] == '' && isset($args['default'])) {
1537
+						$argument_values[$key] = $args['default'];
1538 1538
 					}
1539 1539
 				}
1540 1540
 			}
@@ -1561,12 +1561,12 @@  discard block
 block discarded – undo
1561 1561
 		 *
1562 1562
 		 */
1563 1563
 		public function get_arguments() {
1564
-			if ( empty( $this->arguments ) ) {
1564
+			if (empty($this->arguments)) {
1565 1565
 				$this->arguments = $this->set_arguments();
1566 1566
 			}
1567 1567
 
1568
-			$this->arguments = apply_filters( 'wp_super_duper_arguments', $this->arguments, $this->options, $this->instance );
1569
-			$this->arguments = $this->add_name_from_key( $this->arguments, true );
1568
+			$this->arguments = apply_filters('wp_super_duper_arguments', $this->arguments, $this->options, $this->instance);
1569
+			$this->arguments = $this->add_name_from_key($this->arguments, true);
1570 1570
 
1571 1571
 			return $this->arguments;
1572 1572
 		}
@@ -1578,7 +1578,7 @@  discard block
 block discarded – undo
1578 1578
 		 * @param array $widget_args
1579 1579
 		 * @param string $content
1580 1580
 		 */
1581
-		public function output( $args = array(), $widget_args = array(), $content = '' ) {
1581
+		public function output($args = array(), $widget_args = array(), $content = '') {
1582 1582
 
1583 1583
 		}
1584 1584
 
@@ -1586,9 +1586,9 @@  discard block
 block discarded – undo
1586 1586
 		 * Add the dynamic block code inline when the wp-block in enqueued.
1587 1587
 		 */
1588 1588
 		public function register_block() {
1589
-			wp_add_inline_script( 'wp-blocks', $this->block() );
1590
-			if ( class_exists( 'SiteOrigin_Panels' ) ) {
1591
-				wp_add_inline_script( 'wp-blocks', $this->siteorigin_js() );
1589
+			wp_add_inline_script('wp-blocks', $this->block());
1590
+			if (class_exists('SiteOrigin_Panels')) {
1591
+				wp_add_inline_script('wp-blocks', $this->siteorigin_js());
1592 1592
 			}
1593 1593
 		}
1594 1594
 
@@ -1602,9 +1602,9 @@  discard block
 block discarded – undo
1602 1602
 			$show      = false;
1603 1603
 			$arguments = $this->get_arguments();
1604 1604
 
1605
-			if ( ! empty( $arguments ) ) {
1606
-				foreach ( $arguments as $argument ) {
1607
-					if ( isset( $argument['advanced'] ) && $argument['advanced'] ) {
1605
+			if (!empty($arguments)) {
1606
+				foreach ($arguments as $argument) {
1607
+					if (isset($argument['advanced']) && $argument['advanced']) {
1608 1608
 						$show = true;
1609 1609
 						break; // no need to continue if we know we have it
1610 1610
 					}
@@ -1622,19 +1622,19 @@  discard block
 block discarded – undo
1622 1622
 		public function get_url() {
1623 1623
 			$url = $this->url;
1624 1624
 
1625
-			if ( ! $url ) {
1626
-				$content_dir = wp_normalize_path( untrailingslashit( WP_CONTENT_DIR ) );
1627
-				$content_url = untrailingslashit( WP_CONTENT_URL );
1625
+			if (!$url) {
1626
+				$content_dir = wp_normalize_path(untrailingslashit(WP_CONTENT_DIR));
1627
+				$content_url = untrailingslashit(WP_CONTENT_URL);
1628 1628
 
1629 1629
 				// Replace http:// to https://.
1630
-				if ( strpos( $content_url, 'http://' ) === 0 && strpos( plugins_url(), 'https://' ) === 0 ) {
1631
-					$content_url = str_replace( 'http://', 'https://', $content_url );
1630
+				if (strpos($content_url, 'http://') === 0 && strpos(plugins_url(), 'https://') === 0) {
1631
+					$content_url = str_replace('http://', 'https://', $content_url);
1632 1632
 				}
1633 1633
 
1634 1634
 				// Check if we are inside a plugin
1635
-				$file_dir = str_replace( "/includes", "", wp_normalize_path( dirname( __FILE__ ) ) );
1636
-				$url = str_replace( $content_dir, $content_url, $file_dir );
1637
-				$url = trailingslashit( $url );
1635
+				$file_dir = str_replace("/includes", "", wp_normalize_path(dirname(__FILE__)));
1636
+				$url = str_replace($content_dir, $content_url, $file_dir);
1637
+				$url = trailingslashit($url);
1638 1638
 				$this->url = $url;
1639 1639
 			}
1640 1640
 
@@ -1650,15 +1650,15 @@  discard block
 block discarded – undo
1650 1650
 
1651 1651
 			$url = $this->url;
1652 1652
 
1653
-			if ( ! $url ) {
1653
+			if (!$url) {
1654 1654
 				// check if we are inside a plugin
1655
-				$file_dir = str_replace( "/includes", "", dirname( __FILE__ ) );
1655
+				$file_dir = str_replace("/includes", "", dirname(__FILE__));
1656 1656
 
1657
-				$dir_parts = explode( "/wp-content/", $file_dir );
1658
-				$url_parts = explode( "/wp-content/", plugins_url() );
1657
+				$dir_parts = explode("/wp-content/", $file_dir);
1658
+				$url_parts = explode("/wp-content/", plugins_url());
1659 1659
 
1660
-				if ( ! empty( $url_parts[0] ) && ! empty( $dir_parts[1] ) ) {
1661
-					$url       = trailingslashit( $url_parts[0] . "/wp-content/" . $dir_parts[1] );
1660
+				if (!empty($url_parts[0]) && !empty($dir_parts[1])) {
1661
+					$url       = trailingslashit($url_parts[0] . "/wp-content/" . $dir_parts[1]);
1662 1662
 					$this->url = $url;
1663 1663
 				}
1664 1664
 			}
@@ -1679,45 +1679,45 @@  discard block
 block discarded – undo
1679 1679
 		 * @return string
1680 1680
 		 *@since 1.1.0
1681 1681
 		 */
1682
-		public function get_block_icon( $icon ) {
1682
+		public function get_block_icon($icon) {
1683 1683
 
1684 1684
 			// check if we have a Font Awesome icon
1685 1685
 			$fa_type = '';
1686
-			if ( substr( $icon, 0, 7 ) === "fas fa-" ) {
1686
+			if (substr($icon, 0, 7) === "fas fa-") {
1687 1687
 				$fa_type = 'solid';
1688
-			} elseif ( substr( $icon, 0, 7 ) === "far fa-" ) {
1688
+			} elseif (substr($icon, 0, 7) === "far fa-") {
1689 1689
 				$fa_type = 'regular';
1690
-			} elseif ( substr( $icon, 0, 7 ) === "fab fa-" ) {
1690
+			} elseif (substr($icon, 0, 7) === "fab fa-") {
1691 1691
 				$fa_type = 'brands';
1692 1692
 			} else {
1693 1693
 				$icon = "'" . $icon . "'";
1694 1694
 			}
1695 1695
 
1696 1696
 			// set the icon if we found one
1697
-			if ( $fa_type ) {
1698
-				$fa_icon = str_replace( array( "fas fa-", "far fa-", "fab fa-" ), "", $icon );
1697
+			if ($fa_type) {
1698
+				$fa_icon = str_replace(array("fas fa-", "far fa-", "fab fa-"), "", $icon);
1699 1699
 				$icon    = "el('svg',{width: 20, height: 20, viewBox: '0 0 20 20'},el('use', {'xlink:href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "','href': '" . $this->get_url() . "icons/" . $fa_type . ".svg#" . $fa_icon . "'}))";
1700 1700
 			}
1701 1701
 
1702 1702
 			return $icon;
1703 1703
 		}
1704 1704
 
1705
-		public function group_arguments( $arguments ) {
1706
-			if ( ! empty( $arguments ) ) {
1705
+		public function group_arguments($arguments) {
1706
+			if (!empty($arguments)) {
1707 1707
 				$temp_arguments = array();
1708
-				$general        = __( "General", 'ayecode-connect' );
1708
+				$general        = __("General", 'ayecode-connect');
1709 1709
 				$add_sections   = false;
1710
-				foreach ( $arguments as $key => $args ) {
1711
-					if ( isset( $args['group'] ) ) {
1712
-						$temp_arguments[ $args['group'] ][ $key ] = $args;
1710
+				foreach ($arguments as $key => $args) {
1711
+					if (isset($args['group'])) {
1712
+						$temp_arguments[$args['group']][$key] = $args;
1713 1713
 						$add_sections                             = true;
1714 1714
 					} else {
1715
-						$temp_arguments[ $general ][ $key ] = $args;
1715
+						$temp_arguments[$general][$key] = $args;
1716 1716
 					}
1717 1717
 				}
1718 1718
 
1719 1719
 				// only add sections if more than one
1720
-				if ( $add_sections ) {
1720
+				if ($add_sections) {
1721 1721
 					$arguments = $temp_arguments;
1722 1722
 				}
1723 1723
 			}
@@ -1730,38 +1730,38 @@  discard block
 block discarded – undo
1730 1730
 		 *
1731 1731
 		 * @since 1.1.17
1732 1732
 		 */
1733
-		public function group_block_tabs( $tabs, $arguments ) {
1734
-			if ( ! empty( $tabs ) && ! empty( $arguments ) ) {
1733
+		public function group_block_tabs($tabs, $arguments) {
1734
+			if (!empty($tabs) && !empty($arguments)) {
1735 1735
 				$has_sections = false;
1736 1736
 
1737
-				foreach ( $this->arguments as $key => $args ) {
1738
-					if ( isset( $args['group'] ) ) {
1737
+				foreach ($this->arguments as $key => $args) {
1738
+					if (isset($args['group'])) {
1739 1739
 						$has_sections = true;
1740 1740
 						break;
1741 1741
 					}
1742 1742
 				}
1743 1743
 
1744
-				if ( ! $has_sections ) {
1744
+				if (!$has_sections) {
1745 1745
 					return $tabs;
1746 1746
 				}
1747 1747
 
1748 1748
 				$new_tabs = array();
1749 1749
 
1750
-				foreach ( $tabs as $tab_key => $tab ) {
1750
+				foreach ($tabs as $tab_key => $tab) {
1751 1751
 					$new_groups = array();
1752 1752
 
1753
-					if ( ! empty( $tab['groups'] ) && is_array( $tab['groups'] ) ) {
1754
-						foreach ( $tab['groups'] as $group ) {
1755
-							if ( isset( $arguments[ $group ] ) ) {
1753
+					if (!empty($tab['groups']) && is_array($tab['groups'])) {
1754
+						foreach ($tab['groups'] as $group) {
1755
+							if (isset($arguments[$group])) {
1756 1756
 								$new_groups[] = $group;
1757 1757
 							}
1758 1758
 						}
1759 1759
 					}
1760 1760
 
1761
-					if ( ! empty( $new_groups ) ) {
1761
+					if (!empty($new_groups)) {
1762 1762
 						$tab['groups'] = $new_groups;
1763 1763
 
1764
-						$new_tabs[ $tab_key ] = $tab;
1764
+						$new_tabs[$tab_key] = $tab;
1765 1765
 					}
1766 1766
 				}
1767 1767
 
@@ -1788,7 +1788,7 @@  discard block
 block discarded – undo
1788 1788
 			?>
1789 1789
 			<script>
1790 1790
 			<?php
1791
-			if ( ! $sd_is_js_functions_loaded ) {
1791
+			if (!$sd_is_js_functions_loaded) {
1792 1792
 				$sd_is_js_functions_loaded = true;
1793 1793
 			?>
1794 1794
 function sd_show_view_options($this){
@@ -2065,7 +2065,7 @@  discard block
 block discarded – undo
2065 2065
 	}
2066 2066
 }
2067 2067
 
2068
-<?php if( !isset( $_REQUEST['sd-block-recover-debug'] ) ){ ?>
2068
+<?php if (!isset($_REQUEST['sd-block-recover-debug'])) { ?>
2069 2069
 // Wait will window is loaded before calling.
2070 2070
 window.onload = function() {
2071 2071
 	sd_auto_recover_blocks();
@@ -2244,7 +2244,7 @@  discard block
 block discarded – undo
2244 2244
 				$classes = [];
2245 2245
 
2246 2246
 				<?php
2247
-				if($aui_bs5){
2247
+				if ($aui_bs5) {
2248 2248
 					?>
2249 2249
 				$aui_bs5 = true;
2250 2250
 				$p_ml = 'ms-';
@@ -2253,7 +2253,7 @@  discard block
 block discarded – undo
2253 2253
 				$p_pl = 'ps-';
2254 2254
 				$p_pr = 'pe-';
2255 2255
 					<?php
2256
-				}else{
2256
+				} else {
2257 2257
 						?>
2258 2258
 				$aui_bs5 = false;
2259 2259
 				$p_ml = 'ml-';
@@ -2441,7 +2441,7 @@  discard block
 block discarded – undo
2441 2441
 			}
2442 2442
 
2443 2443
 			function sd_get_class_build_keys(){
2444
-				return <?php echo json_encode(sd_get_class_build_keys());?>;
2444
+				return <?php echo json_encode(sd_get_class_build_keys()); ?>;
2445 2445
 			}
2446 2446
 
2447 2447
 			<?php
@@ -2449,7 +2449,7 @@  discard block
 block discarded – undo
2449 2449
 
2450 2450
 			}
2451 2451
 
2452
-			if(method_exists($this,'block_global_js')){
2452
+			if (method_exists($this, 'block_global_js')) {
2453 2453
 					echo $this->block_global_js();
2454 2454
 			}
2455 2455
 			?>
@@ -2481,9 +2481,9 @@  discard block
 block discarded – undo
2481 2481
 					var InnerBlocks = blockEditor.InnerBlocks;
2482 2482
 
2483 2483
 					var term_query_type = '';
2484
-					var post_type_rest_slugs = <?php if(! empty( $this->arguments ) && isset($this->arguments['post_type']['onchange_rest']['values'])){echo "[".json_encode($this->arguments['post_type']['onchange_rest']['values'])."]";}else{echo "[]";} ?>;
2485
-					const taxonomies_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2486
-					const sort_by_<?php echo str_replace("-","_", $this->id);?> = [{label: "Please wait", value: 0}];
2484
+					var post_type_rest_slugs = <?php if (!empty($this->arguments) && isset($this->arguments['post_type']['onchange_rest']['values'])) {echo "[" . json_encode($this->arguments['post_type']['onchange_rest']['values']) . "]"; } else {echo "[]"; } ?>;
2485
+					const taxonomies_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2486
+					const sort_by_<?php echo str_replace("-", "_", $this->id); ?> = [{label: "Please wait", value: 0}];
2487 2487
 					const MediaUpload = wp.blockEditor.MediaUpload;
2488 2488
 
2489 2489
 					/**
@@ -2498,87 +2498,87 @@  discard block
 block discarded – undo
2498 2498
 					 * @return {?WPBlock}          The block, if it has been successfully
2499 2499
 					 *                             registered; otherwise `undefined`.
2500 2500
 					 */
2501
-					registerBlockType('<?php echo str_replace( "_", "-", sanitize_title_with_dashes( $this->options['textdomain'] ) . '/' . sanitize_title_with_dashes( $this->options['class_name'] ) );  ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
2502
-						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2 ; ?>,
2503
-						title: '<?php echo addslashes( $this->options['name'] ); ?>', // Block title.
2504
-						description: '<?php echo addslashes( $this->options['widget_ops']['description'] )?>', // Block title.
2505
-						icon: <?php echo $this->get_block_icon( $this->options['block-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/.
2501
+					registerBlockType('<?php echo str_replace("_", "-", sanitize_title_with_dashes($this->options['textdomain']) . '/' . sanitize_title_with_dashes($this->options['class_name'])); ?>', { // Block name. Block names must be string that contains a namespace prefix. Example: my-plugin/my-custom-block.
2502
+						apiVersion: <?php echo isset($this->options['block-api-version']) ? absint($this->options['block-api-version']) : 2; ?>,
2503
+						title: '<?php echo addslashes($this->options['name']); ?>', // Block title.
2504
+						description: '<?php echo addslashes($this->options['widget_ops']['description'])?>', // Block title.
2505
+						icon: <?php echo $this->get_block_icon($this->options['block-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/.
2506 2506
 						supports: {
2507 2507
 							<?php
2508
-							if(!isset($this->options['block-supports']['renaming'])){
2508
+							if (!isset($this->options['block-supports']['renaming'])) {
2509 2509
 								$this->options['block-supports']['renaming'] = false;
2510 2510
 							}
2511
-							if ( isset( $this->options['block-supports'] ) ) {
2512
-								echo $this->array_to_attributes( $this->options['block-supports'] );
2511
+							if (isset($this->options['block-supports'])) {
2512
+								echo $this->array_to_attributes($this->options['block-supports']);
2513 2513
 							}
2514 2514
 							?>
2515 2515
 						},
2516 2516
 						__experimentalLabel( attributes, { context } ) {
2517 2517
 							var visibility_html = attributes && attributes.visibility_conditions ? ' &#128065;' : '';
2518 2518
 							var metadata_name = attributes && attributes.metadata && attributes.metadata.name ? attributes.metadata.name : '';
2519
-							var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr( addslashes( $this->options['name'] ) ) . "'"; ?>;
2519
+							var label_name = <?php echo !empty($this->options['block-label']) ? $this->options['block-label'] : "'" . esc_attr(addslashes($this->options['name'])) . "'"; ?>;
2520 2520
 							return metadata_name ? metadata_name + visibility_html  : label_name + visibility_html;
2521 2521
 						},
2522
-						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.
2523
-						<?php if ( isset( $this->options['block-keywords'] ) ) {
2522
+						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.
2523
+						<?php if (isset($this->options['block-keywords'])) {
2524 2524
 						echo "keywords : " . $this->options['block-keywords'] . ",";
2525 2525
 						}
2526 2526
 
2527 2527
 
2528 2528
 						// block hover preview.
2529 2529
 						$example_args = array();
2530
-						if(!empty($this->arguments)){
2531
-							foreach($this->arguments as $key => $a_args){
2532
-								if(isset($a_args['example'])){
2530
+						if (!empty($this->arguments)) {
2531
+							foreach ($this->arguments as $key => $a_args) {
2532
+								if (isset($a_args['example'])) {
2533 2533
 									$example_args[$key] = $a_args['example'];
2534 2534
 								}
2535 2535
 							}
2536 2536
 						}
2537
-						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: '.absint($this->options['example']['viewportWidth']) : '';
2537
+						$viewport_width = isset($this->options['example']['viewportWidth']) ? 'viewportWidth: ' . absint($this->options['example']['viewportWidth']) : '';
2538 2538
 						$example_inner_blocks = !empty($this->options['example']['innerBlocks']) && is_array($this->options['example']['innerBlocks']) ? 'innerBlocks: ' . wp_json_encode($this->options['example']['innerBlocks']) : '';
2539
-						if( isset( $this->options['example'] ) && $this->options['example'] === false ){
2539
+						if (isset($this->options['example']) && $this->options['example'] === false) {
2540 2540
 							// no preview if set to false
2541
-						}elseif( !empty( $example_args ) ){
2542
-							echo "example : {attributes:{".$this->array_to_attributes( $example_args )."},$viewport_width},";
2543
-						}elseif( !empty( $this->options['example'] ) ){
2541
+						}elseif (!empty($example_args)) {
2542
+							echo "example : {attributes:{" . $this->array_to_attributes($example_args) . "},$viewport_width},";
2543
+						}elseif (!empty($this->options['example'])) {
2544 2544
 							unset($this->options['example']['viewportWidth']);
2545 2545
 							unset($this->options['example']['innerBlocks']);
2546
-							$example_atts = $this->array_to_attributes( $this->options['example'] );
2546
+							$example_atts = $this->array_to_attributes($this->options['example']);
2547 2547
 							$example_parts = array();
2548
-							if($example_atts){
2549
-								$example_parts[] = rtrim($example_atts,",");
2548
+							if ($example_atts) {
2549
+								$example_parts[] = rtrim($example_atts, ",");
2550 2550
 							}
2551
-							if($viewport_width){
2551
+							if ($viewport_width) {
2552 2552
 								$example_parts[] = $viewport_width;
2553 2553
 							}
2554
-							if($example_inner_blocks){
2554
+							if ($example_inner_blocks) {
2555 2555
 								$example_parts[] = $example_inner_blocks;
2556 2556
 							}
2557
-							if(!empty($example_parts)){
2558
-								echo "example : {".implode(',', $example_parts)."},";
2557
+							if (!empty($example_parts)) {
2558
+								echo "example : {" . implode(',', $example_parts) . "},";
2559 2559
 							}
2560
-						}else{
2560
+						} else {
2561 2561
 							echo 'example : {viewportWidth: 500},';
2562 2562
 						}
2563 2563
 
2564 2564
 
2565 2565
 
2566 2566
 						// limit to parent
2567
-						if( !empty( $this->options['parent'] ) ){
2568
-							echo "parent : " . wp_json_encode( $this->options['parent'] ) . ",";
2567
+						if (!empty($this->options['parent'])) {
2568
+							echo "parent : " . wp_json_encode($this->options['parent']) . ",";
2569 2569
 						}
2570 2570
 
2571 2571
 						// limit allowed blocks
2572
-						if( !empty( $this->options['allowed-blocks'] ) ){
2573
-							echo "allowedBlocks : " . wp_json_encode( $this->options['allowed-blocks'] ) . ",";
2572
+						if (!empty($this->options['allowed-blocks'])) {
2573
+							echo "allowedBlocks : " . wp_json_encode($this->options['allowed-blocks']) . ",";
2574 2574
 						}
2575 2575
 
2576 2576
 						// maybe set no_wrap
2577
-						$no_wrap = isset( $this->options['no_wrap'] ) && $this->options['no_wrap'] ? true : false;
2578
-						if ( isset( $this->arguments['no_wrap'] ) && $this->arguments['no_wrap'] ) {
2577
+						$no_wrap = isset($this->options['no_wrap']) && $this->options['no_wrap'] ? true : false;
2578
+						if (isset($this->arguments['no_wrap']) && $this->arguments['no_wrap']) {
2579 2579
 							$no_wrap = true;
2580 2580
 						}
2581
-						if ( $no_wrap ) {
2581
+						if ($no_wrap) {
2582 2582
 							$this->options['block-wrap'] = '';
2583 2583
 						}
2584 2584
 
@@ -2595,7 +2595,7 @@  discard block
 block discarded – undo
2595 2595
 
2596 2596
 							echo "attributes : {";
2597 2597
 
2598
-							if ( $show_advanced ) {
2598
+							if ($show_advanced) {
2599 2599
 								echo "show_advanced: {";
2600 2600
 								echo "	type: 'boolean',";
2601 2601
 								echo "  default: false,";
@@ -2603,57 +2603,57 @@  discard block
 block discarded – undo
2603 2603
 							}
2604 2604
 
2605 2605
 							// block wrap element
2606
-							if ( ! empty( $this->options['block-wrap'] ) ) { //@todo we should validate this?
2606
+							if (!empty($this->options['block-wrap'])) { //@todo we should validate this?
2607 2607
 								echo "block_wrap: {";
2608 2608
 								echo "	type: 'string',";
2609
-								echo "  default: '" . esc_attr( $this->options['block-wrap'] ) . "',";
2609
+								echo "  default: '" . esc_attr($this->options['block-wrap']) . "',";
2610 2610
 								echo "},";
2611 2611
 							}
2612 2612
 
2613 2613
 
2614
-							if ( ! empty( $this->arguments ) ) {
2614
+							if (!empty($this->arguments)) {
2615 2615
 
2616
-								foreach ( $this->arguments as $key => $args ) {
2616
+								foreach ($this->arguments as $key => $args) {
2617 2617
 
2618
-									if( $args['type'] == 'image' ||  $args['type'] == 'images' ){
2618
+									if ($args['type'] == 'image' || $args['type'] == 'images') {
2619 2619
 										$img_drag_drop = true;
2620 2620
 									}
2621 2621
 
2622 2622
 									// set if we should show alignment
2623
-									if ( $key == 'alignment' ) {
2623
+									if ($key == 'alignment') {
2624 2624
 										$show_alignment = true;
2625 2625
 									}
2626 2626
 
2627 2627
 									$extra = '';
2628 2628
 
2629
-									if ( $args['type'] == 'notice' ||  $args['type'] == 'tab' ) {
2629
+									if ($args['type'] == 'notice' || $args['type'] == 'tab') {
2630 2630
 										continue;
2631 2631
 									}
2632
-									elseif ( $args['type'] == 'checkbox' ) {
2632
+									elseif ($args['type'] == 'checkbox') {
2633 2633
 										$type    = 'boolean';
2634
-										$default = isset( $args['default'] ) && $args['default'] ? 'true' : 'false';
2635
-									} elseif ( $args['type'] == 'number' ) {
2634
+										$default = isset($args['default']) && $args['default'] ? 'true' : 'false';
2635
+									} elseif ($args['type'] == 'number') {
2636 2636
 										$type    = 'number';
2637
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2638
-									} elseif ( $args['type'] == 'select' && ! empty( $args['multiple'] ) ) {
2637
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2638
+									} elseif ($args['type'] == 'select' && !empty($args['multiple'])) {
2639 2639
 										$type = 'array';
2640
-										if ( isset( $args['default'] ) && is_array( $args['default'] ) ) {
2641
-											$default = ! empty( $args['default'] ) ? "['" . implode( "','", $args['default'] ) . "']" : "[]";
2640
+										if (isset($args['default']) && is_array($args['default'])) {
2641
+											$default = !empty($args['default']) ? "['" . implode("','", $args['default']) . "']" : "[]";
2642 2642
 										} else {
2643
-											$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2643
+											$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2644 2644
 										}
2645
-									} elseif ( $args['type'] == 'tagselect' ) {
2645
+									} elseif ($args['type'] == 'tagselect') {
2646 2646
 										$type    = 'array';
2647
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2648
-									} elseif ( $args['type'] == 'multiselect' ) {
2647
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2648
+									} elseif ($args['type'] == 'multiselect') {
2649 2649
 										$type    = 'array';
2650
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2651
-									} elseif ( $args['type'] == 'image_xy' ) {
2650
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2651
+									} elseif ($args['type'] == 'image_xy') {
2652 2652
 										$type    = 'object';
2653
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2654
-									} elseif ( $args['type'] == 'image' ) {
2653
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2654
+									} elseif ($args['type'] == 'image') {
2655 2655
 										$type    = 'string';
2656
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2656
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2657 2657
 
2658 2658
 										// add a field for ID
2659 2659
 	//                                    echo $key . "_id : {";
@@ -2665,7 +2665,7 @@  discard block
 block discarded – undo
2665 2665
 
2666 2666
 									} else {
2667 2667
 										$type    = !empty($args['hidden_type']) ? esc_attr($args['hidden_type']) : 'string';
2668
-										$default = isset( $args['default'] ) ? "'" . $args['default'] . "'" : "''";
2668
+										$default = isset($args['default']) ? "'" . $args['default'] . "'" : "''";
2669 2669
 
2670 2670
 									}
2671 2671
 									echo $key . " : {";
@@ -2678,7 +2678,7 @@  discard block
 block discarded – undo
2678 2678
 							echo "content : {type : 'string',default: 'Please select the attributes in the block settings'},";
2679 2679
 							echo "sd_shortcode : {type : 'string',default: ''},";
2680 2680
 
2681
-							if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
2681
+							if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) {
2682 2682
 								echo "sd_shortcode_close : {type : 'string',default: ''},";
2683 2683
 							}
2684 2684
 
@@ -2697,7 +2697,7 @@  discard block
 block discarded – undo
2697 2697
 
2698 2698
 <?php
2699 2699
 // only include the drag/drop functions if required.
2700
-if( $img_drag_drop ){
2700
+if ($img_drag_drop) {
2701 2701
 
2702 2702
 ?>
2703 2703
 
@@ -2763,9 +2763,9 @@  discard block
 block discarded – undo
2763 2763
 							}
2764 2764
 
2765 2765
 							<?php
2766
-							if(!empty($this->options['block-edit-raw'])) {
2766
+							if (!empty($this->options['block-edit-raw'])) {
2767 2767
 								echo $this->options['block-edit-raw']; // strings have to be in single quotes, may cause issues
2768
-							}else{
2768
+							} else {
2769 2769
 							?>
2770 2770
 
2771 2771
 function hasSelectedInnerBlock(props) {
@@ -2789,7 +2789,7 @@  discard block
 block discarded – undo
2789 2789
 	var $value = '';
2790 2790
 	<?php
2791 2791
 	// if we have a post_type and a category then link them
2792
-	if( isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked']) ){
2792
+	if (isset($this->arguments['post_type']) && isset($this->arguments['category']) && !empty($this->arguments['category']['post_type_linked'])) {
2793 2793
 	?>
2794 2794
 	if(typeof(prev_attributes[props.clientId]) != 'undefined' && selectedBlock && selectedBlock.clientId === props.clientId){
2795 2795
 		$pt = props.attributes.post_type;
@@ -2804,9 +2804,9 @@  discard block
 block discarded – undo
2804 2804
 		}
2805 2805
 <?php
2806 2806
 	$cat_path = '';
2807
-	if ( ! empty( $this->arguments['post_type']['onchange_rest']['path'] ) ) {
2808
-		$cat_path = esc_js( strip_tags( $this->arguments['post_type']['onchange_rest']['path'] ) );
2809
-		$cat_path = str_replace( array( '&quot;', '&#039;' ), array( '"', "'" ), $cat_path );
2807
+	if (!empty($this->arguments['post_type']['onchange_rest']['path'])) {
2808
+		$cat_path = esc_js(strip_tags($this->arguments['post_type']['onchange_rest']['path']));
2809
+		$cat_path = str_replace(array('&quot;', '&#039;'), array('"', "'"), $cat_path);
2810 2810
 	}
2811 2811
 ?>
2812 2812
 		/* taxonomies */
@@ -2814,15 +2814,15 @@  discard block
 block discarded – undo
2814 2814
 			if (!window.gdCPTCats) {
2815 2815
 				window.gdCPTCats = [];
2816 2816
 			}
2817
-			var gdCatPath = "<?php echo ( ! empty( $cat_path ) ? $cat_path : "/wp/v2/" + $value + "/categories/?per_page=100" ); ?>";
2817
+			var gdCatPath = "<?php echo (!empty($cat_path) ? $cat_path : "/wp/v2/" +$value + "/categories/?per_page=100"); ?>";
2818 2818
 			if (window.gdCPTCats[gdCatPath]) {
2819 2819
 				terms = window.gdCPTCats[gdCatPath];
2820
-				while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2821
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2820
+				while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2821
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2822 2822
 				}
2823
-				taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2823
+				taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2824 2824
 				jQuery.each( terms, function( key, val ) {
2825
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2825
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2826 2826
 				});
2827 2827
 
2828 2828
 				/* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */
@@ -2832,12 +2832,12 @@  discard block
 block discarded – undo
2832 2832
 			} else {
2833 2833
 				wp.apiFetch({path: gdCatPath}).then(terms => {
2834 2834
 					window.gdCPTCats[gdCatPath] = terms;
2835
-					while (taxonomies_<?php echo str_replace("-","_", $this->id);?>.length) {
2836
-						taxonomies_<?php echo str_replace("-","_", $this->id);?>.pop();
2835
+					while (taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2836
+						taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2837 2837
 					}
2838
-					taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: "All", value: 0});
2838
+					taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: "All", value: 0});
2839 2839
 					jQuery.each( terms, function( key, val ) {
2840
-						taxonomies_<?php echo str_replace("-","_", $this->id);?>.push({label: val.name, value: val.id});
2840
+						taxonomies_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val.name, value: val.id});
2841 2841
 					});
2842 2842
 
2843 2843
 					/* Setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options. */
@@ -2845,7 +2845,7 @@  discard block
 block discarded – undo
2845 2845
 					props.setAttributes({category: [0] });
2846 2846
 					props.setAttributes({category: $old_cat_value });
2847 2847
 
2848
-					return taxonomies_<?php echo str_replace("-","_", $this->id);?>;
2848
+					return taxonomies_<?php echo str_replace("-", "_", $this->id); ?>;
2849 2849
 				});
2850 2850
 			}
2851 2851
 		}
@@ -2857,12 +2857,12 @@  discard block
 block discarded – undo
2857 2857
 			}
2858 2858
 			if (window.gdCPTSort[$pt]) {
2859 2859
 				response = window.gdCPTSort[$pt];
2860
-				while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2861
-					sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2860
+				while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2861
+					sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2862 2862
 				}
2863 2863
 
2864 2864
 				jQuery.each( response, function( key, val ) {
2865
-					sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2865
+					sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2866 2866
 				});
2867 2867
 
2868 2868
 				// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2877,12 +2877,12 @@  discard block
 block discarded – undo
2877 2877
 				jQuery.post(ajaxurl, data, function(response) {
2878 2878
 					response = JSON.parse(response);
2879 2879
 					window.gdCPTSort[$pt] = response;
2880
-					while (sort_by_<?php echo str_replace("-","_", $this->id);?>.length) {
2881
-						sort_by_<?php echo str_replace("-","_", $this->id);?>.pop();
2880
+					while (sort_by_<?php echo str_replace("-", "_", $this->id); ?>.length) {
2881
+						sort_by_<?php echo str_replace("-", "_", $this->id); ?>.pop();
2882 2882
 					}
2883 2883
 
2884 2884
 					jQuery.each( response, function( key, val ) {
2885
-						sort_by_<?php echo str_replace("-","_", $this->id);?>.push({label: val, value: key});
2885
+						sort_by_<?php echo str_replace("-", "_", $this->id); ?>.push({label: val, value: key});
2886 2886
 					});
2887 2887
 
2888 2888
 					// setting the value back and fourth fixes the no update issue that sometimes happens where it won't update the options.
@@ -2890,7 +2890,7 @@  discard block
 block discarded – undo
2890 2890
 					props.setAttributes({sort_by: [0] });
2891 2891
 					props.setAttributes({sort_by: $old_sort_by_value });
2892 2892
 
2893
-					return sort_by_<?php echo str_replace("-","_", $this->id);?>;
2893
+					return sort_by_<?php echo str_replace("-", "_", $this->id); ?>;
2894 2894
 				});
2895 2895
 			}
2896 2896
 		}
@@ -2898,9 +2898,9 @@  discard block
 block discarded – undo
2898 2898
 	<?php } ?>
2899 2899
 <?php
2900 2900
 $current_screen = function_exists('get_current_screen') ? get_current_screen() : '';
2901
-if(!empty($current_screen->base) && $current_screen->base==='widgets'){
2901
+if (!empty($current_screen->base) && $current_screen->base === 'widgets') {
2902 2902
 	echo 'const { deviceType } = "";';
2903
-}else{
2903
+} else {
2904 2904
 ?>
2905 2905
 /** Get device type const. */
2906 2906
 const wpVersion = '<?php global $wp_version; echo esc_attr($wp_version); ?>';
@@ -2959,13 +2959,13 @@  discard block
 block discarded – undo
2959 2959
 
2960 2960
 									var data = {
2961 2961
 										'action': 'super_duper_output_shortcode',
2962
-										'shortcode': '<?php echo $this->options['base_id'];?>',
2962
+										'shortcode': '<?php echo $this->options['base_id']; ?>',
2963 2963
 										'attributes': props.attributes,
2964 2964
 										'block_parent_name': parentBlocks.length ? parentBlocks[parentBlocks.length - 1].name : '',
2965
-										'post_id': <?php global $post; if ( isset( $post->ID ) ) {
2965
+										'post_id': <?php global $post; if (isset($post->ID)) {
2966 2966
 										echo $post->ID;
2967
-									}else{echo '0';}?>,
2968
-										'_ajax_nonce': '<?php echo wp_create_nonce( 'super_duper_output_shortcode' );?>'
2967
+									} else {echo '0'; }?>,
2968
+										'_ajax_nonce': '<?php echo wp_create_nonce('super_duper_output_shortcode'); ?>'
2969 2969
 									};
2970 2970
 
2971 2971
 									jQuery.post(ajaxurl, data, function (response) {
@@ -2974,17 +2974,17 @@  discard block
 block discarded – undo
2974 2974
 
2975 2975
 										// if the content is empty then we place some placeholder text
2976 2976
 										if (env == '') {
2977
-											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e( 'Placeholder for:', 'ayecode-connect' );?> " + props.name + "</div>";
2977
+											env = "<div style='background:#0185ba33;padding: 10px;border: 4px #ccc dashed;'>" + "<?php _e('Placeholder for:', 'ayecode-connect'); ?> " + props.name + "</div>";
2978 2978
 										}
2979 2979
 
2980 2980
 										 <?php
2981
-										if(!empty($this->options['nested-block'])){
2981
+										if (!empty($this->options['nested-block'])) {
2982 2982
 											?>
2983 2983
 											// props.setAttributes({content: env});
2984 2984
 										is_fetching = false;
2985 2985
 										prev_attributes[props.clientId] = props.attributes;
2986 2986
 											 <?php
2987
-										}else{
2987
+										} else {
2988 2988
 										?>
2989 2989
 										props.setAttributes({content: env});
2990 2990
 										is_fetching = false;
@@ -3010,38 +3010,38 @@  discard block
 block discarded – undo
3010 3010
 							}
3011 3011
 
3012 3012
 							<?php
3013
-							if(!empty($this->options['block-edit-js'])) {
3014
-								echo  $this->options['block-edit-js'] ; // strings have to be in single quotes, may cause issues
3013
+							if (!empty($this->options['block-edit-js'])) {
3014
+								echo  $this->options['block-edit-js']; // strings have to be in single quotes, may cause issues
3015 3015
 							}
3016 3016
 
3017 3017
 
3018 3018
 
3019 3019
 
3020
-							if(empty($this->options['block-save-return'])){
3020
+							if (empty($this->options['block-save-return'])) {
3021 3021
 							?>
3022 3022
 								///////////////////////////////////////////////////////////////////////
3023 3023
 
3024 3024
 									 // build the shortcode.
3025
-								shortcode = "[<?php echo $this->options['base_id'];?>";
3025
+								shortcode = "[<?php echo $this->options['base_id']; ?>";
3026 3026
 								<?php
3027 3027
 
3028
-								if(! empty( $this->arguments )){
3028
+								if (!empty($this->arguments)) {
3029 3029
 
3030
-								foreach($this->arguments as $key => $args){
3030
+								foreach ($this->arguments as $key => $args) {
3031 3031
 								   // if($args['type']=='tabs'){continue;}
3032 3032
 
3033 3033
 								   // don't add metadata arguments
3034
-								   if (substr($key, 0, 9 ) === 'metadata_') {
3034
+								   if (substr($key, 0, 9) === 'metadata_') {
3035 3035
 									   continue;
3036 3036
 								   }
3037 3037
 								?>
3038
-								if (props.attributes.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3039
-									if ('<?php echo esc_attr( $key );?>' == 'html') {
3040
-									} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3041
-										shortcode += props.attributes.<?php echo esc_attr( $key );?>.length && ( props.attributes.<?php echo esc_attr( $key );?>.x.length || props.attributes.<?php echo esc_attr( $key );?>.y.length ) ? " <?php echo esc_attr( $key );?>='{x:" + props.attributes.<?php echo esc_attr( $key );?>.x + ",y:"+props.attributes.<?php echo esc_attr( $key );?>.y +"}' " : "";
3038
+								if (props.attributes.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
3039
+									if ('<?php echo esc_attr($key); ?>' == 'html') {
3040
+									} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
3041
+										shortcode += props.attributes.<?php echo esc_attr($key); ?>.length && ( props.attributes.<?php echo esc_attr($key); ?>.x.length || props.attributes.<?php echo esc_attr($key); ?>.y.length ) ? " <?php echo esc_attr($key); ?>='{x:" + props.attributes.<?php echo esc_attr($key); ?>.x + ",y:"+props.attributes.<?php echo esc_attr($key); ?>.y +"}' " : "";
3042 3042
 									} else {
3043
-										//shortcode += props.attributes.<?php echo esc_attr( $key );?>.length ? " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' " : "";
3044
-										shortcode +=  " <?php echo esc_attr( $key );?>='" + props.attributes.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' ";
3043
+										//shortcode += props.attributes.<?php echo esc_attr($key); ?>.length ? " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' " : "";
3044
+										shortcode +=  " <?php echo esc_attr($key); ?>='" + props.attributes.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' ";
3045 3045
 									}
3046 3046
 								}
3047 3047
 								<?php
@@ -3060,8 +3060,8 @@  discard block
 block discarded – undo
3060 3060
 
3061 3061
 
3062 3062
 									<?php
3063
-									if(!empty($this->options['nested-block']) || !empty($this->arguments['html']) ){
3064
-										echo "props.setAttributes({sd_shortcode_close: '[/".esc_attr( $this->options['base_id'] )."]'});";
3063
+									if (!empty($this->options['nested-block']) || !empty($this->arguments['html'])) {
3064
+										echo "props.setAttributes({sd_shortcode_close: '[/" . esc_attr($this->options['base_id']) . "]'});";
3065 3065
 									}
3066 3066
 									?>
3067 3067
 								}
@@ -3076,7 +3076,7 @@  discard block
 block discarded – undo
3076 3076
 
3077 3077
 								el(wp.blockEditor.BlockControls, {key: 'controls'},
3078 3078
 
3079
-									<?php if($show_alignment){?>
3079
+									<?php if ($show_alignment) {?>
3080 3080
 									el(
3081 3081
 										wp.blockEditor.AlignmentToolbar,
3082 3082
 										{
@@ -3094,9 +3094,9 @@  discard block
 block discarded – undo
3094 3094
 
3095 3095
 									<?php
3096 3096
 
3097
-									if(! empty( $this->arguments )){
3097
+									if (!empty($this->arguments)) {
3098 3098
 
3099
-									if ( $show_advanced ) {
3099
+									if ($show_advanced) {
3100 3100
 									?>
3101 3101
 									el('div', {
3102 3102
 											style: {'padding-left': '16px','padding-right': '16px'}
@@ -3116,42 +3116,42 @@  discard block
 block discarded – undo
3116 3116
 									<?php
3117 3117
 									}
3118 3118
 
3119
-									$arguments = $this->group_arguments( $this->arguments );
3120
-									$block_group_tabs = ! empty( $this->options['block_group_tabs'] ) ? $this->group_block_tabs( $this->options['block_group_tabs'], $arguments ) : array();
3119
+									$arguments = $this->group_arguments($this->arguments);
3120
+									$block_group_tabs = !empty($this->options['block_group_tabs']) ? $this->group_block_tabs($this->options['block_group_tabs'], $arguments) : array();
3121 3121
 
3122 3122
 									// Do we have sections?
3123 3123
 									$has_sections = $arguments == $this->arguments ? false : true;
3124 3124
 
3125
-									if($has_sections){
3125
+									if ($has_sections) {
3126 3126
 									$panel_count = 0;
3127 3127
 									$open_tab = '';
3128 3128
 
3129 3129
 									$open_tab_groups = array();
3130 3130
 									$used_tabs = array();
3131 3131
 
3132
-									foreach ( $arguments as $key => $args ) {
3132
+									foreach ($arguments as $key => $args) {
3133 3133
 										$close_tab = false;
3134 3134
 										$close_tabs = false;
3135 3135
 
3136
-										 if ( ! empty( $block_group_tabs ) ) {
3137
-											foreach ( $block_group_tabs as $tab_name => $tab_args ) {
3138
-												if ( in_array( $key, $tab_args['groups'] ) ) {
3136
+										 if (!empty($block_group_tabs)) {
3137
+											foreach ($block_group_tabs as $tab_name => $tab_args) {
3138
+												if (in_array($key, $tab_args['groups'])) {
3139 3139
 													$open_tab_groups[] = $key;
3140 3140
 
3141
-													if ( $open_tab != $tab_name ) {
3141
+													if ($open_tab != $tab_name) {
3142 3142
 														$tab_args['tab']['tabs_open'] = $open_tab == '' ? true : false;
3143 3143
 														$tab_args['tab']['open'] = true;
3144 3144
 
3145
-														$this->block_tab_start( '', $tab_args );
3145
+														$this->block_tab_start('', $tab_args);
3146 3146
 														$open_tab = $tab_name;
3147 3147
 														$used_tabs[] = $tab_name;
3148 3148
 													}
3149 3149
 
3150
-													if ( $open_tab_groups == $tab_args['groups'] ) {
3150
+													if ($open_tab_groups == $tab_args['groups']) {
3151 3151
 														$close_tab = true;
3152 3152
 														$open_tab_groups = array();
3153 3153
 
3154
-														if ( $used_tabs == array_keys( $block_group_tabs ) ) {
3154
+														if ($used_tabs == array_keys($block_group_tabs)) {
3155 3155
 															$close_tabs = true;
3156 3156
 														}
3157 3157
 													}
@@ -3160,27 +3160,27 @@  discard block
 block discarded – undo
3160 3160
 										}
3161 3161
 										?>
3162 3162
 										el(wp.components.PanelBody, {
3163
-												title: '<?php esc_attr_e( $key ); ?>',
3164
-												initialOpen: <?php if ( $panel_count ) {
3163
+												title: '<?php esc_attr_e($key); ?>',
3164
+												initialOpen: <?php if ($panel_count) {
3165 3165
 												echo "false";
3166 3166
 											} else {
3167 3167
 												echo "true";
3168 3168
 											}?>
3169 3169
 											},
3170 3170
 											<?php
3171
-											foreach ( $args as $k => $a ) {
3172
-												$this->block_tab_start( $k, $a );
3173
-												$this->block_row_start( $k, $a );
3174
-												$this->build_block_arguments( $k, $a );
3175
-												$this->block_row_end( $k, $a );
3176
-												$this->block_tab_end( $k, $a );
3171
+											foreach ($args as $k => $a) {
3172
+												$this->block_tab_start($k, $a);
3173
+												$this->block_row_start($k, $a);
3174
+												$this->build_block_arguments($k, $a);
3175
+												$this->block_row_end($k, $a);
3176
+												$this->block_tab_end($k, $a);
3177 3177
 											}
3178 3178
 											?>
3179 3179
 										),
3180 3180
 										<?php
3181
-										$panel_count ++;
3181
+										$panel_count++;
3182 3182
 
3183
-										if($close_tab || $close_tabs){
3183
+										if ($close_tab || $close_tabs) {
3184 3184
 											$tab_args = array(
3185 3185
 												'tab'	=> array(
3186 3186
 													'tabs_close' => $close_tabs,
@@ -3188,24 +3188,24 @@  discard block
 block discarded – undo
3188 3188
 												)
3189 3189
 
3190 3190
 											);
3191
-											$this->block_tab_end( '', $tab_args );
3191
+											$this->block_tab_end('', $tab_args);
3192 3192
 //											echo '###close'; print_r($tab_args);
3193 3193
 											$panel_count = 0;
3194 3194
 										}
3195 3195
 //
3196 3196
 
3197 3197
 									}
3198
-									}else {
3198
+									} else {
3199 3199
 									?>
3200 3200
 									el(wp.components.PanelBody, {
3201
-											title: '<?php esc_attr_e( "Settings", 'ayecode-connect' ); ?>',
3201
+											title: '<?php esc_attr_e("Settings", 'ayecode-connect'); ?>',
3202 3202
 											initialOpen: true
3203 3203
 										},
3204 3204
 										<?php
3205
-										foreach ( $this->arguments as $key => $args ) {
3206
-											$this->block_row_start( $key, $args );
3207
-											$this->build_block_arguments( $key, $args );
3208
-											$this->block_row_end( $key, $args );
3205
+										foreach ($this->arguments as $key => $args) {
3206
+											$this->block_row_start($key, $args);
3207
+											$this->build_block_arguments($key, $args);
3208
+											$this->block_row_end($key, $args);
3209 3209
 										}
3210 3210
 										?>
3211 3211
 									),
@@ -3219,11 +3219,11 @@  discard block
 block discarded – undo
3219 3219
 
3220 3220
 								<?php
3221 3221
 								// If the user sets block-output array then build it
3222
-								if ( ! empty( $this->options['block-output'] ) ) {
3223
-								$this->block_element( $this->options['block-output'] );
3224
-							}elseif(!empty($this->options['block-edit-return'])){
3222
+								if (!empty($this->options['block-output'])) {
3223
+								$this->block_element($this->options['block-output']);
3224
+							}elseif (!empty($this->options['block-edit-return'])) {
3225 3225
 								   echo $this->options['block-edit-return'];
3226
-							}else{
3226
+							} else {
3227 3227
 								// if no block-output is set then we try and get the shortcode html output via ajax.
3228 3228
 								$block_edit_wrap_tag = !empty($this->options['block_edit_wrap_tag']) ? esc_attr($this->options['block_edit_wrap_tag']) : 'div';
3229 3229
 								?>
@@ -3250,27 +3250,27 @@  discard block
 block discarded – undo
3250 3250
 							var align = '';
3251 3251
 
3252 3252
 							// build the shortcode.
3253
-							var content = "[<?php echo $this->options['base_id'];?>";
3253
+							var content = "[<?php echo $this->options['base_id']; ?>";
3254 3254
 							$html = '';
3255 3255
 							<?php
3256 3256
 
3257
-							if(! empty( $this->arguments )){
3257
+							if (!empty($this->arguments)) {
3258 3258
 
3259
-							foreach($this->arguments as $key => $args){
3259
+							foreach ($this->arguments as $key => $args) {
3260 3260
 							   // if($args['type']=='tabs'){continue;}
3261 3261
 
3262 3262
 							   // don't add metadata arguments
3263
-							   if (substr($key, 0, 9 ) === 'metadata_') {
3263
+							   if (substr($key, 0, 9) === 'metadata_') {
3264 3264
 								   continue;
3265 3265
 							   }
3266 3266
 							?>
3267
-							if (attr.hasOwnProperty("<?php echo esc_attr( $key );?>")) {
3268
-								if ('<?php echo esc_attr( $key );?>' == 'html') {
3269
-									$html = attr.<?php echo esc_attr( $key );?>;
3270
-								} else if ('<?php echo esc_attr( $args['type'] );?>' == 'image_xy') {
3271
-									content += " <?php echo esc_attr( $key );?>='{x:" + attr.<?php echo esc_attr( $key );?>.x + ",y:"+attr.<?php echo esc_attr( $key );?>.y +"}' ";
3267
+							if (attr.hasOwnProperty("<?php echo esc_attr($key); ?>")) {
3268
+								if ('<?php echo esc_attr($key); ?>' == 'html') {
3269
+									$html = attr.<?php echo esc_attr($key); ?>;
3270
+								} else if ('<?php echo esc_attr($args['type']); ?>' == 'image_xy') {
3271
+									content += " <?php echo esc_attr($key); ?>='{x:" + attr.<?php echo esc_attr($key); ?>.x + ",y:"+attr.<?php echo esc_attr($key); ?>.y +"}' ";
3272 3272
 								} else {
3273
-									content += " <?php echo esc_attr( $key );?>='" + attr.<?php echo esc_attr( $key );?>.toString().replace('\'','&#39;') + "' ";
3273
+									content += " <?php echo esc_attr($key); ?>='" + attr.<?php echo esc_attr($key); ?>.toString().replace('\'','&#39;') + "' ";
3274 3274
 								}
3275 3275
 							}
3276 3276
 							<?php
@@ -3290,7 +3290,7 @@  discard block
 block discarded – undo
3290 3290
 							?>
3291 3291
 							// if has html element
3292 3292
 							if ($html) {
3293
-								//content += $html + "[/<?php echo $this->options['base_id'];?>]";
3293
+								//content += $html + "[/<?php echo $this->options['base_id']; ?>]";
3294 3294
 							}
3295 3295
 
3296 3296
 							// @todo should we add inline style here or just css classes?
@@ -3320,7 +3320,7 @@  discard block
 block discarded – undo
3320 3320
 //                                <x?php
3321 3321
 //							}else
3322 3322
 
3323
-							if(!empty($this->options['block-output'])){
3323
+							if (!empty($this->options['block-output'])) {
3324 3324
 //                               echo "return";
3325 3325
 //                               $this->block_element( $this->options['block-output'], true );
3326 3326
 //                               echo ";";
@@ -3330,30 +3330,30 @@  discard block
 block discarded – undo
3330 3330
 								   '',
3331 3331
 								   {},
3332 3332
 								  // el('', {dangerouslySetInnerHTML: {__html: content}}),
3333
-								   <?php $this->block_element( $this->options['block-output'], true ); ?>
3334
-								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3333
+								   <?php $this->block_element($this->options['block-output'], true); ?>
3334
+								  // el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
3335 3335
 							   );
3336 3336
 								<?php
3337 3337
 
3338
-							}elseif(!empty($this->options['block-save-return'])){
3338
+							}elseif (!empty($this->options['block-save-return'])) {
3339 3339
 								   echo 'return ' . $this->options['block-save-return'];
3340
-							}elseif(!empty($this->options['nested-block'])){
3340
+							}elseif (!empty($this->options['nested-block'])) {
3341 3341
 								?>
3342 3342
 							  return el(
3343 3343
 								   '',
3344 3344
 								   {},
3345 3345
 								   el('', {dangerouslySetInnerHTML: {__html: content+"\n"}}),
3346 3346
 								   InnerBlocks.Content ? el( InnerBlocks.Content ) : '', // @todo i think we need a comma here
3347
-								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id'];?>]"}})
3347
+								 //  el('', {dangerouslySetInnerHTML: {__html: "[/<?php echo $this->options['base_id']; ?>]"}})
3348 3348
 							   );
3349 3349
 								<?php
3350
-							}elseif(!empty( $this->options['block-save-return'] ) ){
3351
-								echo "return ". $this->options['block-edit-return'].";";
3352
-							}elseif(isset( $this->options['block-wrap'] ) && $this->options['block-wrap'] == ''){
3350
+							}elseif (!empty($this->options['block-save-return'])) {
3351
+								echo "return " . $this->options['block-edit-return'] . ";";
3352
+							}elseif (isset($this->options['block-wrap']) && $this->options['block-wrap'] == '') {
3353 3353
 							?>
3354 3354
 							return content;
3355 3355
 							<?php
3356
-							}else{
3356
+							} else {
3357 3357
 							?>
3358 3358
 							var block_wrap = 'div';
3359 3359
 							if (attr.hasOwnProperty("block_wrap")) {
@@ -3382,48 +3382,48 @@  discard block
 block discarded – undo
3382 3382
 			 * We only add the <script> tags for code highlighting, so we strip them from the output.
3383 3383
 			 */
3384 3384
 
3385
-			return str_replace( array(
3385
+			return str_replace(array(
3386 3386
 				'<script>',
3387 3387
 				'</script>'
3388
-			), '', $output );
3388
+			), '', $output);
3389 3389
 		}
3390 3390
 
3391 3391
 
3392 3392
 
3393
-		public function block_row_start($key, $args){
3393
+		public function block_row_start($key, $args) {
3394 3394
 
3395 3395
 			// check for row
3396
-			if(!empty($args['row'])){
3396
+			if (!empty($args['row'])) {
3397 3397
 
3398
-				if(!empty($args['row']['open'])){
3398
+				if (!empty($args['row']['open'])) {
3399 3399
 
3400 3400
 				// element require
3401
-				$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3402
-				$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3403
-				$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3401
+				$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3402
+				$device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3403
+				$device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3404 3404
 				$device_type_icon = '';
3405
-				if($device_type=='Desktop'){
3405
+				if ($device_type == 'Desktop') {
3406 3406
 					$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3407
-				}elseif($device_type=='Tablet'){
3407
+				}elseif ($device_type == 'Tablet') {
3408 3408
 					$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3409
-				}elseif($device_type=='Mobile'){
3409
+				}elseif ($device_type == 'Mobile') {
3410 3410
 					$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3411 3411
 				}
3412 3412
 				echo $element_require;
3413 3413
 				echo $device_type_require;
3414 3414
 
3415
-					if(false){?><script><?php }?>
3415
+					if (false) {?><script><?php }?>
3416 3416
 						el('div', {
3417 3417
 								className: 'bsui components-base-control',
3418 3418
 							},
3419
-							<?php if(!empty($args['row']['title'])){ ?>
3419
+							<?php if (!empty($args['row']['title'])) { ?>
3420 3420
 							el('label', {
3421 3421
 									className: 'components-base-control__label position-relative',
3422 3422
 									style: {width:"100%"}
3423 3423
 								},
3424
-								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['row']['title'] ) ?>'}}),
3425
-								<?php if($device_type_icon){ ?>
3426
-									deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3424
+								el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['row']['title']) ?>'}}),
3425
+								<?php if ($device_type_icon) { ?>
3426
+									deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})
3427 3427
 								<?php
3428 3428
 								}
3429 3429
 								?>
@@ -3431,17 +3431,17 @@  discard block
 block discarded – undo
3431 3431
 
3432 3432
 							),
3433 3433
 							<?php }?>
3434
-							<?php if(!empty($args['row']['desc'])){ ?>
3434
+							<?php if (!empty($args['row']['desc'])) { ?>
3435 3435
 							el('p', {
3436 3436
 									className: 'components-base-control__help mb-0',
3437 3437
 								},
3438
-								'<?php echo addslashes( $args['row']['desc'] ); ?>'
3438
+								'<?php echo addslashes($args['row']['desc']); ?>'
3439 3439
 							),
3440 3440
 							<?php }?>
3441 3441
 							el(
3442 3442
 								'div',
3443 3443
 								{
3444
-									className: 'row mb-n2 <?php if(!empty($args['row']['class'])){ echo esc_attr($args['row']['class']);} ?>',
3444
+									className: 'row mb-n2 <?php if (!empty($args['row']['class'])) { echo esc_attr($args['row']['class']); } ?>',
3445 3445
 								},
3446 3446
 								el(
3447 3447
 									'div',
@@ -3450,36 +3450,36 @@  discard block
 block discarded – undo
3450 3450
 									},
3451 3451
 
3452 3452
 					<?php
3453
-					if(false){?></script><?php }
3454
-				}elseif(!empty($args['row']['close'])){
3455
-					if(false){?><script><?php }?>
3453
+					if (false) {?></script><?php }
3454
+				}elseif (!empty($args['row']['close'])) {
3455
+					if (false) {?><script><?php }?>
3456 3456
 						el(
3457 3457
 							'div',
3458 3458
 							{
3459 3459
 								className: 'col pl-0 ps-0',
3460 3460
 							},
3461 3461
 					<?php
3462
-					if(false){?></script><?php }
3463
-				}else{
3464
-					if(false){?><script><?php }?>
3462
+					if (false) {?></script><?php }
3463
+				} else {
3464
+					if (false) {?><script><?php }?>
3465 3465
 						el(
3466 3466
 							'div',
3467 3467
 							{
3468 3468
 								className: 'col pl-0 ps-0 pr-2 pe-2',
3469 3469
 							},
3470 3470
 					<?php
3471
-					if(false){?></script><?php }
3471
+					if (false) {?></script><?php }
3472 3472
 				}
3473 3473
 
3474 3474
 			}
3475 3475
 
3476 3476
 		}
3477 3477
 
3478
-		public function block_row_end($key, $args){
3478
+		public function block_row_end($key, $args) {
3479 3479
 
3480
-			if(!empty($args['row'])){
3480
+			if (!empty($args['row'])) {
3481 3481
 				// maybe close
3482
-				if(!empty($args['row']['close'])){
3482
+				if (!empty($args['row']['close'])) {
3483 3483
 					echo "))";
3484 3484
 				}
3485 3485
 
@@ -3487,14 +3487,14 @@  discard block
 block discarded – undo
3487 3487
 			}
3488 3488
 		}
3489 3489
 
3490
-		public function block_tab_start($key, $args){
3490
+		public function block_tab_start($key, $args) {
3491 3491
 
3492 3492
 			// check for row
3493
-			if(!empty($args['tab'])){
3493
+			if (!empty($args['tab'])) {
3494 3494
 
3495
-				if(!empty($args['tab']['tabs_open'])){
3495
+				if (!empty($args['tab']['tabs_open'])) {
3496 3496
 
3497
-					if(false){?><script><?php }?>
3497
+					if (false) {?><script><?php }?>
3498 3498
 
3499 3499
 el('div',{className: 'bsui'},
3500 3500
 
@@ -3503,52 +3503,52 @@  discard block
 block discarded – undo
3503 3503
 									{
3504 3504
 										activeClass: 'is-active',
3505 3505
 										className: 'btn-groupx',
3506
-										initialTabName: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3506
+										initialTabName: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3507 3507
 										tabs: [
3508 3508
 
3509 3509
 					<?php
3510
-					if(false){?></script><?php }
3510
+					if (false) {?></script><?php }
3511 3511
 				}
3512 3512
 
3513
-				if(!empty($args['tab']['open'])){
3513
+				if (!empty($args['tab']['open'])) {
3514 3514
 
3515
-					if(false){?><script><?php }?>
3515
+					if (false) {?><script><?php }?>
3516 3516
 							{
3517
-												name: '<?php echo addslashes( esc_attr( $args['tab']['key']) ); ?>',
3518
-												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes( esc_attr( $args['tab']['title']) ); ?>'}}),
3519
-												className: '<?php echo addslashes( esc_attr( $args['tab']['class']) ); ?>',
3520
-												content: el('div',{}, <?php if(!empty($args['tab']['desc'])){ ?>el('p', {
3517
+												name: '<?php echo addslashes(esc_attr($args['tab']['key'])); ?>',
3518
+												title: el('div', {dangerouslySetInnerHTML: {__html: '<?php echo addslashes(esc_attr($args['tab']['title'])); ?>'}}),
3519
+												className: '<?php echo addslashes(esc_attr($args['tab']['class'])); ?>',
3520
+												content: el('div',{}, <?php if (!empty($args['tab']['desc'])) { ?>el('p', {
3521 3521
 									className: 'components-base-control__help mb-0',
3522
-									dangerouslySetInnerHTML: {__html:'<?php echo addslashes( $args['tab']['desc'] ); ?>'}
3522
+									dangerouslySetInnerHTML: {__html:'<?php echo addslashes($args['tab']['desc']); ?>'}
3523 3523
 								}),<?php }
3524
-					if(false){?></script><?php }
3524
+					if (false) {?></script><?php }
3525 3525
 				}
3526 3526
 
3527 3527
 			}
3528 3528
 
3529 3529
 		}
3530 3530
 
3531
-		public function block_tab_end($key, $args){
3531
+		public function block_tab_end($key, $args) {
3532 3532
 
3533
-			if(!empty($args['tab'])){
3533
+			if (!empty($args['tab'])) {
3534 3534
 				// maybe close
3535
-				if(!empty($args['tab']['close'])){
3535
+				if (!empty($args['tab']['close'])) {
3536 3536
 					echo ")}, /* tab close */";
3537 3537
 				}
3538 3538
 
3539
-				if(!empty($args['tab']['tabs_close'])){
3540
-					if(false){?><script><?php }?>
3539
+				if (!empty($args['tab']['tabs_close'])) {
3540
+					if (false) {?><script><?php }?>
3541 3541
 						]}, ( tab ) => {
3542 3542
 								return tab.content;
3543 3543
 							}
3544 3544
 						)), /* tabs close */
3545
-					<?php if(false){ ?></script><?php }
3545
+					<?php if (false) { ?></script><?php }
3546 3546
 				}
3547 3547
 			}
3548 3548
 		}
3549 3549
 
3550
-		public function build_block_arguments( $key, $args ) {
3551
-			$custom_attributes = ! empty( $args['custom_attributes'] ) ? $this->array_to_attributes( $args['custom_attributes'] ) : '';
3550
+		public function build_block_arguments($key, $args) {
3551
+			$custom_attributes = !empty($args['custom_attributes']) ? $this->array_to_attributes($args['custom_attributes']) : '';
3552 3552
 			$options           = '';
3553 3553
 			$extra             = '';
3554 3554
 			$require           = '';
@@ -3556,28 +3556,28 @@  discard block
 block discarded – undo
3556 3556
 			$after_elements	   = '';
3557 3557
 
3558 3558
 			// `content` is a protected and special argument
3559
-			if ( $key == 'content' ) {
3559
+			if ($key == 'content') {
3560 3560
 				return;
3561 3561
 			}
3562 3562
 
3563
-			$device_type = ! empty( $args['device_type'] ) ? esc_attr($args['device_type']) : '';
3564
-			$device_type_require = ! empty( $args['device_type'] ) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3563
+			$device_type = !empty($args['device_type']) ? esc_attr($args['device_type']) : '';
3564
+			$device_type_require = !empty($args['device_type']) ? " deviceType == '" . esc_attr($device_type) . "' && " : '';
3565 3565
 			$device_type_icon = '';
3566
-			if($device_type=='Desktop'){
3566
+			if ($device_type == 'Desktop') {
3567 3567
 				$device_type_icon = '<span class="dashicons dashicons-desktop" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3568
-			}elseif($device_type=='Tablet'){
3568
+			}elseif ($device_type == 'Tablet') {
3569 3569
 				$device_type_icon = '<span class="dashicons dashicons-tablet" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3570
-			}elseif($device_type=='Mobile'){
3570
+			}elseif ($device_type == 'Mobile') {
3571 3571
 				$device_type_icon = '<span class="dashicons dashicons-smartphone" style="font-size: 18px;" onclick="sd_show_view_options(this);"></span>';
3572 3572
 			}
3573 3573
 
3574 3574
 			// icon
3575 3575
 			$icon = '';
3576
-			if( !empty( $args['icon'] ) ){
3576
+			if (!empty($args['icon'])) {
3577 3577
 				$icon .= "el('div', {";
3578
-									$icon .= "dangerouslySetInnerHTML: {__html: '".self::get_widget_icon( esc_attr($args['icon']))."'},";
3578
+									$icon .= "dangerouslySetInnerHTML: {__html: '" . self::get_widget_icon(esc_attr($args['icon'])) . "'},";
3579 3579
 									$icon .= "className: 'text-center',";
3580
-									$icon .= "title: '".addslashes( $args['title'] )."',";
3580
+									$icon .= "title: '" . addslashes($args['title']) . "',";
3581 3581
 								$icon .= "}),";
3582 3582
 
3583 3583
 				// blank title as its added to the icon.
@@ -3585,27 +3585,27 @@  discard block
 block discarded – undo
3585 3585
 			}
3586 3586
 
3587 3587
 			// require advanced
3588
-			$require_advanced = ! empty( $args['advanced'] ) ? "props.attributes.show_advanced && " : "";
3588
+			$require_advanced = !empty($args['advanced']) ? "props.attributes.show_advanced && " : "";
3589 3589
 
3590 3590
 			// element require
3591
-			$element_require = ! empty( $args['element_require'] ) ? $this->block_props_replace( $args['element_require'], true ) . " && " : "";
3591
+			$element_require = !empty($args['element_require']) ? $this->block_props_replace($args['element_require'], true) . " && " : "";
3592 3592
 
3593 3593
 
3594 3594
 			$onchange  = "props.setAttributes({ $key: $key } )";
3595
-			$onchangecomplete  = "";
3595
+			$onchangecomplete = "";
3596 3596
 			$value     = "props.attributes.$key";
3597
-			$text_type = array( 'text', 'password', 'number', 'email', 'tel', 'url', 'colorx','range' );
3598
-			if ( in_array( $args['type'], $text_type ) ) {
3597
+			$text_type = array('text', 'password', 'number', 'email', 'tel', 'url', 'colorx', 'range');
3598
+			if (in_array($args['type'], $text_type)) {
3599 3599
 				$type = 'TextControl';
3600 3600
 				// Save numbers as numbers and not strings
3601
-				if ( $args['type'] == 'number' ) {
3601
+				if ($args['type'] == 'number') {
3602 3602
 					$onchange = "props.setAttributes({ $key: $key ? Number($key) : '' } )";
3603 3603
 				}
3604 3604
 
3605
-				if (substr($key, 0, 9 ) === 'metadata_') {
3606
-					$real_key = str_replace('metadata_','', $key );
3605
+				if (substr($key, 0, 9) === 'metadata_') {
3606
+					$real_key = str_replace('metadata_', '', $key);
3607 3607
 					$onchange = "props.setAttributes({ metadata: { $real_key: $key } } )";
3608
-					$value     = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3608
+					$value = "props.attributes.metadata && props.attributes.metadata.$real_key ? props.attributes.metadata.$real_key : ''";
3609 3609
 				}
3610 3610
 			}
3611 3611
 //			else if ( $args['type'] == 'popup' ) {
@@ -3625,12 +3625,12 @@  discard block
 block discarded – undo
3625 3625
 //
3626 3626
 //				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3627 3627
 //			}
3628
-			else if ( $args['type'] == 'styleid' ) {
3628
+			else if ($args['type'] == 'styleid') {
3629 3629
 				$type = 'TextControl';
3630 3630
 				$args['type'] == 'text';
3631 3631
 				// Save numbers as numbers and not strings
3632
-				$value     = "props.attributes.$key ? props.attributes.$key : ''";
3633
-			}else if ( $args['type'] == 'notice' ) {
3632
+				$value = "props.attributes.$key ? props.attributes.$key : ''";
3633
+			} else if ($args['type'] == 'notice') {
3634 3634
 
3635 3635
 				$notice_message = !empty($args['desc']) ? addslashes($args['desc']) : '';
3636 3636
 				$notice_status = !empty($args['status']) ? esc_attr($args['status']) : 'info';
@@ -3692,11 +3692,11 @@  discard block
 block discarded – undo
3692 3692
 							return;
3693 3693
 						}
3694 3694
 */
3695
-			elseif ( $args['type'] == 'color' ) {
3695
+			elseif ($args['type'] == 'color') {
3696 3696
 				$type = 'ColorPicker';
3697 3697
 				$onchange = "";
3698 3698
 				$extra = "color: $value,";
3699
-				if(!empty($args['disable_alpha'])){
3699
+				if (!empty($args['disable_alpha'])) {
3700 3700
 					$extra .= "disableAlpha: true,";
3701 3701
 				}
3702 3702
 				$onchangecomplete = "onChangeComplete: function($key) {
@@ -3705,7 +3705,7 @@  discard block
 block discarded – undo
3705 3705
 							$key: value
3706 3706
 						});
3707 3707
 					},";
3708
-			}elseif ( $args['type'] == 'gradient' ) {
3708
+			}elseif ($args['type'] == 'gradient') {
3709 3709
 				$type = 'GradientPicker';
3710 3710
 				$extra .= "gradients: [{
3711 3711
 			name: 'Vivid cyan blue to vivid purple',
@@ -3744,7 +3744,7 @@  discard block
 block discarded – undo
3744 3744
 			slug: 'cool-to-warm-spectrum',
3745 3745
 		}],";
3746 3746
 
3747
-			}elseif ( $args['type'] == 'image' ) {
3747
+			}elseif ($args['type'] == 'image') {
3748 3748
 //                print_r($args);
3749 3749
 
3750 3750
 				$img_preview = isset($args['focalpoint']) && !$args['focalpoint'] ? " props.attributes.$key && el('img', { src: props.attributes.$key,style: {maxWidth:'100%',background: '#ccc'}})," : " ( props.attributes.$key ||  props.attributes.{$key}_use_featured ) && el(wp.components.FocalPointPicker,{
@@ -3806,7 +3806,7 @@  discard block
 block discarded – undo
3806 3806
 				$onchange = "";
3807 3807
 
3808 3808
 				//$inside_elements = ",el('div',{},'file upload')";
3809
-			} else if ( $args['type'] == 'images' ) {
3809
+			} else if ($args['type'] == 'images') {
3810 3810
 				$img_preview = "props.attributes.$key && (function() {
3811 3811
 	let uploads = JSON.parse('['+props.attributes.$key+']');
3812 3812
 	let images = [];
@@ -3819,7 +3819,7 @@  discard block
 block discarded – undo
3819 3819
 			el('i',{
3820 3820
 				className: 'fas fa-times-circle text-danger position-absolute  ml-n2 mt-n1 bg-white rounded-circle c-pointer',
3821 3821
 				onClick: function() {
3822
-					aui_confirm('".esc_attr__('Are you sure?')."', '".esc_attr__('Delete')."', '".esc_attr__('Cancel')."', true).then(function(confirmed) {
3822
+					aui_confirm('" . esc_attr__('Are you sure?') . "', '" . esc_attr__('Delete') . "', '" . esc_attr__('Cancel') . "', true).then(function(confirmed) {
3823 3823
 						if (confirmed) {
3824 3824
 							let new_uploads = JSON.parse('['+props.attributes.$key+']');
3825 3825
 							new_uploads.splice(index, 1);
@@ -3882,36 +3882,36 @@  discard block
 block discarded – undo
3882 3882
 
3883 3883
 				//$inside_elements = ",el('div',{},'file upload')";
3884 3884
 			}
3885
-			elseif ( $args['type'] == 'checkbox' ) {
3885
+			elseif ($args['type'] == 'checkbox') {
3886 3886
 				$type = 'CheckboxControl';
3887 3887
 				$extra .= "checked: props.attributes.$key,";
3888 3888
 				$onchange = "props.setAttributes({ $key: ! props.attributes.$key } )";
3889
-			} elseif ( $args['type'] == 'textarea' ) {
3889
+			} elseif ($args['type'] == 'textarea') {
3890 3890
 				$type = 'TextareaControl';
3891 3891
 
3892
-			} elseif ( $args['type'] == 'select' || $args['type'] == 'multiselect' ) {
3892
+			} elseif ($args['type'] == 'select' || $args['type'] == 'multiselect') {
3893 3893
 				$type = 'SelectControl';
3894 3894
 
3895
-				if($args['name'] == 'category' && !empty($args['post_type_linked'])){
3896
-					$options .= "options: taxonomies_".str_replace("-","_", $this->id).",";
3897
-				}elseif($args['name'] == 'sort_by' && !empty($args['post_type_linked'])){
3898
-					$options .= "options: sort_by_".str_replace("-","_", $this->id).",";
3899
-				}else {
3895
+				if ($args['name'] == 'category' && !empty($args['post_type_linked'])) {
3896
+					$options .= "options: taxonomies_" . str_replace("-", "_", $this->id) . ",";
3897
+				}elseif ($args['name'] == 'sort_by' && !empty($args['post_type_linked'])) {
3898
+					$options .= "options: sort_by_" . str_replace("-", "_", $this->id) . ",";
3899
+				} else {
3900 3900
 
3901
-					if ( ! empty( $args['options'] ) ) {
3901
+					if (!empty($args['options'])) {
3902 3902
 						$options .= "options: [";
3903
-						foreach ( $args['options'] as $option_val => $option_label ) {
3904
-							$options .= "{ value: '" . esc_attr( $option_val ) . "', label: '" . esc_js( addslashes( $option_label ) ) . "' },";
3903
+						foreach ($args['options'] as $option_val => $option_label) {
3904
+							$options .= "{ value: '" . esc_attr($option_val) . "', label: '" . esc_js(addslashes($option_label)) . "' },";
3905 3905
 						}
3906 3906
 						$options .= "],";
3907 3907
 					}
3908 3908
 				}
3909
-				if ( isset( $args['multiple'] ) && $args['multiple'] ) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3909
+				if (isset($args['multiple']) && $args['multiple']) { //@todo multiselect does not work at the moment: https://github.com/WordPress/gutenberg/issues/5550
3910 3910
 					$extra .= ' multiple:true,style:{height:"auto",paddingRight:"8px","overflow-y":"auto"}, ';
3911 3911
 				}
3912 3912
 
3913
-				if($args['type'] == 'multiselect' ||  ( isset( $args['multiple'] ) && $args['multiple'] ) ){
3914
-					$after_elements	 .= "props.attributes.$key && el( wp.components.Button, {
3913
+				if ($args['type'] == 'multiselect' || (isset($args['multiple']) && $args['multiple'])) {
3914
+					$after_elements .= "props.attributes.$key && el( wp.components.Button, {
3915 3915
 									  className: 'components-button components-circular-option-picker__clear is-secondary is-small',
3916 3916
 									  style: {margin:'-8px 0 8px 0',display: 'block'},
3917 3917
 									  onClick: function(){
@@ -3923,7 +3923,7 @@  discard block
 block discarded – undo
3923 3923
 									'Clear'
3924 3924
 							),";
3925 3925
 				}
3926
-			} elseif ( $args['type'] == 'tagselect' ) {
3926
+			} elseif ($args['type'] == 'tagselect') {
3927 3927
 //				$type = 'FormTokenField';
3928 3928
 //
3929 3929
 //				if ( ! empty( $args['options'] ) ) {
@@ -3958,19 +3958,19 @@  discard block
 block discarded – undo
3958 3958
 //				$value     = "[]";
3959 3959
 //				$extra .= ' __experimentalExpandOnFocus: true,';
3960 3960
 
3961
-			} else if ( $args['type'] == 'alignment' ) {
3961
+			} else if ($args['type'] == 'alignment') {
3962 3962
 				$type = 'AlignmentToolbar'; // @todo this does not seem to work but cant find a example
3963
-			} else if ( $args['type'] == 'margins' ) {
3963
+			} else if ($args['type'] == 'margins') {
3964 3964
 
3965
-			} else if ( $args['type'] == 'visibility_conditions' && ( function_exists( 'wp_is_block_theme' ) && wp_is_block_theme() ) ) {
3965
+			} else if ($args['type'] == 'visibility_conditions' && (function_exists('wp_is_block_theme') && wp_is_block_theme())) {
3966 3966
 				$type = 'TextControl';
3967 3967
 				$value = "(props.attributes.$key ? props.attributes.$key : '')";
3968 3968
 				$args['type'] = 'text';
3969 3969
 				$options .= 'disabled:true,';
3970
-				$bsvc_title = esc_attr( addslashes( $args['title'] ) );
3971
-				$bsvc_body = $this->block_visibility_fields( $args );
3970
+				$bsvc_title = esc_attr(addslashes($args['title']));
3971
+				$bsvc_body = $this->block_visibility_fields($args);
3972 3972
 				// @TODO reset button
3973
-				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __( 'Reset', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __( 'Close', 'ayecode-connect' ) . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __( 'Save Rules', 'ayecode-connect' ) . '</button>';
3973
+				$bsvc_footer = '<button type="button" class="btn btn-danger d-none">' . __('Reset', 'ayecode-connect') . '</button><button type="button" class="btn btn-secondary bs-vc-close text-white" data-bs-dismiss="modal">' . __('Close', 'ayecode-connect') . '</button><button type="button" class="btn btn-primary bs-vc-save">' . __('Save Rules', 'ayecode-connect') . '</button>';
3974 3974
 				$after_elements .= "el('div', {className: 'components-base-control bs-vc-button-wrap'}, el(wp.components.Button, {
3975 3975
 						className: 'components-button components-circular-option-picker__clear is-primary is-smallx',
3976 3976
 						onClick: function() {
@@ -3989,25 +3989,25 @@  discard block
 block discarded – undo
3989 3989
 									jQuery('.bs-vc-modal-form').trigger('change');
3990 3990
 								}
3991 3991
 							});
3992
-							aui_modal('" . $bsvc_title . "', '" . addslashes( $bsvc_body ) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', '');
3992
+							aui_modal('" . $bsvc_title . "', '" . addslashes($bsvc_body) . "', '" . $bsvc_footer . "', true, 'bs-vc-modal', 'modal-lg', '');
3993 3993
 							jQuery(document).off('change', '#bsvc_raw_value').on('change', '#bsvc_raw_value', function(e) {
3994 3994
 								props.setAttributes({" . $key . ": e.target.value});
3995 3995
 							});
3996 3996
 						}
3997 3997
 					},
3998
-					'" . addslashes( ! empty( $args['button_title'] ) ? $args['button_title'] : $args['title'] ) . "'
3998
+					'" . addslashes(!empty($args['button_title']) ? $args['button_title'] : $args['title']) . "'
3999 3999
 				) ),";
4000 4000
 			} else {
4001
-				return;// if we have not implemented the control then don't break the JS.
4001
+				return; // if we have not implemented the control then don't break the JS.
4002 4002
 			}
4003 4003
 
4004 4004
 			// color input does not show the labels so we add them
4005
-			if($args['type']=='color'){
4005
+			if ($args['type'] == 'color') {
4006 4006
 				// add show only if advanced
4007 4007
 				echo $require_advanced;
4008 4008
 				// add setting require if defined
4009 4009
 				echo $element_require;
4010
-				echo "el('div', {style: {'marginBottom': '8px'}}, '".addslashes( $args['title'] )."'),";
4010
+				echo "el('div', {style: {'marginBottom': '8px'}}, '" . addslashes($args['title']) . "'),";
4011 4011
 			}
4012 4012
 
4013 4013
 			// add show only if advanced
@@ -4019,22 +4019,22 @@  discard block
 block discarded – undo
4019 4019
 			// icon
4020 4020
 			echo $icon;
4021 4021
 			?>
4022
-			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type  : "wp.components.".$type; ?>, {
4023
-			label: <?php if ( empty( $args['title'] ) ) { echo "''"; } else if ( empty( $args['row'] ) && ! empty( $args['device_type'] ) ) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes( $args['title'] ) ?>'}}),<?php if ( $device_type_icon ) { ?>deviceType == '<?php echo $device_type;?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4024
-			} else { ?>'<?php echo addslashes( trim( esc_html( $args['title'] ) ) ); ?>'<?php } ?>,
4025
-			help: <?php echo ( isset( $args['desc'] ) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim( wp_kses_post( addslashes( $args['desc'] ) ) ) . "'}})" : "''" ); ?>,
4022
+			el( <?php echo $args['type'] == 'image' || $args['type'] == 'images' ? $type : "wp.components." . $type; ?>, {
4023
+			label: <?php if (empty($args['title'])) { echo "''"; } else if (empty($args['row']) && !empty($args['device_type'])) { ?>el('label',{className:'components-base-control__label',style:{width:"100%"}},el('span',{dangerouslySetInnerHTML: {__html: '<?php echo addslashes($args['title']) ?>'}}),<?php if ($device_type_icon) { ?>deviceType == '<?php echo $device_type; ?>' && el('span',{dangerouslySetInnerHTML: {__html: '<?php echo $device_type_icon; ?>'},title: deviceType + ": Set preview mode to change",style: {right:"0",position:"absolute",color:"var(--wp-admin-theme-color)"}})<?php } ?>)<?php
4024
+			} else { ?>'<?php echo addslashes(trim(esc_html($args['title']))); ?>'<?php } ?>,
4025
+			help: <?php echo (isset($args['desc']) ? "el('span', {dangerouslySetInnerHTML: {__html: '" . trim(wp_kses_post(addslashes($args['desc']))) . "'}})" : "''"); ?>,
4026 4026
 			value: <?php echo $value; ?>,
4027
-			<?php if ( $type == 'TextControl' && $args['type'] != 'text' ) {
4028
-				echo "type: '" . addslashes( $args['type'] ) . "',";
4027
+			<?php if ($type == 'TextControl' && $args['type'] != 'text') {
4028
+				echo "type: '" . addslashes($args['type']) . "',";
4029 4029
 			} ?>
4030
-			<?php if ( ! empty( $args['placeholder'] ) ) {
4031
-				echo "placeholder: '" . esc_js( addslashes( trim( esc_html( $args['placeholder'] ) ) ) ) . "',";
4030
+			<?php if (!empty($args['placeholder'])) {
4031
+				echo "placeholder: '" . esc_js(addslashes(trim(esc_html($args['placeholder'])))) . "',";
4032 4032
 			} ?>
4033 4033
 			<?php echo $options; ?>
4034 4034
 			<?php echo $extra; ?>
4035 4035
 			<?php echo $custom_attributes; ?>
4036 4036
 			<?php echo $onchangecomplete; ?>
4037
-			<?php if ( $onchange ) { ?>
4037
+			<?php if ($onchange) { ?>
4038 4038
 			onChange: function ( <?php echo $key; ?> ) {
4039 4039
 				<?php echo $onchange; ?>
4040 4040
 			}
@@ -4053,15 +4053,15 @@  discard block
 block discarded – undo
4053 4053
 		 *@todo there is prob a faster way to do this, also we could add some validation here.
4054 4054
 		 *
4055 4055
 		 */
4056
-		public function array_to_attributes( $custom_attributes, $html = false ) {
4056
+		public function array_to_attributes($custom_attributes, $html = false) {
4057 4057
 			$attributes = '';
4058
-			if ( ! empty( $custom_attributes ) ) {
4058
+			if (!empty($custom_attributes)) {
4059 4059
 
4060
-				foreach ( $custom_attributes as $key => $val ) {
4061
-					if(is_array($val)){
4062
-						$attributes .= $key.': {'.$this->array_to_attributes( $val, $html ).'},';
4063
-					}else{
4064
-						$attributes .= $html ?  " $key='$val' " : "'$key': '$val',";
4060
+				foreach ($custom_attributes as $key => $val) {
4061
+					if (is_array($val)) {
4062
+						$attributes .= $key . ': {' . $this->array_to_attributes($val, $html) . '},';
4063
+					} else {
4064
+						$attributes .= $html ? " $key='$val' " : "'$key': '$val',";
4065 4065
 					}
4066 4066
 				}
4067 4067
 
@@ -4079,113 +4079,113 @@  discard block
 block discarded – undo
4079 4079
 		 *
4080 4080
 		 * @param $args
4081 4081
 		 */
4082
-		public function block_element( $args, $save = false ) {
4082
+		public function block_element($args, $save = false) {
4083 4083
 
4084 4084
 //            print_r($args);echo '###';exit;
4085 4085
 
4086
-			if ( ! empty( $args ) ) {
4087
-				foreach ( $args as $element => $new_args ) {
4086
+			if (!empty($args)) {
4087
+				foreach ($args as $element => $new_args) {
4088 4088
 
4089
-					if ( is_array( $new_args ) ) { // its an element
4089
+					if (is_array($new_args)) { // its an element
4090 4090
 
4091 4091
 
4092
-						if ( isset( $new_args['element'] ) ) {
4092
+						if (isset($new_args['element'])) {
4093 4093
 
4094
-							if ( isset( $new_args['element_require'] ) ) {
4095
-								echo str_replace( array(
4094
+							if (isset($new_args['element_require'])) {
4095
+								echo str_replace(array(
4096 4096
 										"'+",
4097 4097
 										"+'"
4098
-									), '', $this->block_props_replace( $new_args['element_require'] ) ) . " &&  ";
4099
-								unset( $new_args['element_require'] );
4098
+									), '', $this->block_props_replace($new_args['element_require'])) . " &&  ";
4099
+								unset($new_args['element_require']);
4100 4100
 							}
4101 4101
 
4102
-							if($new_args['element']=='InnerBlocks'){
4102
+							if ($new_args['element'] == 'InnerBlocks') {
4103 4103
 								echo "\n el( InnerBlocks, {";
4104
-							}elseif($new_args['element']=='innerBlocksProps'){
4104
+							}elseif ($new_args['element'] == 'innerBlocksProps') {
4105 4105
 								$element = isset($new_args['inner_element']) ? esc_attr($new_args['inner_element']) : 'div';
4106 4106
 							  //  echo "\n el( 'section', wp.blockEditor.useInnerBlocksProps( blockProps, {";
4107 4107
 //                                echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4108 4108
 								echo $save ? "\n el( '$element', wp.blockEditor.useInnerBlocksProps.save( " : "\n el( '$element', wp.blockEditor.useInnerBlocksProps( ";
4109 4109
 								echo $save ? "wp.blockEditor.useBlockProps.save( {" : "wp.blockEditor.useBlockProps( {";
4110
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4110
+								echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
4111 4111
 
4112 4112
 								echo "} ), {";
4113
-								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element( $new_args['innerBlocksProps'],$save ) : '';
4113
+								echo !empty($new_args['innerBlocksProps']) && !$save ? $this->block_element($new_args['innerBlocksProps'], $save) : '';
4114 4114
 							//    echo '###';
4115 4115
 
4116 4116
 							  //  echo '###';
4117
-							}elseif($new_args['element']=='BlocksProps'){
4117
+							}elseif ($new_args['element'] == 'BlocksProps') {
4118 4118
 
4119
-								if ( isset($new_args['if_inner_element']) ) {
4119
+								if (isset($new_args['if_inner_element'])) {
4120 4120
 									$element = $new_args['if_inner_element'];
4121
-								}else {
4122
-									$element = isset($new_args['inner_element']) ? "'".esc_attr($new_args['inner_element'])."'" : "'div'";
4121
+								} else {
4122
+									$element = isset($new_args['inner_element']) ? "'" . esc_attr($new_args['inner_element']) . "'" : "'div'";
4123 4123
 								}
4124 4124
 
4125 4125
 								unset($new_args['inner_element']);
4126 4126
 								echo $save ? "\n el( $element, wp.blockEditor.useBlockProps.save( {" : "\n el( $element, wp.blockEditor.useBlockProps( {";
4127
-								echo !empty($new_args['blockProps']) ? $this->block_element( $new_args['blockProps'],$save ) : '';
4127
+								echo !empty($new_args['blockProps']) ? $this->block_element($new_args['blockProps'], $save) : '';
4128 4128
 
4129 4129
 
4130 4130
 							   // echo "} ),";
4131 4131
 
4132
-							}else{
4132
+							} else {
4133 4133
 								echo "\n el( '" . $new_args['element'] . "', {";
4134 4134
 							}
4135 4135
 
4136 4136
 
4137 4137
 							// get the attributes
4138
-							foreach ( $new_args as $new_key => $new_value ) {
4138
+							foreach ($new_args as $new_key => $new_value) {
4139 4139
 
4140 4140
 
4141
-								if ( $new_key == 'element' || $new_key == 'content'|| $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array( $new_value ) ) {
4141
+								if ($new_key == 'element' || $new_key == 'content' || $new_key == 'if_content' || $new_key == 'element_require' || $new_key == 'element_repeat' || is_array($new_value)) {
4142 4142
 									// do nothing
4143 4143
 								} else {
4144
-									echo $this->block_element( array( $new_key => $new_value ),$save );
4144
+									echo $this->block_element(array($new_key => $new_value), $save);
4145 4145
 								}
4146 4146
 							}
4147 4147
 
4148
-							echo $new_args['element']=='BlocksProps' ? '} ),' : "},";// end attributes
4148
+							echo $new_args['element'] == 'BlocksProps' ? '} ),' : "},"; // end attributes
4149 4149
 
4150 4150
 							// get the content
4151 4151
 							$first_item = 0;
4152
-							foreach ( $new_args as $new_key => $new_value ) {
4153
-								if ( $new_key === 'content' || $new_key === 'if_content' || is_array( $new_value ) ) {
4152
+							foreach ($new_args as $new_key => $new_value) {
4153
+								if ($new_key === 'content' || $new_key === 'if_content' || is_array($new_value)) {
4154 4154
 
4155
-									if ( $new_key === 'content' ) {
4156
-										echo "'" . $this->block_props_replace( wp_slash( $new_value ) ) . "'";
4157
-									}else if ( $new_key === 'if_content' ) {
4158
-										echo  $this->block_props_replace(  $new_value  );
4155
+									if ($new_key === 'content') {
4156
+										echo "'" . $this->block_props_replace(wp_slash($new_value)) . "'";
4157
+									} else if ($new_key === 'if_content') {
4158
+										echo  $this->block_props_replace($new_value);
4159 4159
 									}
4160 4160
 
4161
-									if ( is_array( $new_value ) ) {
4161
+									if (is_array($new_value)) {
4162 4162
 
4163
-										if ( isset( $new_value['element_require'] ) ) {
4164
-											echo str_replace( array(
4163
+										if (isset($new_value['element_require'])) {
4164
+											echo str_replace(array(
4165 4165
 													"'+",
4166 4166
 													"+'"
4167
-												), '', $this->block_props_replace( $new_value['element_require'] ) ) . " &&  ";
4168
-											unset( $new_value['element_require'] );
4167
+												), '', $this->block_props_replace($new_value['element_require'])) . " &&  ";
4168
+											unset($new_value['element_require']);
4169 4169
 										}
4170 4170
 
4171
-										if ( isset( $new_value['element_repeat'] ) ) {
4171
+										if (isset($new_value['element_repeat'])) {
4172 4172
 											$x = 1;
4173
-											while ( $x <= absint( $new_value['element_repeat'] ) ) {
4174
-												$this->block_element( array( '' => $new_value ),$save );
4175
-												$x ++;
4173
+											while ($x <= absint($new_value['element_repeat'])) {
4174
+												$this->block_element(array('' => $new_value), $save);
4175
+												$x++;
4176 4176
 											}
4177 4177
 										} else {
4178
-											$this->block_element( array( '' => $new_value ),$save );
4178
+											$this->block_element(array('' => $new_value), $save);
4179 4179
 										}
4180 4180
 									}
4181
-									$first_item ++;
4181
+									$first_item++;
4182 4182
 								}
4183 4183
 							}
4184 4184
 
4185
-							if($new_args['element']=='innerBlocksProps' || $new_args['element']=='xBlocksProps'){
4186
-								echo "))";// end content
4187
-							}else{
4188
-								echo ")";// end content
4185
+							if ($new_args['element'] == 'innerBlocksProps' || $new_args['element'] == 'xBlocksProps') {
4186
+								echo "))"; // end content
4187
+							} else {
4188
+								echo ")"; // end content
4189 4189
 							}
4190 4190
 
4191 4191
 
@@ -4194,26 +4194,26 @@  discard block
 block discarded – undo
4194 4194
 						}
4195 4195
 					} else {
4196 4196
 
4197
-						if ( substr( $element, 0, 3 ) === "if_" ) {
4197
+						if (substr($element, 0, 3) === "if_") {
4198 4198
 							$extra = '';
4199
-							if( strpos($new_args, '[%WrapClass%]') !== false ){
4200
-								$new_args = str_replace('[%WrapClass%]"','" + sd_build_aui_class(props.attributes)',$new_args);
4201
-								$new_args = str_replace('[%WrapClass%]','+ sd_build_aui_class(props.attributes)',$new_args);
4199
+							if (strpos($new_args, '[%WrapClass%]') !== false) {
4200
+								$new_args = str_replace('[%WrapClass%]"', '" + sd_build_aui_class(props.attributes)', $new_args);
4201
+								$new_args = str_replace('[%WrapClass%]', '+ sd_build_aui_class(props.attributes)', $new_args);
4202 4202
 							}
4203
-							echo str_replace( "if_", "", $element ) . ": " . $this->block_props_replace( $new_args, true ) . ",";
4204
-						} elseif ( $element == 'style' &&  strpos($new_args, '[%WrapStyle%]') !== false ) {
4205
-							$new_args = str_replace('[%WrapStyle%]','',$new_args);
4206
-							echo $element . ": {..." . $this->block_props_replace( $new_args ) . " , ...sd_build_aui_styles(props.attributes) },";
4203
+							echo str_replace("if_", "", $element) . ": " . $this->block_props_replace($new_args, true) . ",";
4204
+						} elseif ($element == 'style' && strpos($new_args, '[%WrapStyle%]') !== false) {
4205
+							$new_args = str_replace('[%WrapStyle%]', '', $new_args);
4206
+							echo $element . ": {..." . $this->block_props_replace($new_args) . " , ...sd_build_aui_styles(props.attributes) },";
4207 4207
 //                            echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4208
-						} elseif ( $element == 'style' ) {
4209
-							echo $element . ": " . $this->block_props_replace( $new_args ) . ",";
4210
-						} elseif ( ( $element == 'class' || $element == 'className'  ) &&  strpos($new_args, '[%WrapClass%]') !== false ) {
4211
-							$new_args = str_replace('[%WrapClass%]','',$new_args);
4212
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "' + sd_build_aui_class(props.attributes),";
4213
-						} elseif ( $element == 'template' && $new_args ) {
4208
+						} elseif ($element == 'style') {
4209
+							echo $element . ": " . $this->block_props_replace($new_args) . ",";
4210
+						} elseif (($element == 'class' || $element == 'className') && strpos($new_args, '[%WrapClass%]') !== false) {
4211
+							$new_args = str_replace('[%WrapClass%]', '', $new_args);
4212
+							echo $element . ": '" . $this->block_props_replace($new_args) . "' + sd_build_aui_class(props.attributes),";
4213
+						} elseif ($element == 'template' && $new_args) {
4214 4214
 							echo $element . ": $new_args,";
4215 4215
 						} else {
4216
-							echo $element . ": '" . $this->block_props_replace( $new_args ) . "',";
4216
+							echo $element . ": '" . $this->block_props_replace($new_args) . "',";
4217 4217
 						}
4218 4218
 
4219 4219
 					}
@@ -4228,11 +4228,11 @@  discard block
 block discarded – undo
4228 4228
 		 *
4229 4229
 		 * @return mixed
4230 4230
 		 */
4231
-		public function block_props_replace( $string, $no_wrap = false ) {
4232
-			if ( $no_wrap ) {
4233
-				$string = str_replace( array( "[%", "%]", "%:checked]" ), array( "props.attributes.", "", "" ), $string );
4231
+		public function block_props_replace($string, $no_wrap = false) {
4232
+			if ($no_wrap) {
4233
+				$string = str_replace(array("[%", "%]", "%:checked]"), array("props.attributes.", "", ""), $string);
4234 4234
 			} else {
4235
-				$string = str_replace( array( "![%", "[%", "%]", "%:checked]" ), array( "'+!props.attributes.", "'+props.attributes.", "+'", "+'" ), $string );
4235
+				$string = str_replace(array("![%", "[%", "%]", "%:checked]"), array("'+!props.attributes.", "'+props.attributes.", "+'", "+'"), $string);
4236 4236
 			}
4237 4237
 
4238 4238
 			return $string;
@@ -4244,65 +4244,65 @@  discard block
 block discarded – undo
4244 4244
 		 * @param array $args
4245 4245
 		 * @param array $instance
4246 4246
 		 */
4247
-		public function widget( $args, $instance ) {
4248
-			if ( ! is_array( $args ) ) {
4247
+		public function widget($args, $instance) {
4248
+			if (!is_array($args)) {
4249 4249
 				$args = array();
4250 4250
 			}
4251 4251
 
4252 4252
 			// Get the filtered values
4253
-			$argument_values = $this->argument_values( $instance );
4254
-			$argument_values = $this->string_to_bool( $argument_values );
4255
-			$output          = $this->output( $argument_values, $args );
4253
+			$argument_values = $this->argument_values($instance);
4254
+			$argument_values = $this->string_to_bool($argument_values);
4255
+			$output          = $this->output($argument_values, $args);
4256 4256
 
4257 4257
 			$no_wrap = false;
4258
-			if ( isset( $argument_values['no_wrap'] ) && $argument_values['no_wrap'] ) {
4258
+			if (isset($argument_values['no_wrap']) && $argument_values['no_wrap']) {
4259 4259
 				$no_wrap = true;
4260 4260
 			}
4261 4261
 
4262 4262
 			ob_start();
4263
-			if ( $output && ! $no_wrap ) {
4263
+			if ($output && !$no_wrap) {
4264 4264
 
4265 4265
 				$class_original = $this->options['widget_ops']['classname'];
4266
-				$class = $this->options['widget_ops']['classname']." sdel-".$this->get_instance_hash();
4266
+				$class = $this->options['widget_ops']['classname'] . " sdel-" . $this->get_instance_hash();
4267 4267
 
4268 4268
 				// Before widget
4269
-				$before_widget = ! empty( $args['before_widget'] ) ? $args['before_widget'] : '';
4270
-				$before_widget = $before_widget ? str_replace( $class_original, $class, $before_widget ) : $before_widget;
4271
-				$before_widget = apply_filters( 'wp_super_duper_before_widget', $before_widget, $args, $instance, $this );
4272
-				$before_widget = apply_filters( 'wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this );
4269
+				$before_widget = !empty($args['before_widget']) ? $args['before_widget'] : '';
4270
+				$before_widget = $before_widget ? str_replace($class_original, $class, $before_widget) : $before_widget;
4271
+				$before_widget = apply_filters('wp_super_duper_before_widget', $before_widget, $args, $instance, $this);
4272
+				$before_widget = apply_filters('wp_super_duper_before_widget_' . $this->base_id, $before_widget, $args, $instance, $this);
4273 4273
 
4274 4274
 				// After widget
4275
-				$after_widget = ! empty( $args['after_widget'] ) ? $args['after_widget'] : '';
4276
-				$after_widget = apply_filters( 'wp_super_duper_after_widget', $after_widget, $args, $instance, $this );
4277
-				$after_widget = apply_filters( 'wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this );
4275
+				$after_widget = !empty($args['after_widget']) ? $args['after_widget'] : '';
4276
+				$after_widget = apply_filters('wp_super_duper_after_widget', $after_widget, $args, $instance, $this);
4277
+				$after_widget = apply_filters('wp_super_duper_after_widget_' . $this->base_id, $after_widget, $args, $instance, $this);
4278 4278
 
4279 4279
 				echo $before_widget;
4280 4280
 				// elementor strips the widget wrapping div so we check for and add it back if needed
4281
-				if ( $this->is_elementor_widget_output() ) {
4281
+				if ($this->is_elementor_widget_output()) {
4282 4282
 					// Filter class & attrs for elementor widget output.
4283
-					$class = apply_filters( 'wp_super_duper_div_classname', $class, $args, $this );
4284
-					$class = apply_filters( 'wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this );
4283
+					$class = apply_filters('wp_super_duper_div_classname', $class, $args, $this);
4284
+					$class = apply_filters('wp_super_duper_div_classname_' . $this->base_id, $class, $args, $this);
4285 4285
 
4286
-					$attrs = apply_filters( 'wp_super_duper_div_attrs', '', $args, $this );
4287
-					$attrs = apply_filters( 'wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this );
4286
+					$attrs = apply_filters('wp_super_duper_div_attrs', '', $args, $this);
4287
+					$attrs = apply_filters('wp_super_duper_div_attrs_' . $this->base_id, '', $args, $this);
4288 4288
 
4289
-					echo "<span class='" . esc_attr( $class  ) . "' " . $attrs . ">";
4289
+					echo "<span class='" . esc_attr($class) . "' " . $attrs . ">";
4290 4290
 				}
4291
-				echo $this->output_title( $args, $instance );
4291
+				echo $this->output_title($args, $instance);
4292 4292
 				echo $output;
4293
-				if ( $this->is_elementor_widget_output() ) {
4293
+				if ($this->is_elementor_widget_output()) {
4294 4294
 					echo "</span>";
4295 4295
 				}
4296 4296
 				echo $after_widget;
4297
-			} elseif ( $this->is_preview() && $output == '' ) {// if preview show a placeholder if empty
4298
-				$output = $this->preview_placeholder_text( "{{" . $this->base_id . "}}" );
4297
+			} elseif ($this->is_preview() && $output == '') {// if preview show a placeholder if empty
4298
+				$output = $this->preview_placeholder_text("{{" . $this->base_id . "}}");
4299 4299
 				echo $output;
4300
-			} elseif ( $output && $no_wrap ) {
4300
+			} elseif ($output && $no_wrap) {
4301 4301
 				echo $output;
4302 4302
 			}
4303 4303
 			$output = ob_get_clean();
4304 4304
 
4305
-			$output = apply_filters( 'wp_super_duper_widget_output', $output, $instance, $args, $this );
4305
+			$output = apply_filters('wp_super_duper_widget_output', $output, $instance, $args, $this);
4306 4306
 
4307 4307
 			echo $output;
4308 4308
 		}
@@ -4315,7 +4315,7 @@  discard block
 block discarded – undo
4315 4315
 		 */
4316 4316
 		public function is_elementor_widget_output() {
4317 4317
 			$result = false;
4318
-			if ( defined( 'ELEMENTOR_VERSION' ) && isset( $this->number ) && $this->number == 'REPLACE_TO_ID' ) {
4318
+			if (defined('ELEMENTOR_VERSION') && isset($this->number) && $this->number == 'REPLACE_TO_ID') {
4319 4319
 				$result = true;
4320 4320
 			}
4321 4321
 
@@ -4330,7 +4330,7 @@  discard block
 block discarded – undo
4330 4330
 		 */
4331 4331
 		public function is_elementor_preview() {
4332 4332
 			$result = false;
4333
-			if ( isset( $_REQUEST['elementor-preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) || ( isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor_ajax' ) ) {
4333
+			if (isset($_REQUEST['elementor-preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor') || (isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor_ajax')) {
4334 4334
 				$result = true;
4335 4335
 			}
4336 4336
 
@@ -4345,7 +4345,7 @@  discard block
 block discarded – undo
4345 4345
 		 */
4346 4346
 		public function is_divi_preview() {
4347 4347
 			$result = false;
4348
-			if ( isset( $_REQUEST['et_fb'] ) || isset( $_REQUEST['et_pb_preview'] ) || ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'elementor' ) ) {
4348
+			if (isset($_REQUEST['et_fb']) || isset($_REQUEST['et_pb_preview']) || (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'elementor')) {
4349 4349
 				$result = true;
4350 4350
 			}
4351 4351
 
@@ -4360,7 +4360,7 @@  discard block
 block discarded – undo
4360 4360
 		 */
4361 4361
 		public function is_beaver_preview() {
4362 4362
 			$result = false;
4363
-			if ( isset( $_REQUEST['fl_builder'] ) ) {
4363
+			if (isset($_REQUEST['fl_builder'])) {
4364 4364
 				$result = true;
4365 4365
 			}
4366 4366
 
@@ -4375,7 +4375,7 @@  discard block
 block discarded – undo
4375 4375
 		 */
4376 4376
 		public function is_siteorigin_preview() {
4377 4377
 			$result = false;
4378
-			if ( ! empty( $_REQUEST['siteorigin_panels_live_editor'] ) ) {
4378
+			if (!empty($_REQUEST['siteorigin_panels_live_editor'])) {
4379 4379
 				$result = true;
4380 4380
 			}
4381 4381
 
@@ -4390,7 +4390,7 @@  discard block
 block discarded – undo
4390 4390
 		 */
4391 4391
 		public function is_cornerstone_preview() {
4392 4392
 			$result = false;
4393
-			if ( ! empty( $_REQUEST['cornerstone_preview'] ) || basename( $_SERVER['REQUEST_URI'] ) == 'cornerstone-endpoint' ) {
4393
+			if (!empty($_REQUEST['cornerstone_preview']) || basename($_SERVER['REQUEST_URI']) == 'cornerstone-endpoint') {
4394 4394
 				$result = true;
4395 4395
 			}
4396 4396
 
@@ -4405,7 +4405,7 @@  discard block
 block discarded – undo
4405 4405
 		 */
4406 4406
 		public function is_fusion_preview() {
4407 4407
 			$result = false;
4408
-			if ( ! empty( $_REQUEST['fb-edit'] ) || ! empty( $_REQUEST['fusion_load_nonce'] ) ) {
4408
+			if (!empty($_REQUEST['fb-edit']) || !empty($_REQUEST['fusion_load_nonce'])) {
4409 4409
 				$result = true;
4410 4410
 			}
4411 4411
 
@@ -4420,7 +4420,7 @@  discard block
 block discarded – undo
4420 4420
 		 */
4421 4421
 		public function is_oxygen_preview() {
4422 4422
 			$result = false;
4423
-			if ( ! empty( $_REQUEST['ct_builder'] ) || ( ! empty( $_REQUEST['action'] ) && ( substr( $_REQUEST['action'], 0, 11 ) === "oxy_render_" || substr( $_REQUEST['action'], 0, 10 ) === "ct_render_" ) ) ) {
4423
+			if (!empty($_REQUEST['ct_builder']) || (!empty($_REQUEST['action']) && (substr($_REQUEST['action'], 0, 11) === "oxy_render_" || substr($_REQUEST['action'], 0, 10) === "ct_render_"))) {
4424 4424
 				$result = true;
4425 4425
 			}
4426 4426
 
@@ -4437,7 +4437,7 @@  discard block
 block discarded – undo
4437 4437
 		public function is_kallyas_zion_preview() {
4438 4438
 			$result = false;
4439 4439
 
4440
-			if ( function_exists( 'znhg_kallyas_theme_config' ) && ! empty( $_REQUEST['zn_pb_edit'] ) ) {
4440
+			if (function_exists('znhg_kallyas_theme_config') && !empty($_REQUEST['zn_pb_edit'])) {
4441 4441
 				$result = true;
4442 4442
 			}
4443 4443
 
@@ -4454,7 +4454,7 @@  discard block
 block discarded – undo
4454 4454
 		public function is_bricks_preview() {
4455 4455
 			$result = false;
4456 4456
 
4457
-			if ( function_exists( 'bricks_is_builder' ) && ( bricks_is_builder() || bricks_is_builder_call() ) ) {
4457
+			if (function_exists('bricks_is_builder') && (bricks_is_builder() || bricks_is_builder_call())) {
4458 4458
 				$result = true;
4459 4459
 			}
4460 4460
 
@@ -4469,25 +4469,25 @@  discard block
 block discarded – undo
4469 4469
 		 */
4470 4470
 		public function is_preview() {
4471 4471
 			$preview = false;
4472
-			if ( $this->is_divi_preview() ) {
4472
+			if ($this->is_divi_preview()) {
4473 4473
 				$preview = true;
4474
-			} elseif ( $this->is_elementor_preview() ) {
4474
+			} elseif ($this->is_elementor_preview()) {
4475 4475
 				$preview = true;
4476
-			} elseif ( $this->is_beaver_preview() ) {
4476
+			} elseif ($this->is_beaver_preview()) {
4477 4477
 				$preview = true;
4478
-			} elseif ( $this->is_siteorigin_preview() ) {
4478
+			} elseif ($this->is_siteorigin_preview()) {
4479 4479
 				$preview = true;
4480
-			} elseif ( $this->is_cornerstone_preview() ) {
4480
+			} elseif ($this->is_cornerstone_preview()) {
4481 4481
 				$preview = true;
4482
-			} elseif ( $this->is_fusion_preview() ) {
4482
+			} elseif ($this->is_fusion_preview()) {
4483 4483
 				$preview = true;
4484
-			} elseif ( $this->is_oxygen_preview() ) {
4484
+			} elseif ($this->is_oxygen_preview()) {
4485 4485
 				$preview = true;
4486
-			} elseif( $this->is_kallyas_zion_preview() ) {
4486
+			} elseif ($this->is_kallyas_zion_preview()) {
4487 4487
 				$preview = true;
4488
-			} elseif( $this->is_block_content_call() ) {
4488
+			} elseif ($this->is_block_content_call()) {
4489 4489
 				$preview = true;
4490
-			} elseif( $this->is_bricks_preview() ) {
4490
+			} elseif ($this->is_bricks_preview()) {
4491 4491
 				$preview = true;
4492 4492
 			}
4493 4493
 
@@ -4502,44 +4502,44 @@  discard block
 block discarded – undo
4502 4502
 		 *
4503 4503
 		 * @return string
4504 4504
 		 */
4505
-		public function output_title( $args, $instance = array() ) {
4505
+		public function output_title($args, $instance = array()) {
4506 4506
 			$output = '';
4507
-			if ( ! empty( $instance['title'] ) ) {
4507
+			if (!empty($instance['title'])) {
4508 4508
 				/** This filter is documented in wp-includes/widgets/class-wp-widget-pages.php */
4509
-				$title  = apply_filters( 'widget_title', $instance['title'], $instance, $this->id_base );
4509
+				$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
4510 4510
 
4511
-				if ( empty( $instance['widget_title_tag'] ) ) {
4512
-					if ( ! isset( $args['before_title'] ) ) {
4511
+				if (empty($instance['widget_title_tag'])) {
4512
+					if (!isset($args['before_title'])) {
4513 4513
 						$args['before_title'] = '';
4514 4514
 					}
4515 4515
 
4516
-					if ( ! isset( $args['after_title'] ) ) {
4516
+					if (!isset($args['after_title'])) {
4517 4517
 						$args['after_title'] = '';
4518 4518
 					}
4519 4519
 
4520 4520
 					$output = $args['before_title'] . $title . $args['after_title'];
4521 4521
 				} else {
4522
-					$tag 			= esc_attr( $instance['widget_title_tag'] );
4523
-					$allowed_tags 	= array( 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p' );
4524
-					$title_tag      = in_array( $tag, $allowed_tags, true ) ? esc_attr( $tag ) : 'h2';
4522
+					$tag 			= esc_attr($instance['widget_title_tag']);
4523
+					$allowed_tags = array('h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'span', 'div', 'p');
4524
+					$title_tag = in_array($tag, $allowed_tags, true) ? esc_attr($tag) : 'h2';
4525 4525
 
4526 4526
 					// classes
4527 4527
 					$title_classes = array();
4528
-					$title_classes[] = !empty( $instance['widget_title_size_class'] ) ? sanitize_html_class( $instance['widget_title_size_class'] ) : '';
4529
-					$title_classes[] = !empty( $instance['widget_title_align_class'] ) ? sanitize_html_class( $instance['widget_title_align_class'] ) : '';
4530
-					$title_classes[] = !empty( $instance['widget_title_color_class'] ) ? "text-".sanitize_html_class( $instance['widget_title_color_class'] ) : '';
4531
-					$title_classes[] = !empty( $instance['widget_title_border_class'] ) ? sanitize_html_class( $instance['widget_title_border_class'] ) : '';
4532
-					$title_classes[] = !empty( $instance['widget_title_border_color_class'] ) ? "border-".sanitize_html_class( $instance['widget_title_border_color_class'] ) : '';
4533
-					$title_classes[] = !empty( $instance['widget_title_mt_class'] ) ? "mt-".absint( $instance['widget_title_mt_class'] ) : '';
4534
-					$title_classes[] = !empty( $instance['widget_title_mr_class'] ) ? "mr-".absint( $instance['widget_title_mr_class'] ) : '';
4535
-					$title_classes[] = !empty( $instance['widget_title_mb_class'] ) ? "mb-".absint( $instance['widget_title_mb_class'] ) : '';
4536
-					$title_classes[] = !empty( $instance['widget_title_ml_class'] ) ? "ml-".absint( $instance['widget_title_ml_class'] ) : '';
4537
-					$title_classes[] = !empty( $instance['widget_title_pt_class'] ) ? "pt-".absint( $instance['widget_title_pt_class'] ) : '';
4538
-					$title_classes[] = !empty( $instance['widget_title_pr_class'] ) ? "pr-".absint( $instance['widget_title_pr_class'] ) : '';
4539
-					$title_classes[] = !empty( $instance['widget_title_pb_class'] ) ? "pb-".absint( $instance['widget_title_pb_class'] ) : '';
4540
-					$title_classes[] = !empty( $instance['widget_title_pl_class'] ) ? "pl-".absint( $instance['widget_title_pl_class'] ) : '';
4541
-
4542
-					$class = !empty( $title_classes ) ? implode(" ",$title_classes) : '';
4528
+					$title_classes[] = !empty($instance['widget_title_size_class']) ? sanitize_html_class($instance['widget_title_size_class']) : '';
4529
+					$title_classes[] = !empty($instance['widget_title_align_class']) ? sanitize_html_class($instance['widget_title_align_class']) : '';
4530
+					$title_classes[] = !empty($instance['widget_title_color_class']) ? "text-" . sanitize_html_class($instance['widget_title_color_class']) : '';
4531
+					$title_classes[] = !empty($instance['widget_title_border_class']) ? sanitize_html_class($instance['widget_title_border_class']) : '';
4532
+					$title_classes[] = !empty($instance['widget_title_border_color_class']) ? "border-" . sanitize_html_class($instance['widget_title_border_color_class']) : '';
4533
+					$title_classes[] = !empty($instance['widget_title_mt_class']) ? "mt-" . absint($instance['widget_title_mt_class']) : '';
4534
+					$title_classes[] = !empty($instance['widget_title_mr_class']) ? "mr-" . absint($instance['widget_title_mr_class']) : '';
4535
+					$title_classes[] = !empty($instance['widget_title_mb_class']) ? "mb-" . absint($instance['widget_title_mb_class']) : '';
4536
+					$title_classes[] = !empty($instance['widget_title_ml_class']) ? "ml-" . absint($instance['widget_title_ml_class']) : '';
4537
+					$title_classes[] = !empty($instance['widget_title_pt_class']) ? "pt-" . absint($instance['widget_title_pt_class']) : '';
4538
+					$title_classes[] = !empty($instance['widget_title_pr_class']) ? "pr-" . absint($instance['widget_title_pr_class']) : '';
4539
+					$title_classes[] = !empty($instance['widget_title_pb_class']) ? "pb-" . absint($instance['widget_title_pb_class']) : '';
4540
+					$title_classes[] = !empty($instance['widget_title_pl_class']) ? "pl-" . absint($instance['widget_title_pl_class']) : '';
4541
+
4542
+					$class = !empty($title_classes) ? implode(" ", $title_classes) : '';
4543 4543
 					$output = "<$title_tag class='$class' >$title</$title_tag>";
4544 4544
 				}
4545 4545
 
@@ -4553,7 +4553,7 @@  discard block
 block discarded – undo
4553 4553
 		 *
4554 4554
 		 * @param array $instance The widget options.
4555 4555
 		 */
4556
-		public function form( $instance ) {
4556
+		public function form($instance) {
4557 4557
 
4558 4558
 			// set widget instance
4559 4559
 			$this->instance = $instance;
@@ -4561,20 +4561,20 @@  discard block
 block discarded – undo
4561 4561
 			// set it as a SD widget
4562 4562
 			echo $this->widget_advanced_toggle();
4563 4563
 
4564
-			echo "<p>" . esc_attr( $this->options['widget_ops']['description'] ) . "</p>";
4564
+			echo "<p>" . esc_attr($this->options['widget_ops']['description']) . "</p>";
4565 4565
 			$arguments_raw = $this->get_arguments();
4566 4566
 
4567
-			if ( is_array( $arguments_raw ) ) {
4567
+			if (is_array($arguments_raw)) {
4568 4568
 
4569
-				$arguments = $this->group_arguments( $arguments_raw );
4569
+				$arguments = $this->group_arguments($arguments_raw);
4570 4570
 
4571 4571
 				// Do we have sections?
4572 4572
 				$has_sections = $arguments == $arguments_raw ? false : true;
4573 4573
 
4574 4574
 
4575
-				if ( $has_sections ) {
4575
+				if ($has_sections) {
4576 4576
 					$panel_count = 0;
4577
-					foreach ( $arguments as $key => $args ) {
4577
+					foreach ($arguments as $key => $args) {
4578 4578
 
4579 4579
 						?>
4580 4580
 						<script>
@@ -4584,26 +4584,26 @@  discard block
 block discarded – undo
4584 4584
 
4585 4585
 						$hide       = $panel_count ? ' style="display:none;" ' : '';
4586 4586
 						$icon_class = $panel_count ? 'fas fa-chevron-up' : 'fas fa-chevron-down';
4587
-						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes( $key ) . "'>" . esc_attr( $key ) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4588
-						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes( $key ) . "' $hide>";
4587
+						echo "<button onclick='jQuery(this).find(\"i\").toggleClass(\"fas fa-chevron-up fas fa-chevron-down\");jQuery(this).next().slideToggle();' type='button' class='sd-toggle-group-button sd-input-group-toggle" . sanitize_title_with_dashes($key) . "'>" . esc_attr($key) . " <i style='float:right;' class='" . $icon_class . "'></i></button>";
4588
+						echo "<div class='sd-toggle-group sd-input-group-" . sanitize_title_with_dashes($key) . "' $hide>";
4589 4589
 
4590
-						foreach ( $args as $k => $a ) {
4590
+						foreach ($args as $k => $a) {
4591 4591
 
4592 4592
 							$this->widget_inputs_row_start($k, $a);
4593
-							$this->widget_inputs( $a, $instance );
4593
+							$this->widget_inputs($a, $instance);
4594 4594
 							$this->widget_inputs_row_end($k, $a);
4595 4595
 
4596 4596
 						}
4597 4597
 
4598 4598
 						echo "</div>";
4599 4599
 
4600
-						$panel_count ++;
4600
+						$panel_count++;
4601 4601
 
4602 4602
 					}
4603 4603
 				} else {
4604
-					foreach ( $arguments as $key => $args ) {
4604
+					foreach ($arguments as $key => $args) {
4605 4605
 						$this->widget_inputs_row_start($key, $args);
4606
-						$this->widget_inputs( $args, $instance );
4606
+						$this->widget_inputs($args, $instance);
4607 4607
 						$this->widget_inputs_row_end($key, $args);
4608 4608
 					}
4609 4609
 				}
@@ -4611,28 +4611,28 @@  discard block
 block discarded – undo
4611 4611
 			}
4612 4612
 		}
4613 4613
 
4614
-		public function widget_inputs_row_start( $key, $args ) {
4615
-			if ( ! empty( $args['row'] ) ) {
4614
+		public function widget_inputs_row_start($key, $args) {
4615
+			if (!empty($args['row'])) {
4616 4616
 				// Maybe open
4617
-				if ( ! empty( $args['row']['open'] ) ) {
4617
+				if (!empty($args['row']['open'])) {
4618 4618
 					?>
4619
-					<div class='bsui sd-argument' data-argument='<?php echo esc_attr( $args['row']['key'] ); ?>' data-element_require='<?php echo ( ! empty( $args['row']['element_require'] ) ? $this->convert_element_require( $args['row']['element_require'] ) : '' ); ?>'>
4620
-					<?php if ( ! empty( $args['row']['title'] ) ) { ?>
4619
+					<div class='bsui sd-argument' data-argument='<?php echo esc_attr($args['row']['key']); ?>' data-element_require='<?php echo (!empty($args['row']['element_require']) ? $this->convert_element_require($args['row']['element_require']) : ''); ?>'>
4620
+					<?php if (!empty($args['row']['title'])) { ?>
4621 4621
 					<?php
4622
-						if ( isset( $args['row']['icon'] ) ) {
4622
+						if (isset($args['row']['icon'])) {
4623 4623
 							$args['row']['icon'] = '';
4624 4624
 						}
4625 4625
 
4626
-						if ( ! isset( $args['row']['device_type'] ) && isset( $args['device_type'] ) ) {
4626
+						if (!isset($args['row']['device_type']) && isset($args['device_type'])) {
4627 4627
 							$args['row']['device_type'] = $args['device_type'];
4628 4628
 						}
4629 4629
 					?>
4630
-					<label class="mb-0"><?php echo $this->widget_field_title( $args['row'] ); ?><?php echo $this->widget_field_desc( $args['row'] ); ?></label>
4630
+					<label class="mb-0"><?php echo $this->widget_field_title($args['row']); ?><?php echo $this->widget_field_desc($args['row']); ?></label>
4631 4631
 					<?php } ?>
4632
-					<div class='row<?php echo ( ! empty( $args['row']['class'] ) ? ' ' . esc_attr( $args['row']['class'] ) : '' ); ?>'>
4632
+					<div class='row<?php echo (!empty($args['row']['class']) ? ' ' . esc_attr($args['row']['class']) : ''); ?>'>
4633 4633
 					<div class='col pr-2'>
4634 4634
 					<?php
4635
-				} else if ( ! empty( $args['row']['close'] ) ) {
4635
+				} else if (!empty($args['row']['close'])) {
4636 4636
 					echo "<div class='col pl-0 ps-0'>";
4637 4637
 				} else {
4638 4638
 					echo "<div class='col pl-0 ps-0 pr-2 pe-2'>";
@@ -4640,10 +4640,10 @@  discard block
 block discarded – undo
4640 4640
 			}
4641 4641
 		}
4642 4642
 
4643
-		public function widget_inputs_row_end( $key, $args ) {
4644
-			if ( ! empty( $args['row'] ) ) {
4643
+		public function widget_inputs_row_end($key, $args) {
4644
+			if (!empty($args['row'])) {
4645 4645
 				// Maybe close
4646
-				if ( ! empty( $args['row']['close'] ) ) {
4646
+				if (!empty($args['row']['close'])) {
4647 4647
 					echo "</div></div>";
4648 4648
 				}
4649 4649
 				echo "</div>";
@@ -4658,7 +4658,7 @@  discard block
 block discarded – undo
4658 4658
 		public function widget_advanced_toggle() {
4659 4659
 
4660 4660
 			$output = '';
4661
-			if ( $this->block_show_advanced() ) {
4661
+			if ($this->block_show_advanced()) {
4662 4662
 				$val = 1;
4663 4663
 			} else {
4664 4664
 				$val = 0;
@@ -4678,14 +4678,14 @@  discard block
 block discarded – undo
4678 4678
 		 *@since 1.0.0
4679 4679
 		 *
4680 4680
 		 */
4681
-		public function convert_element_require( $input ) {
4682
-			$input = str_replace( "'", '"', $input );// we only want double quotes
4681
+		public function convert_element_require($input) {
4682
+			$input = str_replace("'", '"', $input); // we only want double quotes
4683 4683
 
4684
-			$output = esc_attr( str_replace( array( "[%", "%]", "%:checked]" ), array(
4684
+			$output = esc_attr(str_replace(array("[%", "%]", "%:checked]"), array(
4685 4685
 				"jQuery(form).find('[data-argument=\"",
4686 4686
 				"\"]').find('input,select,textarea').val()",
4687 4687
 				"\"]').find('input:checked').val()"
4688
-			), $input ) );
4688
+			), $input));
4689 4689
 
4690 4690
 			return $output;
4691 4691
 		}
@@ -4696,48 +4696,48 @@  discard block
 block discarded – undo
4696 4696
 		 * @param $args
4697 4697
 		 * @param $instance
4698 4698
 		 */
4699
-		public function widget_inputs( $args, $instance ) {
4699
+		public function widget_inputs($args, $instance) {
4700 4700
 
4701 4701
 			$class             = "";
4702 4702
 			$element_require   = "";
4703 4703
 			$custom_attributes = "";
4704 4704
 
4705 4705
 			// get value
4706
-			if ( isset( $instance[ $args['name'] ] ) ) {
4707
-				$value = $instance[ $args['name'] ];
4708
-			} elseif ( ! isset( $instance[ $args['name'] ] ) && ! empty( $args['default'] ) ) {
4709
-				$value = is_array( $args['default'] ) ? array_map( "esc_html", $args['default'] ) : esc_html( $args['default'] );
4706
+			if (isset($instance[$args['name']])) {
4707
+				$value = $instance[$args['name']];
4708
+			} elseif (!isset($instance[$args['name']]) && !empty($args['default'])) {
4709
+				$value = is_array($args['default']) ? array_map("esc_html", $args['default']) : esc_html($args['default']);
4710 4710
 			} else {
4711 4711
 				$value = '';
4712 4712
 			}
4713 4713
 
4714 4714
 			// get placeholder
4715
-			if ( ! empty( $args['placeholder'] ) ) {
4716
-				$placeholder = "placeholder='" . esc_html( $args['placeholder'] ) . "'";
4715
+			if (!empty($args['placeholder'])) {
4716
+				$placeholder = "placeholder='" . esc_html($args['placeholder']) . "'";
4717 4717
 			} else {
4718 4718
 				$placeholder = '';
4719 4719
 			}
4720 4720
 
4721 4721
 			// get if advanced
4722
-			if ( isset( $args['advanced'] ) && $args['advanced'] ) {
4722
+			if (isset($args['advanced']) && $args['advanced']) {
4723 4723
 				$class .= " sd-advanced-setting ";
4724 4724
 			}
4725 4725
 
4726 4726
 			// element_require
4727
-			if ( isset( $args['element_require'] ) && $args['element_require'] ) {
4727
+			if (isset($args['element_require']) && $args['element_require']) {
4728 4728
 				$element_require = $args['element_require'];
4729 4729
 			}
4730 4730
 
4731 4731
 			// custom_attributes
4732
-			if ( isset( $args['custom_attributes'] ) && $args['custom_attributes'] ) {
4733
-				$custom_attributes = $this->array_to_attributes( $args['custom_attributes'], true );
4732
+			if (isset($args['custom_attributes']) && $args['custom_attributes']) {
4733
+				$custom_attributes = $this->array_to_attributes($args['custom_attributes'], true);
4734 4734
 			}
4735 4735
 
4736 4736
 			// before wrapper
4737 4737
 			?>
4738
-			<p class="sd-argument <?php echo esc_attr( $class ); ?>" data-argument='<?php echo esc_attr( $args['name'] ); ?>' data-element_require='<?php if ( $element_require ) { echo $this->convert_element_require( $element_require );} ?>'>
4738
+			<p class="sd-argument <?php echo esc_attr($class); ?>" data-argument='<?php echo esc_attr($args['name']); ?>' data-element_require='<?php if ($element_require) { echo $this->convert_element_require($element_require); } ?>'>
4739 4739
 			<?php
4740
-			switch ( $args['type'] ) {
4740
+			switch ($args['type']) {
4741 4741
 				//array('text','password','number','email','tel','url','color')
4742 4742
 				case "text":
4743 4743
 				case "password":
@@ -4747,33 +4747,33 @@  discard block
 block discarded – undo
4747 4747
 				case "url":
4748 4748
 				case "color":
4749 4749
 					?>
4750
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4751
-					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="<?php echo esc_attr( $args['type'] ); ?>" value="<?php echo esc_attr( $value ); ?>">
4750
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4751
+					<input <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="<?php echo esc_attr($args['type']); ?>" value="<?php echo esc_attr($value); ?>">
4752 4752
 					<?php
4753 4753
 
4754 4754
 					break;
4755 4755
 				case "select":
4756
-					$multiple = isset( $args['multiple'] ) && $args['multiple'] ? true : false;
4757
-					if ( $multiple ) {
4758
-						if ( empty( $value ) ) {
4756
+					$multiple = isset($args['multiple']) && $args['multiple'] ? true : false;
4757
+					if ($multiple) {
4758
+						if (empty($value)) {
4759 4759
 							$value = array();
4760 4760
 						}
4761 4761
 					}
4762 4762
 					?>
4763
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4764
-					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); if ( $multiple ) { echo "[]"; } ?>"
4765
-						<?php if ( $multiple ) {
4763
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4764
+					<select <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); if ($multiple) { echo "[]"; } ?>"
4765
+						<?php if ($multiple) {
4766 4766
 							echo "multiple";
4767 4767
 						} //@todo not implemented yet due to gutenberg not supporting it
4768 4768
 						?>>
4769 4769
 						<?php
4770 4770
 
4771
-						if ( ! empty( $args['options'] ) ) {
4772
-							foreach ( $args['options'] as $val => $label ) {
4773
-								if ( $multiple ) {
4774
-									$selected = in_array( $val, $value ) ? 'selected="selected"' : '';
4771
+						if (!empty($args['options'])) {
4772
+							foreach ($args['options'] as $val => $label) {
4773
+								if ($multiple) {
4774
+									$selected = in_array($val, $value) ? 'selected="selected"' : '';
4775 4775
 								} else {
4776
-									$selected = selected( $value, $val, false );
4776
+									$selected = selected($value, $val, false);
4777 4777
 								}
4778 4778
 								echo "<option value='$val' " . $selected . ">$label</option>";
4779 4779
 							}
@@ -4784,20 +4784,20 @@  discard block
 block discarded – undo
4784 4784
 					break;
4785 4785
 				case "checkbox":
4786 4786
 					?>
4787
-					<input <?php echo $placeholder; ?> <?php checked( 1, $value, true ) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="checkbox" value="1">
4788
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args );?><?php echo $this->widget_field_desc( $args ); ?></label>
4787
+					<input <?php echo $placeholder; ?> <?php checked(1, $value, true) ?> <?php echo $custom_attributes; ?> class="widefat" id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="checkbox" value="1">
4788
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4789 4789
 					<?php
4790 4790
 					break;
4791 4791
 				case "textarea":
4792 4792
 					?>
4793
-					<label for="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>"><?php echo $this->widget_field_title( $args ); ?><?php echo $this->widget_field_desc( $args ); ?></label>
4794
-					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>"><?php echo esc_attr( $value ); ?></textarea>
4793
+					<label for="<?php echo esc_attr($this->get_field_id($args['name'])); ?>"><?php echo $this->widget_field_title($args); ?><?php echo $this->widget_field_desc($args); ?></label>
4794
+					<textarea <?php echo $placeholder; ?> class="widefat" <?php echo $custom_attributes; ?> id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>"><?php echo esc_attr($value); ?></textarea>
4795 4795
 					<?php
4796 4796
 
4797 4797
 					break;
4798 4798
 				case "hidden":
4799 4799
 					?>
4800
-					<input id="<?php echo esc_attr( $this->get_field_id( $args['name'] ) ); ?>" name="<?php echo esc_attr( $this->get_field_name( $args['name'] ) ); ?>" type="hidden" value="<?php echo esc_attr( $value ); ?>">
4800
+					<input id="<?php echo esc_attr($this->get_field_id($args['name'])); ?>" name="<?php echo esc_attr($this->get_field_name($args['name'])); ?>" type="hidden" value="<?php echo esc_attr($value); ?>">
4801 4801
 					<?php
4802 4802
 					break;
4803 4803
 				default:
@@ -4807,15 +4807,15 @@  discard block
 block discarded – undo
4807 4807
 			?></p><?php
4808 4808
 		}
4809 4809
 
4810
-		public function get_widget_icon($icon = 'box-top', $title = ''){
4811
-			if($icon=='box-top'){
4812
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4813
-			}elseif($icon=='box-right'){
4814
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4815
-			}elseif($icon=='box-bottom'){
4816
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4817
-			}elseif($icon=='box-left'){
4818
-				return '<svg title="'.esc_attr($title).'" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4810
+		public function get_widget_icon($icon = 'box-top', $title = '') {
4811
+			if ($icon == 'box-top') {
4812
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.048" height="9.017" fill="#555D66"></rect><rect x="16.265" y="5.498" width="1.023" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.186" width="8.964" height="2.482" fill="#272B2F"></rect><rect x="5.487" y="16.261" width="9.026" height="1.037" fill="#555D66"></rect></svg>';
4813
+			}elseif ($icon == 'box-right') {
4814
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1.046" height="9.017" fill="#555D66"></rect><rect x="15.244" y="5.498" width="2.518" height="9.003" fill="#272B2F"></rect><rect x="5.518" y="2.719" width="8.964" height="0.954" fill="#555D66"></rect><rect x="5.487" y="16.308" width="9.026" height="0.99" fill="#555D66"></rect></svg>';
4815
+			}elseif ($icon == 'box-bottom') {
4816
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.714" y="5.492" width="1" height="9.017" fill="#555D66"></rect><rect x="16.261" y="5.498" width="1.027" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.968" fill="#555D66"></rect><rect x="5.487" y="15.28" width="9.026" height="2.499" fill="#272B2F"></rect></svg>';
4817
+			}elseif ($icon == 'box-left') {
4818
+				return '<svg title="' . esc_attr($title) . '" width="20px" height="20px" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" fill-rule="evenodd" clip-rule="evenodd" stroke-linejoin="round" stroke-miterlimit="1.414" role="img" aria-hidden="true" focusable="false"><rect x="2.202" y="5.492" width="2.503" height="9.017" fill="#272B2F"></rect><rect x="16.276" y="5.498" width="1.012" height="9.003" fill="#555D66"></rect><rect x="5.518" y="2.719" width="8.964" height="0.966" fill="#555D66"></rect><rect x="5.487" y="16.303" width="9.026" height="0.995" fill="#555D66"></rect></svg>';
4819 4819
 			}
4820 4820
 		}
4821 4821
 
@@ -4827,14 +4827,14 @@  discard block
 block discarded – undo
4827 4827
 		 * @return string
4828 4828
 		 * @todo, need to make its own tooltip script
4829 4829
 		 */
4830
-		public function widget_field_desc( $args ) {
4830
+		public function widget_field_desc($args) {
4831 4831
 
4832 4832
 			$description = '';
4833
-			if ( isset( $args['desc'] ) && $args['desc'] ) {
4834
-				if ( isset( $args['desc_tip'] ) && $args['desc_tip'] ) {
4835
-					$description = $this->desc_tip( $args['desc'] );
4833
+			if (isset($args['desc']) && $args['desc']) {
4834
+				if (isset($args['desc_tip']) && $args['desc_tip']) {
4835
+					$description = $this->desc_tip($args['desc']);
4836 4836
 				} else {
4837
-					$description = '<span class="description">' . wp_kses_post( $args['desc'] ) . '</span>';
4837
+					$description = '<span class="description">' . wp_kses_post($args['desc']) . '</span>';
4838 4838
 				}
4839 4839
 			}
4840 4840
 
@@ -4848,18 +4848,18 @@  discard block
 block discarded – undo
4848 4848
 		 *
4849 4849
 		 * @return string
4850 4850
 		 */
4851
-		public function widget_field_title( $args ) {
4851
+		public function widget_field_title($args) {
4852 4852
 			$title = '';
4853 4853
 
4854
-			if ( isset( $args['title'] ) && $args['title'] ) {
4855
-				if ( ! empty( $args['device_type'] ) ) {
4854
+			if (isset($args['title']) && $args['title']) {
4855
+				if (!empty($args['device_type'])) {
4856 4856
 					$args['title'] .= ' (' . $args['device_type'] . ')'; // Append device type to title.
4857 4857
 				}
4858 4858
 
4859
-				if ( isset( $args['icon'] ) && $args['icon'] ) {
4860
-					$title = self::get_widget_icon( $args['icon'], $args['title']  );
4859
+				if (isset($args['icon']) && $args['icon']) {
4860
+					$title = self::get_widget_icon($args['icon'], $args['title']);
4861 4861
 				} else {
4862
-					$title = esc_attr( $args['title'] );
4862
+					$title = esc_attr($args['title']);
4863 4863
 				}
4864 4864
 			}
4865 4865
 
@@ -4874,11 +4874,11 @@  discard block
 block discarded – undo
4874 4874
 		 *
4875 4875
 		 * @return string
4876 4876
 		 */
4877
-		function desc_tip( $tip, $allow_html = false ) {
4878
-			if ( $allow_html ) {
4879
-				$tip = $this->sanitize_tooltip( $tip );
4877
+		function desc_tip($tip, $allow_html = false) {
4878
+			if ($allow_html) {
4879
+				$tip = $this->sanitize_tooltip($tip);
4880 4880
 			} else {
4881
-				$tip = esc_attr( $tip );
4881
+				$tip = esc_attr($tip);
4882 4882
 			}
4883 4883
 
4884 4884
 			return '<span class="gd-help-tip dashicons dashicons-editor-help" title="' . $tip . '"></span>';
@@ -4891,8 +4891,8 @@  discard block
 block discarded – undo
4891 4891
 		 *
4892 4892
 		 * @return string
4893 4893
 		 */
4894
-		public function sanitize_tooltip( $var ) {
4895
-			return htmlspecialchars( wp_kses( html_entity_decode( $var ), array(
4894
+		public function sanitize_tooltip($var) {
4895
+			return htmlspecialchars(wp_kses(html_entity_decode($var), array(
4896 4896
 				'br'     => array(),
4897 4897
 				'em'     => array(),
4898 4898
 				'strong' => array(),
@@ -4902,7 +4902,7 @@  discard block
 block discarded – undo
4902 4902
 				'li'     => array(),
4903 4903
 				'ol'     => array(),
4904 4904
 				'p'      => array(),
4905
-			) ) );
4905
+			)));
4906 4906
 		}
4907 4907
 
4908 4908
 		/**
@@ -4914,23 +4914,23 @@  discard block
 block discarded – undo
4914 4914
 		 * @return array
4915 4915
 		 * @todo we should add some sanitation here.
4916 4916
 		 */
4917
-		public function update( $new_instance, $old_instance ) {
4917
+		public function update($new_instance, $old_instance) {
4918 4918
 
4919 4919
 			//save the widget
4920
-			$instance = array_merge( (array) $old_instance, (array) $new_instance );
4920
+			$instance = array_merge((array) $old_instance, (array) $new_instance);
4921 4921
 
4922 4922
 			// set widget instance
4923 4923
 			$this->instance = $instance;
4924 4924
 
4925
-			if ( empty( $this->arguments ) ) {
4925
+			if (empty($this->arguments)) {
4926 4926
 				$this->get_arguments();
4927 4927
 			}
4928 4928
 
4929 4929
 			// check for checkboxes
4930
-			if ( ! empty( $this->arguments ) ) {
4931
-				foreach ( $this->arguments as $argument ) {
4932
-					if ( isset( $argument['type'] ) && $argument['type'] == 'checkbox' && ! isset( $new_instance[ $argument['name'] ] ) ) {
4933
-						$instance[ $argument['name'] ] = '0';
4930
+			if (!empty($this->arguments)) {
4931
+				foreach ($this->arguments as $argument) {
4932
+					if (isset($argument['type']) && $argument['type'] == 'checkbox' && !isset($new_instance[$argument['name']])) {
4933
+						$instance[$argument['name']] = '0';
4934 4934
 					}
4935 4935
 				}
4936 4936
 			}
@@ -4948,7 +4948,7 @@  discard block
 block discarded – undo
4948 4948
 		 */
4949 4949
 		public function is_block_content_call() {
4950 4950
 			$result = false;
4951
-			if ( wp_doing_ajax() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'super_duper_output_shortcode' ) {
4951
+			if (wp_doing_ajax() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'super_duper_output_shortcode') {
4952 4952
 				$result = true;
4953 4953
 			}
4954 4954
 
@@ -4961,9 +4961,9 @@  discard block
 block discarded – undo
4961 4961
 		 * @return string
4962 4962
 		 *@since 1.0.20
4963 4963
 		 */
4964
-		public function get_instance_hash(){
4965
-			$instance_string = $this->base_id.serialize($this->instance);
4966
-			return hash('crc32b',$instance_string);
4964
+		public function get_instance_hash() {
4965
+			$instance_string = $this->base_id . serialize($this->instance);
4966
+			return hash('crc32b', $instance_string);
4967 4967
 		}
4968 4968
 
4969 4969
 		/**
@@ -4974,14 +4974,14 @@  discard block
 block discarded – undo
4974 4974
 		 * @return string
4975 4975
 		 *@since 1.0.20
4976 4976
 		 */
4977
-		public function get_instance_style($rules = array()){
4977
+		public function get_instance_style($rules = array()) {
4978 4978
 			$css = '';
4979 4979
 
4980
-			if(!empty($rules)){
4980
+			if (!empty($rules)) {
4981 4981
 				$rules = array_unique($rules);
4982 4982
 				$instance_hash = $this->get_instance_hash();
4983 4983
 				$css .= "<style>";
4984
-				foreach($rules as $rule){
4984
+				foreach ($rules as $rule) {
4985 4985
 					$css .= ".sdel-$instance_hash $rule";
4986 4986
 				}
4987 4987
 				$css .= "</style>";
@@ -4999,9 +4999,9 @@  discard block
 block discarded – undo
4999 4999
 		 *@since 1.0.28
5000 5000
 		 *
5001 5001
 		 */
5002
-		public function encode_shortcodes( $content ) {
5002
+		public function encode_shortcodes($content) {
5003 5003
 			// Avoids existing encoded tags.
5004
-			$trans   = array(
5004
+			$trans = array(
5005 5005
 				'&#91;' => '&#091;',
5006 5006
 				'&#93;' => '&#093;',
5007 5007
 				'&amp;#91;' => '&#091;',
@@ -5012,7 +5012,7 @@  discard block
 block discarded – undo
5012 5012
 				'&amp;gt;' => '&0gt;',
5013 5013
 			);
5014 5014
 
5015
-			$content = strtr( $content, $trans );
5015
+			$content = strtr($content, $trans);
5016 5016
 
5017 5017
 			$trans   = array(
5018 5018
 				'[' => '&#91;',
@@ -5023,7 +5023,7 @@  discard block
 block discarded – undo
5023 5023
 				"'" => '&#39;',
5024 5024
 			);
5025 5025
 
5026
-			$content = strtr( $content, $trans );
5026
+			$content = strtr($content, $trans);
5027 5027
 
5028 5028
 			return $content;
5029 5029
 		}
@@ -5037,8 +5037,8 @@  discard block
 block discarded – undo
5037 5037
 		 *@since 1.0.28
5038 5038
 		 *
5039 5039
 		 */
5040
-		public function decode_shortcodes( $content ) {
5041
-			$trans   = array(
5040
+		public function decode_shortcodes($content) {
5041
+			$trans = array(
5042 5042
 				'&#91;' => '[',
5043 5043
 				'&#93;' => ']',
5044 5044
 				'&amp;#91;' => '[',
@@ -5051,7 +5051,7 @@  discard block
 block discarded – undo
5051 5051
 				'&apos;' => "'",
5052 5052
 			);
5053 5053
 
5054
-			$content = strtr( $content, $trans );
5054
+			$content = strtr($content, $trans);
5055 5055
 
5056 5056
 			$trans   = array(
5057 5057
 				'&#091;' => '&#91;',
@@ -5064,31 +5064,31 @@  discard block
 block discarded – undo
5064 5064
 				'&amp;0gt;' => '&gt;',
5065 5065
 			);
5066 5066
 
5067
-			$content = strtr( $content, $trans );
5067
+			$content = strtr($content, $trans);
5068 5068
 
5069 5069
 			return $content;
5070 5070
 		}
5071 5071
 
5072
-		public function block_visibility_fields( $args ) {
5073
-			$value = ! empty( $args['value'] ) ? esc_attr( $args['value'] ) : '';
5072
+		public function block_visibility_fields($args) {
5073
+			$value = !empty($args['value']) ? esc_attr($args['value']) : '';
5074 5074
 			$content = '<div class="bs-vc-rule-template d-none">';
5075 5075
 				$content .= '<div class="p-3 pb-0 mb-3 border border-1 rounded-1 position-relative bs-vc-rule" data-bs-index="BSVCINDEX" >';
5076 5076
 					$content .= '<div class="row">';
5077 5077
 						$content .= '<div class="col-sm-12">';
5078
-							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__( 'Remove Rule', 'ayecode-connect' ) . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5078
+							$content .= '<div class="bs-rule-action position-absolute top-0 end-0 p-2 zindex-5"><span class="text-danger c-pointer bs-vc-remove-rule" title="' . esc_attr__('Remove Rule', 'ayecode-connect') . '"><i class="fas fa-circle-minus fs-6"></i></span></div>';
5079 5079
 							$content .= aui()->select(
5080 5080
 								array(
5081 5081
 									'id'          => 'bsvc_rule_BSVCINDEX',
5082 5082
 									'name'        => 'bsvc_rule_BSVCINDEX',
5083
-									'label'       => __( 'Rule', 'ayecode-connect' ),
5084
-									'placeholder' => __( 'Select Rule...', 'ayecode-connect' ),
5083
+									'label'       => __('Rule', 'ayecode-connect'),
5084
+									'placeholder' => __('Select Rule...', 'ayecode-connect'),
5085 5085
 									'class'       => 'bsvc_rule form-select-sm no-select2 mw-100',
5086 5086
 									'options'     => sd_visibility_rules_options(),
5087 5087
 									'default'     => '',
5088 5088
 									'value'       => '',
5089 5089
 									'label_type'  => '',
5090 5090
 									'select2'     => false,
5091
-									'input_group_left' => __( 'Rule:', 'ayecode-connect' ),
5091
+									'input_group_left' => __('Rule:', 'ayecode-connect'),
5092 5092
 									'extra_attributes' => array(
5093 5093
 										'data-minimum-results-for-search' => '-1'
5094 5094
 									)
@@ -5097,15 +5097,15 @@  discard block
 block discarded – undo
5097 5097
 
5098 5098
 						$content .= '</div>';
5099 5099
 
5100
-						if ( class_exists( 'GeoDirectory' ) ) {
5100
+						if (class_exists('GeoDirectory')) {
5101 5101
 							$content .= '<div class="col-md-7 col-sm-12">';
5102 5102
 
5103 5103
 								$content .= aui()->select(
5104 5104
 									array(
5105 5105
 										'id'          => 'bsvc_gd_field_BSVCINDEX',
5106 5106
 										'name'        => 'bsvc_gd_field_BSVCINDEX',
5107
-										'label'       => __( 'FIELD', 'ayecode-connect' ),
5108
-										'placeholder' => __( 'FIELD', 'ayecode-connect' ),
5107
+										'label'       => __('FIELD', 'ayecode-connect'),
5108
+										'placeholder' => __('FIELD', 'ayecode-connect'),
5109 5109
 										'class'       => 'bsvc_gd_field form-select-sm no-select2 mw-100',
5110 5110
 										'options'     => sd_visibility_gd_field_options(),
5111 5111
 										'default'     => '',
@@ -5126,8 +5126,8 @@  discard block
 block discarded – undo
5126 5126
 									array(
5127 5127
 										'id'          => 'bsvc_gd_field_condition_BSVCINDEX',
5128 5128
 										'name'        => 'bsvc_gd_field_condition_BSVCINDEX',
5129
-										'label'       => __( 'CONDITION', 'ayecode-connect' ),
5130
-										'placeholder' => __( 'CONDITION', 'ayecode-connect' ),
5129
+										'label'       => __('CONDITION', 'ayecode-connect'),
5130
+										'placeholder' => __('CONDITION', 'ayecode-connect'),
5131 5131
 										'class'       => 'bsvc_gd_field_condition form-select-sm no-select2 mw-100',
5132 5132
 										'options'     => sd_visibility_field_condition_options(),
5133 5133
 										'default'     => '',
@@ -5149,9 +5149,9 @@  discard block
 block discarded – undo
5149 5149
 										'type'            => 'text',
5150 5150
 										'id'              => 'bsvc_gd_field_search_BSVCINDEX',
5151 5151
 										'name'            => 'bsvc_gd_field_search_BSVCINDEX',
5152
-										'label'           => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5152
+										'label'           => __('VALUE TO MATCH', 'ayecode-connect'),
5153 5153
 										'class'           => 'bsvc_gd_field_search form-control-sm',
5154
-										'placeholder'     => __( 'VALUE TO MATCH', 'ayecode-connect' ),
5154
+										'placeholder'     => __('VALUE TO MATCH', 'ayecode-connect'),
5155 5155
 										'label_type'      => '',
5156 5156
 										'value'           => '',
5157 5157
 										'element_require' => '([%bsvc_rule_BSVCINDEX%]=="gd_field" && [%bsvc_gd_field_condition_BSVCINDEX%] && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_empty" && [%bsvc_gd_field_condition_BSVCINDEX%]!="is_not_empty")'
@@ -5163,11 +5163,11 @@  discard block
 block discarded – undo
5163 5163
 
5164 5164
 					$content .= '</div>';
5165 5165
 
5166
-					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __( 'Select User Roles:', 'ayecode-connect' ) . '</label>';
5166
+					$content .= '<div class="row aui-conditional-field" data-element-require="jQuery(form).find(\'[name=bsvc_rule_BSVCINDEX]\').val()==\'user_roles\'" data-argument="bsvc_user_roles_BSVCINDEX_1"><label for="bsvc_user_roles_BSVCINDEX_1" class="form-label mb-3">' . __('Select User Roles:', 'ayecode-connect') . '</label>';
5167 5167
 						$role_options = sd_user_roles_options();
5168 5168
 
5169 5169
 						$role_option_i = 0;
5170
-						foreach ( $role_options as $role_option_key => $role_option_name ) {
5170
+						foreach ($role_options as $role_option_key => $role_option_name) {
5171 5171
 							$role_option_i++;
5172 5172
 
5173 5173
 							$content .= '<div class="col-sm-6">';
@@ -5191,14 +5191,14 @@  discard block
 block discarded – undo
5191 5191
 			$content .= '</div>';
5192 5192
 			$content .= '<form id="bs-vc-modal-form" class="bs-vc-modal-form">';
5193 5193
 			$content .= '<div class="bs-vc-rule-sets"></div>';
5194
-			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __( 'Add Rule', 'ayecode-connect' ) . '</button></div></div>';
5194
+			$content .= '<div class="row"><div class="col-sm-12 text-center pt-1 pb-4"><button type="button" class="btn btn-sm btn-primary d-block w-100 bs-vc-add-rule"><i class="fas fa-plus"></i> ' . __('Add Rule', 'ayecode-connect') . '</button></div></div>';
5195 5195
 			$content .= '<div class="row"><div class="col-md-6 col-sm-12">';
5196 5196
 			$content .= aui()->select(
5197 5197
 				array(
5198 5198
 					'id'          => 'bsvc_output',
5199 5199
 					'name'        => 'bsvc_output',
5200
-					'label'       => __( 'What should happen if rules met.', 'ayecode-connect' ),
5201
-					'placeholder' => __( 'Default Output', 'ayecode-connect' ),
5200
+					'label'       => __('What should happen if rules met.', 'ayecode-connect'),
5201
+					'placeholder' => __('Default Output', 'ayecode-connect'),
5202 5202
 					'class'       => 'bsvc_output form-select-sm no-select2 mw-100',
5203 5203
 					'options'     => sd_visibility_output_options(),
5204 5204
 					'default'     => '',
@@ -5217,8 +5217,8 @@  discard block
 block discarded – undo
5217 5217
 				array(
5218 5218
 					'id'              => 'bsvc_page',
5219 5219
 					'name'            => 'bsvc_page',
5220
-					'label'           => __( 'Page Content', 'ayecode-connect' ),
5221
-					'placeholder'     => __( 'Select Page ID...', 'ayecode-connect' ),
5220
+					'label'           => __('Page Content', 'ayecode-connect'),
5221
+					'placeholder'     => __('Select Page ID...', 'ayecode-connect'),
5222 5222
 					'class'           => 'bsvc_page form-select-sm no-select2 mw-100',
5223 5223
 					'options'         => sd_template_page_options(),
5224 5224
 					'default'         => '',
@@ -5233,8 +5233,8 @@  discard block
 block discarded – undo
5233 5233
 				array(
5234 5234
 					'id'          => 'bsvc_tmpl_part',
5235 5235
 					'name'        => 'bsvc_tmpl_part',
5236
-					'label'       => __( 'Template Part', 'ayecode-connect' ),
5237
-					'placeholder' => __( 'Select Template Part...', 'ayecode-connect' ),
5236
+					'label'       => __('Template Part', 'ayecode-connect'),
5237
+					'placeholder' => __('Select Template Part...', 'ayecode-connect'),
5238 5238
 					'class'       => 'bsvc_tmpl_part form-select-sm no-select2 mw-100',
5239 5239
 					'options'     => sd_template_part_options(),
5240 5240
 					'default'     => '',
@@ -5252,8 +5252,8 @@  discard block
 block discarded – undo
5252 5252
 				array(
5253 5253
 					'id'               => 'bsvc_message_type',
5254 5254
 					'name'             => 'bsvc_message_type',
5255
-					'label'            => __( 'Custom Message Type', 'ayecode-connect' ),
5256
-					'placeholder'      => __( 'Default (none)', 'ayecode-connect' ),
5255
+					'label'            => __('Custom Message Type', 'ayecode-connect'),
5256
+					'placeholder'      => __('Default (none)', 'ayecode-connect'),
5257 5257
 					'class'            => 'bsvc_message_type form-select-sm no-select2 mw-100',
5258 5258
 					'options'          => sd_aui_colors(),
5259 5259
 					'default'          => '',
@@ -5276,7 +5276,7 @@  discard block
 block discarded – undo
5276 5276
 					'name'            => 'bsvc_message',
5277 5277
 					'label'           => '',
5278 5278
 					'class'           => 'bsvc_message form-control-sm',
5279
-					'placeholder'     => __( 'CUSTOM MESSAGE TO SHOW', 'ayecode-connect' ),
5279
+					'placeholder'     => __('CUSTOM MESSAGE TO SHOW', 'ayecode-connect'),
5280 5280
 					'label_type'      => '',
5281 5281
 					'value'           => '',
5282 5282
 					'form_group_class' => ' ',
@@ -5298,7 +5298,7 @@  discard block
 block discarded – undo
5298 5298
 			global $shortcode_insert_button_once;
5299 5299
 
5300 5300
 			// Fix conflicts with UpSolution Core in header template edit element.
5301
-			if ( defined( 'US_CORE_DIR' ) && ! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html' ) {
5301
+			if (defined('US_CORE_DIR') && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'us_ajax_hb_get_ebuilder_html') {
5302 5302
 				$shortcode_insert_button_once = true;
5303 5303
 			}
5304 5304
 		}
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+                    foreach ( $tabs as $key => $label ) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
70
-					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab ';
71
-					$url   = esc_url(
68
+                    $key   = sanitize_key( $key );
69
+                    $label = esc_html( $label );
70
+                    $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab ';
71
+                    $url   = esc_url(
72 72
                         add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+                echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,82 +86,82 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
93 93
 
94
-	}
94
+    }
95 95
 
96
-	/**
97
-	 * Retrieves reports page tabs.
98
-	 *
99
-	 * @return array
100
-	 */
101
-	public function get_tabs() {
96
+    /**
97
+     * Retrieves reports page tabs.
98
+     *
99
+     * @return array
100
+     */
101
+    public function get_tabs() {
102 102
 
103
-		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
106
-		);
103
+        $tabs = array(
104
+            'reports' => __( 'Reports', 'invoicing' ),
105
+            'export'  => __( 'Export', 'invoicing' ),
106
+        );
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
-	}
108
+        return apply_filters( 'getpaid_report_tabs', $tabs );
109
+    }
110 110
 
111
-	/**
112
-	 * Displays the reports tab.
113
-	 *
114
-	 */
115
-	public function display_reports_tab() {
111
+    /**
112
+     * Displays the reports tab.
113
+     *
114
+     */
115
+    public function display_reports_tab() {
116 116
 
117
-		$reports = new GetPaid_Reports_Report();
118
-		$reports->display();
117
+        $reports = new GetPaid_Reports_Report();
118
+        $reports->display();
119 119
 
120
-	}
120
+    }
121 121
 
122
-	/**
123
-	 * Displays the exports tab.
124
-	 *
125
-	 */
126
-	public function display_exports_tab() {
122
+    /**
123
+     * Displays the exports tab.
124
+     *
125
+     */
126
+    public function display_exports_tab() {
127 127
 
128
-		$exports = new GetPaid_Reports_Export();
129
-		$exports->display();
128
+        $exports = new GetPaid_Reports_Export();
129
+        $exports->display();
130 130
 
131
-	}
131
+    }
132 132
 
133
-	/**
134
-	 * Donwnloads a graph.
135
-	 *
136
-	 * @param array $args
137
-	 */
138
-	public function download_graph( $args ) {
133
+    /**
134
+     * Donwnloads a graph.
135
+     *
136
+     * @param array $args
137
+     */
138
+    public function download_graph( $args ) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
141
-			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
143
-		}
140
+        if ( ! empty( $args['graph'] ) ) {
141
+            $downloader = new GetPaid_Graph_Downloader();
142
+            $downloader->download( $args['graph'] );
143
+        }
144 144
 
145
-	}
145
+    }
146 146
 
147
-	/**
148
-	 * Exports invoices.
149
-	 *
150
-	 * @param array $args
151
-	 */
152
-	public function export_invoices( $args ) {
147
+    /**
148
+     * Exports invoices.
149
+     *
150
+     * @param array $args
151
+     */
152
+    public function export_invoices( $args ) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+        if ( ! empty( $args['post_type'] ) ) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
157
-				$downloader = new GetPaid_Subscription_Exporter();
158
-			} else {
159
-				$downloader = new GetPaid_Invoice_Exporter();
160
-			}
156
+            if ( 'subscriptions' === $args['post_type'] ) {
157
+                $downloader = new GetPaid_Subscription_Exporter();
158
+            } else {
159
+                $downloader = new GetPaid_Invoice_Exporter();
160
+            }
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
163
-		}
162
+            $downloader->export( $args['post_type'], $args );
163
+        }
164 164
 
165
-	}
165
+    }
166 166
 
167 167
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,46 +50,46 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo esc_html( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo esc_html($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach ( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-					$key   = sanitize_key( $key );
69
-					$label = esc_html( $label );
68
+					$key   = sanitize_key($key);
69
+					$label = esc_html($label);
70 70
 					$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab ';
71 71
 					$url   = esc_url(
72
-                        add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+                        add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
                     );
74 74
 
75
-				echo wp_kses_post( "\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>" );
75
+				echo wp_kses_post("\n\t\t\t<a href='$url' class='" . $class . "'>$label</a>");
76 76
 
77 77
 					}
78 78
 				?>
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array( 'jquery' ), '3.7.1', true );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.min.js', array('jquery'), '3.7.1', true);
93 93
 
94 94
 	}
95 95
 
@@ -101,11 +101,11 @@  discard block
 block discarded – undo
101 101
 	public function get_tabs() {
102 102
 
103 103
 		$tabs = array(
104
-			'reports' => __( 'Reports', 'invoicing' ),
105
-			'export'  => __( 'Export', 'invoicing' ),
104
+			'reports' => __('Reports', 'invoicing'),
105
+			'export'  => __('Export', 'invoicing'),
106 106
 		);
107 107
 
108
-		return apply_filters( 'getpaid_report_tabs', $tabs );
108
+		return apply_filters('getpaid_report_tabs', $tabs);
109 109
 	}
110 110
 
111 111
 	/**
@@ -135,11 +135,11 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param array $args
137 137
 	 */
138
-	public function download_graph( $args ) {
138
+	public function download_graph($args) {
139 139
 
140
-		if ( ! empty( $args['graph'] ) ) {
140
+		if (!empty($args['graph'])) {
141 141
 			$downloader = new GetPaid_Graph_Downloader();
142
-			$downloader->download( $args['graph'] );
142
+			$downloader->download($args['graph']);
143 143
 		}
144 144
 
145 145
 	}
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	 *
150 150
 	 * @param array $args
151 151
 	 */
152
-	public function export_invoices( $args ) {
152
+	public function export_invoices($args) {
153 153
 
154
-		if ( ! empty( $args['post_type'] ) ) {
154
+		if (!empty($args['post_type'])) {
155 155
 
156
-			if ( 'subscriptions' === $args['post_type'] ) {
156
+			if ('subscriptions' === $args['post_type']) {
157 157
 				$downloader = new GetPaid_Subscription_Exporter();
158 158
 			} else {
159 159
 				$downloader = new GetPaid_Invoice_Exporter();
160 160
 			}
161 161
 
162
-			$downloader->export( $args['post_type'], $args );
162
+			$downloader->export($args['post_type'], $args);
163 163
 		}
164 164
 
165 165
 	}
Please login to merge, or discard this patch.